Exemple #1
0
        /// <summary>
        /// Converts <see cref="ILdapEntity"/> to a Novell <see cref="LdapEntry"/>
        /// </summary>
        /// <param name="entity">The entity to be converted</param>
        /// <param name="mapper">Mapper providing attribute names</param>
        /// <typeparam name="T">A <see cref="ILdapEntity"/> to be converted</typeparam>
        /// <returns></returns>
        public static LdapEntry ToNovellEntry <T>(this T entity, LdapAttributeMapper mapper) where T : ILdapEntity
        {
            var propertiesWithAttributes = Mappings.GetAttributes <T>();

            var attributeSet = new LdapAttributeSet();

            foreach (var property in propertiesWithAttributes)
            {
                string attributeName = mapper.GetAttributeKey(property.Key);
                attributeSet.Add(new LdapAttribute(attributeName,
                                                   property.Value.GetValue(entity).ToString()));
            }

            return(new LdapEntry(entity.DistinguishedName, attributeSet));
        }
Exemple #2
0
        /// <summary>
        /// Converts Novell <see cref="LdapEntry"/> to a <see cref="ILdapEntity"/>
        /// </summary>
        /// <param name="entry">Novell entry</param>
        /// <param name="mapper">Mapper providing attribute names</param>
        /// <typeparam name="T">The resulting entity type</typeparam>
        /// <returns></returns>
        public static T ToLdapEntity <T>(this LdapEntry entry, LdapAttributeMapper mapper) where T : ILdapEntity
        {
            Dictionary <LdapAttributeAttribute, PropertyInfo> propertiesWithAttributes = Mappings.GetAttributes <T>();

            LdapAttributeSet attributeSet = entry.getAttributeSet();

            var entity = (T)FormatterServices.GetUninitializedObject(typeof(T));

            foreach (var property in propertiesWithAttributes)
            {
                string attributeName = mapper.GetAttributeKey(property.Key);
                property.Value.SetValue(entity, attributeSet.getAttribute(attributeName).StringValue);
            }

            if (entity.DistinguishedName == null)
            {
                entity.DistinguishedName = entry.DN;
            }
            return(entity);
        }
 public FilterBuilder(LdapAttributeMapper mapper)
 {
     _mapper = mapper;
 }
 public LdapQueryProvider(LdapAttributeMapper mapper)
 {
     _mapper = mapper;
 }
 public QueryTranslator(LdapAttributeMapper mapper)
 {
     _mapper = mapper;
 }
Exemple #6
0
 public void Setup()
 {
     _mapper = Generators.CreateMapper();
 }