Adding dynamic properties to new classes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a new class ServiceTimer based upon the .NET System.Timers.Timer class. This has a new property CollectionIntervalMinutes 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?
 
Richard said:
I have created a new class ServiceTimer based upon the .NET
System.Timers.Timer class. This has a new property
CollectionIntervalMinutes 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
 
----- Frans Bouma [C# MVP] wrote: ----

Richard Abraham wrote
I have created a new class ServiceTimer based upon the .NE
System.Timers.Timer class. This has a new propert
CollectionIntervalMinutes 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
creating the new class as both a standard class and a component class
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.ComponentModel

namespace EA_Read_Event_Logs_Servic

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

public ServiceTimer(

/
// TODO: Add constructor logic her
/


public void ScheduleNext(

DateTime d1 = DateTime.Now

Enabled = true
Interval = (CollectionInterval * 60 * 1000) -
((((d1.Hour * 60) + d1.Minute) * 60 + d1.Second) * 1000 + d1.Millisecond) % (CollectionInterval * 60 * 1000)


/// <summary
/// Interval between log collections, maximum value one day, units are minute
/// </summary
public double CollectionIntervalMinute

ge

return CollectionInterval

se

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

CollectionInterval = value

els

throw new ArgumentOutOfRangeException("CollectionInterval", value, "Collection Interval must be less than 1440 (1 day) and greater than 0")
}



/// <summary
/// Minutes to wait between collection
/// </summary
private double CollectionInterval = 60
 
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/issues/03/05/Design-TimeControls/default.asp
x



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

Richard said:
I have created a new class ServiceTimer based upon the .NET
System.Timers.Timer class. This has a new property
CollectionIntervalMinutes 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.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.ComponentModel;

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

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

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

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

/// <summary>
/// Minutes to wait between collections
/// </summary>
private double CollectionInterval = 60;
}
}
 
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/issues/03/05/Design-TimeControls/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.Timer class. This has a new propert
CollectionIntervalMinutes 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 > aretried > 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
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
appropriate
My C# code is below, hope that helps
=========================================================================== =
using System
using System.Timers
using System.ComponentModel
namespace EA_Read_Event_Logs_Servic

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

public ServiceTimer(

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

DateTime d1 = DateTime.Now
Enabled = true
Interval = (CollectionInterval * 60 * 1000) -
((((d1.Hour * 60) + d1.Minute) * 60 + d1.Second) * 1000
d1.Millisecond) % (CollectionInterval * 60 * 1000);
/// <summary>> /// Interval between log collections, maximum value one day, units ar
minutes /// </summary>> public double CollectionIntervalMinute

ge

return CollectionInterval

se

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

CollectionInterval = value

els

throw new ArgumentOutOfRangeException("CollectionInterval", value
"Collection Interval must be less than 1440 (1 day) and greater than 0")
};
/// <summary>> /// Minutes to wait between collection
/// </summary>> private double CollectionInterval = 60
 
Back
Top