Пример #1
0
 /// <summary>
 /// Set the context from a property on the source with the same property name as the target, i.e. straight through mapping.
 /// </summary>
 /// <typeparam name="TModel">The target model.</typeparam>
 /// <typeparam name="TProp">The target property.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="configure"></param>
 /// <returns></returns>
 public static SchemaPropertyBuilder <TModel, TProp> Get <TModel, TProp>(
     this SchemaPropertyBuilder <TModel, TProp> builder,
     Action <SchemaProcessorBuilder> configure = null)
 {
     return(builder
            .Add(Processor.Property <GetProcessor>(configure)));
 }
Пример #2
0
 /// <summary>
 /// Switch the context to a property on the source with the given alias.
 /// </summary>
 /// <typeparam name="TModel">The target model.</typeparam>
 /// <typeparam name="TProp">The target property.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="sourceProperty">The name of property on the source.</param>
 /// <param name="configure"></param>
 /// <returns></returns>
 public static SchemaPropertyBuilder <TModel, TProp> Get <TModel, TProp>(
     this SchemaPropertyBuilder <TModel, TProp> builder, string sourceProperty,
     Action <SchemaProcessorBuilder> configure = null)
 {
     return(builder
            .Add(Processor.Property <GetProcessor>(c =>
     {
         c.Option(GetProcessor.SourcePropertyOptionKey, sourceProperty);
         configure?.Invoke(c);
     })));
 }
Пример #3
0
 public static SchemaPropertyBuilder <TModel, TProp> Constant <TModel, TProp, TValue>(
     this SchemaPropertyBuilder <TModel, TProp> builder, TValue value, Action <SchemaProcessorBuilder> configure = null)
 {
     return(builder
            .Add(Processor.Property <ConstantProcessor <TValue> >(c =>
     {
         c.AllowedStages(PropertyStageMarker.Populating);
         c.Option(ConstantProcessor <TValue> .ConstantOptionKey, value);
         configure?.Invoke(c);
     })));
 }
Пример #4
0
 public static SchemaPropertyBuilder <TModel, TProp> SetStage <TModel, TProp>(
     this SchemaPropertyBuilder <TModel, TProp> builder, PropertyStageMarker marker,
     Action <SchemaProcessorBuilder> configure = null)
 {
     return(builder
            .Add(Processor.Property <SetStageProcessor>(c =>
     {
         c.Option(SetStageProcessor.Marker, marker);
         configure?.Invoke(c);
     })));
 }
Пример #5
0
 public static SchemaPropertyBuilder <TModel, TProp> Ensure <TModel, TProp, TReplacement>(
     this SchemaPropertyBuilder <TModel, TProp> builder, TReplacement replacement, Action <SchemaProcessorBuilder> configure = null)
 {
     return(builder
            .Add(Processor.Property <EnsureProcessor>(c =>
     {
         c.Option(EnsureProcessor.EnsureType, typeof(TReplacement));
         c.Option(EnsureProcessor.EnsureReplacement, replacement);
         configure?.Invoke(c);
     })));
 }
Пример #6
0
 /// <summary>
 ///     Map a nested class, unrelated to source model or property.
 /// </summary>
 /// <typeparam name="TModel">The target model.</typeparam>
 /// <typeparam name="TProp">The target property.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="configure"></param>
 /// <returns></returns>
 public static SchemaPropertyBuilder <TModel, TProp> Nested <TModel, TProp>(
     this SchemaPropertyBuilder <TModel, TProp> builder,
     Action <SchemaProcessorBuilder> configure = null)
 {
     return(builder
            .Add(Processor.Property <NestedProcessor>(c =>
     {
         c.AllowedStages(PropertyStageMarker.Populating);
         c.Option(NestedProcessor.OutputTypeOption, typeof(TProp));
         configure?.Invoke(c);
     })));
 }