本文整理汇总了C#中System.Xml.Serialization.EnumMapping类 的典型用法代码示例。如果您正苦于以下问题:C# EnumMapping类的具体用法?C# EnumMapping怎么用?C# EnumMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumMapping类 属于System.Xml.Serialization命名空间,在下文中一共展示了EnumMapping类 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FindChoiceEnumValue
private string FindChoiceEnumValue(ElementAccessor element, EnumMapping choiceMapping, bool useReflection)
{
string ident = null;
for (int i = 0; i < choiceMapping.Constants.Length; i++)
{
string xmlName = choiceMapping.Constants[i].XmlName;
if (element.Any && (element.Name.Length == 0))
{
if (!(xmlName == "##any:"))
{
continue;
}
if (useReflection)
{
ident = choiceMapping.Constants[i].Value.ToString(CultureInfo.InvariantCulture);
}
else
{
ident = choiceMapping.Constants[i].Name;
}
break;
}
int length = xmlName.LastIndexOf(':');
string str3 = (length < 0) ? choiceMapping.Namespace : xmlName.Substring(0, length);
string str4 = (length < 0) ? xmlName : xmlName.Substring(length + 1);
if ((element.Name == str4) && (((element.Form == XmlSchemaForm.Unqualified) && string.IsNullOrEmpty(str3)) || (element.Namespace == str3)))
{
if (useReflection)
{
ident = choiceMapping.Constants[i].Value.ToString(CultureInfo.InvariantCulture);
}
else
{
ident = choiceMapping.Constants[i].Name;
}
break;
}
}
if ((ident == null) || (ident.Length == 0))
{
if (element.Any && (element.Name.Length == 0))
{
throw new InvalidOperationException(Res.GetString("XmlChoiceMissingAnyValue", new object[] { choiceMapping.TypeDesc.FullName }));
}
throw new InvalidOperationException(Res.GetString("XmlChoiceMissingValue", new object[] { choiceMapping.TypeDesc.FullName, element.Namespace + ":" + element.Name, element.Name, element.Namespace }));
}
if (!useReflection)
{
CodeIdentifier.CheckValidIdentifier(ident);
}
return ident;
}
开发者ID:pritesh-mandowara-sp, 项目名称:DecompliedDotNetLibraries, 代码行数:52, 代码来源:XmlSerializationWriterCodeGen.cs
示例2: ImportEnumMapping
private EnumMapping ImportEnumMapping(EnumModel model, string ns, bool repeats)
{
XmlAttributes a = this.GetAttributes(model.Type, false);
string str = ns;
if ((a.XmlType != null) && (a.XmlType.Namespace != null))
{
str = a.XmlType.Namespace;
}
string name = IsAnonymousType(a, ns) ? null : this.XsdTypeName(model.Type, a, model.TypeDesc.Name);
name = XmlConvert.EncodeLocalName(name);
EnumMapping mapping = (EnumMapping) this.GetTypeMapping(name, str, model.TypeDesc, this.types, model.Type);
if (mapping == null)
{
mapping = new EnumMapping {
TypeDesc = model.TypeDesc,
TypeName = name,
Namespace = str,
IsFlags = model.Type.IsDefined(typeof(FlagsAttribute), false)
};
if (mapping.IsFlags && repeats)
{
throw new InvalidOperationException(Res.GetString("XmlIllegalAttributeFlagsArray", new object[] { model.TypeDesc.FullName }));
}
mapping.IsList = repeats;
mapping.IncludeInSchema = (a.XmlType == null) || a.XmlType.IncludeInSchema;
if (!mapping.IsAnonymousType)
{
this.types.Add(name, str, mapping);
}
else
{
this.anonymous[model.Type] = mapping;
}
ArrayList list = new ArrayList();
for (int i = 0; i < model.Constants.Length; i++)
{
ConstantMapping mapping2 = this.ImportConstantMapping(model.Constants[i]);
if (mapping2 != null)
{
list.Add(mapping2);
}
}
if (list.Count == 0)
{
throw new InvalidOperationException(Res.GetString("XmlNoSerializableMembers", new object[] { model.TypeDesc.FullName }));
}
mapping.Constants = (ConstantMapping[]) list.ToArray(typeof(ConstantMapping));
this.typeScope.AddTypeMapping(mapping);
}
return mapping;
}
开发者ID:pritesh-mandowara-sp, 项目名称:DecompliedDotNetLibraries, 代码行数:51, 代码来源:XmlReflectionImporter.cs
示例3: FindChoiceEnumValue
string FindChoiceEnumValue(ElementAccessor element, EnumMapping choiceMapping, bool useReflection) {
string enumValue = null;
for (int i = 0; i < choiceMapping.Constants.Length; i++) {
string xmlName = choiceMapping.Constants[i].XmlName;
if (element.Any && element.Name.Length == 0) {
if (xmlName == "##any:") {
if (useReflection)
enumValue = choiceMapping.Constants[i].Value.ToString(CultureInfo.InvariantCulture);
else
enumValue = choiceMapping.Constants[i].Name;
break;
}
continue;
}
int colon = xmlName.LastIndexOf(':');
string choiceNs = colon < 0 ? choiceMapping.Namespace : xmlName.Substring(0, colon);
string choiceName = colon < 0 ? xmlName : xmlName.Substring(colon+1);
if (element.Name == choiceName) {
if ((element.Form == XmlSchemaForm.Unqualified && string.IsNullOrEmpty(choiceNs)) || element.Namespace == choiceNs) {
if (useReflection)
enumValue = choiceMapping.Constants[i].Value.ToString(CultureInfo.InvariantCulture);
else
enumValue = choiceMapping.Constants[i].Name;
break;
}
}
}
if (enumValue == null || enumValue.Length == 0) {
if (element.Any && element.Name.Length == 0) {
// Type {0} is missing enumeration value '##any' for XmlAnyElementAttribute.
throw new InvalidOperationException(Res.GetString(Res.XmlChoiceMissingAnyValue, choiceMapping.TypeDesc.FullName));
}
// Type {0} is missing value for '{1}'.
throw new InvalidOperationException(Res.GetString(Res.XmlChoiceMissingValue, choiceMapping.TypeDesc.FullName, element.Namespace + ":" + element.Name, element.Name, element.Namespace));
}
if(!useReflection)
CodeIdentifier.CheckValidIdentifier(enumValue);
return enumValue;
}
开发者ID:uQr, 项目名称:referencesource, 代码行数:42, 代码来源:XmlSerializationWriter.cs
示例4: WriteEnumValue
void WriteEnumValue(EnumMapping mapping, string source) {
string methodName = ReferenceMapping(mapping);
#if DEBUG
// use exception in the place of Debug.Assert to avoid throwing asserts from a server process such as aspnet_ewp.exe
if (methodName == null) throw new InvalidOperationException(Res.GetString(Res.XmlInternalErrorMethod, mapping.TypeDesc.Name) + Environment.StackTrace);
#endif
Writer.Write(methodName);
Writer.Write("(");
Writer.Write(source);
Writer.Write(")");
}
开发者ID:uQr, 项目名称:referencesource, 代码行数:13, 代码来源:XmlSerializationWriter.cs
示例5: ExportEnum
internal CodeTypeDeclaration ExportEnum(EnumMapping mapping, Type type) {
CodeTypeDeclaration codeClass = new CodeTypeDeclaration(mapping.TypeDesc.Name);
codeClass.Comments.Add(new CodeCommentStatement(Res.GetString(Res.XmlRemarks), true));
codeClass.IsEnum = true;
if (mapping.IsFlags && mapping.Constants.Length > 31) {
codeClass.BaseTypes.Add(new CodeTypeReference(typeof(long)));
}
codeClass.TypeAttributes |= TypeAttributes.Public;
CodeNamespace.Types.Add(codeClass);
for (int i = 0; i < mapping.Constants.Length; i++) {
ExportConstant(codeClass, mapping.Constants[i], type, mapping.IsFlags, 1L << i);
}
if (mapping.IsFlags) {
// Add [FlagsAttribute]
CodeAttributeDeclaration flags = new CodeAttributeDeclaration(typeof(FlagsAttribute).FullName);
codeClass.CustomAttributes.Add(flags);
}
CodeGenerator.ValidateIdentifiers(codeClass);
return codeClass;
}
开发者ID:iskiselev, 项目名称:JSIL.NetFramework, 代码行数:21, 代码来源:CodeExporter.cs
示例6: WriteHashtable
string WriteHashtable(EnumMapping mapping, string typeName) {
CodeIdentifier.CheckValidIdentifier(typeName);
string propName = MakeUnique(mapping, typeName + "Values");
if (propName == null) return CodeIdentifier.GetCSharpName(typeName);
string memberName = MakeUnique(mapping, "_" + propName);
propName = CodeIdentifier.GetCSharpName(propName);
Writer.WriteLine();
Writer.Write(typeof(Hashtable).FullName);
Writer.Write(" ");
Writer.Write(memberName);
Writer.WriteLine(";");
Writer.WriteLine();
Writer.Write("internal ");
Writer.Write(typeof(Hashtable).FullName);
Writer.Write(" ");
Writer.Write(propName);
Writer.WriteLine(" {");
Writer.Indent++;
Writer.WriteLine("get {");
Writer.Indent++;
Writer.Write("if ((object)");
Writer.Write(memberName);
Writer.WriteLine(" == null) {");
Writer.Indent++;
Writer.Write(typeof(Hashtable).FullName);
Writer.Write(" h = new ");
Writer.Write(typeof(Hashtable).FullName);
Writer.WriteLine("();");
ConstantMapping[] constants = mapping.Constants;
for (int i = 0; i < constants.Length; i++) {
Writer.Write("h.Add(");
WriteQuotedCSharpString(constants[i].XmlName);
if (!mapping.TypeDesc.UseReflection){
Writer.Write(", (long)");
Writer.Write(mapping.TypeDesc.CSharpName);
Writer.Write("[email protected]");
CodeIdentifier.CheckValidIdentifier(constants[i].Name);
Writer.Write(constants[i].Name);
}
else{
Writer.Write(", ");
Writer.Write(constants[i].Value.ToString(CultureInfo.InvariantCulture)+"L");
}
Writer.WriteLine(");");
}
Writer.Write(memberName);
Writer.WriteLine(" = h;");
Writer.Indent--;
Writer.WriteLine("}");
Writer.Write("return ");
Writer.Write(memberName);
Writer.WriteLine(";");
Writer.Indent--;
Writer.WriteLine("}");
Writer.Indent--;
Writer.WriteLine("}");
return propName;
}
开发者ID:JokerMisfits, 项目名称:linux-packaging-mono, 代码行数:73, 代码来源:XmlSerializationReader.cs
示例7: ImportEnumeratedDataType
TypeMapping ImportEnumeratedDataType(XmlSchemaSimpleType dataType, string typeNs, string identifier, bool isList) {
TypeMapping mapping = (TypeMapping)ImportedMappings[dataType];
if (mapping != null)
return mapping;
XmlSchemaSimpleType sourceDataType = FindDataType(dataType.DerivedFrom);
TypeDesc sourceTypeDesc = Scope.GetTypeDesc(sourceDataType);
if (sourceTypeDesc != null && sourceTypeDesc != Scope.GetTypeDesc(typeof(string)))
return ImportPrimitiveDataType(dataType);
identifier = Accessor.UnescapeName(identifier);
string typeName = GenerateUniqueTypeName(identifier);
EnumMapping enumMapping = new EnumMapping();
enumMapping.IsReference = Schemas.IsReference(dataType);
enumMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Enum, null, 0);
enumMapping.TypeName = identifier;
enumMapping.Namespace = typeNs;
enumMapping.IsFlags = isList;
CodeIdentifiers constants = new CodeIdentifiers();
if (!(dataType.Content is XmlSchemaSimpleTypeRestriction))
throw new InvalidOperationException(Res.GetString(Res.XmlInvalidEnumContent, dataType.Content.GetType().Name, identifier));
XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)dataType.Content;
for (int i = 0; i < restriction.Facets.Count; i++) {
object facet = restriction.Facets[i];
if (!(facet is XmlSchemaEnumerationFacet)) continue;
XmlSchemaEnumerationFacet enumeration = (XmlSchemaEnumerationFacet)facet;
ConstantMapping constant = new ConstantMapping();
string constantName = CodeIdentifier.MakeValid(enumeration.Value);
constant.Name = constants.AddUnique(constantName, constant);
constant.XmlName = enumeration.Value;
constant.Value = i;
}
enumMapping.Constants = (ConstantMapping[])constants.ToArray(typeof(ConstantMapping));
if (isList && enumMapping.Constants.Length > 63) {
// if we have 64+ flag constants we cannot map the type to long enum, we will use string mapping instead.
mapping = new PrimitiveMapping();
mapping.TypeDesc = Scope.GetTypeDesc(typeof(string));
mapping.TypeName = mapping.TypeDesc.DataType.Name;
ImportedMappings.Add(dataType, mapping);
return mapping;
}
ImportedMappings.Add(dataType, enumMapping);
Scope.AddTypeMapping(enumMapping);
return enumMapping;
}
开发者ID:gbarnett, 项目名称:shared-source-cli-2.0, 代码行数:47, 代码来源:soapschemaimporter.cs
示例8: ExportEnum
void ExportEnum(EnumMapping mapping) {
CodeTypeDeclaration codeClass = new CodeTypeDeclaration(mapping.TypeDesc.Name);
codeClass.IsEnum = true;
codeClass.TypeAttributes |= TypeAttributes.Public;
codeClass.Comments.Add(new CodeCommentStatement("<remarks/>", true));
codeNamespace.Types.Add(codeClass);
codeClass.CustomAttributes = new CodeAttributeDeclarationCollection();
AddTypeMetadata(codeClass.CustomAttributes, mapping.TypeName, mapping.Namespace, mapping.IncludeInSchema);
for (int i = 0; i < mapping.Constants.Length; i++) {
ExportConstant(codeClass, mapping.Constants[i]);
}
if (mapping.IsFlags) {
AddCustomAttribute(codeClass.CustomAttributes, typeof(FlagsAttribute), new CodeAttributeArgument[0]);
}
}
开发者ID:ArildF, 项目名称:masters, 代码行数:16, 代码来源:soapcodeexporter.cs
示例9: WriteEnumValue
private void WriteEnumValue(EnumMapping mapping, SourceInfo source, out Type returnType)
{
string methodName = ReferenceMapping(mapping);
#if DEBUG
// use exception in the place of Debug.Assert to avoid throwing asserts from a server process such as aspnet_ewp.exe
if (methodName == null) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorMethod, mapping.TypeDesc.Name));
#endif
// For enum, its write method (eg. Write1_Gender) could be called multiple times
// prior to its declaration.
MethodBuilder methodBuilder = EnsureMethodBuilder(typeBuilder,
methodName,
CodeGenerator.PrivateMethodAttributes,
typeof(string),
new Type[] { mapping.TypeDesc.Type });
ilg.Ldarg(0);
source.Load(mapping.TypeDesc.Type);
ilg.Call(methodBuilder);
returnType = typeof(string);
}
开发者ID:shiftkey-tester, 项目名称:corefx, 代码行数:21, 代码来源:XmlSerializationWriterILGen.cs
示例10: ExportEnum
internal CodeTypeDeclaration ExportEnum(EnumMapping mapping, Type type)
{
CodeTypeDeclaration declaration = new CodeTypeDeclaration(mapping.TypeDesc.Name);
declaration.Comments.Add(new CodeCommentStatement(Res.GetString("XmlRemarks"), true));
declaration.IsEnum = true;
if (mapping.IsFlags && (mapping.Constants.Length > 0x1f))
{
declaration.BaseTypes.Add(new CodeTypeReference(typeof(long)));
}
declaration.TypeAttributes |= TypeAttributes.Public;
this.CodeNamespace.Types.Add(declaration);
for (int i = 0; i < mapping.Constants.Length; i++)
{
ExportConstant(declaration, mapping.Constants[i], type, mapping.IsFlags, ((long) 1L) << i);
}
if (mapping.IsFlags)
{
CodeAttributeDeclaration declaration2 = new CodeAttributeDeclaration(typeof(FlagsAttribute).FullName);
declaration.CustomAttributes.Add(declaration2);
}
CodeGenerator.ValidateIdentifiers(declaration);
return declaration;
}
开发者ID:pritesh-mandowara-sp, 项目名称:DecompliedDotNetLibraries, 代码行数:23, 代码来源:CodeExporter.cs
示例11: WriteEnumMethod
void WriteEnumMethod(EnumMapping mapping) {
string tableName = null;
if (mapping.IsFlags)
tableName = WriteHashtable(mapping, mapping.TypeDesc.Name);
string methodName = (string)methodNames[mapping];
writer.WriteLine();
string fullTypeName = CodeIdentifier.EscapeKeywords(mapping.TypeDesc.FullName);
if (mapping.IsSoap) {
writer.Write("object");
writer.Write(" ");
writer.Write(methodName);
writer.WriteLine("() {");
writer.Indent++;
writer.WriteLine("string s = Reader.ReadElementString();");
}
else {
writer.Write(fullTypeName);
writer.Write(" ");
writer.Write(methodName);
writer.WriteLine("(string s) {");
writer.Indent++;
}
ConstantMapping[] constants = mapping.Constants;
if (mapping.IsFlags) {
writer.Write("return (");
writer.Write(fullTypeName);
writer.Write(")ToEnum(s, ");
writer.Write(tableName);
writer.Write(", ");
WriteQuotedCSharpString(fullTypeName);
writer.WriteLine(");");
}
else {
writer.WriteLine("switch (s) {");
writer.Indent++;
for (int i = 0; i < constants.Length; i++) {
ConstantMapping c = constants[i];
CodeIdentifier.CheckValidIdentifier(c.Name);
writer.Write("case ");
WriteQuotedCSharpString(c.XmlName);
writer.Write(": return ");
writer.Write(fullTypeName);
writer.Write("[email protected]");
writer.Write(c.Name);
writer.WriteLine(";");
}
writer.Write("default: throw CreateUnknownConstantException(s, typeof(");
writer.Write(fullTypeName);
writer.WriteLine("));");
writer.Indent--;
writer.WriteLine("}");
}
writer.Indent--;
writer.WriteLine("}");
}
开发者ID:ArildF, 项目名称:masters, 代码行数:62, 代码来源:xmlserializationreader.cs
示例12: WriteHashtable
string WriteHashtable(EnumMapping mapping, string typeName) {
CodeIdentifier.CheckValidIdentifier(typeName);
string propName = MakeUnique(mapping, typeName + "Values");
if (propName == null) return CodeIdentifier.EscapeKeywords(typeName);
string memberName = MakeUnique(mapping, "_" + propName);
propName = CodeIdentifier.EscapeKeywords(propName);
writer.WriteLine();
writer.Write(typeof(Hashtable).FullName);
writer.Write(" ");
writer.Write(memberName);
writer.WriteLine(";");
writer.WriteLine();
writer.Write("internal ");
writer.Write(typeof(Hashtable).FullName);
writer.Write(" ");
writer.Write(propName);
writer.WriteLine(" {");
writer.Indent++;
writer.WriteLine("get {");
writer.Indent++;
writer.Write("if ((object)");
writer.Write(memberName);
writer.WriteLine(" == null) {");
writer.Indent++;
writer.Write(typeof(Hashtable).FullName);
writer.Write(" h = new ");
writer.Write(typeof(Hashtable).FullName);
writer.WriteLine("();");
ConstantMapping[] constants = mapping.Constants;
for (int i = 0; i < constants.Length; i++) {
writer.Write("h.Add(");
WriteQuotedCSharpString(constants[i].XmlName);
writer.Write(", (");
writer.Write(typeof(long).FullName);
writer.Write(")");
writer.Write(CodeIdentifier.EscapeKeywords(mapping.TypeDesc.FullName));
writer.Write("[email protected]");
CodeIdentifier.CheckValidIdentifier(constants[i].Name);
writer.Write(constants[i].Name);
writer.WriteLine(");");
}
writer.Write(memberName);
writer.WriteLine(" = h;");
writer.Indent--;
writer.WriteLine("}");
writer.Write("return ");
writer.Write(memberName);
writer.WriteLine(";");
writer.Indent--;
writer.WriteLine("}");
writer.Indent--;
writer.WriteLine("}");
return propName;
}
开发者ID:ArildF, 项目名称:masters, 代码行数:70, 代码来源:xmlserializationreader.cs
示例13: ImportEnumeratedDataType
private TypeMapping ImportEnumeratedDataType(XmlSchemaSimpleType dataType, string typeNs, string identifier, TypeFlags flags, bool isList)
{
TypeMapping mapping = (TypeMapping)ImportedMappings[dataType];
if (mapping != null)
return mapping;
XmlSchemaType sourceType = dataType;
while (!sourceType.DerivedFrom.IsEmpty)
{
sourceType = FindType(sourceType.DerivedFrom, TypeFlags.CanBeElementValue | TypeFlags.CanBeAttributeValue);
}
if (sourceType is XmlSchemaComplexType) return null;
TypeDesc sourceTypeDesc = Scope.GetTypeDesc((XmlSchemaSimpleType)sourceType);
if (sourceTypeDesc != null && sourceTypeDesc.FullName != typeof(string).FullName)
return ImportPrimitiveDataType(dataType, flags);
identifier = Accessor.UnescapeName(identifier);
string typeName = GenerateUniqueTypeName(identifier);
EnumMapping enumMapping = new EnumMapping();
enumMapping.IsReference = Schemas.IsReference(dataType);
enumMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Enum, null, 0);
if (dataType.Name != null && dataType.Name.Length > 0)
enumMapping.TypeName = identifier;
enumMapping.Namespace = typeNs;
enumMapping.IsFlags = isList;
CodeIdentifiers constants = new CodeIdentifiers();
XmlSchemaSimpleTypeContent content = dataType.Content;
if (content is XmlSchemaSimpleTypeRestriction)
{
XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)content;
for (int i = 0; i < restriction.Facets.Count; i++)
{
object facet = restriction.Facets[i];
if (!(facet is XmlSchemaEnumerationFacet)) continue;
XmlSchemaEnumerationFacet enumeration = (XmlSchemaEnumerationFacet)facet;
// validate the enumeration value
if (sourceTypeDesc != null && sourceTypeDesc.HasCustomFormatter)
{
XmlCustomFormatter.ToDefaultValue(enumeration.Value, sourceTypeDesc.FormatterName);
}
ConstantMapping constant = new ConstantMapping();
string constantName = CodeIdentifier.MakeValid(enumeration.Value);
constant.Name = constants.AddUnique(constantName, constant);
constant.XmlName = enumeration.Value;
constant.Value = i;
}
}
enumMapping.Constants = (ConstantMapping[])constants.ToArray(typeof(ConstantMapping));
if (isList && enumMapping.Constants.Length > 63)
{
// if we have 64+ flag constants we cannot map the type to long enum, we will use string mapping instead.
mapping = GetDefaultMapping(TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue | TypeFlags.CanBeAttributeValue);
ImportedMappings.Add(dataType, mapping);
return mapping;
}
ImportedMappings.Add(dataType, enumMapping);
Scope.AddTypeMapping(enumMapping);
return enumMapping;
}
开发者ID:geoffkizer, 项目名称:corefx, 代码行数:60, 代码来源:XmlSchemaImporter.cs
示例14: ExportEnumMapping
XmlQualifiedName ExportEnumMapping(EnumMapping mapping, string ns) {
XmlSchemaSimpleType dataType = (XmlSchemaSimpleType)types[mapping];
if (dataType == null) {
CheckForDuplicateType(mapping.TypeName, mapping.Namespace);
dataType = new XmlSchemaSimpleType();
dataType.Name = mapping.TypeName;
types.Add(mapping, dataType);
AddSchemaItem(dataType, mapping.Namespace, ns);
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
restriction.BaseTypeName = new XmlQualifiedName("string", XmlSchema.Namespace);
for (int i = 0; i < mapping.Constants.Length; i++) {
ConstantMapping constant = mapping.Constants[i];
XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet();
enumeration.Value = constant.XmlName;
restriction.Facets.Add(enumeration);
}
if (!mapping.IsFlags) {
dataType.Content = restriction;
}
else {
XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList();
XmlSchemaSimpleType enumType = new XmlSchemaSimpleType();
enumType.Content = restriction;
list.ItemType = enumType;
dataType.Content = list;
}
}
else {
AddSchemaImport(mapping.Namespace, ns);
}
return new XmlQualifiedName(mapping.TypeName, mapping.Namespace);
}
开发者ID:ArildF, 项目名称:masters, 代码行数:34, 代码来源:soapschemaexporter.cs
示例15: CheckChoiceIdentifierMapping
private void CheckChoiceIdentifierMapping(EnumMapping choiceMapping)
{
System.Xml.Serialization.NameTable table = new System.Xml.Serialization.NameTable();
for (int i = 0; i < choiceMapping.Constants.Length; i++)
{
string xmlName = choiceMapping.Constants[i].XmlName;
int length = xmlName.LastIndexOf(':');
string name = (length < 0) ? xmlName : xmlName.Substring(length + 1);
string ns = (length < 0) ? "" : xmlName.Substring(0, length);
if (table[name, ns] != null)
{
throw new InvalidOperationException(Res.GetString("XmlChoiceIdDuplicate", new object[] { choiceMapping.TypeName, xmlName }));
}
table.Add(name, ns, choiceMapping.Constants[i]);
}
}
开发者ID:pritesh-mandowara-sp, 项目名称:DecompliedDotNetLibraries, 代码行数:16, 代码来源:XmlReflectionImporter.cs
示例16: ExportEnumMapping
XmlSchemaType ExportEnumMapping(EnumMapping mapping, string ns) {
if (!mapping.IncludeInSchema) throw new InvalidOperationException(Res.GetString(Res.XmlCannotIncludeInSchema, mapping.TypeDesc.Name));
XmlSchemaSimpleType dataType = (XmlSchemaSimpleType)types[mapping];
if (dataType == null) {
CheckForDuplicateType(mapping, mapping.Namespace);
dataType = new XmlSchemaSimpleType();
dataType.Name = mapping.TypeName;
if (!mapping.IsAnonymousType) {
types.Add(mapping, dataType);
AddSchemaItem(dataType, mapping.Namespace, ns);
}
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
restriction.BaseTypeName = new XmlQualifiedName("string", XmlSchema.Namespace);
for (int i = 0; i < mapping.Constants.Length; i++) {
ConstantMapping constant = mapping.Constants[i];
XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet();
enumeration.Value = constant.XmlName;
restriction.Facets.Add(enumeration);
}
if (!mapping.IsFlags) {
dataType.Content = restriction;
}
else {
XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList();
XmlSchemaSimpleType enumType = new XmlSchemaSimpleType();
enumType.Content = restriction;
list.ItemType = enumType;
dataType.Content = list;
}
}
if (!mapping.IsAnonymousType) {
AddSchemaImport(mapping.Namespace, ns);
}
return dataType;
}
开发者ID:uQr, 项目名称:referencesource, 代码行数:36, 代码来源:XmlSchemaExporter.cs
示例17: WriteEnumMethod
private string WriteEnumMethod(EnumMapping mapping, object v)
{
if (mapping != null && mapping.IsSoap)
{
throw new PlatformNotSupportedException();
}
if (mapping != null && mapping.IsFlags)
{
Type type = mapping.TypeDesc.Type;
List<string> valueStrings = new List<string>();
List<long> valueIds = new List<long>();
foreach (var value in Enum.GetValues(type))
{
valueStrings.Add(value.ToString());
valueIds.Add(Convert.ToInt64(value));
}
return FromEnum(Convert.ToInt64(v), valueStrings.ToArray(), valueIds.ToArray());
}
else
{
return v.ToString();
}
}
开发者ID:geoffkizer, 项目名称:corefx, 代码行数:26, 代码来源:ReflectionXmlSerializationWriter.cs
示例18: WriteEnumMethod
private void WriteEnumMethod(EnumMapping mapping)
{
string methodName = (string)MethodNames[mapping];
List<Type> argTypes = new List<Type>();
List<string> argNames = new List<string>();
argTypes.Add(mapping.TypeDesc.Type);
argNames.Add("v");
ilg = new CodeGenerator(this.typeBuilder);
ilg.BeginMethod(
typeof(string),
GetMethodBuilder(methodName),
argTypes.ToArray(),
argNames.ToArray(),
CodeGenerator.PrivateMethodAttributes);
LocalBuilder sLoc = ilg.DeclareLocal(typeof(string), "s");
ilg.Load(null);
ilg.Stloc(sLoc);
ConstantMapping[] constants = mapping.Constants;
if (constants.Length > 0)
{
InternalHashtable values = new InternalHashtable();
List<Label> caseLabels = new List<Label>();
List<string> retValues = new List<string>();
Label defaultLabel = ilg.DefineLabel();
Label endSwitchLabel = ilg.DefineLabel();
// This local is necessary; otherwise, it becomes if/else
LocalBuilder localTmp = ilg.DeclareLocal(mapping.TypeDesc.Type, "localTmp");
ilg.Ldarg("v");
ilg.Stloc(localTmp);
for (int i = 0; i < constants.Length; i++)
{
ConstantMapping c = constants[i];
if (values[c.Value] == null)
{
Label caseLabel = ilg.DefineLabel();
ilg.Ldloc(localTmp);
ilg.Ldc(Enum.ToObject(mapping.TypeDesc.Type, c.Value));
ilg.Beq(caseLabel);
caseLabels.Add(caseLabel);
retValues.Add(GetCSharpString(c.XmlName));
values.Add(c.Value, c.Value);
}
}
if (mapping.IsFlags)
{
ilg.Br(defaultLabel);
for (int i = 0; i < caseLabels.Count; i++)
{
ilg.MarkLabel(caseLabels[i]);
ilg.Ldc(retValues[i]);
ilg.Stloc(sLoc);
ilg.Br(endSwitchLabel);
}
ilg.MarkLabel(defaultLabel);
RaCodeGen.ILGenForEnumLongValue(ilg, "v");
LocalBuilder strArray = ilg.DeclareLocal(typeof(String[]), "strArray");
ilg.NewArray(typeof(String), constants.Length);
ilg.Stloc(strArray);
for (int i = 0; i < constants.Length; i++)
{
ConstantMapping c = constants[i];
ilg.Ldloc(strArray);
ilg.Ldc(i);
ilg.Ldstr(GetCSharpString(c.XmlName));
ilg.Stelem(typeof(String));
}
ilg.Ldloc(strArray);
LocalBuilder longArray = ilg.DeclareLocal(typeof(long[]), "longArray");
ilg.NewArray(typeof(long), constants.Length);
ilg.Stloc(longArray);
for (int i = 0; i < constants.Length; i++)
{
ConstantMapping c = constants[i];
ilg.Ldloc(longArray);
ilg.Ldc(i);
ilg.Ldc(c.Value);
ilg.Stelem(typeof(long));
}
ilg.Ldloc(longArray);
ilg.Ldstr(GetCSharpString(mapping.TypeDesc.FullName));
MethodInfo XmlSerializationWriter_FromEnum = typeof(XmlSerializationWriter).GetMethod(
"FromEnum",
CodeGenerator.StaticBindingFlags,
new Type[] { typeof(Int64), typeof(String[]), typeof(Int64[]), typeof(String) }
);
ilg.Call(XmlSerializationWriter_FromEnum);
ilg.Stloc(sLoc);
ilg.Br(endSwitchLabel);
}
else
{
ilg.Br(defaultLabel);
// Case bodies
for (int i = 0; i < caseLabels.Count; i++)
{
ilg.MarkLabel(caseLabels[i]);
//.........这里部分代码省略.........
开发者ID:shiftkey-tester, 项目名称:corefx, 代码行数:101, 代码来源:XmlSerializationWriterILGen.cs
示例19: ExportEnumMapping
private XmlSchemaType ExportEnumMapping(EnumMapping mapping, string ns)
{
if (!mapping.IncludeInSchema)
{
throw new InvalidOperationException(Res.GetString("XmlCannotIncludeInSchema", new object[] { mapping.TypeDesc.Name }));
}
XmlSchemaSimpleType type = (XmlSchemaSimpleType) this.types[mapping];
if (type == null)
{
this.CheckForDuplicateType(mapping, mapping.Namespace);
type = new XmlSchemaSimpleType {
Name = mapping.TypeName
};
if (!mapping.IsAnonymousType)
{
this.types.Add(mapping, type);
this.AddSchemaItem(type, mapping.Namespace, ns);
}
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction {
BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
};
for (int i = 0; i < mapping.Constants.Length; i++)
{
ConstantMapping mapping2 = mapping.Constants[i];
XmlSchemaEnumerationFacet item = new XmlSchemaEnumerationFacet {
Value = mapping2.XmlName
};
restriction.Facets.Add(item);
}
if (!mapping.IsFlags)
{
type.Content = restriction;
}
else
{
XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList();
XmlSchemaSimpleType type2 = new XmlSchemaSimpleType {
Content = restriction
};
list.ItemType = type2;
type.Content = list;
}
}
if (!mapping.IsAnonymousType)
{
this.AddSchemaImport(mapping.Namespace, ns);
}
return type;
}
开发者ID:pritesh-mandowara-sp, 项目名称:DecompliedDotNetLibraries, 代码行数:49, 代码来源:XmlSchemaExporter.cs
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:18296| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9687| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8185| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8553| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8463| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9399| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8434| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7869| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8419| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7398| 2022-11-06
请发表评论