/// <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))); }
public static SchemaPropertyBuilder <TModel, TProp> Collection <TModel, TProp>( this SchemaPropertyBuilder <TModel, TProp> builder, Action <CollectionPropertyBuilder <TModel, TProp> > collection) { collection(new CollectionPropertyBuilder <TModel, TProp>(builder)); return(builder); }
/// <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); }))); }
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); }))); }
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); }))); }
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); }))); }
/// <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); }))); }
public static SchemaPropertyBuilder <TModel, TProp> Add <TModel, TProp, TProcessor>( this SchemaPropertyBuilder <TModel, TProp> builder, ModelProcessorDefinition <TProcessor> processor) where TProcessor : IModelProcessor { if (processor == null) { throw new ArgumentNullException(nameof(processor)); } if (processor.SchemaBuilder == null) { throw new InvalidOperationException("Processor missing SchemaBuilder"); } builder.AddProcessorInfo(processor.SchemaBuilder.Build()); return(builder); }
public SitecoreHelpers(SchemaPropertyBuilder <TModel, TProp> schemaBuilder) { SchemaBuilder = schemaBuilder ?? throw new ArgumentNullException(nameof(schemaBuilder)); }
public CollectionPropertyBuilder(SchemaPropertyBuilder <TModel, TProp> schemaBuilder) => _schemaBuilder = schemaBuilder ?? throw new ArgumentNullException(nameof(schemaBuilder));