ConvertXmlNameToJsonName() static private method

static private ConvertXmlNameToJsonName ( XmlDictionaryString xmlName ) : XmlDictionaryString
xmlName System.Xml.XmlDictionaryString
return System.Xml.XmlDictionaryString
Example #1
0
 private void CopyMembersAndCheckDuplicateNames()
 {
     if (this.traditionalClassDataContract.MemberNames != null)
     {
         int length = this.traditionalClassDataContract.MemberNames.Length;
         Dictionary <string, object> dictionary = new Dictionary <string, object>(length);
         XmlDictionaryString[]       strArray   = new XmlDictionaryString[length];
         for (int i = 0; i < length; i++)
         {
             if (dictionary.ContainsKey(this.traditionalClassDataContract.MemberNames[i].Value))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(System.Runtime.Serialization.SR.GetString("JsonDuplicateMemberNames", new object[] { DataContract.GetClrTypeFullName(this.traditionalClassDataContract.UnderlyingType), this.traditionalClassDataContract.MemberNames[i].Value })));
             }
             dictionary.Add(this.traditionalClassDataContract.MemberNames[i].Value, null);
             strArray[i] = DataContractJsonSerializer.ConvertXmlNameToJsonName(this.traditionalClassDataContract.MemberNames[i]);
         }
         this.memberNames = strArray;
     }
 }
Example #2
0
 private void CopyMembersAndCheckDuplicateNames()
 {
     if (_traditionalClassDataContract.MemberNames != null)
     {
         int memberCount = _traditionalClassDataContract.MemberNames.Length;
         Dictionary <string, object?> memberTable        = new Dictionary <string, object?>(memberCount);
         XmlDictionaryString[]        decodedMemberNames = new XmlDictionaryString[memberCount];
         for (int i = 0; i < memberCount; i++)
         {
             if (memberTable.ContainsKey(_traditionalClassDataContract.MemberNames[i].Value))
             {
                 throw new SerializationException(SR.Format(SR.JsonDuplicateMemberNames, DataContract.GetClrTypeFullName(_traditionalClassDataContract.UnderlyingType), _traditionalClassDataContract.MemberNames[i].Value));
             }
             else
             {
                 memberTable.Add(_traditionalClassDataContract.MemberNames[i].Value, null);
                 decodedMemberNames[i] = DataContractJsonSerializer.ConvertXmlNameToJsonName(_traditionalClassDataContract.MemberNames[i]);
             }
         }
         _memberNames = decodedMemberNames;
     }
 }
 void CopyMembersAndCheckDuplicateNames()
 {
     if (traditionalClassDataContract.MemberNames != null)
     {
         int memberCount = traditionalClassDataContract.MemberNames.Length;
         Dictionary <string, object> memberTable        = new Dictionary <string, object>(memberCount);
         XmlDictionaryString[]       decodedMemberNames = new XmlDictionaryString[memberCount];
         for (int i = 0; i < memberCount; i++)
         {
             if (memberTable.ContainsKey(traditionalClassDataContract.MemberNames[i].Value))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(SR.GetString(SR.JsonDuplicateMemberNames,
                                                                                                                   DataContract.GetClrTypeFullName(traditionalClassDataContract.UnderlyingType), traditionalClassDataContract.MemberNames[i].Value)));
             }
             else
             {
                 memberTable.Add(traditionalClassDataContract.MemberNames[i].Value, null);
                 decodedMemberNames[i] = DataContractJsonSerializer.ConvertXmlNameToJsonName(traditionalClassDataContract.MemberNames[i]);
             }
         }
         this.memberNames = decodedMemberNames;
     }
 }