本文整理汇总了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()
);
}
示例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>();
}
示例3: Create
public static IReaderStrategy Create(
ISourceDefinitionConfigurator sources, ITimeProvider timeProvider, IPrincipal runAs)
{
var builder = new Builder();
sources.ConfigureSourceProcessingStrategy(builder);
return builder.Build(timeProvider, runAs);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
}
示例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));
}
示例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(); });
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}