public void SetUp()
 {
     _mappingArguments = new PropertyMappingArguments <X509Certificate2ArrayPropertyMappingTest>
     {
         AttributeName = "att",
         PropertyName  = "name",
         PropertyType  = typeof(object)
     };
 }
 public void SetUp()
 {
     _mappingArguments = new PropertyMappingArguments <DateCollectionPropertyMappingTest>
     {
         AttributeName = "att",
         PropertyName  = "name",
         PropertyType  = typeof(object)
     };
 }
예제 #3
0
        protected PropertyMappingGeneric(PropertyMappingArguments <T> arguments)
            : base(arguments.PropertyType, arguments.PropertyName, arguments.AttributeName, arguments.IsDistinguishedName, arguments.ReadOnly)
        {
            Getter = arguments.Getter;
            Setter = arguments.Setter;

            DirectoryValueMappings = arguments.DirectoryMappings;
            InstanceValueMappings  = arguments.InstanceMappings;
        }
 public void SetUp()
 {
     _mappingArguments = new PropertyMappingArguments <EnumPropertyMappingTest>
     {
         AttributeName = "att",
         PropertyName  = "name",
         PropertyType  = typeof(EnumTest)
     };
 }
 public void SetUp()
 {
     _mappingArguments = new PropertyMappingArguments<DatePropertyMappingTest>
     {
         AttributeName = "att",
         PropertyName = "name",
         PropertyType = typeof(object),
         DirectoryMappings = new Dictionary<string, object>(),
         InstanceMappings = new Dictionary<object, string>()
     };
 }
        public void SetUp()
        {
            _guid = new Guid(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 });

            _mappingArguments = new PropertyMappingArguments <GuidPropertyMappingTest>
            {
                AttributeName = "att",
                PropertyName  = "name",
                PropertyType  = typeof(object)
            };
        }
        public void SetUp()
        {
            _certificate  = new X509Certificate2(Resources.ResourceHelper.GetAssemblyResource(@"Resources\cert.cer"));
            _certificate2 = new X509Certificate2(Resources.ResourceHelper.GetAssemblyResource(@"Resources\cert.cer2"));

            _mappingArguments = new PropertyMappingArguments <X509Certificate2PropertyMappingTest>
            {
                AttributeName = "att",
                PropertyName  = "name",
                PropertyType  = typeof(object)
            };
        }
        public void SetUp()
        {
            _certificate  = new X509Certificate2(Properties.Resources.cert);
            _certificate2 = new X509Certificate2(Properties.Resources.cert2);

            _mappingArguments = new PropertyMappingArguments <X509Certificate2PropertyMappingTest>
            {
                AttributeName = "att",
                PropertyName  = "name",
                PropertyType  = typeof(object)
            };
        }
예제 #9
0
        public IPropertyMapping ToPropertyMapping()
        {
            var arguments = new PropertyMappingArguments <T>
            {
                PropertyName        = PropertyInfo.Name,
                PropertyType        = PropertyInfo.PropertyType,
                AttributeName       = AttributeName ?? PropertyInfo.Name.Replace('_', '-'),
                Getter              = DelegateBuilder.BuildGetter <T>(PropertyInfo),
                Setter              = DelegateBuilder.BuildSetter <T>(PropertyInfo),
                IsDistinguishedName = IsDistinguishedName,
                ReadOnly            = IsDistinguishedName ? Mapping.ReadOnly.Always : ReadOnlyConfiguration.GetValueOrDefault(Mapping.ReadOnly.Never)
            };

            return(new CustomPropertyMapping <T, TProperty>(arguments, _convertFrom, _convertTo, _convertToFilter, _isEqual));
        }
예제 #10
0
        public IPropertyMapping ToPropertyMapping()
        {
            var arguments = new PropertyMappingArguments <T>
            {
                PropertyName        = PropertyInfo.Name,
                PropertyType        = PropertyInfo.PropertyType,
                AttributeName       = AttributeName ?? PropertyInfo.Name.Replace('_', '-'),
                Getter              = DelegateBuilder.BuildGetter <T>(PropertyInfo),
                Setter              = DelegateBuilder.BuildSetter <T>(PropertyInfo),
                IsStoreGenerated    = IsStoreGenerated,
                IsDistinguishedName = IsDistinguishedName,
                IsReadOnly          = IsReadOnly,
            };

            return(new CustomPropertyMapping <T, TProperty>(arguments, _convertFrom, _convertTo, _convertToFilter, _isEqual));
        }
 public void SetUp()
 {
     _guid        = new Guid(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 });
     _convertFrom = d =>
     {
         var bytes = d.GetValues(typeof(byte[]))[0] as byte[];
         return(new Guid(bytes));
     };
     _convertToFilter  = v => v.ToStringOctet();
     _convertTo        = v => v.ToByteArray();
     _compareTo        = (v1, v2) => v1 == v2;
     _mappingArguments = new PropertyMappingArguments <CustomPropertyMappingTest>
     {
         AttributeName = "att",
         PropertyName  = "name",
         PropertyType  = typeof(object)
     };
 }
예제 #12
0
        public void SetUp()
        {
            _bytes = new byte[]
            {
                1, 5, 0, 0, 27, 14, 3, 139, 251, 73, 97, 48, 157, 6, 235, 192, 201, 125, 33,
                65, 182, 209, 6, 82, 206, 165, 32, 24
            };
            _identifier =
                new SecurityIdentifier(_bytes, 0);

            _identifier2 = WindowsIdentity.GetCurrent().User.AccountDomainSid;

            _mappingArguments = new PropertyMappingArguments <SecurityIdentifierArrayPropertyMappingTest>
            {
                AttributeName = "att",
                PropertyName  = "name",
                PropertyType  = typeof(object)
            };
        }
        public IPropertyMapping ToPropertyMapping()
        {
            var type      = typeof(T);
            var arguments = new PropertyMappingArguments <T>
            {
                PropertyName  = PropertyInfo.Name,
                PropertyType  = PropertyInfo.PropertyType,
                AttributeName = AttributeName ?? PropertyInfo.Name.Replace('_', '-'),
                Getter        = DelegateBuilder.BuildGetter <T>(PropertyInfo),
                Setter        = !type.IsAnonymous()
                             ? DelegateBuilder.BuildSetter <T>(PropertyInfo)
                             : null,
                IsDistinguishedName = IsDistinguishedName,
                ReadOnly            = ReadOnlyConfiguration.GetValueOrDefault(ReadOnly.Never),
                DirectoryMappings   = _directoryMappings,
                InstanceMappings    = _instanceMappings
            };

            var mapping = new DatePropertyMapping <T>(arguments, DateTimeFormat);

            return(mapping);
        }
예제 #14
0
        public void SetUp()
        {
            _bytes = new byte[]
            {
                1, 5, 0, 0, 27, 14, 3, 139, 251, 73, 97, 48, 157, 6, 235, 192, 201, 125, 33,
                65, 182, 209, 6, 82, 206, 165, 32, 24
            };
            _identifier =
                new SecurityIdentifier(_bytes, 0);

            _identifier2 = new SecurityIdentifier(new byte[]
            {
                1, 5, 0, 0, 24, 231, 136, 168, 3, 161, 50, 243, 78, 221, 38,
                69, 104, 65, 224, 78, 188, 248, 211, 212, 60, 19, 48, 228,
            }, 0);

            _mappingArguments = new PropertyMappingArguments <SecurityIdentifierPropertyMappingTest>
            {
                AttributeName = "att",
                PropertyName  = "name",
                PropertyType  = typeof(object)
            };
        }
예제 #15
0
        public virtual IPropertyMapping ToPropertyMapping()
        {
            IPropertyMapping mapping;

            var type      = typeof(T);
            var arguments = new PropertyMappingArguments <T>
            {
                PropertyName  = PropertyInfo.Name,
                PropertyType  = PropertyInfo.PropertyType,
                AttributeName = AttributeName ?? PropertyInfo.Name.Replace('_', '-'),
                Getter        = DelegateBuilder.BuildGetter <T>(PropertyInfo),
                Setter        = !type.IsAnonymous()
                                                 ? DelegateBuilder.BuildSetter <T>(PropertyInfo)
                                                 : null,
                IsDistinguishedName = IsDistinguishedName,
                ReadOnly            = IsDistinguishedName ? ReadOnly.Always : ReadOnlyConfiguration.GetValueOrDefault(ReadOnly.Never),
                DirectoryMappings   = null,
                InstanceMappings    = null
            };

            if (PropertyInfo.PropertyType == typeof(DateTime) || PropertyInfo.PropertyType == typeof(DateTime?))
            {
                mapping = new DatePropertyMapping <T>(arguments, DateTimeFormat);
            }
            else if (PropertyInfo.PropertyType.IsEnum || (Nullable.GetUnderlyingType(PropertyInfo.PropertyType) != null &&
                                                          Nullable.GetUnderlyingType(PropertyInfo.PropertyType).IsEnum))
            {
                mapping = new EnumPropertyMapping <T>(arguments, IsEnumStoredAsInt);
            }
            else if (PropertyInfo.PropertyType == typeof(byte[]))
            {
                mapping = new ByteArrayPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(Guid) || PropertyInfo.PropertyType == typeof(Guid?))
            {
                mapping = new GuidPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(string))
            {
                mapping = new StringPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(string[]))
            {
                mapping = new StringArrayPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(DateTime[]) || PropertyInfo.PropertyType == typeof(DateTime?[]))
            {
                mapping = new DateArrayPropertyMapping <T>(arguments, DateTimeFormat);
            }
            else if (PropertyInfo.PropertyType == typeof(ICollection <DateTime>) || PropertyInfo.PropertyType == typeof(Collection <DateTime>) ||
                     PropertyInfo.PropertyType == typeof(ICollection <DateTime?>) || PropertyInfo.PropertyType == typeof(Collection <DateTime?>))
            {
                mapping = new DateCollectionPropertyMapping <T>(arguments, DateTimeFormat);
            }
            else if (PropertyInfo.PropertyType == typeof(Collection <string>) || PropertyInfo.PropertyType == typeof(ICollection <string>))
            {
                mapping = new StringCollectionPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(Collection <byte[]>) || PropertyInfo.PropertyType == typeof(ICollection <byte[]>))
            {
                mapping = new ByteArrayCollectionPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(bool) || PropertyInfo.PropertyType == typeof(bool?))
            {
                mapping = new BooleanPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(SecurityIdentifier))
            {
                mapping = new SecurityIdentifierPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(SecurityIdentifier[]))
            {
                mapping = new SecurityIdentifierArrayPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(ICollection <SecurityIdentifier>) || PropertyInfo.PropertyType == typeof(Collection <SecurityIdentifier>))
            {
                mapping = new SecurityIdentifierCollectionPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(X509Certificate2) || PropertyInfo.PropertyType == typeof(X509Certificate))
            {
                mapping = new X509Certificate2PropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(byte[][]))
            {
                mapping = new ByteArrayArrayPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(ICollection <X509Certificate>) || PropertyInfo.PropertyType == typeof(Collection <X509Certificate>) ||
                     PropertyInfo.PropertyType == typeof(ICollection <X509Certificate2>) || PropertyInfo.PropertyType == typeof(Collection <X509Certificate2>))
            {
                mapping = new X509Certificate2CollectionPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType == typeof(X509Certificate[]) || PropertyInfo.PropertyType == typeof(X509Certificate2[]))
            {
                mapping = new X509Certificate2ArrayPropertyMapping <T>(arguments);
            }
            else if (PropertyInfo.PropertyType.IsValueType || (Nullable.GetUnderlyingType(PropertyInfo.PropertyType) != null))
            {
                mapping = new NumericPropertyMapping <T>(arguments);
            }
            else if (typeof(IDirectoryAttributes).IsAssignableFrom(PropertyInfo.PropertyType))
            {
                mapping = new CatchAllPropertyMapping <T>(arguments);
            }
            else
            {
                throw new MappingException(string.Format("Type '{0}' could not be mapped.", PropertyInfo.PropertyType.FullName));
            }

            return(mapping);
        }