C# Class Illusion.ViewModelLocator

A strategy for determining which view model to use for a given view.
Mostra file Open project: kasicass/kasicass

Public Properties

Property Type Description
InterfaceCaptureGroupName string
LocateForView object>.Func
LocateForViewType object>.Func
LocateTypeForViewType Func
NameTransformer NameTransformer
TransformName Func>

Public Methods

Method Description
AddDefaultTypeMapping ( string viewSuffix = "View" ) : void

Adds a default type mapping using the standard namespace mapping convention

AddNamespaceMapping ( string nsSource, string nsTargets, string viewSuffix = "View" ) : void

Adds a standard type mapping based on simple namespace mapping

AddSubNamespaceMapping ( string nsSource, string nsTargets, string viewSuffix = "View" ) : void

Adds a standard type mapping by substituting one subnamespace for another

AddTypeMapping ( string nsSourceReplaceRegEx, string nsSourceFilterRegEx, string nsTargetsRegEx, string viewSuffix = "View" ) : void

Adds a standard type mapping based on namespace RegEx replace and filter patterns

ConfigureTypeMappings ( TypeMappingConfiguration config ) : void

Specifies how type mappings are created, including default type mappings. Calling this method will clear all existing name transformation rules and create new default type mappings according to the configuration.

MakeInterface ( string typeName ) : string

Makes a type name into an interface name.

Private Methods

Method Description
SetAllDefaults ( ) : void
ViewModelLocator ( ) : System

Method Details

AddDefaultTypeMapping() public static method

Adds a default type mapping using the standard namespace mapping convention
public static AddDefaultTypeMapping ( string viewSuffix = "View" ) : void
viewSuffix string Suffix for type name. Should be "View" or synonym of "View". (Optional)
return void

AddNamespaceMapping() public static method

Adds a standard type mapping based on simple namespace mapping
public static AddNamespaceMapping ( string nsSource, string nsTargets, string viewSuffix = "View" ) : void
nsSource string Namespace of source type
nsTargets string Namespaces of target type as an array
viewSuffix string Suffix for type name. Should be "View" or synonym of "View". (Optional)
return void

AddSubNamespaceMapping() public static method

Adds a standard type mapping by substituting one subnamespace for another
public static AddSubNamespaceMapping ( string nsSource, string nsTargets, string viewSuffix = "View" ) : void
nsSource string Subnamespace of source type
nsTargets string Subnamespaces of target type as an array
viewSuffix string Suffix for type name. Should be "View" or synonym of "View". (Optional)
return void

AddTypeMapping() public static method

Adds a standard type mapping based on namespace RegEx replace and filter patterns
public static AddTypeMapping ( string nsSourceReplaceRegEx, string nsSourceFilterRegEx, string nsTargetsRegEx, string viewSuffix = "View" ) : void
nsSourceReplaceRegEx string RegEx replace pattern for source namespace
nsSourceFilterRegEx string RegEx filter pattern for source namespace
nsTargetsRegEx string Array of RegEx replace values for target namespaces
viewSuffix string Suffix for type name. Should be "View" or synonym of "View". (Optional)
return void

ConfigureTypeMappings() public static method

Specifies how type mappings are created, including default type mappings. Calling this method will clear all existing name transformation rules and create new default type mappings according to the configuration.
public static ConfigureTypeMappings ( TypeMappingConfiguration config ) : void
config TypeMappingConfiguration An instance of TypeMappingConfiguration that provides the settings for configuration
return void

MakeInterface() public static method

Makes a type name into an interface name.
public static MakeInterface ( string typeName ) : string
typeName string The part.
return string

Property Details

InterfaceCaptureGroupName public_oe static_oe property

The name of the capture group used as a marker for rules that return interface types
public static string InterfaceCaptureGroupName
return string

LocateForView public_oe static_oe property

Locates the view model for the specified view instance.
Pass the view instance as a parameters and receive a view model instance.
public static Func LocateForView
return object>.Func

LocateForViewType public_oe static_oe property

Locates the view model for the specified view type.
Pass the view type as a parameter and receive a view model instance.
public static Func LocateForViewType
return object>.Func

LocateTypeForViewType public_oe static_oe property

Determines the view model type based on the specified view type.
Pass the view type and receive a view model type. Pass true for the second parameter to search for interfaces.
public static Func LocateTypeForViewType
return Func

NameTransformer public_oe static_oe property

Used to transform names.
public static NameTransformer NameTransformer
return NameTransformer

TransformName public_oe static_oe property

Transforms a View type name into all of its possible ViewModel type names. Accepts a flag to include or exclude interface types.
Arguments: typeName = The name of the View type being resolved to its companion ViewModel. includeInterfaces = Flag to indicate if interface types are included
public static Func> TransformName
return Func>