예제 #1
0
 /// <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);
 }
예제 #2
0
 public void RegisterGlobalTypes(IMemberAccessStrategy memberAccessStrategy)
 {
     memberAccessStrategy.Register <IContentEntity>();
 }
예제 #3
0
 /// <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);
 }
예제 #4
0
 /// <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));
 }
예제 #5
0
 /// <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);
 }
예제 #6
0
 public void RegisterGlobalTypes(IMemberAccessStrategy memberAccessStrategy)
 {
     TemplateContext.GlobalFilters.AddFilter("escape", Escape);
     TemplateContext.GlobalFilters.AddFilter("slugify", Slugify);
     TemplateContext.GlobalFilters.AddFilter("trim", Trim);
 }
예제 #7
0
 /// <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));
 }
예제 #10
0
 public MemberAccessStrategy(IMemberAccessStrategy parent) : this()
 {
     _parent = parent;
 }
예제 #11
0
 public void RegisterGlobalTypes(IMemberAccessStrategy memberAccessStrategy)
 {
     TemplateContext.GlobalFilters.AddFilter("word_count", WordCount);
     TemplateContext.GlobalFilters.AddFilter("character_count", CharacterCount);
 }
예제 #12
0
 public MemberAccessStrategy(IMemberAccessStrategy parent) : this()
 {
     _parent            = parent;
     MemberNameStrategy = _parent.MemberNameStrategy;
 }
예제 #13
0
 public void RegisterGlobalTypes(IMemberAccessStrategy memberAccessStrategy)
 {
     FluidValue.SetTypeMapping <IUser>(x => new UserFluidValue(x));
 }
예제 #14
0
 public void RegisterGlobalTypes(IMemberAccessStrategy memberAccessStrategy)
 {
     TemplateContext.GlobalFilters.AddFilter("contentUrl", ContentUrl);
     TemplateContext.GlobalFilters.AddFilter("assetContentUrl", AssetContentUrl);
 }
예제 #15
0
 /// <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)));
 }
예제 #17
0
 /// <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));
 }
예제 #18
0
 public MemberAccessStrategy(IMemberAccessStrategy parent, bool concurrent = true) : this(concurrent)
 {
     _parent = parent;
 }