Interface IApplication
Describes general application model - usually a root service locator with dependency injection container that governs application initialization, state management, logging etc. An applications is usually implemented with a singleton class that has static conduits to instance properties via App shortcut. Application instances may get passed by reference to simplify mocking
Inherited Members
Namespace: NFX.ApplicationModel
Assembly: NFX.dll
Syntax
public interface IApplication : INamed, ILocalizedTimeProvider
Remarks
This pattern is used on purpose based on careful evaluation of various DI frameworks use-cases in various projects, both server and client-side. The central service/locator hub per process as faciliatetd by the IApplication is the most intuitive and simple dependency resolution facility for 90+% of various business applications - it significantly simplifies development and debugging as Application provides a common root for all ApplicationComponents regardless of the app types
Properties
Active
Returns true when application instance is active and working. This property returns false as soon as application finalization starts on shutdown or Stop() was called Use to exit long-running loops and such
Declaration
bool Active { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
AllowNesting
Returns true when this app container allows nesting of another one
Declaration
bool AllowNesting { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
CommandArgs
References application command arguments
Declaration
IConfigSectionNode CommandArgs { get; }
Property Value
Type | Description |
---|---|
IConfigSectionNode |
ConfigRoot
References application configuration root
Declaration
IConfigSectionNode ConfigRoot { get; }
Property Value
Type | Description |
---|---|
IConfigSectionNode |
DataStore
References application data store
Declaration
IDataStore DataStore { get; }
Property Value
Type | Description |
---|---|
IDataStore |
EventTimer
References event timer - an entity that maintains and runs scheduled instances of Event
Declaration
IEventTimer EventTimer { get; }
Property Value
Type | Description |
---|---|
IEventTimer |
ForceInvariantCulture
True when the app should force the process-wide invariant culture regardless of machine-level culture
Declaration
bool ForceInvariantCulture { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Glue
References glue implementation that may be used to "glue" remote instances/processes/contracts together
Declaration
IGlue Glue { get; }
Property Value
Type | Description |
---|---|
IGlue |
InstanceID
Returns unique identifier of this running instance
Declaration
Guid InstanceID { get; }
Property Value
Type | Description |
---|---|
System.Guid |
Instrumentation
References instrumentation for this application instance
Declaration
IInstrumentation Instrumentation { get; }
Property Value
Type | Description |
---|---|
IInstrumentation |
IsUnitTest
True if app is launched as a unit test as set by the app config "unit-test=true" The general use of this flag is discouraged as code cnstructs should not form special cases just for unit testing, however in some cases this flag is usefull. It is not exposed via App. static accessors
Declaration
bool IsUnitTest { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Log
References app log
Declaration
ILog Log { get; }
Property Value
Type | Description |
---|---|
ILog |
ModuleRoot
References the root module (such as business domain logic) for this application. This is a dependency injection root provided for any application type
Declaration
IModule ModuleRoot { get; }
Property Value
Type | Description |
---|---|
IModule |
ObjectStore
References object store that may be used to persist object graphs between volatile application shutdown cycles
Declaration
IObjectStore ObjectStore { get; }
Property Value
Type | Description |
---|---|
IObjectStore |
SecurityManager
References security manager that performs user authentication based on passed credentials and other security-related global tasks
Declaration
ISecurityManager SecurityManager { get; }
Property Value
Type | Description |
---|---|
ISecurityManager |
ShutdownStarted
Returns true after Dispose() was called to indicate that application is shutting down
Declaration
bool ShutdownStarted { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
StartTime
Returns timestamp when application started as localized app time
Declaration
DateTime StartTime { get; }
Property Value
Type | Description |
---|---|
System.DateTime |
Stopping
Returns true after Stop() was called
Declaration
bool Stopping { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
TimeSource
References time source - an entity that supplies local and UTC times. The concrete implementation may elect to get accurate times from the network or other external precision time sources (i.e. NASA atomic clock)
Declaration
ITimeSource TimeSource { get; }
Property Value
Type | Description |
---|---|
ITimeSource |
Methods
MakeNewSessionInstance(Guid, User)
Factory method that creates new session object suitable for particular application type
Declaration
ISession MakeNewSessionInstance(Guid sessionID, User user = null)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | sessionID | Session identifier |
User | user | Optional user object that the session is for |
Returns
Type | Description |
---|---|
ISession | New session object |
NotifyAllConfigSettingsAboutChange()
Forces notification of all registered IConfigSettings-implementers about configuration change
Declaration
void NotifyAllConfigSettingsAboutChange()
RegisterAppFinishNotifiable(IApplicationFinishNotifiable)
Registers an instance of IApplicationFinishNotifiable with application container to receive a call when underlying application instance will finish its lifecycle.
Declaration
bool RegisterAppFinishNotifiable(IApplicationFinishNotifiable notifiable)
Parameters
Type | Name | Description |
---|---|---|
IApplicationFinishNotifiable | notifiable |
Returns
Type | Description |
---|---|
System.Boolean | True if notifiable instance was not found and was added |
RegisterConfigSettings(IConfigSettings)
Registers an instance of IConfigSettings with application container to receive a call when underlying app configuration changes
Declaration
bool RegisterConfigSettings(IConfigSettings settings)
Parameters
Type | Name | Description |
---|---|---|
IConfigSettings | settings |
Returns
Type | Description |
---|---|
System.Boolean | True if settings instance was not found and was added |
Stop()
Initiates the stop of the application by setting its Stopping to true and Active to false so dependent services may start to terminate
Declaration
void Stop()
UnregisterAppFinishNotifiable(IApplicationFinishNotifiable)
Removes the registration of IApplicationFinishNotifiable from application container
Declaration
bool UnregisterAppFinishNotifiable(IApplicationFinishNotifiable notifiable)
Parameters
Type | Name | Description |
---|---|---|
IApplicationFinishNotifiable | notifiable |
Returns
Type | Description |
---|---|
System.Boolean | True if notifiable instance was found and removed |
UnregisterConfigSettings(IConfigSettings)
Removes the registration of IConfigSettings from application container
Declaration
bool UnregisterConfigSettings(IConfigSettings settings)
Parameters
Type | Name | Description |
---|---|---|
IConfigSettings | settings |
Returns
Type | Description |
---|---|
System.Boolean | True if settings instance was found and removed |