本文整理汇总了C#中ExportContext.Register方法的典型用法代码示例。如果您正苦于以下问题:C# ExportContext.Register方法的具体用法?C# ExportContext.Register怎么用?C# ExportContext.Register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExportContext
的用法示例。
在下文中一共展示了ExportContext.Register方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CircularReferenceDetectionAcrossTypes
public void CircularReferenceDetectionAcrossTypes()
{
ExportContext context = new ExportContext();
ComponentExporter exporter = new ComponentExporter(typeof(Parent));
context.Register(exporter);
context.Register(new ComponentExporter(typeof(ParentChild)));
Parent parent = new Parent();
parent.Child = new ParentChild();
parent.Child.Parent = parent;
exporter.Export(context, parent, new EmptyJsonWriter());
}
示例2: TableExportedViaDataView
public void TableExportedViaDataView()
{
DataTable table = new DataTable();
ExportContext context = new ExportContext();
TestDataViewExporter exporter = new TestDataViewExporter();
context.Register(exporter);
context.Export(table, new JsonRecorder());
Assert.AreSame(table.DefaultView, exporter.LastExported);
}
示例3: DeepCircularReferenceDetection
public void DeepCircularReferenceDetection()
{
ExportContext context = new ExportContext();
ComponentExporter exporter = new ComponentExporter(typeof(Thing));
context.Register(exporter);
Thing thing = new Thing();
thing.Other = new Thing();
thing.Other.Other = new Thing();
thing.Other.Other.Other = thing;
exporter.Export(context, thing, new EmptyJsonWriter());
}
示例4: TableExportedViaItsExporter
public void TableExportedViaItsExporter()
{
DataSet ds = new DataSet();
ds.Tables.Add(new DataTable("Table1"));
ExportContext context = new ExportContext();
TestDataTableExporter exporter = new TestDataTableExporter();
context.Register(exporter);
context.Export(ds, new JsonRecorder());
Assert.AreSame(ds.Tables[0], exporter.LastExported);
}
示例5: MemberExportCustomization
public void MemberExportCustomization()
{
ArrayList calls = new ArrayList();
TestTypeDescriptor logicalType = new TestTypeDescriptor();
PropertyDescriptorCollection properties = logicalType.GetProperties();
Hashtable services;
TestObjectMemberExporter memexp1 = new TestObjectMemberExporter(calls);
services = new Hashtable();
services.Add(typeof(IObjectMemberExporter), memexp1);
properties.Add(new TestPropertyDescriptor("prop1", services));
TestObjectMemberExporter memexp2 = new TestObjectMemberExporter(calls);
services = new Hashtable();
services.Add(typeof(IObjectMemberExporter), memexp2);
properties.Add(new TestPropertyDescriptor("prop2", services));
ComponentExporter exporter = new ComponentExporter(typeof(Thing), logicalType);
ExportContext context = new ExportContext();
context.Register(exporter);
JsonRecorder writer = new JsonRecorder();
Thing thing = new Thing();
context.Export(thing, writer);
Assert.AreEqual(2, calls.Count);
object[] args = { context, writer, thing };
Assert.AreSame(memexp1, calls[0]);
Assert.AreEqual(args, ((TestObjectMemberExporter) calls[0]).ExportArgs);
Assert.AreSame(memexp2, calls[1]);
Assert.AreEqual(args, ((TestObjectMemberExporter) calls[1]).ExportArgs);
}
示例6: MemberExportCustomization
public void MemberExportCustomization()
{
TestObjectMemberExporter memberExporter = new TestObjectMemberExporter();
Hashtable services = new Hashtable();
services.Add(typeof(IObjectMemberExporter), memberExporter);
TestTypeDescriptor logicalType = new TestTypeDescriptor();
PropertyDescriptorCollection properties = logicalType.GetProperties();
properties.Add(new TestPropertyDescriptor("prop", services));
ComponentExporter exporter = new ComponentExporter(typeof(Thing), logicalType);
ExportContext context = new ExportContext();
context.Register(exporter);
JsonRecorder writer = new JsonRecorder();
Thing thing = new Thing();
context.Export(thing, writer);
Assert.AreSame(context, memberExporter.ExportContext);
Assert.AreSame(writer, memberExporter.ExportWriter);
Assert.AreSame(thing, memberExporter.ExportSource);
}