Class MacroExtensionContainer<TContainer, TExtension>
- Namespace
- CMS.MacroEngine
- Assembly
- CMS.MacroEngine.dll
Wrapper class to provide extensions to an arbitrary object. It is a base class for ExtensionTypeContainer and MacroFieldContainer classes.
public class MacroExtensionContainer<TContainer, TExtension> where TContainer : MacroExtensionContainer<TContainer, TExtension>, new() where TExtension : MacroExtension
Type Parameters
TContainerTExtension
- Inheritance
-
objectMacroExtensionContainer<TContainer, TExtension>
- Derived
- Extension Methods
Constructors
MacroExtensionContainer()
public MacroExtensionContainer()
Properties
Extensions
Extensions dictionary
protected StringSafeDictionary<TExtension> Extensions { get; }
Property Value
- StringSafeDictionary<TExtension>
Instance
Container instance
protected static TContainer Instance { get; }
Property Value
- TContainer
RegisteredExtensionNames
Returns enumerable of all registered Extension names.
protected IEnumerable<string> RegisteredExtensionNames { get; }
Property Value
- IEnumerable<string>
RegisteredExtensions
Returns enumerable of all Extensions.
protected IEnumerable<TExtension> RegisteredExtensions { get; }
Property Value
- IEnumerable<TExtension>
Methods
CheckGlobalAdmin(EvaluationContext)
Checks if the current context user is global admin, returns true if so, otherwise returns false
protected static bool CheckGlobalAdmin(EvaluationContext context)
Parameters
contextEvaluationContextEvaluation context
Returns
- bool
GetExtension(string)
Returns a Extension of given name (return null if specified Extension does not exist).
protected TExtension GetExtension(string name)
Parameters
namestringExtension name
Returns
- TExtension
GetExtension(Type, string)
Returns the extension by type and name. Does not cache the result. Does not cache the result.
protected virtual MacroExtension GetExtension(Type type, string name)
Parameters
typeTypeType
namestringMember name
Returns
GetExtensionForObject(object, string)
Returns macro extension object of given name if registered for specified object. Caches the result in the internal cache. It loops through all extensions of given object type. Returns null if there is no such extension for given object.
protected static TExtension GetExtensionForObject(object obj, string name)
Parameters
objobjectObject to check
namestringName of the method
Returns
- TExtension
GetExtensions(Type)
Gets the extensions for the given type. Does not cache the result.
protected virtual List<TExtension> GetExtensions(Type type)
Parameters
typeTypeType
Returns
- List<TExtension>
GetExtensionsForObject(object)
Returns list of macro extension registered for specified object. Caches the result in the internal cache. Returns null if there is no such extension for given object.
protected static IEnumerable<TExtension> GetExtensionsForObject(object obj)
Parameters
objobjectObject to check
Returns
- IEnumerable<TExtension>
RegisterExtension(TExtension)
Registers a Extension to the container.
protected void RegisterExtension(TExtension Extension)
Parameters
ExtensionTExtensionExtension to be registered
RegisterExtensions()
Registers extensions to the container. Override this to call RegisterExtension from within.
protected virtual void RegisterExtensions()