private static QualifiedName GetUniqueName(CodeTypeMember codeMember) { string name = codeMember.Name; CodeAttributeDeclaration dmAttribute = codeMember.CustomAttributes.Find("System.Runtime.Serialization.DataMemberAttribute"); if (dmAttribute != null) { CodeAttributeArgument nameAttrib = dmAttribute.Arguments.Find("Name"); if (nameAttrib != null) { name = nameAttrib.GetStringValue(); } } else { dmAttribute = codeMember.CustomAttributes.Find("System.Runtime.Serialization.EnumMemberAttribute"); if (dmAttribute != null) { CodeAttributeArgument nameAttrib = dmAttribute.Arguments.Find("Value"); if (nameAttrib != null) { name = nameAttrib.GetStringValue(); } } } return(new QualifiedName(null, name)); }
private static QualifiedName GetUniqueName(CodeTypeDeclaration codeType) { string name = codeType.Name; string ns = null; CodeAttributeDeclaration dcAttribute = codeType.CustomAttributes.Find("System.Runtime.Serialization.DataContractAttribute", "System.Runtime.Serialization.CollectionDataContractAttribute"); if (dcAttribute != null) { CodeAttributeArgument nameAttrib = dcAttribute.Arguments.Find("Name"); if (nameAttrib != null) { name = nameAttrib.GetStringValue(); } CodeAttributeArgument namespaceAttrib = dcAttribute.Arguments.Find("Namespace"); if (namespaceAttrib != null) { ns = namespaceAttrib.GetStringValue(); } } return(new QualifiedName(ns, name)); }