本文整理汇总了C#中System.Xml.Serialization.ImportContext类的典型用法代码示例。如果您正苦于以下问题:C# ImportContext类的具体用法?C# ImportContext怎么用?C# ImportContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImportContext类属于System.Xml.Serialization命名空间,在下文中一共展示了ImportContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SchemaImporter
internal SchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, ImportContext context)
{
if (!schemas.Contains(XmlSchema.Namespace))
{
schemas.AddReference(XmlSchemas.XsdSchema);
schemas.SchemaSet.Add(XmlSchemas.XsdSchema);
}
if (!schemas.Contains(XmlReservedNs.NsXml))
{
schemas.AddReference(XmlSchemas.XmlSchema);
schemas.SchemaSet.Add(XmlSchemas.XmlSchema);
}
_schemas = schemas;
_options = options;
_context = context;
Schemas.SetCache(Context.Cache, Context.ShareTypes);
}
开发者ID:dotnet,项目名称:corefx,代码行数:17,代码来源:SchemaImporter.cs
示例2: SchemaImporter
internal SchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, CodeDomProvider codeProvider, ImportContext context) {
if (!schemas.Contains(XmlSchema.Namespace)) {
schemas.AddReference(XmlSchemas.XsdSchema);
schemas.SchemaSet.Add(XmlSchemas.XsdSchema);
}
if (!schemas.Contains(XmlReservedNs.NsXml)) {
schemas.AddReference(XmlSchemas.XmlSchema);
schemas.SchemaSet.Add(XmlSchemas.XmlSchema);
}
this.schemas = schemas;
this.options = options;
this.codeProvider = codeProvider;
this.context = context;
Schemas.SetCache(Context.Cache, Context.ShareTypes);
SchemaImporterExtensionsSection section = PrivilegedConfigurationManager.GetSection(ConfigurationStrings.SchemaImporterExtensionsSectionPath) as SchemaImporterExtensionsSection;
if (section != null)
extensions = section.SchemaImporterExtensionsInternal;
else
extensions = new SchemaImporterExtensionCollection();
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:21,代码来源:SchemaImporter.cs
示例3: Import
private ServiceDescriptionImportWarnings Import(CodeNamespace codeNamespace, ImportContext importContext, Hashtable exportContext, StringCollection warnings) {
allSchemas = new XmlSchemas();
foreach (XmlSchema schema in schemas) {
allSchemas.Add(schema);
}
foreach (ServiceDescription description in serviceDescriptions) {
foreach (XmlSchema schema in description.Types.Schemas) {
allSchemas.Add(schema);
}
}
Hashtable references = new Hashtable();
if (!allSchemas.Contains(ServiceDescription.Namespace)) {
allSchemas.AddReference(ServiceDescription.Schema);
references[ServiceDescription.Schema] = ServiceDescription.Schema;
}
if (!allSchemas.Contains(Soap.Encoding)) {
allSchemas.AddReference(ServiceDescription.SoapEncodingSchema);
references[ServiceDescription.SoapEncodingSchema] = ServiceDescription.SoapEncodingSchema;
}
allSchemas.Compile(null, false);
// Segregate the schemas containing abstract types from those
// containing regular XML definitions. This is important because
// when you import something returning the ur-type (object), then
// you need to import ALL types/elements within ALL schemas. We
// don't want the RPC-based types leaking over into the XML-based
// element definitions. This also occurs when you have derivation:
// we need to search the schemas for derived types: but WHICH schemas
// should we search.
foreach (ServiceDescription description in serviceDescriptions) {
foreach (Message message in description.Messages) {
foreach (MessagePart part in message.Parts) {
bool isEncoded;
bool isLiteral;
FindUse(part, out isEncoded, out isLiteral);
if (part.Element != null && !part.Element.IsEmpty) {
if (isEncoded) throw new InvalidOperationException(Res.GetString(Res.CanTSpecifyElementOnEncodedMessagePartsPart, part.Name, message.Name));
XmlSchemaElement element = (XmlSchemaElement)allSchemas.Find(part.Element, typeof(XmlSchemaElement));
if (element != null) {
AddSchema(element.Parent as XmlSchema, isEncoded, isLiteral, abstractSchemas, concreteSchemas, references);
if (element.SchemaTypeName != null && !element.SchemaTypeName.IsEmpty) {
XmlSchemaType type = (XmlSchemaType)allSchemas.Find(element.SchemaTypeName, typeof(XmlSchemaType));
if (type != null) {
AddSchema(type.Parent as XmlSchema, isEncoded, isLiteral, abstractSchemas, concreteSchemas, references);
}
}
}
}
if (part.Type != null && !part.Type.IsEmpty) {
XmlSchemaType type = (XmlSchemaType)allSchemas.Find(part.Type, typeof(XmlSchemaType));
if (type != null) {
AddSchema(type.Parent as XmlSchema, isEncoded, isLiteral, abstractSchemas, concreteSchemas, references);
}
}
}
}
}
Hashtable imports;
foreach (XmlSchemas xmlschemas in new XmlSchemas[] { abstractSchemas, concreteSchemas }) {
// collect all imports
imports = new Hashtable();
foreach (XmlSchema schema in xmlschemas) {
AddImport(schema, imports);
}
// make sure we add them to the corresponding schema collections
foreach (XmlSchema schema in imports.Keys) {
if (references[schema] == null && !xmlschemas.Contains(schema)) {
xmlschemas.Add(schema);
}
}
}
// If a schema was not referenced by either a literal or an encoded message part,
// add it to both collections. There's no way to tell which it should be.
imports = new Hashtable();
foreach (XmlSchema schema in allSchemas) {
if (!abstractSchemas.Contains(schema) && !concreteSchemas.Contains(schema)) {
AddImport(schema, imports);
}
}
// make sure we add them to the corresponding schema collections
foreach (XmlSchema schema in imports.Keys) {
if (references[schema] != null)
continue;
if (!abstractSchemas.Contains(schema)) {
abstractSchemas.Add(schema);
}
if (!concreteSchemas.Contains(schema)) {
concreteSchemas.Add(schema);
}
}
if (abstractSchemas.Count > 0) {
foreach (XmlSchema schema in references.Values) {
abstractSchemas.AddReference(schema);
}
StringCollection schemaWarnings = SchemaCompiler.Compile(abstractSchemas);
foreach (string warning in schemaWarnings)
warnings.Add(warning);
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:ServiceDescriptionImporter.cs
示例4: XmlSchemaImporter
public XmlSchemaImporter (XmlSchemas schemas, CodeGenerationOptions options, ImportContext context)
{
this.schemas = schemas;
this.options = options;
if (context != null) {
typeIdentifiers = context.TypeIdentifiers;
InitSharedData (context);
}
else
typeIdentifiers = new CodeIdentifiers ();
InitializeExtensions ();
}
开发者ID:nestalk,项目名称:mono,代码行数:13,代码来源:XmlSchemaImporter.cs
示例5: SoapSchemaImporter
/// <include file='doc\SoapSchemaImporter.uex' path='docs/doc[@for="SoapSchemaImporter.SoapSchemaImporter3"]/*' />
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public SoapSchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, ImportContext context) : base(schemas, options, null, context){}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:5,代码来源:soapschemaimporter.cs
示例6: ImportPrimitiveMapping
PrimitiveMapping ImportPrimitiveMapping(PrimitiveModel model, ImportContext context, string dataType, bool repeats) {
PrimitiveMapping mapping = new PrimitiveMapping();
if (dataType.Length > 0) {
mapping.TypeDesc = typeScope.GetTypeDesc(dataType, XmlSchema.Namespace);
if (mapping.TypeDesc == null) {
// try it as a non-Xsd type
mapping.TypeDesc = typeScope.GetTypeDesc(dataType, UrtTypes.Namespace);
if (mapping.TypeDesc == null) {
throw new InvalidOperationException(Res.GetString(Res.XmlUdeclaredXsdType, dataType));
}
}
}
else {
mapping.TypeDesc = model.TypeDesc;
}
mapping.TypeName = mapping.TypeDesc.DataType.Name;
mapping.Namespace = mapping.TypeDesc.IsXsdType ? XmlSchema.Namespace : UrtTypes.Namespace;
mapping.IsList = repeats;
CheckContext(mapping.TypeDesc, context);
return mapping;
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:21,代码来源:xmlreflectionimporter.cs
示例7: UnsupportedException
static Exception UnsupportedException(TypeDesc typeDesc, ImportContext context) {
return new InvalidOperationException(Res.GetString(Res.XmlIllegalTypeContext, typeDesc.FullName, GetContextName(context)));
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:3,代码来源:xmlreflectionimporter.cs
示例8: ImportSpecialMapping
SpecialMapping ImportSpecialMapping(Type type, TypeDesc typeDesc, string ns, ImportContext context) {
if (specials == null)
specials = new Hashtable();
SpecialMapping mapping = (SpecialMapping)specials[type];
if (mapping != null) {
CheckContext(mapping.TypeDesc, context);
return mapping;
}
if (typeDesc.Kind == TypeKind.Serializable) {
SerializableMapping serializableMapping = null;
// get the schema method info
object[] attrs = type.GetCustomAttributes(typeof(XmlSchemaProviderAttribute), false);
if (attrs.Length > 0) {
// new IXmlSerializable
XmlSchemaProviderAttribute provider = (XmlSchemaProviderAttribute)attrs[0];
MethodInfo method = GetMethodFromSchemaProvider(provider, type);
serializableMapping = new SerializableMapping(method, provider.IsAny, ns);
XmlQualifiedName qname = serializableMapping.XsiType;
if (qname != null && !qname.IsEmpty) {
if (serializables == null)
serializables = new NameTable();
SerializableMapping existingMapping = (SerializableMapping)serializables[qname];
if (existingMapping != null) {
if (existingMapping.Type == null) {
serializableMapping = existingMapping;
}
else if (existingMapping.Type != type) {
SerializableMapping next = existingMapping.Next;
existingMapping.Next = serializableMapping;
serializableMapping.Next = next;
}
}
else {
XmlSchemaType xsdType = serializableMapping.XsdType;
if (xsdType != null)
SetBase(serializableMapping, xsdType.DerivedFrom);
serializables[qname] = serializableMapping;
}
serializableMapping.TypeName = qname.Name;
serializableMapping.Namespace = qname.Namespace;
}
serializableMapping.TypeDesc = typeDesc;
serializableMapping.Type = type;
IncludeTypes(type);
}
else {
// old IXmlSerializable
serializableMapping = new SerializableMapping();
serializableMapping.TypeDesc = typeDesc;
serializableMapping.Type = type;
}
mapping = serializableMapping;
}
else {
mapping = new SpecialMapping();
mapping.TypeDesc = typeDesc;
}
CheckContext(typeDesc, context);
specials.Add(type, mapping);
typeScope.AddTypeMapping(mapping);
return mapping;
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:64,代码来源:xmlreflectionimporter.cs
示例9: ImportTypeMapping
TypeMapping ImportTypeMapping(TypeModel model, string ns, ImportContext context, string dataType, XmlAttributes a) {
return ImportTypeMapping(model, ns, context, dataType, a, false, false);
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:3,代码来源:xmlreflectionimporter.cs
示例10: ImportSpecialMapping
private SpecialMapping ImportSpecialMapping(Type type, TypeDesc typeDesc, string ns, ImportContext context, RecursionLimiter limiter)
{
if (_specials == null)
_specials = new Hashtable();
SpecialMapping mapping = (SpecialMapping)_specials[type];
if (mapping != null)
{
CheckContext(mapping.TypeDesc, context);
return mapping;
}
if (typeDesc.Kind == TypeKind.Serializable)
{
SerializableMapping serializableMapping = null;
// get the schema method info
object[] attrs = type.GetTypeInfo().GetCustomAttributes(typeof(XmlSchemaProviderAttribute), false).ToArray();
if (attrs.Length > 0)
{
// new IXmlSerializable
XmlSchemaProviderAttribute provider = (XmlSchemaProviderAttribute)attrs[0];
MethodInfo method = GetMethodFromSchemaProvider(provider, type);
serializableMapping = new SerializableMapping(method, provider.IsAny, ns);
XmlQualifiedName qname = serializableMapping.XsiType;
if (qname != null && !qname.IsEmpty)
{
serializableMapping.TypeName = qname.Name;
serializableMapping.Namespace = qname.Namespace;
}
serializableMapping.TypeDesc = typeDesc;
serializableMapping.Type = type;
IncludeTypes(type.GetTypeInfo());
}
else
{
// old IXmlSerializable
serializableMapping = new SerializableMapping();
serializableMapping.TypeDesc = typeDesc;
serializableMapping.Type = type;
}
mapping = serializableMapping;
}
else
{
mapping = new SpecialMapping();
mapping.TypeDesc = typeDesc;
}
CheckContext(typeDesc, context);
_specials.Add(type, mapping);
_typeScope.AddTypeMapping(mapping);
return mapping;
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:52,代码来源:XmlReflectionImporter.cs
示例11: GetContextName
private static string GetContextName(ImportContext context)
{
switch (context)
{
case ImportContext.Element: return "element";
case ImportContext.Attribute: return "attribute";
case ImportContext.Text: return "text";
default:
throw new ArgumentException(SR.XmlInternalError, nameof(context));
}
}
开发者ID:omariom,项目名称:corefx,代码行数:11,代码来源:XmlReflectionImporter.cs
示例12: UnsupportedException
private static Exception UnsupportedException(TypeDesc typeDesc, ImportContext context)
{
return new InvalidOperationException(Res.GetString("XmlIllegalTypeContext", new object[] { typeDesc.FullName, GetContextName(context) }));
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:XmlReflectionImporter.cs
示例13: ImportTypeMapping
private TypeMapping ImportTypeMapping(TypeModel model, string ns, ImportContext context, string dataType, XmlAttributes a, bool repeats, bool openModel, RecursionLimiter limiter)
{
TypeMapping mapping3;
try
{
if (dataType.Length > 0)
{
TypeDesc desc = TypeScope.IsOptionalValue(model.Type) ? model.TypeDesc.BaseTypeDesc : model.TypeDesc;
if (!desc.IsPrimitive)
{
throw new InvalidOperationException(Res.GetString("XmlInvalidDataTypeUsage", new object[] { dataType, "XmlElementAttribute.DataType" }));
}
TypeDesc typeDesc = this.typeScope.GetTypeDesc(dataType, "http://www.w3.org/2001/XMLSchema");
if (typeDesc == null)
{
throw new InvalidOperationException(Res.GetString("XmlInvalidXsdDataType", new object[] { dataType, "XmlElementAttribute.DataType", new XmlQualifiedName(dataType, "http://www.w3.org/2001/XMLSchema").ToString() }));
}
if (desc.FullName != typeDesc.FullName)
{
throw new InvalidOperationException(Res.GetString("XmlDataTypeMismatch", new object[] { dataType, "XmlElementAttribute.DataType", desc.FullName }));
}
}
if (a == null)
{
a = this.GetAttributes(model.Type, false);
}
if ((a.XmlFlags & ~(XmlAttributeFlags.Type | XmlAttributeFlags.Root)) != ((XmlAttributeFlags) 0))
{
throw new InvalidOperationException(Res.GetString("XmlInvalidTypeAttributes", new object[] { model.Type.FullName }));
}
switch (model.TypeDesc.Kind)
{
case TypeKind.Root:
case TypeKind.Struct:
case TypeKind.Class:
if (context != ImportContext.Element)
{
throw UnsupportedException(model.TypeDesc, context);
}
goto Label_0216;
case TypeKind.Primitive:
if (a.XmlFlags != ((XmlAttributeFlags) 0))
{
throw InvalidAttributeUseException(model.Type);
}
return this.ImportPrimitiveMapping((PrimitiveModel) model, context, dataType, repeats);
case TypeKind.Enum:
return this.ImportEnumMapping((EnumModel) model, ns, repeats);
case TypeKind.Array:
case TypeKind.Collection:
case TypeKind.Enumerable:
if (context != ImportContext.Element)
{
throw UnsupportedException(model.TypeDesc, context);
}
break;
default:
goto Label_02E5;
}
this.arrayNestingLevel++;
ArrayMapping mapping = this.ImportArrayLikeMapping((ArrayModel) model, ns, limiter);
this.arrayNestingLevel--;
return mapping;
Label_0216:
if (model.TypeDesc.IsOptionalValue)
{
TypeDesc desc3 = string.IsNullOrEmpty(dataType) ? model.TypeDesc.BaseTypeDesc : this.typeScope.GetTypeDesc(dataType, "http://www.w3.org/2001/XMLSchema");
string typeName = (desc3.DataType == null) ? desc3.Name : desc3.DataType.Name;
TypeMapping baseMapping = this.GetTypeMapping(typeName, ns, desc3, this.types, null);
if (baseMapping == null)
{
baseMapping = this.ImportTypeMapping(this.modelScope.GetTypeModel(model.TypeDesc.BaseTypeDesc.Type), ns, context, dataType, null, repeats, openModel, limiter);
}
return this.CreateNullableMapping(baseMapping, model.TypeDesc.Type);
}
return this.ImportStructLikeMapping((StructModel) model, ns, openModel, a, limiter);
Label_02E5:
if (model.TypeDesc.Kind == TypeKind.Serializable)
{
if ((a.XmlFlags & ~XmlAttributeFlags.Root) != ((XmlAttributeFlags) 0))
{
throw new InvalidOperationException(Res.GetString("XmlSerializableAttributes", new object[] { model.TypeDesc.FullName, typeof(XmlSchemaProviderAttribute).Name }));
}
}
else if (a.XmlFlags != ((XmlAttributeFlags) 0))
{
throw InvalidAttributeUseException(model.Type);
}
if (!model.TypeDesc.IsSpecial)
{
throw UnsupportedException(model.TypeDesc, context);
}
mapping3 = this.ImportSpecialMapping(model.Type, model.TypeDesc, ns, context, limiter);
}
catch (Exception exception)
{
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:XmlReflectionImporter.cs
示例14: ImportSpecialMapping
private SpecialMapping ImportSpecialMapping(Type type, TypeDesc typeDesc, string ns, ImportContext context, RecursionLimiter limiter)
{
if (this.specials == null)
{
this.specials = new Hashtable();
}
SpecialMapping mapping = (SpecialMapping) this.specials[type];
if (mapping != null)
{
this.CheckContext(mapping.TypeDesc, context);
return mapping;
}
if (typeDesc.Kind == TypeKind.Serializable)
{
SerializableMapping mapping2 = null;
object[] customAttributes = type.GetCustomAttributes(typeof(XmlSchemaProviderAttribute), false);
if (customAttributes.Length > 0)
{
XmlSchemaProviderAttribute provider = (XmlSchemaProviderAttribute) customAttributes[0];
mapping2 = new SerializableMapping(GetMethodFromSchemaProvider(provider, type), provider.IsAny, ns);
XmlQualifiedName xsiType = mapping2.XsiType;
if ((xsiType != null) && !xsiType.IsEmpty)
{
if (this.serializables == null)
{
this.serializables = new System.Xml.Serialization.NameTable();
}
SerializableMapping mapping3 = (SerializableMapping) this.serializables[xsiType];
if (mapping3 != null)
{
if (mapping3.Type == null)
{
mapping2 = mapping3;
}
else if (mapping3.Type != type)
{
SerializableMapping next = mapping3.Next;
mapping3.Next = mapping2;
mapping2.Next = next;
}
}
else
{
XmlSchemaType xsdType = mapping2.XsdType;
if (xsdType != null)
{
this.SetBase(mapping2, xsdType.DerivedFrom);
}
this.serializables[xsiType] = mapping2;
}
mapping2.TypeName = xsiType.Name;
mapping2.Namespace = xsiType.Namespace;
}
mapping2.TypeDesc = typeDesc;
mapping2.Type = type;
this.IncludeTypes(type);
}
else
{
mapping2 = new SerializableMapping {
TypeDesc = typeDesc,
Type = type
};
}
mapping = mapping2;
}
else
{
mapping = new SpecialMapping {
TypeDesc = typeDesc
};
}
this.CheckContext(typeDesc, context);
this.specials.Add(type, mapping);
this.typeScope.AddTypeMapping(mapping);
return mapping;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:77,代码来源:XmlReflectionImporter.cs
示例15: ImportPrimitiveMapping
private PrimitiveMapping ImportPrimitiveMapping(PrimitiveModel model, ImportContext context, string dataType, bool repeats)
{
PrimitiveMapping mapping = new PrimitiveMapping();
if (dataType.Length > 0)
{
mapping.TypeDesc = this.typeScope.GetTypeDesc(dataType, "http://www.w3.org/2001/XMLSchema");
if (mapping.TypeDesc == null)
{
mapping.TypeDesc = this.typeScope.GetTypeDesc(dataType, "http://microsoft.com/wsdl/types/");
if (mapping.TypeDesc == null)
{
throw new InvalidOperationException(Res.GetString("XmlUdeclaredXsdType", new object[] { dataType }));
}
}
}
else
{
mapping.TypeDesc = model.TypeDesc;
}
mapping.TypeName = mapping.TypeDesc.DataType.Name;
mapping.Namespace = mapping.TypeDesc.IsXsdType ? "http://www.w3.org/2001/XMLSchema" : "http://microsoft.com/wsdl/types/";
mapping.IsList = repeats;
this.CheckContext(mapping.TypeDesc, context);
return mapping;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:XmlReflectionImporter.cs
示例16: ImportTypeMapping
TypeMapping ImportTypeMapping(TypeModel model, string ns, ImportContext context, string dataType, XmlSchemaForm form, bool repeats) {
if (dataType.Length > 0) {
if (!model.TypeDesc.IsPrimitive) {
throw new InvalidOperationException(Res.GetString(Res.XmlInvalidDataTypeUsage, dataType, "XmlElementAttribute.DataType"));
}
TypeDesc td = typeScope.GetTypeDesc(new XmlQualifiedName(dataType, XmlSchema.Namespace));
if (td == null) {
throw new InvalidOperationException(Res.GetString(Res.XmlInvalidXsdDataType, dataType, "XmlElementAttribute.DataType", new XmlQualifiedName(dataType, XmlSchema.Namespace).ToString()));
}
if (model.TypeDesc.FullName != td.FullName) {
throw new InvalidOperationException(Res.GetString(Res.XmlDataTypeMismatch, dataType, "XmlElementAttribute.DataType", model.TypeDesc.FullName));
}
}
XmlAttributes a = GetAttributes(model.Type);
if ((a.XmlFlags & ~(XmlAttributeFlags.Type | XmlAttributeFlags.Root)) != 0)
throw new InvalidOperationException(Res.GetString(Res.XmlInvalidTypeAttributes, model.Type.FullName));
switch (model.TypeDesc.Kind) {
case TypeKind.Enum:
return ImportEnumMapping((EnumModel)model, ns, repeats);
case TypeKind.Primitive:
if (a.XmlFlags != 0) throw InvalidAttributeUseException(model.Type);
return ImportPrimitiveMapping((PrimitiveModel)model, context, dataType, repeats);
case TypeKind.Array:
case TypeKind.Collection:
case TypeKind.Enumerable:
if (a.XmlFlags != 0) throw InvalidAttributeUseException(model.Type);
if (context != ImportContext.Element) throw UnsupportedException(model.TypeDesc, context);
arrayNestingLevel++;
ArrayMapping arrayMapping = ImportArrayLikeMapping((ArrayModel)model, ns, form);
arrayNestingLevel--;
return arrayMapping;
case TypeKind.Root:
case TypeKind.Class:
case TypeKind.Struct:
case TypeKind.Interface:
if (context != ImportContext.Element) throw UnsupportedException(model.TypeDesc, context);
return ImportStructLikeMapping((StructModel)model, ns, form);
default:
if (a.XmlFlags != 0) throw InvalidAttributeUseException(model.Type);
if (model.TypeDesc.IsSpecial)
return ImportSpecialMapping(model.Type, model.TypeDesc, ns, context);
throw UnsupportedException(model.TypeDesc, context);
}
}
开发者ID:ArildF,项目名称:masters,代码行数:48,代码来源:xmlreflectionimporter.cs
示例17: ImportSpecialMapping
SpecialMapping ImportSpecialMapping(Type type, TypeDesc typeDesc, string ns, ImportContext context) {
SpecialMapping mapping = (SpecialMapping)specials[type];
if (mapping != null) {
CheckContext(mapping.TypeDesc, context);
return mapping;
}
if (typeDesc.Kind == TypeKind.Serializable) {
SerializableMapping serializableMapping = new SerializableMapping();
serializableMapping.Type = type;
mapping = serializableMapping;
}
else {
mapping = new SpecialMapping();
}
mapping.TypeDesc = typeDesc;
mapping.TypeName = typeDesc.Name;
CheckContext(typeDesc, context);
specials.Add(type, mapping);
return mapping;
}
开发者ID:ArildF,项目名称:masters,代码行数:20,代码来源:xmlreflectionimporter.cs
示例18: UnsupportedException
private static Exception UnsupportedException(TypeDesc typeDesc, ImportContext context)
{
return new InvalidOperationException(SR.Format(SR.XmlIllegalTypeContext, typeDesc.FullName, GetContextName(context)));
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:4,代码来源:XmlReflectionImporter.cs
示例19: SoapSchemaImporter
public SoapSchemaImporter (XmlSchemas schemas,CodeGenerationOptions options,
CodeDomProvider codeProvider, ImportContext context)
{
_importer = new XmlSchemaImporter (schemas, options, codeProvider, context);
_importer.UseEncodedFormat = true;
}
开发者ID:nobled,项目名称:mono,代码行数:6,代码来源:SoapSchemaImporter.cs
示例20: GetContextName
static string GetContextName(ImportContext context) {
switch (context) {
case ImportContext.Element: return "element";
case ImportContext.Attribute: return "attribute";
case ImportContext.Text: return "text";
default:
throw new ArgumentException(Res.GetString(Res.XmlInternalError), "context");
}
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:9,代码来源:xmlreflectionimporter.cs
注:本文中的System.Xml.Serialization.ImportContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论