本文整理汇总了C#中ExportContext类的典型用法代码示例。如果您正苦于以下问题:C# ExportContext类的具体用法?C# ExportContext怎么用?C# ExportContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExportContext类属于命名空间,在下文中一共展示了ExportContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportValue
protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
{
Debug.Assert(value != null);
Debug.Assert(writer != null);
ExportTime((DateTime) value, writer);
}
示例2: ExportData
protected override void ExportData(System.Xml.XmlWriter writer, ExportContext context)
{
object data = GetData();
var stringData = data as string;
if (stringData != null)
{
writer.WriteString(stringData);
return;
}
var listData = data as List<string>;
if (listData != null)
{
string output = String.Join(";", listData.ToArray());
writer.WriteString(output);
return;
}
var enumerableData = data as IEnumerable;
if (enumerableData != null)
{
var sb = new StringBuilder();
foreach (var item in enumerableData)
{
if (sb.Length != 0)
sb.Append(";");
sb.Append(Convert.ToString(item, CultureInfo.InvariantCulture));
}
writer.WriteString(sb.ToString());
return;
}
throw ExportNotImplementedException(data);
}
示例3: ExportValue
protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
{
Debug.Assert(context != null);
Debug.Assert(value != null);
Debug.Assert(writer != null);
if (_properties.Count == 0)
{
writer.WriteString(value.ToString());
}
else
{
writer.WriteStartObject();
foreach (PropertyDescriptor property in _properties)
{
object propertyValue = property.GetValue(value);
if (!JsonNull.LogicallyEquals(propertyValue))
{
writer.WriteMember(property.Name);
context.Export(propertyValue, writer);
}
}
writer.WriteEndObject();
}
}
示例4: CreateFromDataContractSerializer
public static string CreateFromDataContractSerializer(Type type, MemberInfo[] pathToMember, StringBuilder rootElementXpath, out XmlNamespaceManager namespaces)
{
ExportContext context;
if (type == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("type"));
}
if (pathToMember == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("pathToMember"));
}
DataContract dataContract = DataContract.GetDataContract(type);
if (rootElementXpath == null)
{
context = new ExportContext(dataContract);
}
else
{
context = new ExportContext(rootElementXpath);
}
for (int i = 0; i < pathToMember.Length; i++)
{
dataContract = ProcessDataContract(dataContract, context, pathToMember[i]);
}
namespaces = context.Namespaces;
return context.XPath;
}
示例5: ExportDataSet
private static void ExportDataSet(ExportContext context, DataSet dataSet, JsonWriter writer)
{
Debug.Assert(context != null);
Debug.Assert(dataSet != null);
Debug.Assert(writer != null);
writer.WriteStartObject();
foreach (DataTable table in dataSet.Tables)
{
writer.WriteMember(table.TableName);
//
// If there is an exporter (perhaps an override) for the
// DataTable in effect then use it. Otherwise our
// DataTableExporter.
//
IExporter tableExporter = context.FindExporter(table.GetType());
if (tableExporter != null)
tableExporter.Export(context, table, writer);
else
DataTableExporter.ExportTable(context, table, writer);
}
writer.WriteEndObject();
}
示例6: ResolveFluentMethod
private static void ResolveFluentMethod(ExportContext context)
{
if (string.IsNullOrEmpty(_parameters.ConfigurationMethod)) return;
var methodPath = _parameters.ConfigurationMethod;
var path = new Stack<string>(methodPath.Split('.'));
var method = path.Pop();
var fullQualifiedType = string.Join(".", path.Reverse());
foreach (var sourceAssembly in context.SourceAssemblies)
{
var type = sourceAssembly.GetType(fullQualifiedType, false);
if (type != null)
{
var constrMethod = type.GetMethod(method);
if (constrMethod != null && constrMethod.IsStatic)
{
var pars = constrMethod.GetParameters();
if (pars.Length == 1 && pars[0].ParameterType == typeof(ConfigurationBuilder))
{
context.ConfigurationMethod = builder => constrMethod.Invoke(null, new object[] { builder });
break;
}
}
}
}
}
示例7: Process
public void Process()
{
using(SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(@"D:\product.xlsx", SpreadsheetDocumentType.Workbook))
{
var excelExportContext = new ExportContext(spreadsheetDocument);
uint rowNo = 0;
foreach(var product in _products)
{
rowNo++;
if(product.Price > 44)
{
product.MapColumn<Product>(x => x.Description, "F");
product.MapStyle<Product>(x => x.Name, new CellFill(hexColor: "FFFF0000"));
}
if(product.Price < 33)
{
product.MapStyle<Product>(x => x.Code, new CellBorder(left: true, right: true));
}
excelExportContext.RenderEntity(product, rowNo);
}
excelExportContext.SaveChanges();
}
}
示例8: ExportData
protected override void ExportData(System.Xml.XmlWriter writer, ExportContext context)
{
var data = GetData();
var node = data as Node;
if (node != null)
{
writer.WriteStartElement("Path");
writer.WriteString(node.Path);
if (context != null)
context.AddReference(node.Path);
writer.WriteEndElement();
return;
}
var nodes = data as IEnumerable;
if (nodes != null)
{
foreach (Node item in nodes)
{
writer.WriteStartElement("Path");
writer.WriteString(item.Path);
if (context != null)
context.AddReference(item.Path);
writer.WriteEndElement();
}
return;
}
throw ExportNotImplementedException(GetData());
}
示例9: CreateFromDataContractSerializer
// Here you can provide your own root element Xpath which will replace the Xpath of the top level element
public static string CreateFromDataContractSerializer(Type type, MemberInfo[] pathToMember, StringBuilder rootElementXpath, out XmlNamespaceManager namespaces)
{
if (type == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("type"));
}
if (pathToMember == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("pathToMember"));
}
DataContract currentContract = DataContract.GetDataContract(type);
ExportContext context;
if (rootElementXpath == null)
{
context = new ExportContext(currentContract);
}
else
{
// use the provided xpath for top level element
context = new ExportContext(rootElementXpath);
}
for (int pathToMemberIndex = 0; pathToMemberIndex < pathToMember.Length; pathToMemberIndex++)
{
currentContract = ProcessDataContract(currentContract, context, pathToMember[pathToMemberIndex]);
}
namespaces = context.Namespaces;
return context.XPath;
}
示例10: Export
public string Export(IEnumerable<string> contentTypes, IEnumerable<ContentItem> contentItems, ExportOptions exportOptions) {
var exportDocument = CreateExportRoot();
var context = new ExportContext {
Document = exportDocument,
ContentTypes = contentTypes,
ExportOptions = exportOptions
};
_exportEventHandlers.Invoke(x => x.Exporting(context), Logger);
if (exportOptions.ExportMetadata && (!exportOptions.ExportData || contentItems.Any())) {
exportDocument.Element("Orchard").Add(ExportMetadata(contentTypes));
}
if (exportOptions.ExportSiteSettings) {
exportDocument.Element("Orchard").Add(ExportSiteSettings());
}
if (exportOptions.ExportData && contentItems.Any()) {
exportDocument.Element("Orchard").Add(ExportData(contentTypes, contentItems, exportOptions.ImportBatchSize));
}
_exportEventHandlers.Invoke(x => x.Exported(context), Logger);
return WriteExportFile(exportDocument.ToString());
}
示例11: GenericExportingReflectiveTypeData
// TODO: sort out argument order, etc, with superclass
public GenericExportingReflectiveTypeData(
ExportContext ctx, Type fullType, TypeData baseType, TypeData[] args)
: base(fullType, ctx)
{
_baseType = baseType;
_args = args;
}
示例12: ExportValue
protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
{
Debug.Assert(context != null);
Debug.Assert(value != null);
Debug.Assert(writer != null);
ExportRecord(context, (DbDataRecord) value, writer);
}
示例13: ExportData
protected override void ExportData(System.Xml.XmlWriter writer, ExportContext context)
{
//-- For exmple:
// <Url authType="Forms">localhost:1315/</Url>
// <Url authType="Windows">name.server.xy</Url>
writer.WriteRaw(GetRawXml());
}
示例14: ExportValue
protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
{
if (context == null) throw new ArgumentNullException("context");
if (value == null) throw new ArgumentNullException("value");
if (writer == null) throw new ArgumentNullException("writer");
ExportTime((DateTime) value, writer);
}
示例15: ExportValue
protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
{
Debug.Assert(context != null);
Debug.Assert(value != null);
Debug.Assert(writer != null);
((IJsonExportable) value).Export(context, writer);
}