Пример #1
0
 public static ITypeConfiguration <T> CustomSerializer <T>(this ITypeConfiguration <T> @this,
                                                           IExtendedXmlCustomSerializer serializer)
 {
     @this.Root.With <CustomSerializationExtension>()
     .XmlSerializers.Assign(@this.Get(), serializer);
     return(@this);
 }
Пример #2
0
 public static ITypeConfiguration <T> AddMigration <T>(this ITypeConfiguration <T> @this,
                                                       IEnumerable <Action <XElement> > migrations)
 {
     @this.Root.With <MigrationsExtension>()
     .Add(@this.Get(), migrations.Fixed());
     return(@this);
 }
Пример #3
0
 public static ITypeConfiguration <T> EmitWhen <T>(this ITypeConfiguration <T> @this,
                                                   Func <T, bool> specification)
 {
     @this.Root.With <AllowedInstancesExtension>()
     .Assign(@this.Get(),
             new AllowedValueSpecification(new DelegatedSpecification <T>(specification).AdaptForNull()));
     return(@this);
 }
Пример #4
0
        internal static IMemberConfiguration Member(this ITypeConfiguration @this, string member)
        {
            var metadata = @this.Get()
                           .GetMember(member)
                           .SingleOrDefault();
            var result = metadata != null ? ((IInternalTypeConfiguration)@this).Member(metadata) : null;

            return(result);
        }
Пример #5
0
 public static ITypeConfiguration <T> Unregister <T>(this ITypeConfiguration <T> @this)
 {
     @this.Root.With <CustomSerializationExtension>()
     .Types.Remove(@this.Get());
     return(@this);
 }
Пример #6
0
 public static ITypeConfiguration <T> Register <T>(this ITypeConfiguration <T> @this, ISerializer serializer)
 {
     @this.Root.With <CustomSerializationExtension>()
     .Types.Assign(@this.Get(), serializer);
     return(@this);
 }
 /// <summary>
 /// Adds a set of migration delegates to the configured type.  A migration allows older persisted XML to migrate to an
 /// object model schema that has changed since the XML was persisted.  The provided command specifies how to
 /// manipulate the element that represents the type so that it can (hopefully 😇) be deserialized without error.
 /// </summary>
 /// <param name="this">The type configuration to configure.</param>
 /// <param name="migrations">The delegates that specify how to migrate an Xml element that represents an older schema.
 /// </param>
 /// <returns>The configured type configuration.</returns>
 public static ITypeConfiguration AddMigration(this ITypeConfiguration @this, IEnumerable <Action <XElement> > migrations)
 => @this.Root.With <MigrationsExtension>()
 .Apply(@this.Get(), migrations.Fixed())
 .Return(@this);
Пример #8
0
 /// <summary>
 /// Marks a type as "allowed" so that it is emitted during serialization and read during deserialization.  Note that
 /// including a type establishes an "allowed-only" policy so that only types that are explicitly included are
 /// considered for processing.
 /// </summary>
 /// <param name="this">The type configuration to configure.</param>
 /// <returns>The configured type configuration.</returns>
 public static ITypeConfiguration Include(this ITypeConfiguration @this)
 => @this.Root.With <AllowedTypesExtension>()
 .Allowed.Apply(@this.Get())
 .Return(@this);
Пример #9
0
 /// <summary>
 /// Marks the specified type as ignored, meaning it will not emit or read when encountered in a graph.
 /// </summary>
 /// <typeparam name="T">The type under configuration.</typeparam>
 /// <param name="this">The type configuration to configure.</param>
 /// <returns>The configured type configuration.</returns>
 public static ITypeConfiguration <T> Ignore <T>(this ITypeConfiguration <T> @this)
 => @this.Ignore(@this.Get())
 .Return(@this);