C# Class WizardWrx.Core.AssemblyLocatorBase

Use a class derived from this class to get the fully qualified name of the file from which the assembly in which the derived class is defined was loaded. See Remarks.
Given the location from which an assembly was loaded, you can learn almost anything else you need to know about that file, such as its size, age, version, and directory. Given the directory, you can locate satellite files, such as configuration files that contain settings that it uses.
Mostrar archivo Open project: txwizard/WizardWrx_NET_API

Protected Properties

Property Type Description
_strAssemblyLocation string

Public Methods

Method Description
AssemblyLocatorBase ( ) : System

Initialize the one and only property of this class, which holds the fully qualified path from which the containing assembly was loaded. Use this constructor to link the configuration file to the assembly that defines this class.

IMPORTANT: If the assembly loads from the Global Assembly Cache, its configuration file must be stored in the application directory. Be aware that if an assembly exists in the Global Assembly Cache, it loads from there, even if there is a copy in the application directory.

AssemblyLocatorBase ( Assembly pasmLinkedAssembly ) : System

Initialize the one and only property of this class, which holds the fully qualified path from which the containing assembly was loaded. Use this constructor to link the configuration file to the assembly that defines this class.

IMPORTANT: If the assembly loads from the Global Assembly Cache, its configuration file must be stored in the application directory. Be aware that if an assembly exists in the Global Assembly Cache, it loads from there, even if there is a copy in the application directory.

GetDLLSetting ( string pstrSettingsKey ) : string

Return the specified setting value, as a string.

Protected Methods

Method Description
GetAssemblyBuildDate ( DateTimeKind pdtmKind ) : DateTime

Return the LastWriteTime of the file that contains the executing assembly. For all practical purposes, that is the date on which the assembly was built.

GetAssemblyVersion ( ) : Version

Return the Version structure, to expedite parsing its parts.

GetAssemblyVersionString ( ) : string

Return the complete version of the executing assembly.

SetPropertiesFromDLLConfiguration ( Type pderivedType ) : PropertySourceCounts

Set the like named properties from the linked configuration file.

This can almost certainly be simplified by enumerating the settings, but either way risks a NOT FOUND exception. This method uses some fairly tricky Reflection gymnastics to map the key names in a configuration file to property names on an object.

Private Methods

Method Description
FromString ( PropertyInfo piThisProperty, string strConfigValueString ) : object

Create an object of the correct type from a string. Please see the Remarks section for important information.

For conversion purposes, objects fall into two groups: enumerations, and everything else. Segregating inputs into the correct group is done by evaluating the PropertyType.BaseType property of the input PropertyInfo object, since enumerations derive from a distinct base type, System.Enum. Everything else derives from System.Object, and its conversion is handled by the SetValue method on the supplied PropertyInfo object.

FullyQualifiedDLLConfigFileName ( bool pfIsForShow ) : string
InitializeInstance ( ) : void

Both constructors call this method to finish initializing the instance. Private string member _strAssemblyLocation must be initialized before the constructor calls this method.

SaveErrorReport ( Type pderivedType, string pstrPropertyName, Exception pexAllKinds ) : Exception

Protected method SetPropertiesFromDLLConfiguration calls this routine to assemble an error message for appending to a string, for subsequent review by callers of derived classes.

Method Details

AssemblyLocatorBase() public method

Initialize the one and only property of this class, which holds the fully qualified path from which the containing assembly was loaded. Use this constructor to link the configuration file to the assembly that defines this class.
IMPORTANT: If the assembly loads from the Global Assembly Cache, its configuration file must be stored in the application directory. Be aware that if an assembly exists in the Global Assembly Cache, it loads from there, even if there is a copy in the application directory.
public AssemblyLocatorBase ( ) : System
return System

AssemblyLocatorBase() public method

Initialize the one and only property of this class, which holds the fully qualified path from which the containing assembly was loaded. Use this constructor to link the configuration file to the assembly that defines this class.
IMPORTANT: If the assembly loads from the Global Assembly Cache, its configuration file must be stored in the application directory. Be aware that if an assembly exists in the Global Assembly Cache, it loads from there, even if there is a copy in the application directory.
public AssemblyLocatorBase ( Assembly pasmLinkedAssembly ) : System
pasmLinkedAssembly Assembly /// Pass in a reference to the assembly to which the configuration file /// is linked. For example, you can use the executing assembly of the /// object at the top of the inheritance tree. ///
return System

GetAssemblyBuildDate() protected method

Return the LastWriteTime of the file that contains the executing assembly. For all practical purposes, that is the date on which the assembly was built.
protected GetAssemblyBuildDate ( DateTimeKind pdtmKind ) : DateTime
pdtmKind DateTimeKind /// This DateTimeKind enumeration member specifies whether to report the /// LastWriteTime or the LastWriteTimeUtc. ///
return DateTime

GetAssemblyVersion() protected method

Return the Version structure, to expedite parsing its parts.
protected GetAssemblyVersion ( ) : Version
return Version

GetAssemblyVersionString() protected method

Return the complete version of the executing assembly.
protected GetAssemblyVersionString ( ) : string
return string

GetDLLSetting() public method

Return the specified setting value, as a string.
public GetDLLSetting ( string pstrSettingsKey ) : string
pstrSettingsKey string /// This string is the name (key) of the desired setting. ///
return string

SetPropertiesFromDLLConfiguration() protected method

Set the like named properties from the linked configuration file.
This can almost certainly be simplified by enumerating the settings, but either way risks a NOT FOUND exception. This method uses some fairly tricky Reflection gymnastics to map the key names in a configuration file to property names on an object.
protected SetPropertiesFromDLLConfiguration ( Type pderivedType ) : PropertySourceCounts
pderivedType Type /// When the derived class constructor calls this method, it must pass in a /// reference to its own Type property. ///
return PropertySourceCounts

Property Details

_strAssemblyLocation protected_oe property

Once the energy required to gather the location has been expended, save it for future use.
protected string _strAssemblyLocation
return string