本文整理汇总了C#中System.Xml.Serialization.XmlTypeMapping类的典型用法代码示例。如果您正苦于以下问题:C# XmlTypeMapping类的具体用法?C# XmlTypeMapping怎么用?C# XmlTypeMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlTypeMapping类属于System.Xml.Serialization命名空间,在下文中一共展示了XmlTypeMapping类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
public static XmlSerializer Create(XmlTypeMapping xmlTypeMapping)
{
XmlSerializer xs = _factory.CreateSerializer(xmlTypeMapping);
if (xs == null)
xs = new XmlSerializer(xmlTypeMapping);
return xs;
}
开发者ID:4-Roads,项目名称:FourRoads.Common,代码行数:7,代码来源:XmlInjectedSerilization.cs
示例2: ExportTypeMapping
/// <include file='doc\XmlSchemaExporter.uex' path='docs/doc[@for="XmlSchemaExporter.ExportTypeMapping"]/*' />
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public void ExportTypeMapping(XmlTypeMapping xmlTypeMapping)
{
xmlTypeMapping.CheckShallow();
CheckScope(xmlTypeMapping.Scope);
ExportElement(xmlTypeMapping.Accessor);
ExportRootIfNecessary(xmlTypeMapping.Scope);
}
开发者ID:AtsushiKan,项目名称:corefx,代码行数:11,代码来源:XmlSchemaExporter.cs
示例3: ExportTypeMapping
/// <include file='doc\XmlCodeExporter.uex' path='docs/doc[@for="XmlCodeExporter.ExportTypeMapping"]/*' />
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public void ExportTypeMapping(XmlTypeMapping xmlTypeMapping) {
xmlTypeMapping.CheckShallow();
CheckScope(xmlTypeMapping.Scope);
if (xmlTypeMapping.Accessor.Any) throw new InvalidOperationException(Res.GetString(Res.XmlIllegalWildcard));
ExportElement(xmlTypeMapping.Accessor);
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:11,代码来源:xmlcodeexporter.cs
示例4: RegisterClrType
public void RegisterClrType (XmlTypeMapping map, Type type, string ns)
{
if (type == typeof(object)) ns = "";
string mapKey = type.FullName + "/" + ns;
if (!_clrTypes.ContainsKey (mapKey))
_clrTypes.Add (mapKey, map);
}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:ReflectionHelper.cs
示例5: Print
public static void Print(XmlTypeMapping tm)
{
Console.WriteLine("/XmlTypeMapping:");
Console.WriteLine("ElementName: {0} ", tm.ElementName);
Console.WriteLine("Namespace: {0} ", tm.Namespace);
Console.WriteLine("TypeName: {0} ", tm.TypeName);
Console.WriteLine("FullTypeName: {0} ", tm.TypeFullName);
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:XmlReflectionImporterTests.cs
示例6: AddMappingMetadata
public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlTypeMapping member, string ns)
{
if (member.Namespace != ns && member.Namespace != "") {
CodeAttributeDeclaration ratt = new CodeAttributeDeclaration ("System.Xml.Serialization.XmlRoot");
ratt.Arguments.Add (MapCodeGenerator.GetArg (member.ElementName));
ratt.Arguments.Add (MapCodeGenerator.GetArg ("Namespace", member.Namespace));
ratt.Arguments.Add (MapCodeGenerator.GetArg ("IsNullable", member.IsNullable));
metadata.Add (ratt);
}
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:10,代码来源:XmlCodeExporter.cs
示例7: CreateSerializer
public XmlSerializer CreateSerializer (XmlTypeMapping xmlTypeMapping)
{
lock (serializersBySource)
{
XmlSerializer ser = (XmlSerializer) serializersBySource [xmlTypeMapping.Source];
if (ser == null) {
ser = new XmlSerializer (xmlTypeMapping);
serializersBySource [xmlTypeMapping.Source] = ser;
}
return ser;
}
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:12,代码来源:XmlSerializerFactory.cs
示例8: GenerateTypeElement
private void GenerateTypeElement(object o, XmlTypeMapping xmlMapping)
{
ElementAccessor element = xmlMapping.Accessor;
TypeMapping mapping = element.Mapping;
WriteStartDocument();
if (o == null)
{
if (element.IsNullable)
{
if (mapping.IsSoap)
{
throw new PlatformNotSupportedException();
}
else
{
WriteNullTagLiteral(element.Name, (element.Form == XmlSchemaForm.Qualified ? element.Namespace : ""));
}
}
else
{
WriteEmptyTag(element.Name, (element.Form == XmlSchemaForm.Qualified ? element.Namespace : ""));
}
return;
}
if (!mapping.TypeDesc.IsValueType && !mapping.TypeDesc.Type.GetTypeInfo().IsPrimitive)
{
TopLevelElement();
}
WriteMember(o, null, new ElementAccessor[] { element }, null, null, mapping.TypeDesc, !element.IsSoap, xmlMapping);
if (mapping.IsSoap)
{
throw new PlatformNotSupportedException();
}
}
开发者ID:geoffkizer,项目名称:corefx,代码行数:39,代码来源:ReflectionXmlSerializationWriter.cs
示例9: ImportTypeMapping
/// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="XmlReflectionImporter.ImportTypeMapping1"]/*' />
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public XmlTypeMapping ImportTypeMapping(Type type, string defaultNamespace) {
ElementAccessor element = new ElementAccessor();
element.IsSoap = true;
element.Mapping = ImportTypeMapping(modelScope.GetTypeModel(type));
element.Name = element.Mapping.DefaultElementName;
element.Namespace = element.Mapping.Namespace == null ? defaultNamespace : element.Mapping.Namespace;
element.Form = XmlSchemaForm.Qualified;
XmlTypeMapping xmlMapping = new XmlTypeMapping(typeScope, element);
xmlMapping.SetKeyInternal(XmlMapping.GenerateKey(type, null, defaultNamespace));
xmlMapping.IsSoap = true;
xmlMapping.GenerateSerializer = true;
return xmlMapping;
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:17,代码来源:soapreflectionimporter.cs
示例10: GenerateEnum
protected override void GenerateEnum (XmlTypeMapping map, CodeTypeDeclaration codeEnum)
{
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.SoapType");
if (map.XmlType != map.TypeData.TypeName) att.Arguments.Add (GetArg (map.XmlType));
if (map.XmlTypeNamespace != "") att.Arguments.Add (GetArg ("Namespace", map.XmlTypeNamespace));
AddCustomAttribute (codeEnum, att, false);
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:SoapCodeExporter.cs
示例11: GenerateTypeElement
string GenerateTypeElement(XmlTypeMapping xmlTypeMapping) {
ElementAccessor element = xmlTypeMapping.Accessor;
TypeMapping mapping = element.Mapping;
string methodName = NextMethodName(element.Name);
Writer.WriteLine();
Writer.Write("public object ");
Writer.Write(methodName);
Writer.WriteLine("() {");
Writer.Indent++;
Writer.WriteLine("object o = null;");
MemberMapping member = new MemberMapping();
member.TypeDesc = mapping.TypeDesc;
//member.ReadOnly = !mapping.TypeDesc.HasDefaultConstructor;
member.Elements = new ElementAccessor[] { element };
Member[] members = new Member[] { new Member(this,"o", "o", "a", 0, member) };
Writer.WriteLine("Reader.MoveToContent();");
string unknownNode = "UnknownNode(null, " + ExpectedElements(members) + ");";
WriteMemberElements(members, "throw CreateUnknownNodeException();", unknownNode, element.Any ? members[0] : null, null, null);
if (element.IsSoap) {
Writer.WriteLine("Referenced(o);");
Writer.WriteLine("ReadReferencedElements();");
}
Writer.WriteLine("return (object)o;");
Writer.Indent--;
Writer.WriteLine("}");
return methodName;
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:27,代码来源:XmlSerializationReader.cs
示例12: RegisterDerivedMap
void RegisterDerivedMap (XmlTypeMapping map, XmlTypeMapping derivedMap)
{
map.DerivedTypes.Add (derivedMap);
map.DerivedTypes.AddRange (derivedMap.DerivedTypes);
if (map.BaseMap != null)
RegisterDerivedMap (map.BaseMap, derivedMap);
else {
XmlTypeMapping obmap = ImportTypeMapping (typeof(object));
if (obmap != map)
obmap.DerivedTypes.Add (derivedMap);
}
}
开发者ID:anand-bhola,项目名称:mono,代码行数:13,代码来源:XmlReflectionImporter.cs
示例13: BuildClassMap
void BuildClassMap (XmlTypeMapping map, XmlQualifiedName typeQName, XmlSchemaComplexType stype)
{
CodeIdentifiers classIds = new CodeIdentifiers();
classIds.AddReserved (map.TypeData.TypeName);
ClassMap cmap = new ClassMap ();
map.ObjectMap = cmap;
bool isMixed = stype.IsMixed;
if (stype.Particle != null)
ImportParticleComplexContent (typeQName, cmap, stype.Particle, classIds, isMixed);
else
{
if (stype.ContentModel is XmlSchemaSimpleContent) {
ImportSimpleContent (typeQName, map, (XmlSchemaSimpleContent)stype.ContentModel, classIds, isMixed);
}
else if (stype.ContentModel is XmlSchemaComplexContent) {
ImportComplexContent (typeQName, map, (XmlSchemaComplexContent)stype.ContentModel, classIds, isMixed);
}
}
ImportAttributes (typeQName, cmap, stype.Attributes, stype.AnyAttribute, classIds);
ImportExtensionTypes (typeQName);
if (isMixed) AddTextMember (typeQName, cmap, classIds);
AddObjectDerivedMap (map);
}
开发者ID:nestalk,项目名称:mono,代码行数:28,代码来源:XmlSchemaImporter.cs
示例14: RegisterMapFixup
void RegisterMapFixup (XmlTypeMapping map, XmlQualifiedName typeQName, XmlSchemaComplexType stype)
{
// This check is introduced for bug #650117, but might be too wide to catch erroneous cases...
if (fixup_registered_types.Contains (stype))
throw new InvalidOperationException (String.Format ("Circular dependency for schema type {0} in namespace {1}", map.ElementName, map.Namespace));
fixup_registered_types.Add (stype);
MapFixup fixup = new MapFixup ();
fixup.Map = map;
fixup.SchemaType = stype;
fixup.TypeName = typeQName;
pendingMaps.Enqueue (fixup);
}
开发者ID:nestalk,项目名称:mono,代码行数:12,代码来源:XmlSchemaImporter.cs
示例15: CreateElementInfo
XmlTypeMapElementInfo CreateElementInfo (string ns, XmlTypeMapMember member, string name, TypeData typeData, bool isNillable, XmlSchemaForm form, XmlTypeMapping emap, int order)
{
XmlTypeMapElementInfo einfo = new XmlTypeMapElementInfo (member, typeData);
einfo.ElementName = name;
einfo.Namespace = ns;
einfo.IsNullable = isNillable;
einfo.Form = GetForm (form, ns, true);
if (typeData.IsComplexType)
einfo.MappedType = emap;
einfo.ExplicitOrder = order;
return einfo;
}
开发者ID:nestalk,项目名称:mono,代码行数:12,代码来源:XmlSchemaImporter.cs
示例16: SetMapBaseType
void SetMapBaseType (XmlTypeMapping map, Type baseType)
{
// This method sets the base type for a given map.
// If the map already inherits from this type, it does nothing.
// Fiirst of all, check if the map already inherits from baseType
XmlTypeMapping topMap = null;
while (map != null)
{
if (map.TypeData.Type == baseType)
return;
topMap = map;
map = map.BaseMap;
}
// Does not have the requested base type.
// Then, get/create a map for that base type.
XmlTypeMapping baseMap = ReflectType (baseType);
// Add this map as a derived map of the base map
topMap.BaseMap = baseMap;
baseMap.DerivedTypes.Add (topMap);
baseMap.DerivedTypes.AddRange (topMap.DerivedTypes);
// Now add the base type fields to all derived maps
ClassMap baseClassMap = (ClassMap)baseMap.ObjectMap;
ClassMap cmap = (ClassMap)topMap.ObjectMap;
foreach (XmlTypeMapMember member in baseClassMap.AllMembers)
cmap.AddMember (member);
foreach (XmlTypeMapping derivedMap in topMap.DerivedTypes)
{
cmap = (ClassMap)derivedMap.ObjectMap;
foreach (XmlTypeMapMember member in baseClassMap.AllMembers)
cmap.AddMember (member);
}
}
开发者ID:nestalk,项目名称:mono,代码行数:42,代码来源:XmlSchemaImporter.cs
示例17: ImportMemberMapping
XmlMemberMapping ImportMemberMapping (string name, string ns, bool isNullable, TypeData type, XmlTypeMapping emap, int order)
{
XmlTypeMapMemberElement mapMem;
if (type.IsListType)
mapMem = new XmlTypeMapMemberList ();
else
mapMem = new XmlTypeMapMemberElement ();
mapMem.Name = name;
mapMem.TypeData = type;
mapMem.ElementInfo.Add (CreateElementInfo (ns, mapMem, name, type, isNullable, XmlSchemaForm.None, emap, order));
return new XmlMemberMapping (name, ns, mapMem, encodedFormat);
}
开发者ID:nestalk,项目名称:mono,代码行数:14,代码来源:XmlSchemaImporter.cs
示例18: CreateTypeMapping
XmlTypeMapping CreateTypeMapping (XmlQualifiedName typeQName, SchemaTypes schemaType, XmlQualifiedName root)
{
string typeName = CodeIdentifier.MakeValid (typeQName.Name);
typeName = typeIdentifiers.AddUnique (typeName, null);
TypeData typeData = new TypeData (typeName, typeName, typeName, schemaType, null);
string rootElem;
string rootNs;
if (root != null) {
rootElem = root.Name;
rootNs = root.Namespace;
}
else {
rootElem = typeQName.Name;
rootNs = "";
}
XmlTypeMapping map = new XmlTypeMapping (rootElem, rootNs, typeData, typeQName.Name, typeQName.Namespace);
map.IncludeInSchema = true;
RegisterTypeMapping (typeQName, typeData, map);
return map;
}
开发者ID:nestalk,项目名称:mono,代码行数:24,代码来源:XmlSchemaImporter.cs
示例19: BuildPendingMap
void BuildPendingMap (XmlTypeMapping map)
{
if (map.ObjectMap != null) return;
foreach (MapFixup fixup in pendingMaps)
{
if (fixup.Map == map) {
BuildClassMap (fixup.Map, fixup.TypeName, fixup.SchemaType);
return;
}
}
throw new InvalidOperationException ("Can't complete map of type " + map.XmlType + " : " + map.Namespace);
}
开发者ID:nestalk,项目名称:mono,代码行数:13,代码来源:XmlSchemaImporter.cs
示例20: CreateArrayTypeMapping
XmlTypeMapping CreateArrayTypeMapping (XmlQualifiedName typeQName, TypeData arrayTypeData)
{
XmlTypeMapping map;
if (encodedFormat) map = new XmlTypeMapping ("Array", XmlSerializer.EncodingNamespace, arrayTypeData, "Array", XmlSerializer.EncodingNamespace);
else map = new XmlTypeMapping (arrayTypeData.XmlType, typeQName.Namespace, arrayTypeData, arrayTypeData.XmlType, typeQName.Namespace);
map.IncludeInSchema = true;
RegisterTypeMapping (typeQName, arrayTypeData, map);
return map;
}
开发者ID:nestalk,项目名称:mono,代码行数:11,代码来源:XmlSchemaImporter.cs
注:本文中的System.Xml.Serialization.XmlTypeMapping类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论