本文整理汇总了C#中Configuration.AddType方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.AddType方法的具体用法?C# Configuration.AddType怎么用?C# Configuration.AddType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration.AddType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAttributedAssembler
public IAssembler<DerivedUserDTO, DerivedUser> CreateAttributedAssembler()
{
Configuration cfg = new Configuration();
cfg.AddType(typeof(DerivedUserDTO));
cfg.AddType<ProjectDTO>(); // todo: should this be automatically detected
cfg.AddType<DocumentDTO>(); // todo: should this be automatically detected
cfg.AddType<TaskDTO>(); // todo: should this be automatically detected
return cfg.GetAssembler<DerivedUserDTO, DerivedUser>();
}
示例2: Recognize_External_Assemblies_For_Base_Class
public void Recognize_External_Assemblies_For_Base_Class()
{
Configuration cfg = new Configuration();
//cfg.AddAssemblyReference("nunit.core.dll"); not needed, but can be done
//cfg.AddAssemblyReference("nunit.framework.dll");
cfg.AddType<ExternalDependency>();
cfg.BuildAssemblers();
}
示例3: Formatting_Works_For_User_Aggregates_Not_Derived_From_SimpleFunctionBase
public void Formatting_Works_For_User_Aggregates_Not_Derived_From_SimpleFunctionBase()
{
Configuration cfg = new Configuration();
cfg.RegisterFunction<MedianFn>("median");
cfg.AddType(typeof(Dummy2));
IAssembler<Dummy2, User> asm = cfg.GetAssembler<Dummy2, User>();
Dummy2 dummy = asm.AssembleFrom(Helpers.CreateComplexUser());
Assert.AreEqual("Median document length: 4.00 characters", dummy.MedianDocumentNameLengthInfo);
}
示例4: Formatting_Works_For_Aggregate_Expressions
public void Formatting_Works_For_Aggregate_Expressions()
{
Configuration cfg = new Configuration();
cfg.AddType(typeof(Dummy));
IAssembler<Dummy, User> asm = cfg.GetAssembler<Dummy, User>();
Dummy dummy = asm.AssembleFrom(Helpers.CreateComplexUser());
Assert.AreEqual("2 documents", dummy.DocumentInfo);
Assert.AreEqual("Avg document length: 4.00 characters", dummy.AvgDocumentNameLengthInfo);
}
示例5: SetUp
public void SetUp()
{
Configuration cfg = new Configuration();
cfg.AddType(typeof(AttributedUserDTO));
m_assembler = cfg.GetAssembler<AttributedUserDTO, User>();
m_source = new List<User>(3);
m_source.Add(new User());
m_source[0].FirstName = "Zdeslav";
m_source[0].LastName = "Vojkovic";
m_source[0].Age = 33;
m_source[0].Id = 1;
m_source[0].UserName = "zdeslavv";
m_source.Add(Helpers.CreateComplexUser());
m_source.Add(m_source[1].Boss);
}
示例6: Recognize_External_Assemblies_For_Implemented_Interfaces
public void Recognize_External_Assemblies_For_Implemented_Interfaces()
{
Configuration cfg = new Configuration();
cfg.AddType<ExternalDependency2>();
cfg.BuildAssemblers();
}
示例7: Setup
public void Setup()
{
Configuration cfg;
cfg = new Configuration();
cfg.AddType<UserDTO>();
cfg.AddType<ProjectDTO>(); // todo: should this be automatically detected
cfg.AddType<DocumentDTO>(); // todo: should this be automatically detected
cfg.AddType<TaskDTO>(); // todo: should this be automatically detected
cfg.BuildAssemblers();
m_assembler = cfg.GetAssembler<UserDTO, User>();
m_user = Helpers.CreateComplexUser();
}
示例8: SetUpDefaults
public void SetUpDefaults()
{
Configuration cfg = new Configuration();
cfg.AddType<AttributedUserDTO>();
m_asm = cfg.GetAssembler<AttributedUserDTO, User>();
m_user = Helpers.CreateComplexUser();
}
示例9: Compilation_Fails_With_Invalid_Mapping_Expression
public void Compilation_Fails_With_Invalid_Mapping_Expression()
{
Configuration cfg = new Configuration();
cfg.AddType<InvalidDTO>();
cfg.BuildAssemblers();
}
示例10: ComparePerformance
//[Test]
public void ComparePerformance()
{
User user = Helpers.CreateComplexUser();
// add more tasks
user.Projects[0].Tasks.Add(new Task(5));
user.Projects[0].Tasks.Add(new Task(4));
user.Projects[0].Tasks.Add(new Task(2));
user.Projects[0].Tasks.Add(new Task(6));
user.Projects[0].Tasks.Add(new Task(4));
user.Projects[0].Tasks.Add(new Task(2));
user.Projects[1].Tasks.Add(new Task(3));
user.Projects[1].Tasks.Add(new Task(4));
user.Projects[1].Tasks.Add(new Task(5));
user.Projects[1].Tasks.Add(new Task(1));
user.Projects[1].Tasks.Add(new Task(4));
user.Projects[0].Tasks.Add(new Task(5));
user.Projects[0].Tasks.Add(new Task(4));
user.Projects[0].Tasks.Add(new Task(2));
user.Projects[0].Tasks.Add(new Task(6));
user.Projects[0].Tasks.Add(new Task(4));
user.Projects[0].Tasks.Add(new Task(2));
user.Projects[1].Tasks.Add(new Task(3));
user.Projects[1].Tasks.Add(new Task(4));
user.Projects[1].Tasks.Add(new Task(5));
user.Projects[1].Tasks.Add(new Task(1));
user.Projects[1].Tasks.Add(new Task(4));
UserDTO dto = new UserDTO();
Configuration cfg;
cfg = new Configuration();
cfg.AddType(typeof(UserDTO));
cfg.AddType(typeof(ProjectDTO)); // todo: should this be automatically detected
cfg.AddType(typeof(DocumentDTO)); // todo: should this be automatically detected
cfg.AddType(typeof(TaskDTO)); // todo: should this be automatically detected
cfg.BuildAssemblers();
IAssembler<UserDTO, User> assembler = cfg.GetAssembler<UserDTO, User>();
assembler.Assemble(ref dto, ref user); // run it once
long time = Environment.TickCount;
for(int i = 0; i < ITER_COUNT; i++)
{
assembler.Assemble(ref dto, ref user);
}
long time1 = Environment.TickCount - time;
Console.Out.WriteLine("Generated assembler timing = {0}", time1);
Assemble(dto, user); // run it once
time = Environment.TickCount;
for (int i = 0; i < ITER_COUNT; i++)
{
Assemble(dto, user);
}
long time2 = Environment.TickCount - time;
Console.Out.WriteLine("Manual assembler timing = {0}", time2);
Console.Out.WriteLine("Ratio = {0}", time1/(double)time2);
}