当前位置: 首页>>代码示例>>C#>>正文


C# Builder.Build方法代码示例

本文整理汇总了C#中Builder.Build方法的典型用法代码示例。如果您正苦于以下问题:C# Builder.Build方法的具体用法?C# Builder.Build怎么用?C# Builder.Build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Builder的用法示例。


在下文中一共展示了Builder.Build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSecurityService

        protected override ISecurityService GetSecurityService()
        {
            var userBuilder = new Builder<IUser>(Mock.Of<IUser>)
                .With(u =>
                          {
                              u.Email = SecurityTestData.User.Email;
                              u.PasswordHash = HashService.Hash64(SecurityTestData.User.CorrectPassword);
                              u.Active = true;
                          });

            var user = userBuilder.Build();
            var inactiveUser = userBuilder
                .Build(u =>
                          {
                              u.Email = SecurityTestData.User.InactiveEmail;
                              u.Active = false;
                          });

            return new SecurityService(
                new UserDataServiceBuilder()
                    .WithUser(user)
                    .WithUser(inactiveUser)
                    .Build(),
                new SessionDataServiceBuilder()
                    .Build(),
                HashService,
                new UserRegistrationValidator()
                );
        }
开发者ID:MrAntix,项目名称:Poci,代码行数:29,代码来源:user_tests_with_mock_data_layer.cs

示例2: Setup

        public static void Setup(TestContext testContext)
        {
            _connectionStringBuilder = new SqlConnectionStringBuilder
            {
                DataSource = "(local)",
                IntegratedSecurity = true,
                InitialCatalog = "Northwind"
            };

            List<Type> bindMemberList = new List<Type> { typeof(BindFields), typeof(BindProperties) };
            _builder = new Builder(_connectionStringBuilder, typeof(SingleSqlConnection), bindMemberList);

            _productDataMapper = _builder.Build<Product>();
            _orderDataMapper = _builder.Build<Order>();
        }
开发者ID:kadete90,项目名称:1314v-AVE-LI41N-G07,代码行数:15,代码来源:MultiDataMappersTests.cs

示例3: Create

 public static IReaderStrategy Create(
     ISourceDefinitionConfigurator sources, ITimeProvider timeProvider, IPrincipal runAs)
 {
     var builder = new Builder();
     sources.ConfigureSourceProcessingStrategy(builder);
     return builder.Build(timeProvider, runAs);
 }
开发者ID:jjvdangelo,项目名称:EventStore,代码行数:7,代码来源:ReaderStrategy.cs

示例4: m1

        public static void m1()
        {
            Builder builder = new Builder(
               SqlDataMapperType,
               DataMapperParams,
               PropertyColumnMapperType,
               MultipleConnectionPolicyType);
            IDataMapper<ProductSimple> productMapper = builder.Build<ProductSimple>();

            ISqlEnumerable<ProductSimple> prods = productMapper.GetAll();
            foreach (ProductSimple p in prods)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("-------------");
            ISqlEnumerable<ProductSimple> prods2 = prods.Where("CategoryID = 7");
            foreach (ProductSimple p in prods2)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("-------------");
            ISqlEnumerable<ProductSimple> prods3 = prods2.Where("UnitsinStock > 30");
            foreach (ProductSimple p in prods3)
            {
                Console.WriteLine(p);
            }
        }
开发者ID:RafaelSPaulo,项目名称:SQL_Mapper,代码行数:29,代码来源:SqlMapperManualTest.cs

示例5: ConnectionDroppingTimeoutTest

        public void ConnectionDroppingTimeoutTest()
        {
            var originalTraceLevel = Diagnostics.CassandraTraceSwitch.Level;
            Diagnostics.CassandraTraceSwitch.Level = TraceLevel.Verbose;
            var sw = Stopwatch.StartNew();
            var thrown = false;
            try
            {
                var builder = new Builder().WithDefaultKeyspace("system")
                                           .AddContactPoints("1.1.1.1") // IP address that drops (not rejects !) the inbound connection
                                           .WithSocketOptions(new SocketOptions().SetConnectTimeoutMillis(700));
                var cluster = builder.Build();
                cluster.Connect();
            }
            catch (NoHostAvailableException)
            {
                thrown = true;
            }

            sw.Stop();

            Assert.True(thrown, "Expected exception");
            Assert.Greater(sw.Elapsed.TotalMilliseconds, 700, "The connection timeout was not respected");

            Diagnostics.CassandraTraceSwitch.Level = originalTraceLevel;
        }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:26,代码来源:ConnectionTimeoutTest.cs

示例6: ConnectionRejectingTimeoutTest

        public void ConnectionRejectingTimeoutTest()
        {
            var originalTraceLevel = Diagnostics.CassandraTraceSwitch.Level;
            Diagnostics.CassandraTraceSwitch.Level = TraceLevel.Verbose;
            var sw = Stopwatch.StartNew();
            var thrown = false;
            try
            {
                var builder = new Builder().WithDefaultKeyspace("system")
                                           .AddContactPoints("127.9.9.9") // local IP that will most likely not be in use
                                           .WithQueryTimeout(500);
                builder.SocketOptions.SetConnectTimeoutMillis(500);
                var cluster = builder.Build();
                cluster.Connect();
            }
            catch (NoHostAvailableException)
            {
                thrown = true;
            }

            sw.Stop();

            Assert.True(thrown, "Expected exception");
            Assert.True(sw.Elapsed.TotalMilliseconds < 1000, "The connection timeout was not respected");

            Diagnostics.CassandraTraceSwitch.Level = originalTraceLevel;
        }
开发者ID:Virus-X,项目名称:csharp-driver,代码行数:27,代码来源:ConnectionTimeoutTest.cs

示例7: UpdateSupplierFromProduct

        public void UpdateSupplierFromProduct()
        {
            // Arrange
            Builder builder = new Builder(
                SqlDataMapperType,
                DataMapperParams,
                PropertyColumnMapperType,
                MultipleConnectionPolicyType);
            IDataMapper productMapper = builder.Build<Product>();
            IConnectionPolicy explicitConnectionPolicy = productMapper.GetConnectionPolicy();
            String fakeName = "teste";
            String trueName = "";
            String updatedName = "";
            // Act
            Product p1 = (Product)productMapper.GetAll().First();
            trueName = p1.SupplierID.CompanyName;
            p1.SupplierID.CompanyName = fakeName;
            productMapper.Update(p1);

            Product p2 = (Product)productMapper.GetAll().First();
            updatedName = p2.SupplierID.CompanyName;

            p2.SupplierID.CompanyName = trueName;
            productMapper.Update(p2);

            // Assert
            Assert.AreEqual(fakeName, updatedName);
        }
开发者ID:RafaelSPaulo,项目名称:SQL_Mapper,代码行数:28,代码来源:SqlMapperUnitTest.cs

示例8: m2

        public static void m2()
        {
            Builder builder = new Builder(
                    typeof(SqlDataMapper<>),
                   new Object[] { SqlMapperUnitTest.getMySqlConnectionString() },
                   typeof(PropertyColumnMapper),
                   typeof(ExplicitConnectionPolicy));

            IDataMapper<ProductSimple> productMapper = builder.Build<ProductSimple>();
            IConnectionPolicy explicitConnectionPolicy = productMapper.GetConnectionPolicy();

            // Act
            explicitConnectionPolicy.OpenConnection();
            explicitConnectionPolicy.BeginTransaction();

            ProductSimple p1 = productMapper.GetAll().First();

            p1.ProductName = "Potatoes";
            productMapper.Update(p1);

            ProductSimple p2 = productMapper.GetAll().First();

            // Assert
            bool result = p1.ProductName == p2.ProductName;
            explicitConnectionPolicy.RollBack();
            explicitConnectionPolicy.Dispose();
        }
开发者ID:RafaelSPaulo,项目名称:SQL_Mapper,代码行数:27,代码来源:SqlMapperManualTest.cs

示例9: PagingOnBoundStatementTest_Async_UsingConfigBasedPagingSetting

        public void PagingOnBoundStatementTest_Async_UsingConfigBasedPagingSetting()
        {
            var pageSize = 10;
            var queryOptions = new QueryOptions().SetPageSize(pageSize);
            Builder builder = new Builder().WithQueryOptions(queryOptions).WithDefaultKeyspace(KeyspaceName);
            builder.AddContactPoint(TestCluster.InitialContactPoint);

            using (ISession session = builder.Build().Connect())
            {
                var totalRowLength = 1003;
                Tuple<string, string> tableNameAndStaticKeyVal = CreateTableWithCompositeIndexAndInsert(session, totalRowLength);
                string statementToBeBound = "SELECT * from " + tableNameAndStaticKeyVal.Item1 + " where label=?";
                PreparedStatement preparedStatementWithoutPaging = session.Prepare(statementToBeBound);
                PreparedStatement preparedStatementWithPaging = session.Prepare(statementToBeBound);
                BoundStatement boundStatemetWithoutPaging = preparedStatementWithoutPaging.Bind(tableNameAndStaticKeyVal.Item2);
                BoundStatement boundStatemetWithPaging = preparedStatementWithPaging.Bind(tableNameAndStaticKeyVal.Item2);

                var rsWithSessionPagingInherited = session.ExecuteAsync(boundStatemetWithPaging).Result;

                var rsWithoutPagingInherited = Session.Execute(boundStatemetWithoutPaging);

                //Check that the internal list of items count is pageSize
                Assert.AreEqual(pageSize, rsWithSessionPagingInherited.InnerQueueCount);
                Assert.AreEqual(totalRowLength, rsWithoutPagingInherited.InnerQueueCount);

                var allTheRowsPaged = rsWithSessionPagingInherited.ToList();
                Assert.AreEqual(totalRowLength, allTheRowsPaged.Count);
            }
        }
开发者ID:GoldenCrystal,项目名称:csharp-driver,代码行数:29,代码来源:BasicTypeTests.cs

示例10: Create

 public static CheckpointStrategy Create(
     ISourceDefinitionConfigurator sources, ProjectionConfig config, ITimeProvider timeProvider)
 {
     var builder = new Builder();
     sources.ConfigureSourceProcessingStrategy(builder);
     return builder.Build(
         config, config.RunAs, Processing.ReaderStrategy.Create(sources, timeProvider, config.RunAs));
 }
开发者ID:jjvdangelo,项目名称:EventStore,代码行数:8,代码来源:CheckpointStrategy.cs

示例11: GetSessionBuilder

        static Builder<ISession> GetSessionBuilder()
        {
            var userBuilder = new Builder<IUser>(Mock.Of<IUser>)
                .With(u => { u.Email = SecurityTestData.User.Email; });

            return new Builder<ISession>(Mock.Of<ISession>)
                .With(s => { s.User = userBuilder.Build(); });
        }
开发者ID:MrAntix,项目名称:Poci,代码行数:8,代码来源:user_tests_with_mock_data_layer.cs

示例12: FromFiles

 /// <summary>
 /// Creates a symbol registry from the specified set of file descriptors.
 /// </summary>
 /// <param name="fileDescriptors">The set of files to include in the registry. Must not contain null values.</param>
 /// <returns>A symbol registry for the given files.</returns>
 public static SymbolRegistry FromFiles(IEnumerable<FileDescriptor> fileDescriptors)
 {
     GrpcPreconditions.CheckNotNull(fileDescriptors);
     var builder = new Builder();
     foreach (var file in fileDescriptors)
     {
         builder.AddFile(file);
     }
     return builder.Build();
 }
开发者ID:grpc,项目名称:grpc,代码行数:15,代码来源:SymbolRegistry.cs

示例13: should_be_able_to_build_an_instance_of_a_blueprinted_object

        public void should_be_able_to_build_an_instance_of_a_blueprinted_object()
        {
            var mockBlueprint = new Mock<IBlueprint<AnObject>>();
            mockBlueprint.Setup(x => x.Create()).Returns(new AnObject());

            var builder = new Builder<AnObject>(mockBlueprint.Object);

            var builtObject = builder.Build();
            Assert.IsInstanceOf<AnObject>(builtObject);
        }
开发者ID:colincasey,项目名称:Blueprinting,代码行数:10,代码来源:BuilderTest.cs

示例14: CreateRoot

 // public static methods
 /// <summary>
 /// Creates a root context.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="configurator">The serialization context configurator.</param>
 /// <returns>
 /// A root context.
 /// </returns>
 public static BsonSerializationContext CreateRoot(
     IBsonWriter writer,
     Action<Builder> configurator = null)
 {
     var builder = new Builder(null, writer);
     if (configurator != null)
     {
         configurator(builder);
     }
     return builder.Build();
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:20,代码来源:BsonSerializationContext.cs

示例15: FromStreamReader

        /// <summary>
        /// Loads a mesh from a stream reader.
        /// </summary>
        public static ObjFileMesh FromStreamReader(StreamReader reader)
        {
            var builder = new Builder();

            string line;
            while ((line = reader.ReadLine()) != null)
            {
                parseLine(builder, line);
            }

            return builder.Build();
        }
开发者ID:corefan,项目名称:awgraphics,代码行数:15,代码来源:ObjFileMesh.Parsing.cs


注:本文中的Builder.Build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。