public void AddMember(MemberSerializingSettings settings)
        {
            if (this.RegisteredMembers.ContainsKey(settings.Alias))
            {
                throw new Exception($"Field {settings.Alias} already added to type {this.Alias}.");
            }

            foreach (var legacyName in settings.LegacyNames)
            {
                this._RegisteredLegacyMembers.Add(legacyName, settings);
            }

            this._RegisteredMembers.Add(settings.Alias, settings);
        }
示例#2
0
        private static MemberSerializingSettings CreateMemberSettings(string name, bool isProperty, SerializedAttribute att)
        {
            var ret = new MemberSerializingSettings(name, att.Alias ?? name, isProperty)
            {
                SkipInstantiating = att.SkipInstantiating,
                DefaultValue      = att.DefaultValue,
                Obfuscate         = att.Obfuscate,
                Serialize         = att.Serialize,
                Deserialize       = att.Deserialize
            };

            if (att.LegacyName != null)
            {
                ret.LegacyNames.Add(att.LegacyName);
            }

            return(ret);
        }