Ejemplo n.º 1
0
        private const int CAT_DEFAULT = 1; // default tracing event category

        #endregion Fields

        #region Methods

        /// <summary>
        /// Converts any value to a form that can be stored into connector attribute.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="isMultivalued"></param>
        /// <returns></returns>
        public static ICollection<object> ConvertToSupportedForm(ConnectorAttributeInfo cai, object value)
        {
            IList<object> rv = new List<object>();
            if (cai.IsMultiValued && value is IEnumerable) {
                foreach (object v in (IEnumerable)value) {
                    if (v == null) {
                        continue;
                    }
                    if (!IsSupported(cai, v)) {
                        rv.Add(v.ToString());
                    } else {
                        rv.Add(v);
                    }
                }
            } else {
                if (value != null && !IsSupported(cai, value)) {
                    rv.Add(value.ToString());
                } else {
                    rv.Add(value);
                }
            }
            return rv;
        }
Ejemplo n.º 2
0
 private static bool IsSupported(ConnectorAttributeInfo cai, object value)
 {
     if (!FrameworkUtil.IsSupportedAttributeType(value.GetType())) {
         LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT,
             "Unsupported attribute type ... calling ToString (Name: \'{0}\' Type: \'{1}\' String Value: \'{2}\'",
             cai.Name, value.GetType(), value.ToString());
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Add each <see cref="ConnectorAttributeInfo" /> object to the <see cref="ObjectClassInfo" />.
 /// </summary>
 public ObjectClassInfoBuilder AddAttributeInfo(ConnectorAttributeInfo info)
 {
     if (_info.ContainsKey(info.Name))
     {
         const string MSG = "ConnectorAttributeInfo of name ''{0}'' already exists!";
         throw new ArgumentException(String.Format(MSG, info.Name));
     }
     _info[info.Name] = info;
     return this;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Determines if this attribute is a special attribute.
 /// </summary>
 /// <param name="attr">
 /// <see cref="ConnectorAttribute" /> to test for against.</param>
 /// <returns>true iff the attribute value is a <see cref="Uid" />,
 /// <see cref="ObjectClass" />, <see cref="Password" />, or
 /// <see cref="OperationalAttributes" />.</returns>
 /// <exception cref="NullReferenceException">iff the attribute parameter is null.</exception>
 public static bool IsSpecial(ConnectorAttributeInfo attr)
 {
     String name = attr.Name;
     return IsSpecialName(name);
 }
Ejemplo n.º 5
0
 private void SetFlag(ConnectorAttributeInfo.Flags flag, bool value)
 {
     if (value)
     {
         _flags = _flags | flag;
     }
     else
     {
         _flags = _flags & ~flag;
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Convenience method to create an AttributeInfo.
 /// </summary>
 /// <remarks>
 /// Equivalent to
 /// <code>
 /// new AttributeInfoBuilder(name,type).setFlags(flags).build()
 /// </code>
 /// </remarks>
 /// <param name="name">The name of the attribute</param>
 /// <param name="type">The type of the attribute</param>
 /// <param name="flags">The flags for the attribute. Null means clear all flags</param>
 /// <returns>The attribute info</returns>
 public static ConnectorAttributeInfo Build(String name, Type type,
     ConnectorAttributeInfo.Flags flags)
 {
     return new ConnectorAttributeInfoBuilder(name, type) { InfoFlags = flags }.Build();
 }