示例#1
0
 public XmlTextSerializer(Type type, RedactAttribute redactAttribute, EncryptAttribute encryptAttribute, Type[] extraTypes)
 {
     _encryptAttribute = encryptAttribute;
     if (!ValueTypes.TryGetValueConverter(type, redactAttribute, extraTypes, out _valueConverter))
     {
         _valueConverter = SimpleTypeValueConverter.Create(type, redactAttribute);
     }
 }
        public XmlAttributeSerializer(Type type, string attributeName, RedactAttribute redactAttribute, EncryptAttribute encryptAttribute, IXmlSerializerOptions options)
        {
            _attributeName    = attributeName;
            _encryptAttribute = encryptAttribute;

            if (!ValueTypes.TryGetValueConverter(type, redactAttribute, options.ExtraTypes, out _valueConverter))
            {
                _valueConverter = SimpleTypeValueConverter.Create(type, redactAttribute);
            }
        }
示例#3
0
        public XmlElementSerializer(EncryptAttribute encryptAttribute, IXmlSerializerOptions options)
        {
            if (!typeof(T).IsPrimitiveLike() && !typeof(T).IsNullablePrimitiveLike() && !ValueTypes.IsRegistered(typeof(T)))
            {
                throw new InvalidOperationException("Generic argument of XmlElementSerializer<T> must be an primitive, like a primitive (e.g. Guid, DateTime), a nullable of either, or one of: Enum, Type, or Uri.");
            }

            _elementName      = options.RootElementName;
            _alwaysEmitNil    = options.ShouldAlwaysEmitNil;
            _encryptAttribute = encryptAttribute;

            if (!ValueTypes.TryGetValueConverter(typeof(T), options.RedactAttribute, options.ExtraTypes, out _valueConverter))
            {
                _valueConverter = SimpleTypeValueConverter.Create(typeof(T), options.RedactAttribute);
            }
        }