コード例 #1
0
        public static ISizeOfStorage <T> CreateCompiled <T, TComp, TBuilder, TProvider>()
            where TComp : ICalculateFuncCompilerOf <T>
            where TBuilder : ICalculateFuncBuilderOf <T, TComp>, new()
            where TProvider : ISizeMatchingProviderOf <T, TComp>, new()
        {
            var provider = new TProvider();
            var builder  = new TBuilder();

            var strategy = provider.Build();

            builder.Strategy = strategy;
            return(new SizeOfStorage <T>(builder.Build()));
        }
コード例 #2
0
ファイル: UmbracoBuilder.cs プロジェクト: glombek/Umbraco-CMS
        /// <summary>
        /// Gets a collection builder (and registers the collection).
        /// </summary>
        /// <typeparam name="TBuilder">The type of the collection builder.</typeparam>
        /// <returns>The collection builder.</returns>
        public TBuilder WithCollectionBuilder <TBuilder>()
            where TBuilder : ICollectionBuilder, new()
        {
            Type typeOfBuilder = typeof(TBuilder);

            if (_builders.TryGetValue(typeOfBuilder, out ICollectionBuilder o))
            {
                return((TBuilder)o);
            }

            var builder = new TBuilder();

            _builders[typeOfBuilder] = builder;
            return(builder);
        }
コード例 #3
0
            object IObjectReference.GetRealObject(StreamingContext context)
            {
                ExtensionRegistry registry = context.Context as ExtensionRegistry;
                TBuilder          builder  = TemplateInstance.DefaultInstanceForType.CreateBuilderForType();

                builder.MergeFrom(_message, registry ?? ExtensionRegistry.Empty);

                IDeserializationCallback callback = builder as IDeserializationCallback;

                if (callback != null)
                {
                    callback.OnDeserialization(context);
                }

                return(builder);
            }
コード例 #4
0
 public StateBuilder(TBuilder parentBuilder, TName name)
 {
     _state         = new State <TTrig, TName>(name);
     _parentBuilder = parentBuilder;
     _parentBuilder._createdStates.Add(name, _state);
 }
コード例 #5
0
        public static void SeedDatabase(InMemoryObjectContext context)
        {
            var city1 = new TCity {
                Name = "London", Id = 1
            };
            var city2 = new TCity {
                Name = "Leeds", Id = 2
            };
            var builder1 = new TBuilder {
                Id = 1, Name = "Sam", CityId = 1, City = city1
            };

            var mandator1 = new TMandator
            {
                Id          = 1,
                Identity    = Guid.NewGuid(),
                Name        = "One",
                CreatedDate = new DateTime(2012, 12, 12)
            };

            mandator1.Buildings = new List <TBuilding>
            {
                new TBuilding
                {
                    Id         = 1,
                    Identity   = Guid.NewGuid(), LongName = "One L1",
                    BuilderId  = builder1.Id,
                    Builder    = builder1,
                    Mandator   = mandator1,
                    MandatorId = mandator1.Id
                },
                new TBuilding
                {
                    Id         = 2,
                    Identity   = Guid.NewGuid(), LongName = "One L2",
                    BuilderId  = builder1.Id,
                    Builder    = builder1,
                    Mandator   = mandator1,
                    MandatorId = mandator1.Id
                }
            };

            var mandator2 = new TMandator
            {
                Id          = 2,
                Identity    = Guid.NewGuid(),
                Name        = "Two",
                CreatedDate = new DateTime(2012, 12, 12)
            };

            var builder2 = new TBuilder {
                Id = 2, Name = "John", CityId = 2, City = city1
            };
            var builder3 = new TBuilder {
                Id = 3, Name = "Mark", CityId = 2, City = city2
            };

            mandator2.Buildings = new List <TBuilding>
            {
                new TBuilding
                {
                    Id         = 3,
                    Identity   = Guid.NewGuid(), LongName = "Two L1",
                    BuilderId  = builder2.Id,
                    Builder    = builder2,
                    MandatorId = mandator2.Id,
                    Mandator   = mandator2
                },
                new TBuilding
                {
                    Id         = 4,
                    Identity   = Guid.NewGuid(), LongName = "Two L2",
                    BuilderId  = builder3.Id,
                    Builder    = builder3,
                    MandatorId = mandator2.Id,
                    Mandator   = mandator2
                },
                new TBuilding
                {
                    Id         = 5,
                    Identity   = Guid.NewGuid(), LongName = "Two L3",
                    BuilderId  = builder3.Id,
                    Builder    = builder3,
                    MandatorId = mandator2.Id,
                    Mandator   = mandator2
                }
            };

            context.City.Add(city1);
            context.City.Add(city2);

            context.Builder.Add(builder1);
            context.Builder.Add(builder2);
            context.Builder.Add(builder3);

            context.MandatorSet.Add(mandator1);
            context.MandatorSet.Add(mandator2);

            var buildings = context.BuildingSet;

            foreach (var building in context.MandatorSet.SelectMany(x => x.Buildings).Distinct())
            {
                buildings.Add(building);
            }
        }
コード例 #6
0
        public static IFluentHttpClientFactory Create <TBuilder>() where TBuilder : IFluentHttpClientFactoryBuilder, new()
        {
            var builder = new TBuilder();

            return(Create(builder));
        }