Class ViewDescriptorInstanceFactory
A factory for generating ViewDescriptorInstances.
Inherited Members
Namespace: LemonEdge.Client.Core.Views.Core
Assembly: LemonEdge.ClientCore.dll
Syntax
public class ViewDescriptorInstanceFactory : IViewDescriptorInstanceFactory, IHaveAddInListeners
Constructors
ViewDescriptorInstanceFactory(IDomainContextEventHandler, IEntityDescriptorFactory, IReflectionHelper, IViewDescriptorEnumeratorFactory, ILogger<ViewDescriptorInstanceFactory>)
Declaration
public ViewDescriptorInstanceFactory(IDomainContextEventHandler context, IEntityDescriptorFactory entityDescriptorFactory, IReflectionHelper reflectionHelper, IViewDescriptorEnumeratorFactory enumeratorFactory, ILogger<ViewDescriptorInstanceFactory> logger)
Parameters
Type | Name | Description |
---|---|---|
IDomainContextEventHandler | context | |
IEntityDescriptorFactory | entityDescriptorFactory | |
IReflectionHelper | reflectionHelper | |
IViewDescriptorEnumeratorFactory | enumeratorFactory | |
ILogger<ViewDescriptorInstanceFactory> | logger |
Properties
AllDescriptors
A global list of the view descriptors for all valid view types within the system
For internal use only, do not alter these.
Declaration
public IEnumerable<ViewDescriptorInstance> AllDescriptors { get; }
Property Value
Type | Description |
---|---|
IEnumerable<ViewDescriptorInstance> |
EnumeratorFactory
The session IViewDescriptorEnumeratorFactory
Declaration
public IViewDescriptorEnumeratorFactory EnumeratorFactory { get; }
Property Value
Type | Description |
---|---|
IViewDescriptorEnumeratorFactory |
Methods
AddAddInListeners()
Adds listeners.
Declaration
public void AddAddInListeners()
CreateErrorView(ViewDescriptorInstance, IModelLayoutDisplayer, Exception)
Creates an error view from a descriptor and exception.
Declaration
public IModelView CreateErrorView(ViewDescriptorInstance descriptor, IModelLayoutDisplayer displayer, Exception ex)
Parameters
Type | Name | Description |
---|---|---|
ViewDescriptorInstance | descriptor | The descriptor |
IModelLayoutDisplayer | displayer | The layout displayer that will host the created view |
Exception | ex | The exception |
Returns
Type | Description |
---|---|
IModelView |
CreateView(ViewDescriptorInstance, IModelLayoutDisplayer)
Creates an instance of the IModelView described by this view descriptor instance in the specified layout displayer
If the creation of the view fails (because it has not been implemented in the client application) then the system will first attempt to create any view specified through the LemonEdge.Client.Core.Views.Core.ViewDescriptorInstanceFactory.CreateViewFallback(System.Type,System.Type,string) method.
If that fails, or there is no fallback specified, then it will return a standard error view with the message of the error insteadDeclaration
public IModelView CreateView(ViewDescriptorInstance descriptor, IModelLayoutDisplayer displayer)
Parameters
Type | Name | Description |
---|---|---|
ViewDescriptorInstance | descriptor | The descriptor |
IModelLayoutDisplayer | displayer | The layout displayer that will host the created view |
Returns
Type | Description |
---|---|
IModelView | An instance of the view created in the client application UI |
CreateViewFallback(Type, Type, string)
An override to provide a different view to use when loading a display where the CreateView(ViewDescriptorInstance) call fails as it has not been implemented in that specific client application ui.
By providing an alternative this CreateView(ViewDescriptorInstance, IModelLayoutDisplayer) method will attempt to create that view instead if the original fails
This is used for providing more feature rich graphical views that can be replaced by grid versions if the graphical UI has not been implemented in the client such as in the console applicationDeclaration
public void CreateViewFallback(Type viewType, Type fallBack, string fallBackViewCreationParams)
Parameters
Type | Name | Description |
---|---|---|
Type | viewType | The type of view to provide a fall back for if the initial specified one fails |
Type | fallBack | The type of view to create instead of the |
string | fallBackViewCreationParams | The optional serialized parameters to use for the ViewCreationParam when creating the |
FromView(Type, string, ViewDescriptorInstance, string, Type)
Declaration
public ViewDescriptorInstance FromView(Type viewType, string viewCreationParam = "", ViewDescriptorInstance parent = null, string controllerName = "", Type displayableType = null)
Parameters
Type | Name | Description |
---|---|---|
Type | viewType | |
string | viewCreationParam | |
ViewDescriptorInstance | parent | |
string | controllerName | |
Type | displayableType |
Returns
Type | Description |
---|---|
ViewDescriptorInstance |
FromView<T>(string, ViewDescriptorInstance, string, Type)
Returns the system view descriptor instance of the view from the specified parameters
This is used instead of creating a ViewDescriptor from scratch as this automatically correctly fills out the DisplayableItemType, Name and other properties by default so you do not have to
Declaration
public ViewDescriptorInstance FromView<T>(string viewCreationParam = "", ViewDescriptorInstance parent = null, string controllerName = "", Type displayableType = null) where T : IModelView
Parameters
Type | Name | Description |
---|---|---|
string | viewCreationParam | An optional parameter to use when the CreateView(ViewDescriptorInstance) method actually creates the view. See each IModelView type for a description of valid parameters |
ViewDescriptorInstance | parent | An optional instance of the view descriptor that is the parent of this one |
string | controllerName | An optional name for the controller to use when creating the controller automatically for this view. If null the default one will be used. |
Type | displayableType | An optional type this view should work against. If null the default type for the view will be used. |
Returns
Type | Description |
---|---|
ViewDescriptorInstance | A newly created view descriptor instance that fully describes the type of view that should be created by the system in a layout |
Type Parameters
Name | Description |
---|---|
T | Indicates the type of IModelView to return a view descriptor for |
Remarks
For instance to return the view descriptor for a message view:
var view = ViewDescriptorInstance.FromView(typeof(IMessageView));
view.Param = new MessageViewParams() { Message = $"Some custom message for the view."};
RemoveAddInListeners()
Removes listeners.
Declaration
public void RemoveAddInListeners()