コード例 #1
0
        public void ComplexList()
        {
            var container = new ConfigurationContainer();

            container.Type <TestClassReference>()
            .EnableReferences(x => x.Id);
            container.EnableDeferredReferences();
            DoTest(new SerializationSupport(container));
        }
コード例 #2
0
        public void Examples()
        {
            new ConfigurationContainer().EnableDeferredReferences()
            .Type <IElement>().EnableReferences(p => p.Id)
            .Type <Section>().EnableReferences(p => p.Id)
            .Type <Building>().EnableReferences(p => p.Id)
            .Create();


            new ConfigurationContainer().Type <Section>()
            .Name("person")
            .Member(p => p.IsSelected).Name("Selected").Identity().Order(2)
            .Member(p => p.IsEmpty).Name("Empty")

            .Create();


            var serializer = new ConfigurationContainer()

                             .Type <Person>()         // Configuration of Person class
                             .Member(p => p.Password) // First member
                             .Name("P")
                             .Encrypt()
                             .Member(p => p.Name)    // Second member
                             .Name("T")
                             .UseEncryptionAlgorithm(new CustomEncryption())
                             .Type <TestClass>()   // Configuration of another class
                             .CustomSerializer(new TestClassSerializer())
                             .Create();


            new ConfigurationContainer()
            .Type <Person>()
            .Member(p => p.Name).Identity()
            .OnlyConfiguredProperties()
            .Create();

            new ConfigurationContainer().Type <Person>()
            .AddMigration(element => {})
            .OnlyConfiguredProperties()
            .Create();

            new ConfigurationContainer().Type <Person>()
            .OnlyConfiguredProperties()
            .AddMigration(element => { })
            .Create();

            new ConfigurationContainer()
            .Type <Person>()
            .Member(p => p.Name).Identity()
            .OnlyConfiguredProperties()
            .Create();

            new ConfigurationContainer()
            .Type <Person>()
            .OnlyConfiguredProperties()
            .Member(p => p.Name).Identity()
            .Create();

            new ConfigurationContainer().Type <Person>()
            .CustomSerializer((writer, person) => {}, element => new Person())
            .EnableReferences(p => p.Name);

            new ConfigurationContainer().Type <Person>()
            .EnableReferences(p => p.Name)
            .CustomSerializer((writer, person) => { }, element => new Person());

            new ConfigurationContainer().Type <Person>()
            .CustomSerializer((writer, person) => { }, element => new Person())
            .Member(p => p.Name).Identity();

            new ConfigurationContainer().Type <Person>()
            .Member(p => p.Name).Identity()
            .CustomSerializer((writer, person) => { }, element => new Person());

            new ConfigurationContainer().Type <Person>()
            .AddMigration(element => { })
            .Member(p => p.Name).Identity();

            new ConfigurationContainer().Type <Person>()
            .Member(p => p.Name)
            .Identity()
            .AddMigration(element => {});

            var config = new ConfigurationContainer();

            config.EnableDeferredReferences();
            config.Type <Section>().Member(p => p.Id).Name("Identity");
            config.Type <Section>().EnableReferences(p => p.Id);
            var exs = config.Create();
        }