473,795 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding dynamic properties to new classes

I have created a new class ServiceTimer based upon the .NET System.Timers.T imer class. This has a new property CollectionInter valMinutes which I expected to be added to the 'Behavior' section of the class properties and also to be available as a 'Dynamic' property so that I could control it from the application config file. The new property is not shown, but the properties inherited from the base class are

I cannot find any reference to how to do this in the help. I have tried creating the new class as both a standard class and a component class

How should I declare properties in the new class so that they are included in 'Behavior' and ensure they are available as 'Dynamic' properties?
Nov 16 '05 #1
4 3377
Richard Abraham wrote:
I have created a new class ServiceTimer based upon the .NET
System.Timers.T imer class. This has a new property
CollectionInter valMinutes which I expected to be added to the 'Behavior'
section of the class properties and also to be available as a 'Dynamic'
property so that I could control it from the application config file. The
new property is not shown, but the properties inherited from the base class
are.

I cannot find any reference to how to do this in the help. I have tried
creating the new class as both a standard class and a component class.

How should I declare properties in the new class so that they are included
in 'Behavior' and ensure they are available as 'Dynamic' properties?


It's perhaps wise to post your property's declaration, so we can see which
attributes you have applied to the property.

Also consider that VS.NET-related issues like the one you're having are more
at home in the vs.net related newsgroups.

FB

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Nov 16 '05 #2


----- Frans Bouma [C# MVP] wrote: ----

Richard Abraham wrote
I have created a new class ServiceTimer based upon the .NE
System.Timers.T imer class. This has a new propert
CollectionInter valMinutes which I expected to be added to the 'Behavior
section of the class properties and also to be available as a 'Dynamic
property so that I could control it from the application config file. Th
new property is not shown, but the properties inherited from the base clas
are
I cannot find any reference to how to do this in the help. I have trie

creating the new class as both a standard class and a component class
How should I declare properties in the new class so that they are include

in 'Behavior' and ensure they are available as 'Dynamic' properties


It's perhaps wise to post your property's declaration, so we can see whic
attributes you have applied to the property

Also consider that VS.NET-related issues like the one you're having are mor
at home in the vs.net related newsgroups

F

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.co
My .NET Blog: http://weblogs.asp.net/fboum
Microsoft C# MV
Sorry, bit of a newbie here. Not sure which VS newsgroup would be appropriate

My C# code is below, hope that helps

=============== =============== =============== =============== =============== ==

using System
using System.Timers
using System.Componen tModel

namespace EA_Read_Event_L ogs_Servic

/// <summary
/// Summary description for ServiceTimer
/// </summary
public class ServiceTimer: System.Timers.T ime

public ServiceTimer(

/
// TODO: Add constructor logic her
/
public void ScheduleNext(

DateTime d1 = DateTime.Now

Enabled = true
Interval = (CollectionInte rval * 60 * 1000) -
((((d1.Hour * 60) + d1.Minute) * 60 + d1.Second) * 1000 + d1.Millisecond) % (CollectionInte rval * 60 * 1000)
/// <summary
/// Interval between log collections, maximum value one day, units are minute
/// </summary
public double CollectionInter valMinute

ge

return CollectionInter val

se

if ((value <= 60 * 24) & (value > 0)

CollectionInter val = value

els

throw new ArgumentOutOfRa ngeException("C ollectionInterv al", value, "Collection Interval must be less than 1440 (1 day) and greater than 0")
}

/// <summary
/// Minutes to wait between collection
/// </summary
private double CollectionInter val = 60

Nov 16 '05 #3
You haven't decorated the property with attributes to make it appear in the
designer. This is perhaps a good article to get started (It's VB.NET, but the
ideas are the same)

http://msdn.microsoft.com/msdnmag/is...ls/default.asp
x

Richard Abraham wrote:


----- Frans Bouma [C# MVP] wrote: -----

Richard Abraham wrote:
> I have created a new class ServiceTimer based upon the .NET
> System.Timers.T imer class. This has a new property
> CollectionInter valMinutes which I expected to be added to the

'Behavior' > section of the class properties and also to be available
as a 'Dynamic' > property so that I could control it from the
application config file. The > new property is not shown, but the
properties inherited from the base class > are.
>> I cannot find any reference to how to do this in the help. I have

tried > creating the new class as both a standard class and a
component class. >> How should I declare properties in the new class
so that they are included > in 'Behavior' and ensure they are
available as 'Dynamic' properties?
It's perhaps wise to post your property's declaration, so we can see
which attributes you have applied to the property.

Also consider that VS.NET-related issues like the one you're having
are more at home in the vs.net related newsgroups.

FB

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Sorry, bit of a newbie here. Not sure which VS newsgroup would be
appropriate.

My C# code is below, hope that helps.

=============== =============== =============== =============== =============== =
==

using System;
using System.Timers;
using System.Componen tModel;

namespace EA_Read_Event_L ogs_Service
{
/// <summary>
/// Summary description for ServiceTimer.
/// </summary>
public class ServiceTimer: System.Timers.T imer
{
public ServiceTimer()
{
//
// TODO: Add constructor logic here
//
}

public void ScheduleNext()
{
DateTime d1 = DateTime.Now;

Enabled = true;
Interval = (CollectionInte rval * 60 * 1000) -
((((d1.Hour * 60) + d1.Minute) * 60 + d1.Second) * 1000 +
d1.Millisecond) % (CollectionInte rval * 60 * 1000); }

/// <summary>
/// Interval between log collections, maximum value one day, units are
minutes /// </summary>
public double CollectionInter valMinutes
{
get
{
return CollectionInter val;
}
set
{
if ((value <= 60 * 24) & (value > 0))
{
CollectionInter val = value;
}
else
{
throw new ArgumentOutOfRa ngeException("C ollectionInterv al", value,
"Collection Interval must be less than 1440 (1 day) and greater than 0");
}; }
}

/// <summary>
/// Minutes to wait between collections
/// </summary>
private double CollectionInter val = 60;
}
}


--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Nov 16 '05 #4
Thanks Frans, I have applied the decoration and it now works

Even knowing the answer the documentation on attributes isn't very clear but I'll keep reading it until I understand it

----- Frans Bouma [C# MVP] wrote: ----

You haven't decorated the property with attributes to make it appear in th
designer. This is perhaps a good article to get started (It's VB.NET, but th
ideas are the same

http://msdn.microsoft.com/msdnmag/is...ols/default.as


Richard Abraham wrote
----- Frans Bouma [C# MVP] wrote: ----

Richard Abraham wrote
I have created a new class ServiceTimer based upon the .NE

System.Timers.T imer class. This has a new propert
CollectionInter valMinutes which I expected to be added to th

'Behavior' > section of the class properties and also to be availabl
as a 'Dynamic' > property so that I could control it from th
application config file. The > new property is not shown, but th
properties inherited from the base class > are
I cannot find any reference to how to do this in the help. I hav tried > creating the new class as both a standard class and
component class. >> How should I declare properties in the new clas
so that they are included > in 'Behavior' and ensure they ar
available as 'Dynamic' properties?
It's perhaps wise to post your property's declaration, so we can se
which attributes you have applied to the property
Also consider that VS.NET-related issues like the one you're havin

are more at home in the vs.net related newsgroups
F
--

Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.co
My .NET Blog: http://weblogs.asp.net/fboum
Microsoft C# MV Sorry, bit of a newbie here. Not sure which VS newsgroup would b

appropriate
My C# code is below, hope that helps
=============== =============== =============== =============== ===============

=
using System

using System.Timers
using System.Componen tModel
namespace EA_Read_Event_L ogs_Servic


/// <summary>> /// Summary description for ServiceTimer
/// </summary>> public class ServiceTimer: System.Timers.T ime

public ServiceTimer(

/
// TODO: Add constructor logic her
/
public void ScheduleNext(


DateTime d1 = DateTime.Now
Enabled = true

Interval = (CollectionInte rval * 60 * 1000) -
((((d1.Hour * 60) + d1.Minute) * 60 + d1.Second) * 1000
d1.Millisecond) % (CollectionInte rval * 60 * 1000);
/// <summary>> /// Interval between log collections, maximum value one day, units ar

minutes /// </summary>> public double CollectionInter valMinute

ge

return CollectionInter val

se

if ((value <= 60 * 24) & (value > 0)

CollectionInter val = value

els

throw new ArgumentOutOfRa ngeException("C ollectionInterv al", value
"Collection Interval must be less than 1440 (1 day) and greater than 0")
};
/// <summary>> /// Minutes to wait between collection

/// </summary>> private double CollectionInter val = 60


--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.co
My .NET Blog: http://weblogs.asp.net/fboum
Microsoft C# MV

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
3833
by: pablo | last post by:
Dear NewsGroupers, I am relatively new to OOP and cannet get my head around this problem. I have two classes. Class Child extends Parent. There is no constructor for the Child class. So when I create a child object the constructor for the parent object is called. That works fine. But now I have the problem that I want to add an already existing Parent object to create a new Child object. How can this be done?
2
1339
by: listerofsmeg | last post by:
Newbie here. I want to use a .config file with my simple console app, but no matter what I do I cannot get the "dynamic" rollout in my properties window. In the end I gave up and coded the calls to ConfigurationSettings.AppSettings.Get() myself, but my problem now is creating the config file. It looks like I'll have to do that manually too.
5
1454
by: Demetri | last post by:
I would like to know if anyone can suggest how to implement the following: We need to have classes who's properties are defined by a database. The properties can not be hard coded. In addition properties datatype will also be defined by the database and are subject to change in the future. So a property that may return an int could in the future return a bool value. Two questions: 1. How do you implement said senerio?
3
13716
by: Guy Harwood | last post by:
Hi, I have designed a textbox that inherits from the System.Windows.Forms.Textbox control. when the control is readonly the back color changes to a light blue to indicate that it is frozen. This all works well, but i would like the color to be configurable via the app.config file.
3
2229
by: Kiran | last post by:
Hi, If I create a Virtual directory with application name programmatically it will not show up in the available web services while adding web reference(Dynamic discovery fails). Where as if I create the virtual directory manually it will shown up while adding web reference. I have used the following code to create it
3
4886
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
7
22498
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We added an entry to the executable's .exe.config file to specify the URL, and under the 1.1 framework this worked well. Unfortunately, this is not working under the 2.0 framework. I see in the Reference.cs file under the web service reference the...
3
3343
by: cwertman | last post by:
I have a question regarding dynamic properties. I have an Object say Account --Id --Prefix --Fname --Lname --Suffix
15
10871
by: EDBrian | last post by:
My problem is this. Our clients create different fields they want to collect and we allow them build dynamic filters, reports etc... We run some TSQL to actually create the column and all works very well. We are now adding a lot more functionality to our filters and could really benefit from using the LINQ to SQL. I have experimented with the Dynamic Linq...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.