Пример #1
0
        public StructMemberConverter(CborConverterRegistry registry, IMemberMapping memberMapping)
        {
            MemberInfo?memberInfo = memberMapping.MemberInfo;

            if (memberInfo == null)
            {
                throw new CborException("MemberInfo must not be null");
            }

            MemberNameAsString = memberMapping.MemberName !;
            _memberName        = Encoding.UTF8.GetBytes(MemberNameAsString);
            _memberGetter      = GenerateGetter(memberInfo);
            _memberSetter      = GenerateSetter(memberInfo);
            _converter         = (ICborConverter <TM>)memberMapping.Converter !;
            _defaultValue      = (TM)memberMapping.DefaultValue !;
            _ignoreIfDefault   = memberMapping.IgnoreIfDefault;
            _requirementPolicy = memberMapping.RequirementPolicy;
        }
Пример #2
0
        public MemberConverter(CborConverterRegistry registry, IMemberMapping memberMapping)
        {
            MemberInfo?memberInfo = memberMapping.MemberInfo;

            if (memberInfo == null)
            {
                throw new CborException("MemberInfo must not be null");
            }

            _memberName            = Encoding.UTF8.GetBytes(memberMapping.MemberName !);
            _memberGetter          = GenerateGetter(memberInfo);
            _memberSetter          = GenerateSetter(memberInfo);
            _converter             = (ICborConverter <TM>)memberMapping.Converter !;
            _defaultValue          = (TM)memberMapping.DefaultValue !;
            _ignoreIfDefault       = memberMapping.IgnoreIfDefault;
            _shouldSerializeMethod = memberMapping.ShouldSerializeMethod;
            _lengthMode            = memberMapping.LengthMode;
            _requirementPolicy     = memberMapping.RequirementPolicy;
        }