本文整理汇总了C#中System.Xml.Serialization.XmlTypeMapMemberElement类的典型用法代码示例。如果您正苦于以下问题:C# XmlTypeMapMemberElement类的具体用法?C# XmlTypeMapMemberElement怎么用?C# XmlTypeMapMemberElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlTypeMapMemberElement类属于System.Xml.Serialization命名空间,在下文中一共展示了XmlTypeMapMemberElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GenerateArrayElement
protected override void GenerateArrayElement (CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberElement member, string defaultNamespace, bool forceUseMemberName)
{
XmlTypeMapElementInfo einfo = (XmlTypeMapElementInfo) member.ElementInfo[0];
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.XmlArray");
if (forceUseMemberName || (einfo.ElementName != member.Name)) att.Arguments.Add (GetArg ("ElementName", einfo.ElementName));
if (einfo.Namespace != defaultNamespace) att.Arguments.Add (GetArg ("Namespace", einfo.Namespace));
if (einfo.Form == XmlSchemaForm.Unqualified) att.Arguments.Add (MapCodeGenerator.GetEnumArg ("Form", "System.Xml.Schema.XmlSchemaForm", einfo.Form.ToString()));
if (einfo.IsNullable) att.Arguments.Add (GetArg ("IsNullable", true));
if (att.Arguments.Count > 0) attributes.Add (att);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:10,代码来源:XmlCodeExporter.cs
示例2: ImportElementInfo
XmlTypeMapElementInfoList ImportElementInfo (string defaultName, string defaultNamespace, Type defaultType, XmlTypeMapMemberElement member, XmlAttributes atts)
{
XmlTypeMapElementInfoList list = new XmlTypeMapElementInfoList();
ImportTextElementInfo (list, defaultType, member, atts);
if (atts.XmlElements.Count == 0 && list.Count == 0)
{
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(defaultType));
elem.ElementName = defaultName;
elem.Namespace = defaultNamespace;
if (elem.TypeData.IsComplexType)
elem.MappedType = ImportTypeMapping (defaultType, null, defaultNamespace);
list.Add (elem);
}
bool multiType = (atts.XmlElements.Count > 1);
foreach (XmlElementAttribute att in atts.XmlElements)
{
Type elemType = (att.Type != null) ? att.Type : defaultType;
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(elemType, att.DataType));
elem.ElementName = (att.ElementName != null) ? att.ElementName : defaultName;
elem.Namespace = (att.Namespace != null) ? att.Namespace : defaultNamespace;
elem.Form = att.Form;
elem.IsNullable = att.IsNullable;
if (elem.IsNullable && elem.TypeData.IsValueType)
throw new InvalidOperationException ("IsNullable may not be 'true' for value type " + elem.TypeData.FullTypeName + " in member '" + defaultName + "'");
if (elem.TypeData.IsComplexType)
{
if (att.DataType != null) throw new InvalidOperationException ("'" + att.DataType + "' is an invalid value for the XmlElementAttribute.DateTime property. The property may only be specified for primitive types.");
elem.MappedType = ImportTypeMapping (elemType, null, elem.Namespace);
}
if (att.ElementName != null)
elem.ElementName = att.ElementName;
else if (multiType) {
if (elem.MappedType != null) elem.ElementName = elem.MappedType.ElementName;
else elem.ElementName = TypeTranslator.GetTypeData(elemType).XmlType;
}
else
elem.ElementName = defaultName;
list.Add (elem);
}
return list;
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:48,代码来源:XmlReflectionImporter.cs
示例3: GenerateElementMember
protected override void GenerateElementMember (CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberElement member)
{
if (member.ChoiceMember != null) {
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.XmlChoiceIdentifier");
att.Arguments.Add (GetArg(member.ChoiceMember));
attributes.Add (att);
}
if (member.Ignore)
attributes.Add (new CodeAttributeDeclaration ("System.Xml.Serialization.XmlIgnoreAttribute"));
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:11,代码来源:XmlCodeExporter.cs
示例4: ImportTextElementInfo
void ImportTextElementInfo (XmlTypeMapElementInfoList list, Type defaultType, XmlTypeMapMemberElement member, XmlAttributes atts, string defaultNamespace)
{
if (atts.XmlText != null)
{
member.IsXmlTextCollector = true;
if (atts.XmlText.Type != null) {
TypeData td = TypeTranslator.GetTypeData (defaultType);
if ((td.SchemaType == SchemaTypes.Primitive || td.SchemaType == SchemaTypes.Enum) && atts.XmlText.Type != defaultType) {
throw new InvalidOperationException ("The type for XmlText may not be specified for primitive types.");
}
defaultType = atts.XmlText.Type;
}
#if !MOONLIGHT
if (defaultType == typeof(XmlNode)) defaultType = typeof(XmlText); // Nodes must be text nodes
#endif
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(defaultType, atts.XmlText.DataType));
if (elem.TypeData.SchemaType != SchemaTypes.Primitive &&
elem.TypeData.SchemaType != SchemaTypes.Enum &&
elem.TypeData.SchemaType != SchemaTypes.XmlNode &&
!(elem.TypeData.SchemaType == SchemaTypes.Array && elem.TypeData.ListItemTypeData.SchemaType == SchemaTypes.XmlNode)
)
throw new InvalidOperationException ("XmlText cannot be used to encode complex types");
if (elem.TypeData.IsComplexType)
elem.MappedType = ImportTypeMapping (defaultType, null, defaultNamespace);
elem.IsTextElement = true;
elem.WrappedElement = false;
list.Add (elem);
}
}
开发者ID:anand-bhola,项目名称:mono,代码行数:32,代码来源:XmlReflectionImporter.cs
示例5: ImportElementInfo
XmlTypeMapElementInfoList ImportElementInfo (Type cls, string defaultName, string defaultNamespace, Type defaultType, XmlTypeMapMemberElement member, XmlAttributes atts)
{
EnumMap choiceEnumMap = null;
Type choiceEnumType = null;
XmlTypeMapElementInfoList list = new XmlTypeMapElementInfoList();
ImportTextElementInfo (list, defaultType, member, atts, defaultNamespace);
if (atts.XmlChoiceIdentifier != null) {
if (cls == null)
throw new InvalidOperationException ("XmlChoiceIdentifierAttribute not supported in this context.");
member.ChoiceMember = atts.XmlChoiceIdentifier.MemberName;
MemberInfo[] mems = cls.GetMember (member.ChoiceMember, BindingFlags.Instance|BindingFlags.Public);
if (mems.Length == 0)
throw new InvalidOperationException ("Choice member '" + member.ChoiceMember + "' not found in class '" + cls);
if (mems[0] is PropertyInfo) {
PropertyInfo pi = (PropertyInfo)mems[0];
if (!pi.CanWrite || !pi.CanRead)
throw new InvalidOperationException ("Choice property '" + member.ChoiceMember + "' must be read/write.");
choiceEnumType = pi.PropertyType;
}
else choiceEnumType = ((FieldInfo)mems[0]).FieldType;
member.ChoiceTypeData = TypeTranslator.GetTypeData (choiceEnumType);
if (choiceEnumType.IsArray)
choiceEnumType = choiceEnumType.GetElementType ();
choiceEnumMap = ImportTypeMapping (choiceEnumType).ObjectMap as EnumMap;
if (choiceEnumMap == null)
throw new InvalidOperationException ("The member '" + mems[0].Name + "' is not a valid target for XmlChoiceIdentifierAttribute.");
}
if (atts.XmlElements.Count == 0 && list.Count == 0)
{
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(defaultType));
elem.ElementName = defaultName;
elem.Namespace = defaultNamespace;
if (elem.TypeData.IsComplexType)
elem.MappedType = ImportTypeMapping (defaultType, null, defaultNamespace);
list.Add (elem);
}
bool multiType = (atts.XmlElements.Count > 1);
foreach (XmlElementAttribute att in atts.XmlElements)
{
Type elemType = (att.Type != null) ? att.Type : defaultType;
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(elemType, att.DataType));
elem.Form = att.Form;
if (elem.Form != XmlSchemaForm.Unqualified)
elem.Namespace = (att.Namespace != null) ? att.Namespace : defaultNamespace;
elem.IsNullable = att.IsNullable;
if (elem.IsNullable && !elem.TypeData.IsNullable)
throw new InvalidOperationException ("IsNullable may not be 'true' for value type " + elem.TypeData.FullTypeName + " in member '" + defaultName + "'");
if (elem.TypeData.IsComplexType)
{
if (att.DataType.Length != 0) throw new InvalidOperationException (
string.Format(CultureInfo.InvariantCulture, "'{0}' is "
+ "an invalid value for '{1}.{2}' of type '{3}'. "
+ "The property may only be specified for primitive types.",
att.DataType, cls.FullName, defaultName,
elem.TypeData.FullTypeName));
elem.MappedType = ImportTypeMapping (elemType, null, elem.Namespace);
}
if (att.ElementName.Length != 0) {
elem.ElementName = XmlConvert.EncodeLocalName(att.ElementName);
} else if (multiType) {
if (elem.MappedType != null) {
elem.ElementName = elem.MappedType.ElementName;
} else {
elem.ElementName = TypeTranslator.GetTypeData (elemType).XmlType;
}
} else {
elem.ElementName = defaultName;
}
if (choiceEnumMap != null) {
string cname = choiceEnumMap.GetEnumName (choiceEnumType.FullName, elem.ElementName);
if (cname == null)
throw new InvalidOperationException (string.Format (
CultureInfo.InvariantCulture, "Type {0} is missing"
+ " enumeration value '{1}' for element '{1} from"
+ " namespace '{2}'.", choiceEnumType, elem.ElementName,
elem.Namespace));
elem.ChoiceValue = Enum.Parse (choiceEnumType, cname, false);
}
list.Add (elem);
}
return list;
}
开发者ID:anand-bhola,项目名称:mono,代码行数:97,代码来源:XmlReflectionImporter.cs
示例6: ImportSimpleContent
void ImportSimpleContent (XmlQualifiedName typeQName, XmlTypeMapping map, XmlSchemaSimpleContent content, CodeIdentifiers classIds, bool isMixed)
{
XmlSchemaSimpleContentExtension ext = content.Content as XmlSchemaSimpleContentExtension;
ClassMap cmap = (ClassMap)map.ObjectMap;
XmlQualifiedName qname = GetContentBaseType (content.Content);
TypeData simpleType = null;
if (!IsPrimitiveTypeNamespace (qname.Namespace))
{
// Add base map members to this map
XmlTypeMapping baseMap = ImportType (qname, null, true);
BuildPendingMap (baseMap);
if (baseMap.IsSimpleType) {
simpleType = baseMap.TypeData;
} else {
ClassMap baseClassMap = (ClassMap)baseMap.ObjectMap;
foreach (XmlTypeMapMember member in baseClassMap.AllMembers)
cmap.AddMember (member);
map.BaseMap = baseMap;
baseMap.DerivedTypes.Add (map);
}
}
else
simpleType = FindBuiltInType (qname);
if (simpleType != null) {
XmlTypeMapMemberElement member = new XmlTypeMapMemberElement ();
member.Name = classIds.AddUnique("Value", member);
member.TypeData = simpleType;
member.ElementInfo.Add (CreateTextElementInfo (typeQName.Namespace, member, member.TypeData));
member.IsXmlTextCollector = true;
cmap.AddMember (member);
}
if (ext != null)
ImportAttributes (typeQName, cmap, ext.Attributes, ext.AnyAttribute, classIds);
}
开发者ID:nestalk,项目名称:mono,代码行数:41,代码来源:XmlSchemaImporter.cs
示例7: ImportSequenceContent
void ImportSequenceContent (XmlQualifiedName typeQName, ClassMap cmap, XmlSchemaObjectCollection items, CodeIdentifiers classIds, bool multiValue, ref bool isMixed)
{
foreach (XmlSchemaObject item in items)
{
if (item is XmlSchemaElement)
{
string ns;
XmlSchemaElement elem = (XmlSchemaElement) item;
XmlTypeMapping emap;
TypeData typeData = GetElementTypeData (typeQName, elem, null, out emap);
XmlSchemaElement refElem = GetRefElement (typeQName, elem, out ns);
if (elem.MaxOccurs == 1 && !multiValue)
{
XmlTypeMapMemberElement member = null;
if (typeData.SchemaType != SchemaTypes.Array)
{
member = new XmlTypeMapMemberElement ();
if (refElem.DefaultValue != null) member.DefaultValue = ImportDefaultValue (typeData, refElem.DefaultValue);
}
else if (GetTypeMapping (typeData).IsSimpleType)
{
// It is a simple list (space separated list).
// Since this is not supported, map as a single item value
member = new XmlTypeMapMemberElement ();
#if NET_2_0
// In MS.NET those types are mapped to a string
typeData = TypeTranslator.GetTypeData(typeof(string));
#else
typeData = typeData.ListItemTypeData;
#endif
}
else
member = new XmlTypeMapMemberList ();
if (elem.MinOccurs == 0 && typeData.IsValueType)
member.IsOptionalValueType = true;
member.Name = classIds.AddUnique(CodeIdentifier.MakeValid(refElem.Name), member);
member.Documentation = GetDocumentation (elem);
member.TypeData = typeData;
member.ElementInfo.Add (CreateElementInfo (ns, member, refElem.Name, typeData, refElem.IsNillable, refElem.Form, emap, items.IndexOf (item)));
cmap.AddMember (member);
}
else
{
XmlTypeMapMemberFlatList member = new XmlTypeMapMemberFlatList ();
member.ListMap = new ListMap ();
member.Name = classIds.AddUnique(CodeIdentifier.MakeValid(refElem.Name), member);
member.Documentation = GetDocumentation (elem);
member.TypeData = typeData.ListTypeData;
member.ElementInfo.Add (CreateElementInfo (ns, member, refElem.Name, typeData, refElem.IsNillable, refElem.Form, emap, items.IndexOf (item)));
member.ListMap.ItemInfo = member.ElementInfo;
cmap.AddMember (member);
}
}
else if (item is XmlSchemaAny)
{
XmlSchemaAny elem = (XmlSchemaAny) item;
XmlTypeMapMemberAnyElement member = new XmlTypeMapMemberAnyElement ();
member.Name = classIds.AddUnique ("Any", member);
member.Documentation = GetDocumentation (elem);
Type ctype;
if (elem.MaxOccurs != 1 || multiValue)
ctype = isMixed ? typeof(XmlNode[]) : typeof(XmlElement[]);
else
ctype = isMixed ? typeof(XmlNode) : typeof(XmlElement);
member.TypeData = TypeTranslator.GetTypeData (ctype);
XmlTypeMapElementInfo einfo = new XmlTypeMapElementInfo (member, member.TypeData);
einfo.IsUnnamedAnyElement = true;
member.ElementInfo.Add (einfo);
if (isMixed)
{
einfo = CreateTextElementInfo (typeQName.Namespace, member, member.TypeData);
member.ElementInfo.Add (einfo);
member.IsXmlTextCollector = true;
isMixed = false; //Allow only one XmlTextAttribute
}
cmap.AddMember (member);
}
else if (item is XmlSchemaParticle) {
ImportParticleContent (typeQName, cmap, (XmlSchemaParticle)item, classIds, multiValue, ref isMixed);
}
}
}
开发者ID:nestalk,项目名称:mono,代码行数:89,代码来源:XmlSchemaImporter.cs
示例8: AddArrayAttributes
public void AddArrayAttributes (CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberElement member, string defaultNamespace, bool forceUseMemberName)
{
GenerateArrayElement (attributes, member, defaultNamespace, forceUseMemberName);
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:4,代码来源:MapCodeGenerator.cs
示例9: GenerateElementInfoMember
protected virtual void GenerateElementInfoMember (CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberElement member, XmlTypeMapElementInfo einfo, TypeData defaultType, string defaultNamespace, bool addAlwaysAttr, bool forceUseMemberName)
{
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:3,代码来源:MapCodeGenerator.cs
示例10: AddElementMemberAttributes
public void AddElementMemberAttributes (XmlTypeMapMemberElement member, string defaultNamespace, CodeAttributeDeclarationCollection attributes, bool forceUseMemberName)
{
TypeData defaultType = member.TypeData;
bool addAlwaysAttr = false;
if (member is XmlTypeMapMemberFlatList)
{
defaultType = defaultType.ListItemTypeData;
addAlwaysAttr = true;
}
foreach (XmlTypeMapElementInfo einfo in member.ElementInfo)
{
if (ExportExtraElementAttributes (attributes, einfo, defaultNamespace, defaultType))
continue;
GenerateElementInfoMember (attributes, member, einfo, defaultType, defaultNamespace, addAlwaysAttr, forceUseMemberName);
if (einfo.MappedType != null) {
ExportMapCode (einfo.MappedType);
RemoveInclude (einfo.MappedType);
}
}
GenerateElementMember (attributes, member);
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:25,代码来源:MapCodeGenerator.cs
示例11: AddAnyElementFieldMember
void AddAnyElementFieldMember (CodeTypeDeclaration codeClass, XmlTypeMapMemberElement member, string defaultNamespace)
{
CodeMemberField codeField = CreateFieldMember (member);
codeClass.Members.Add (codeField);
CodeAttributeDeclarationCollection attributes = new CodeAttributeDeclarationCollection ();
foreach (XmlTypeMapElementInfo einfo in member.ElementInfo)
ExportExtraElementAttributes (attributes, einfo, defaultNamespace, einfo.TypeData);
if (attributes.Count > 0) codeField.CustomAttributes = attributes;
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:11,代码来源:MapCodeGenerator.cs
示例12: AddElementFieldMember
void AddElementFieldMember (CodeTypeDeclaration codeClass, XmlTypeMapMemberElement member, string defaultNamespace)
{
CodeMemberField codeField = CreateFieldMember (member);
codeClass.Members.Add (codeField);
CodeAttributeDeclarationCollection attributes = codeField.CustomAttributes;
if (attributes == null) attributes = new CodeAttributeDeclarationCollection ();
AddElementMemberAttributes (member, defaultNamespace, attributes, false);
if (attributes.Count > 0) codeField.CustomAttributes = attributes;
if (member.TypeData.IsValueType && member.IsOptionalValueType)
{
codeField = new CodeMemberField (typeof(bool), member.Name + "Specified");
codeField.Attributes = MemberAttributes.Public;
codeClass.Members.Add (codeField);
GenerateSpecifierMember (codeField);
}
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:19,代码来源:MapCodeGenerator.cs
示例13: ImportTextElementInfo
void ImportTextElementInfo (XmlTypeMapElementInfoList list, Type defaultType, XmlTypeMapMemberElement member, XmlAttributes atts)
{
if (atts.XmlText != null)
{
member.IsXmlTextCollector = true;
if (atts.XmlText.Type != null) defaultType = atts.XmlText.Type;
if (defaultType == typeof(XmlNode)) defaultType = typeof(XmlText); // Nodes must be text nodes
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(defaultType, atts.XmlText.DataType));
if (elem.TypeData.SchemaType != SchemaTypes.Primitive &&
elem.TypeData.SchemaType != SchemaTypes.Enum &&
elem.TypeData.SchemaType != SchemaTypes.XmlNode &&
!(elem.TypeData.SchemaType == SchemaTypes.Array && elem.TypeData.ListItemTypeData.SchemaType == SchemaTypes.XmlNode)
)
throw new InvalidOperationException ("XmlText cannot be used to encode complex types");
elem.IsTextElement = true;
elem.WrappedElement = false;
list.Add (elem);
}
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:22,代码来源:XmlReflectionImporter.cs
示例14: ImportAnyElementInfo
XmlTypeMapElementInfoList ImportAnyElementInfo (string defaultNamespace, XmlReflectionMember rmember, XmlTypeMapMemberElement member, XmlAttributes atts)
{
XmlTypeMapElementInfoList list = new XmlTypeMapElementInfoList();
ImportTextElementInfo (list, rmember.MemberType, member, atts);
foreach (XmlAnyElementAttribute att in atts.XmlAnyElements)
{
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(typeof(XmlElement)));
if (att.Name != null && att.Name != string.Empty)
{
elem.ElementName = att.Name;
elem.Namespace = (att.Namespace != null) ? att.Namespace : "";
}
else
{
elem.IsUnnamedAnyElement = true;
elem.Namespace = defaultNamespace;
if (att.Namespace != null)
throw new InvalidOperationException ("The element " + rmember.MemberName + " has been attributed with an XmlAnyElementAttribute and a namespace '" + att.Namespace + "', but no name. When a namespace is supplied, a name is also required. Supply a name or remove the namespace.");
}
list.Add (elem);
}
return list;
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:25,代码来源:XmlReflectionImporter.cs
示例15: CreateMapMember
private XmlTypeMapMember CreateMapMember (XmlReflectionMember rmember, string defaultNamespace)
{
XmlTypeMapMember mapMember;
SoapAttributes atts = rmember.SoapAttributes;
TypeData typeData = TypeTranslator.GetTypeData (rmember.MemberType);
if (atts.SoapAttribute != null)
{
// An attribute
if (typeData.SchemaType != SchemaTypes.Enum && typeData.SchemaType != SchemaTypes.Primitive) {
throw new InvalidOperationException (string.Format (CultureInfo.InvariantCulture,
"Cannot serialize member '{0}' of type {1}. " +
"SoapAttribute cannot be used to encode complex types.",
rmember.MemberName, typeData.FullTypeName));
}
if (atts.SoapElement != null)
throw new Exception ("SoapAttributeAttribute and SoapElementAttribute cannot be applied to the same member");
XmlTypeMapMemberAttribute mapAttribute = new XmlTypeMapMemberAttribute ();
if (atts.SoapAttribute.AttributeName.Length == 0)
mapAttribute.AttributeName = XmlConvert.EncodeLocalName (rmember.MemberName);
else
mapAttribute.AttributeName = XmlConvert.EncodeLocalName (atts.SoapAttribute.AttributeName);
mapAttribute.Namespace = (atts.SoapAttribute.Namespace != null) ? atts.SoapAttribute.Namespace : "";
if (typeData.IsComplexType)
mapAttribute.MappedType = ImportTypeMapping (typeData.Type, defaultNamespace);
typeData = TypeTranslator.GetTypeData (rmember.MemberType, atts.SoapAttribute.DataType);
mapMember = mapAttribute;
mapMember.DefaultValue = GetDefaultValue (typeData, atts.SoapDefaultValue);
}
else
{
if (typeData.SchemaType == SchemaTypes.Array) mapMember = new XmlTypeMapMemberList ();
else mapMember = new XmlTypeMapMemberElement ();
if (atts.SoapElement != null && atts.SoapElement.DataType.Length != 0)
typeData = TypeTranslator.GetTypeData (rmember.MemberType, atts.SoapElement.DataType);
// Creates an ElementInfo that identifies the element
XmlTypeMapElementInfoList infoList = new XmlTypeMapElementInfoList();
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (mapMember, typeData);
elem.ElementName = XmlConvert.EncodeLocalName ((atts.SoapElement != null && atts.SoapElement.ElementName.Length != 0) ? atts.SoapElement.ElementName : rmember.MemberName);
elem.Namespace = string.Empty;
elem.IsNullable = (atts.SoapElement != null) ? atts.SoapElement.IsNullable : false;
if (typeData.IsComplexType)
elem.MappedType = ImportTypeMapping (typeData.Type, defaultNamespace);
infoList.Add (elem);
((XmlTypeMapMemberElement)mapMember).ElementInfo = infoList;
}
mapMember.TypeData = typeData;
mapMember.Name = rmember.MemberName;
mapMember.IsReturnValue = rmember.IsReturnValue;
return mapMember;
}
开发者ID:nobled,项目名称:mono,代码行数:61,代码来源:SoapReflectionImporter.cs
示例16: GenerateElementMember
protected virtual void GenerateElementMember (CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberElement member)
{
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:3,代码来源:MapCodeGenerator.cs
示例17: ImportChoiceContent
void ImportChoiceContent (XmlQualifiedName typeQName, ClassMap cmap, XmlSchemaChoice choice, CodeIdentifiers classIds, bool multiValue)
{
XmlTypeMapElementInfoList choices = new XmlTypeMapElementInfoList ();
multiValue = ImportChoices (typeQName, null, choices, choice.Items) || multiValue;
if (choices.Count == 0) return;
if (choice.MaxOccurs > 1) multiValue = true;
XmlTypeMapMemberElement member;
if (multiValue)
{
member = new XmlTypeMapMemberFlatList ();
member.Name = classIds.AddUnique ("Items", member);
ListMap listMap = new ListMap ();
listMap.ItemInfo = choices;
((XmlTypeMapMemberFlatList)member).ListMap = listMap;
}
else
{
member = new XmlTypeMapMemberElement ();
member.Name = classIds.AddUnique ("Item", member);
}
// If all choices have the same type, use that type for the member.
// If not use System.Object.
// If there are at least two choices with the same type, use a choice
// identifier attribute
TypeData typeData = null;
bool twoEqual = false;
bool allEqual = true;
Hashtable types = new Hashtable ();
for (int n = choices.Count - 1; n >= 0; n--)
{
XmlTypeMapElementInfo einfo = (XmlTypeMapElementInfo) choices [n];
// In some complex schemas, we may end up with several options
// with the same name. It is better to ignore the extra options
// than to crash. It's the best we can do, and btw it works
// better than in MS.NET.
if (cmap.GetElement (einfo.ElementName, einfo.Namespace, einfo.ExplicitOrder) != null ||
choices.IndexOfElement (einfo.ElementName, einfo.Namespace) != n)
{
choices.RemoveAt (n);
continue;
}
if (types.ContainsKey (einfo.TypeData)) twoEqual = true;
else types.Add (einfo.TypeData, einfo);
TypeData choiceType = einfo.TypeData;
if (choiceType.SchemaType == SchemaTypes.Class)
{
// When comparing class types, use the most generic class in the
// inheritance hierarchy
XmlTypeMapping choiceMap = GetTypeMapping (choiceType);
BuildPendingMap (choiceMap);
while (choiceMap.BaseMap != null) {
choiceMap = choiceMap.BaseMap;
BuildPendingMap (choiceMap);
choiceType = choiceMap.TypeData;
}
}
if (typeData == null) typeData = choiceType;
else if (typeData != choiceType) allEqual = false;
}
if (!allEqual)
typeData = TypeTranslator.GetTypeData (typeof(object));
if (twoEqual)
{
// Create the choice member
XmlTypeMapMemberElement choiceMember = new XmlTypeMapMemberElement ();
choiceMember.Ignore = true;
choiceMember.Name = classIds.AddUnique (member.Name + "ElementName", choiceMember);
member.ChoiceMember = choiceMember.Name;
// Create the choice enum
XmlTypeMapping enumMap = CreateTypeMapping (new XmlQualifiedName (member.Name + "ChoiceType", typeQName.Namespace), SchemaTypes.Enum, null);
enumMap.IncludeInSchema = false;
CodeIdentifiers codeIdents = new CodeIdentifiers ();
EnumMap.EnumMapMember[] members = new EnumMap.EnumMapMember [choices.Count];
for (int n=0; n<choices.Count; n++)
{
XmlTypeMapElementInfo it =(XmlTypeMapElementInfo) choices[n];
bool extraNs = (it.Namespace != null && it.Namespace != "" && it.Namespace != typeQName.Namespace);
string xmlName = extraNs ? it.Namespace + ":" + it.ElementName : it.ElementName;
string enumName = codeIdents.AddUnique (CodeIdentifier.MakeValid (it.ElementName), it);
members [n] = new EnumMap.EnumMapMember (xmlName, enumName);
}
enumMap.ObjectMap = new EnumMap (members, false);
choiceMember.TypeData = multiValue ? enumMap.TypeData.ListTypeData : enumMap.TypeData;
choiceMember.ElementInfo.Add (CreateElementInfo (typeQName.Namespace, choiceMember, choiceMember.Name, choiceMember.TypeData, false, XmlSchemaForm.None, -1));
//.........这里部分代码省略.........
开发者ID:nestalk,项目名称:mono,代码行数:101,代码来源:XmlSchemaImporter.cs
示例18: GenerateArrayElement
protected virtual void GenerateArrayElement (CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberElement member, string defaultNamespace, bool forceUseMemberName)
{
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:3,代码来源:MapCodeGenerator.cs
示例19: 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
示例20: CreateMapMember
private XmlTypeMapMember CreateMapMember (XmlReflectionMember rmember, string defaultNamespace)
{
XmlTypeMapMember mapMember;
SoapAttributes atts = rmember.SoapAttributes;
TypeData typeData = TypeTranslator.GetTypeData (rmember.MemberType);
if (atts.SoapAttribute != null)
{
// An attribute
if (atts.SoapElement != null)
throw new Exception ("SoapAttributeAttribute and SoapElementAttribute cannot be applied to the same member");
XmlTypeMapMemberAttribute mapAttribute = new XmlTypeMapMemberAttribute ();
if (atts.SoapAttribute.AttributeName == null)
mapAttribute.AttributeName = rmember.MemberName;
else
mapAttribute.AttributeName = atts.SoapAttribute.AttributeName;
mapAttribute.Namespace = (atts.SoapAttribute.Namespace != null) ? atts.SoapAttribute.Namespace : "";
if (typeData.IsComplexType)
mapAttribute.MappedType = ImportTypeMapping (typeData.Type, defaultNamespace);
typeData = TypeTranslator.GetTypeData (rmember.MemberType, atts.SoapAttribute.DataType);
mapMember = mapAttribute;
}
else
{
if (typeData.SchemaType == SchemaTypes.Array) mapMember = new XmlTypeMapMemberList ();
else mapMember = new XmlTypeMapMemberElement ();
if (atts.SoapElement != null && atts.SoapElement.DataType != null)
typeData = TypeTranslator.GetTypeData (rmember.MemberType, atts.SoapElement.DataType);
// Creates an ElementInfo that identifies the element
XmlTypeMapElementInfoList infoList = new XmlTypeMapElementInfoList();
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (mapMember, typeData);
elem.ElementName = (atts.SoapElement != null && atts.SoapElement.ElementName != null) ? atts.SoapElement.ElementName : rmember.MemberName;
elem.Namespace = string.Empty;
elem.IsNullable = (atts.SoapElement != null) ? atts.SoapElement.IsNullable : false;
if (typeData.IsComplexType)
elem.MappedType = ImportTypeMapping (typeData.Type, defaultNamespace);
infoList.Add (elem);
((XmlTypeMapMemberElement)mapMember).ElementInfo = infoList;
}
mapMember.TypeData = typeData;
mapMember.Name = rmember.MemberName;
mapMember.IsReturnValue = rmember.IsReturnValue;
return mapMember;
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:53,代码来源:SoapReflectionImporter.cs
注:本文中的System.Xml.Serialization.XmlTypeMapMemberElement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论