Dotfuscator User's Guide
InsertShelfLifeAttribute

Summary

The InsertShelfLifeAttribute is an instrumentation time attribute for methods. Dotfuscator will insert shelf life code into any method with this attribute. At runtime, the shelf life code can send a warning or expiration message if the application has expired or is about to expire. If the warning period is entered, then a user defined action can be executed. Upon expiration, the default behavior is to exit the application, though a user-defined action can be executed instead. In order to use Shelf Life your application must contain methods marked with a Setup and Teardown attribute. Do not put the InsertShelfLife attribute on the same method containing the Setup Attribute. Methods with this attribute must be executed after the method containing the Setup Attribute.

Application Notification

A SinkElement may be used to specify a method to call, or a property or field to set in the application when a warning or expiration event occurs.

If the SinkElement is a property, the property will be set to true if the warning period is entered or the application is expired; false if not. The property should be writable, accessible from the attributed method, and of boolean type. If the property is not static, it must be defined in the same class as the attributed method, and the attributed method must not be static. The name of the property must be specified in ExpirationNotificationSinkName or WarningNotificationSinkName. The generated code will make no attempt to catch or handle exceptions thrown from the property setter. The type defining the property should be specified in ExpirationNotificationSinkOwner or WarningNotificationSinkOwner; if either is left unset, Dotfuscator will look for the property on the type defining the attributed method.

If the SinkElement is a field, the field will be set to true if warning or expiration occurs; false if not. The field should be accessible from the attributed method, and of boolean type. If the field is not static, it must be defined on the same class as the attributed method, and the attributed method must not be static. The name of the field must be specified in ExpirationNotificationSinkName or WarningNotificationSinkName . The type defining the field should be specified in ExpirationNotificationSinkOwner or WarningNotificationSinkOwner; if either is left unset, Dotfuscator will look for the field on the type defining the attributed method.

If the SinkElement is a method, the method will be called with a single Boolean parameter set to true if the warning period is entered or the application is expired; false if not. The target method should be accessible from the attributed method, and must take one parameter of boolean type. If the target method is not static, it must be defined in the same class as the attributed method, and the attributed method must not be static. The name of the target method must be specified in ExpirationNotificationSinkName or WarningNotificationSinkName. The generated code will make no attempt to catch or handle exceptions thrown from the target method. The type defining the target method should be specified in ExpirationNotificationSinkOwner or WarningNotificationSinkOwner; if either is left unset, Dotfuscator will look for the target method on the type defining the attributed method.

If the SinkElement is a method argument, the named argument should be a Delegate type and the Delegate must have this signature: void( bool ). The Delegate will be invoked with the boolean argument set to true if the warning period is entered or the application is expired; false if not. The generated code will make no attempt to catch or handle exceptions thrown from the invoked Delegate. The name of the method argument must be specified in ApplicationNotificationSinkName. ApplicationNotificationSinkOwner is unused.

If the SinkElement is a Delegate, it should be a field of Delegate type. The Delegate will be invoked with the boolean argument set to true if the warning period is entered or the application is expired; false if not. If the field is not static, it must be defined on the same class as the attributed method, and the attributed method must not be static. The name of the field must be specified in ExpirationNotificationSinkName or WarningNotificationSinkName. In this case, the ExpirationNotificationSinkOwner or WarningNotificationSinkOwner are unused. The Delegate must have this signature: void( bool ). The generated code will make no attempt to catch or handle exceptions thrown from the invoked Delegate.

If the ExpirationNotificationSinkElement is set to DefaultAction, Dotfuscator will inject code that exits the application if it is expired. If the WarningNotificationSinkElement is set to DefaultAction, Dotfuscator will not inject any warning specific code.

If the SinkElement is set to None, Dotfuscator will not inject any code to react if the warning period is entered or the application is expired. Dotfuscator will still generate code to send the appropriate message to a PreEmptive Analytics Endpoint if configured to do so from the Global Options tab.

Dotfuscator will remove this custom attribute from the metadata after instrumentation.

InsertShelfLifeAttribute
Copy Code
public class InsertShelfLifeAttribute : Attribute

Constructor Members

Name Summary
InsertShelfLifeAttribute() Initializes a new instance of the class.

Property Members

Name Summary
ActivationKeyFile The path to the Shelf Life Activation Key file.
ExpirationDate Indicates the date the application will expire and/or deactivate. This can be an absolute date

(e.g., 2009-12-31) or a positive integer representing number of days after the Dotfuscation date that the application should expire.

ExpirationNotificationSinkElement : SinkElements Indicates whether and how to notify the application after shelf life expiration, at the time that the attributed method is called. A sink element may be a writable boolean field, settable boolean property, a void( boolean ) method to call, or a Delegate to invoke. To use this property, ExpirationNotificationSinkName must also be set. If ExpirationNotificationSinkElement is a field, property, or method, the ExpirationNotificationSinkOwner should also be set if it is not in the same class as the attributed method. If the SinkElement is set to “DefaultAction”, Dotfuscator will inject code that exits the application if shelf life expiration is detected.
ExpirationNotificationSinkName : String The name of the property, field, method to set or call after a shelf life expiration check. If this property is set, ExpirationNotificationSinkElement is required to be set as well. If this property is not set, Dotfuscator will not generate code that notifies the application of expiration.
ExpirationNotificationSinkOwner : Type ExpirationNotificationSinkOwner indicates the name of the type that defines the ExpirationNotificationSink method, field, property, argument, or delegate. If not set, the named sink element is searched for on the attributed method’s type.

ExtendedKeyMethodArguements : string

A pattern indicating which parameter names and values should be automatically added to the messages extended key data at runtime.  See Automatically Sending Method Parameters as Extended Keys for details on supported patterns.

ExtendedKeySourceElement : SourceElements Indicates how to access the extended key dictionary at runtime, at the time that the attributed method is called (e.g. a field, property, method, or method parameter). To use this property, ExtendedKeySourceName must also be set. If ExtendedKeySourceElement is a field, method, or property, ExtendedKeySourceOwner must also be set unless the field, method or property is defined on the same class as the attributed method.
ExtendedKeySourceName : string The name of the property, field, method, or method parameter that will contain the extended key dictionary at runtime, at the time that the attributed method is called. If this property is set, ExtendedKeySourceElement is required to be set as well. If this property is not set, Dotfuscator will not generate code to send extended key information.
ExtendedKeySourceOwner : Type If the ExtendedKeySourceElement is a field, method or property, ExtendedKeySourceOwner indicates the name of the type that defines the field, method or property. If not set, the named source element is searched for on the attributed method’s type.
PrivateKeyFile The path to a PKCS #12 Private Key file that is optionally used to provide additional validation of a Shelf Life token.
PrivateKeyFilePassword The password protecting the Private Key file.
ShelfLifeTokenSourceElement ShelfLifeTokenSourceElement indicates how to access the optional shelf life token source at runtime, at the time that the attributed method is called (e.g. a field, property, method, or method parameter). To use this property, ShelfLifeTokenSourceName must also be set. If ShelfLifeTokenSourceElement is a field, method, or property, ShelfLifeTokenSourceOwner must also be set unless the field, method or property is defined on the same class as the attributed method.
ShelfLifeTokenSourceName The name of the property, field, method, or method parameter that will contain the shelf life token at runtime, at the time that the attributed method is called. If this property is set, ShelfLifeTokenSourceElement is required to be set as well. If this property is not set, Dotfuscator will create a shelf life token from the shelf life activation key during instrumentation.
ShelfLifeTokenSourceOwner If the ShelfLifeTokenSourceElement is a field, method or property, ShelfLifeTokenSourceOwner indicates the name of the type that defines the field, method or property. If not set, the named source element is searched for on the attributed method’s type.
WarningDate Indicates the date a warning of impending application expiration will occur. This can be an absolute date

(e.g., 2009-12-31) or a positive integer representing number of days after the Dotfuscation date that the application should issue a warning.

WarningNotificationSinkElement Indicates whether and how to notify the application of impending shelf life expiration, at the time that the attributed method is called. A sink element may be a writable boolean field, settable boolean property, a void( boolean ) method to call, or a Delegate to invoke. To use this property, WarningNotificationSinkName must also be set. If ApplicationNotificationSinkElement is a field, property, or method, the WarningNotificationSinkOwner should also be set if it is not in the same class as the attributed method. If the SinkElement is set to “DefaultAction”, Dotfuscator will not inject code to perform any additional warning behavior.
WarningNotificationSinkName The name of the property, field, method to set or call after a shelf life warning check. If this property is set, WarningNotificationSinkElement is required to be set as well. If this property is not set, Dotfuscator will not inject code to perform any additional warning behavior.
WarningNotificationSinkOwner WarningNotificationSinkOwner indicates the name of the type that defines the WarningNotificationSink method, field, property, argument, or delegate. If not set, the named sink element is searched for on the attributed method’s type.
See Also

Instrumentation

References

 

 


© 2016 PreEmptive Solutions, LLC. All Rights Reserved.

www.preemptive.com