Class ApplicationComponent
An abstraction of a disposable application component - major implementation/functionality part of any app.
Components logically subdivide application chassis so their instances may be discovered
by other parties, for example: one may iterate over all components in an application that support instrumentation and logging.
Services are sub-types of components.
Use "ApplicationComponent.AllComponents" to access all components in the container
Inheritance
System.Object
ApplicationComponent
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Azos.dll
Syntax
[SlimSerializationProhibited]
public abstract class ApplicationComponent : DisposableObject, IDisposable, IApplicationComponent
Constructors
ApplicationComponent(IApplicationComponent)
Declaration
protected ApplicationComponent(IApplicationComponent director)
Parameters
ApplicationComponent(IApplication)
Declaration
protected ApplicationComponent(IApplication application)
Parameters
Properties
App
References application that this component services
Declaration
public IApplication App { get; }
Property Value
ComponentCommonName
Returns the common name used to identify the component, for example "Glue" for various IGlue implementations.
This name is searched-by some management tools that allow to find component by this name that does not change between
application restarts like ComponentSID does. Subordinate (non-root) components return null
Declaration
public virtual string ComponentCommonName { get; }
Property Value
Type |
Description |
System.String |
|
ComponentDirector
Returns a reference to component that this app component services/operates under, or null
Declaration
public IApplicationComponent ComponentDirector { get; }
Property Value
ComponentEffectiveLogLevel
Determines the effective log level for this component, taking it from director if it is not defined on this level
Declaration
public virtual MessageType ComponentEffectiveLogLevel { get; }
Property Value
ComponentLogFromPrefix
Returns a prefix used in "From" log message field. May Override in your particular component to reflect the better from,
as the default uses class name concatenated with instance SID
Declaration
public virtual string ComponentLogFromPrefix { get; }
Property Value
Type |
Description |
System.String |
|
ComponentLogLevel
Sets the log level for this component, if not defined then the component logger uses the director/log level
via the ComponentEffectiveLogLevel property
Declaration
[Config("$log-level|$component-log-level|$cmp-log-level")]
[ExternalParameter(new string[]{"log"})]
public MessageType? ComponentLogLevel { get; set; }
Property Value
ComponentLogTopic
Returns value for "Topic" log message field.
Must override in your particular component to reflect the proper logging topic
Declaration
public abstract string ComponentLogTopic { get; }
Property Value
Type |
Description |
System.String |
|
ComponentSID
Returns process/instance unique app component system id
Declaration
public ulong ComponentSID { get; }
Property Value
Type |
Description |
System.UInt64 |
|
ComponentStartTime
Returns local computer time of component start (not from application container time)
Declaration
public DateTime ComponentStartTime { get; }
Property Value
Type |
Description |
System.DateTime |
|
Methods
AllComponents(IApplication)
Returns a thread-safe enumerable( a snapshot) of all known component instances
Declaration
public static IEnumerable<ApplicationComponent> AllComponents(IApplication app)
Parameters
Returns
Destructor()
Declaration
protected override void Destructor()
Overrides
GetAppComponentByCommonName(IApplication, String)
Returns an existing application component instance by its ComponentCommonName or null. The search is case-insensitive
Declaration
public static ApplicationComponent GetAppComponentByCommonName(IApplication app, string name)
Parameters
Returns
GetAppComponentBySID(IApplication, UInt64)
Returns an existing application component instance by its ComponentSID or null
Declaration
public static ApplicationComponent GetAppComponentBySID(IApplication app, ulong sid)
Parameters
Returns
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
WriteLog(MessageType, String, String, Exception, Nullable<Guid>, String, String, Int32)
Writes a log message for this component; returns the new log msg GDID for correlation, or GDID.Empty if no message was logged.
The file/src are only used if from
is null/blank
Declaration
protected virtual Guid WriteLog(MessageType type, string from, string text, Exception error = null, Guid? related = default(Guid? ), string pars = null, string file = null, int src = 0)
Parameters
Type |
Name |
Description |
MessageType |
type |
|
System.String |
from |
|
System.String |
text |
|
System.Exception |
error |
|
System.Nullable<System.Guid> |
related |
|
System.String |
pars |
|
System.String |
file |
|
System.Int32 |
src |
|
Returns
Type |
Description |
System.Guid |
|
WriteLogFromHere(MessageType, String, Exception, Nullable<Guid>, String, String, Int32)
Writes message into component log using caller file name and line number for the FROM field
Declaration
protected Guid WriteLogFromHere(MessageType type, string text, Exception error = null, Guid? related = default(Guid? ), string pars = null, string file = null, int src = 0)
Parameters
Type |
Name |
Description |
MessageType |
type |
|
System.String |
text |
|
System.Exception |
error |
|
System.Nullable<System.Guid> |
related |
|
System.String |
pars |
|
System.String |
file |
|
System.Int32 |
src |
|
Returns
Type |
Description |
System.Guid |
|
Implements
System.IDisposable
Extension Methods