/// <summary> /// Registers a type using a <see cref="IMemberAccessor"/> to retrieve any of /// its property values. /// </summary> /// <param name="type">The type to register.</param> /// <param name="getter">The <see cref="IMemberAccessor"/> instance used to retrieve the value.</param> public static void Register(this IMemberAccessStrategy strategy, Type type, IMemberAccessor getter) { strategy.Register(type, "*", getter); }
public void RegisterGlobalTypes(IMemberAccessStrategy memberAccessStrategy) { memberAccessStrategy.Register <IContentEntity>(); }
/// <summary> /// Registers a type using a <see cref="IMemberAccessor"/> to retrieve any of /// its property values. /// </summary> /// <typeparam name="T">The type to register.</typeparam> /// <param name="getter">The <see cref="IMemberAccessor"/> instance used to retrieve the value.</param> public static void Register <T>(this IMemberAccessStrategy strategy, IMemberAccessor getter) { strategy.Register(typeof(T), "*", getter); }
/// <summary> /// Registers a type and all its public properties. /// </summary> /// <typeparam name="T">The type to register.</typeparam> public static void Register <T>(this IMemberAccessStrategy strategy) { strategy.Register(typeof(T)); }
/// <summary> /// Registers a limited set of properties in a type. /// </summary> /// <typeparam name="T">The type to register.</typeparam> /// <param name="names">The names of the properties in the type to register.</param> public static void Register <T>(this IMemberAccessStrategy strategy, params string[] names) { strategy.Register(typeof(T), names); }
public void RegisterGlobalTypes(IMemberAccessStrategy memberAccessStrategy) { TemplateContext.GlobalFilters.AddFilter("escape", Escape); TemplateContext.GlobalFilters.AddFilter("slugify", Slugify); TemplateContext.GlobalFilters.AddFilter("trim", Trim); }
/// <summary> /// Registers a type with a <see cref="Func{T, string, Object}"/> to retrieve any of /// its property values. /// </summary> /// <param name="type">The type to register.</param> /// <param name="accessor">The <see cref="Func{T, string, Object}"/> instance used to retrieve the value.</param> public static void Register <T>(this IMemberAccessStrategy strategy, Func <T, string, object> accessor) { strategy.Register(typeof(T), "*", new DelegateAccessor <T>(accessor)); }
/// <summary> /// Registers a limited set of properties in a type. /// </summary> /// <typeparam name="T">The type to register.</typeparam> /// <param name="strategy">The <see cref="IMemberAccessStrategy"/>.</param> /// <param name="names">The property's expressions in the type to register.</param> public static void Register <T>(this IMemberAccessStrategy strategy, params Expression <Func <T, object> >[] names) { strategy.Register <T>(names.Select(ExpressionHelper.GetPropertyName).ToArray()); }
/// <summary> /// Registers a type with a <see cref="T:Func{T, Task{TResult}}"/> to retrieve the given property's value. /// </summary> /// <param name="strategy">The <see cref="IMemberAccessStrategy"/>.</param> /// <param name="name">The name of the property.</param> /// <param name="accessor">The <see cref="T:Func{T, Task{TResult}}"/> instance used to retrieve the value.</param> public static void Register <T, TResult>(this IMemberAccessStrategy strategy, string name, Func <T, Task <TResult> > accessor) { Register <T, TResult>(strategy, name, (obj, ctx) => accessor(obj)); }
public MemberAccessStrategy(IMemberAccessStrategy parent) : this() { _parent = parent; }
public void RegisterGlobalTypes(IMemberAccessStrategy memberAccessStrategy) { TemplateContext.GlobalFilters.AddFilter("word_count", WordCount); TemplateContext.GlobalFilters.AddFilter("character_count", CharacterCount); }
public MemberAccessStrategy(IMemberAccessStrategy parent) : this() { _parent = parent; MemberNameStrategy = _parent.MemberNameStrategy; }
public void RegisterGlobalTypes(IMemberAccessStrategy memberAccessStrategy) { FluidValue.SetTypeMapping <IUser>(x => new UserFluidValue(x)); }
public void RegisterGlobalTypes(IMemberAccessStrategy memberAccessStrategy) { TemplateContext.GlobalFilters.AddFilter("contentUrl", ContentUrl); TemplateContext.GlobalFilters.AddFilter("assetContentUrl", AssetContentUrl); }
/// <summary> /// Registers a type with a <see cref="Func{T, string, TResult}"/> to retrieve any of /// its property values. /// </summary> /// <param name="type">The type to register.</param> /// <param name="accessor">The <see cref="Func{T, string, TResult}"/> instance used to retrieve the value.</param> public static void Register <T, TResult>(this IMemberAccessStrategy strategy, Func <T, string, TResult> accessor) { Register <T, TResult>(strategy, (obj, name, ctx) => accessor(obj, name)); }
/// <summary> /// Registers a type with a <see cref="Func{T, TemplateContext, TResult}"/> to retrieve the property specified. /// </summary> /// <param name="strategy">The <see cref="IMemberAccessStrategy"/>.</param> /// <param name="name">The name of the property.</param> /// <param name="accessor">The <see cref="Func{T, TemplateContext, TResult}"/> instance used to retrieve the value.</param> public static void Register <T, TResult>(this IMemberAccessStrategy strategy, string name, Func <T, TemplateContext, TResult> accessor) { strategy.Register(typeof(T), name, new DelegateAccessor <T, TResult>((obj, propertyName, ctx) => accessor(obj, ctx))); }
/// <summary> /// Registers a type with a <see cref="Func{T, string, TemplateContext, TResult}"/> to retrieve any of /// its property values. /// </summary> /// <param name="type">The type to register.</param> /// <param name="accessor">The <see cref="Func{T, string, TemplateContext, TResult}"/> instance used to retrieve the value.</param> public static void Register <T, TResult>(this IMemberAccessStrategy strategy, Func <T, string, TemplateContext, TResult> accessor) { strategy.Register(typeof(T), "*", new DelegateAccessor <T, TResult>(accessor)); }
public MemberAccessStrategy(IMemberAccessStrategy parent, bool concurrent = true) : this(concurrent) { _parent = parent; }