Click or drag to resize
ApplicationManager Class
Manages the various subsystem Managers.
Inheritance Hierarchy

Namespace: OpenIIoT.Core
Assembly: OpenIIoT (in OpenIIoT.exe) Version: 0.5.0.39120
Syntax
[DiscoverableAttribute]
public class ApplicationManager : Manager, 
	IApplicationManager, IManager, IStateful, IEventProvider, IProvider

The ApplicationManager type exposes the following members.

Constructors
  NameDescription
Private methodStatic memberApplicationManager
Private methodApplicationManager
Initializes a new instance of the ApplicationManager class with the specified Manager Types.
Top
Properties
  NameDescription
Public propertyAutomaticRestartPending
Gets a value indicating whether the stateful object is pending an automatic restart.
(Inherited from Manager.)
Private propertyDependencies
Gets the dictionary of IManagers upon which this Manager depends, keyed on Type name.
(Inherited from Manager.)
Public propertyEventProviderName
Gets or sets the Event Provider name.
(Inherited from Manager.)
Public propertyInstanceName
Gets the name of the application instance, retrieved from the application's settings file.
Private propertyManagerDependencies
Gets or sets a dictionary containing a list of dependencies for each application Manager.
Private propertyManagerInstances
Gets or sets the list of application Manager instances.
Public propertyManagerName
Gets or sets the name of the Manager.
(Inherited from Manager.)
Public propertyManagers
Gets the list of IManager instances managed by the IApplicationManager.
Private propertyManagerTypes
Gets or sets the list of application Manager Types.
Public propertyProductName
Gets the name of the product, retrieved from AssemblyInfo.cs.
Public propertyProductVersion
Gets the version of the product, retrieved from AssemblyInfo.cs.
Public propertyState
Gets the current State of the Stateful object.
(Inherited from Manager.)
Top
Methods
  NameDescription
Protected methodChangeState(State)
Changes the State of the Manager to the specified State and fires the StateChanged event.
(Inherited from Manager.)
Protected methodChangeState(State, StopType)
Changes the State of the Manager to the specified State and fires the StateChanged event.
(Inherited from Manager.)
Protected methodChangeState(State, String, StopType)
Changes the State of the Manager to the specified State and fires the StateChanged event.
(Inherited from Manager.)
Protected methodDependenciesAreAllInState
Examines the State of the IManager s contained within the Dependencies property to ensure each is in a State contained within the supplied list of State s. If not, an error message is added to the return Result.
(Inherited from Manager.)
Protected methodDependencyT
Retrieves the IManager instance matching the specified Type from the Dependencies dictionary.
(Inherited from Manager.)
Private methodDependencyStateChanged
Occurs when the state of a Manager upon which this Manager is dependent changes.
(Inherited from Manager.)
Public methodDispose
Disposes this Manager.
(Inherited from Manager.)
Protected methodDispose(Boolean)
Disposes the restartTimer property.
(Inherited from Manager.)
Public methodStatic memberGetInstance
Returns the Singleton instance of ApplicationManager
Private methodStatic memberGetInstanceName
Returns the "InstanceName" setting from the app.config file, or the default value if the setting is not retrieved.
Public methodGetManagerT
Returns the Manager from the list of Managers matching the specified Type.
Private methodGetManagerDependenciesT
Retrieves the list of Type s corresponding to the IManager Types on which the specified Manager Type depends.
Public methodStatic memberInstantiate
Returns the singleton instance of the ApplicationManager. Creates an instance if null.
Private methodInstantiateManagerT
Creates and returns an instance of the specified IManager Type.
Private methodInstantiateManagers
Iterates over the list of IManager Types and instantiates each in the order in which they are represented in the list.
Private methodInvokeMethod(MethodInfo, Type, Type, String, Object)
Invokes the specified generic method, supplying the optionally specified array of parameters as method parameters. Throws a new Exception of the specified Type and with the specified message upon encountering a TargetInvocationException.
Private methodInvokeMethodT(MethodInfo, Type, Type, String, Object)
Invokes the specified generic method, supplying the specified Type as the Type parameter and the optionally specified array of parameters as method parameters. Throws a new Exception of the specified Type and with the specified message upon encountering a TargetInvocationException.
Public methodIsInState
Determines whether any of the specified State s match the current State.
(Inherited from Manager.)
Private methodIsManagerRegisteredT
Searches the list of registered IManager instances for the specified instance and returns a value indicating whether it was found.
Private methodManagerStateChanged
Event handler for the StateChanged event of registered Managers.
Protected methodRegisterDependencyT
Adds the specified IManager instance of the specified Type to the Dependencies dictionary.
(Inherited from Manager.)
Private methodRegisterManagerT
Adds the specified IManager to the Manager list and subscribes to its StateChanged event.
Private methodResolveManagerDependenciesT
Returns a list of IManager instances corresponding to the Manager Types upon which the specified Manager is dependent.
Public methodRestart
Restarts the Manager.
(Inherited from Manager.)
Private methodRestartTimerElapsed
Occurs when the restart timer's interval elapses.
(Inherited from Manager.)
Protected methodSetup
Implements the Manager-specific post-instantiation procedure.
(Inherited from Manager.)
Private methodSetupManager
Private methodSetupManagers
Iterates over the list of IManager instances and invokes the Setup method on each.
Protected methodShutdown
Executed upon shutdown of the Manager. Stops all application managers.
(Overrides ManagerShutdown(StopType).)
Public methodStart
Starts the Manager.
(Inherited from Manager.)
Private methodStartManager
Starts the specified IManager instance
Private methodStartManagers
Starts each IManager contained within the specified list of Manager instances.
Protected methodStartup
Executed upon startup of the Manager. Starts all application managers.
(Overrides ManagerStartup.)
Public methodStop
Stops the Manager.
(Inherited from Manager.)
Private methodStopManager
Stops the specified IManager instance.
Private methodStopManagers
Stops each of the IManager instances in the specified Manager instance list.
Protected methodTeardown
Implements the Manager-specific disposal procedure.
(Inherited from Manager.)
Public methodStatic memberTerminate
Terminates Singleton instance of ApplicationManager.
Top
Events
  NameDescription
Public eventStateChanged
Occurs when the State property changes.
(Inherited from Manager.)
Top
Fields
  NameDescription
Private fielddependencies
The dictionary of IManagers upon which this Manager depends, keyed on Type name.
(Inherited from Manager.)
Private fieldStatic memberinstance
The Singleton instance of ApplicationManager.
Private fieldStatic memberlogger
The Logger for this class.
Private fieldrestartTimer
The restart timer, used to automatically restart the Manager following a Stop with pending restart.
(Inherited from Manager.)
Top
Extension Methods
  NameDescription
Public Extension MethodToJson
Serializes and returns as json the specified object.
(Defined by Utility.)
Top
Remarks

This class is a Singleton and is therefore restricted to one instance for the application. External classes may invoke the Instantiate(Type) method to retrieve the instance, however they should not. If the instance is required in a static class or method, or anywhere else where dependency injection is not available, the GetInstance method should be used to retrieve the instance.

The Instantiate(Type) method, and thusly the class constructor, accepts an array of Type s corresponding to each IManager instance to be created. The Application Manager maintains an internal list of these Types, the instances of the Types created (one each), and a dictionary containing the dependencies of each Type.

Upon instantiation, the Application Manager invokes InstantiateManagers method which iterates over the list of Types and creates an instance of each using the InstantiateManagerT method, then registers the new instance with RegisterManagerT(IManager). If all dependencies for a Manager have not yet been instantiated when the dependent Manager is instantiated an exception will be thrown; the order in which the Manager Types appear in the Type list provided to the Instantiate(Type) method must reflect the inter-Manager dependencies. The RegisterManager method adds the Manager instance to the internal list and creates an entry in the dependency dictionary for the Type.

After all Managers have been instantiated, the list of created instances is iterated over and the Setup method is invoked on each. This method allows Managers which are dependent upon other Managers to initialize those dependencies. Examples include the ConfigurationManager, which iterates over the list of Manager instances and registers Managers which implement IConfigurableT, and the EventManager, which does the same for implementations of IEventProvider.

The method GetManagerT and property Managers are provided to allow Managers to retrieve other Managers contained within the application. GetManagerT is primarily provided to allow static methods to access a particular manager. This is the only valid usage; instance methods should use the dependency injection system. The Managers property provides an immutable list of Manager instances which allows for the functionality described above for Setup. This is necessary so that Managers may access other Managers which are not explicitly defined as dependencies. Again, this is the only valid usage of the method.

As with other instances of IManager, the Startup and Shutdown(StopType) methods are invoked upon the invocation of Start and Stop(StopType). The Application Manager uses these methods to start and stop Manager instances.

See Also