コード例 #1
0
        internal static void QuotaSettingSetter(ADPropertyDefinition adPropertyDefinition, object quota, IPropertyBag propertyBag)
        {
            if (adPropertyDefinition == null)
            {
                throw new ArgumentNullException("adPropertyDefinition");
            }
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[DataClassificationConfigSchema.DataClassificationConfigQuotaSettings];
            string text = adPropertyDefinition.Name + ':';

            if (multiValuedProperty != null && multiValuedProperty.Count != 0)
            {
                for (int i = multiValuedProperty.Count - 1; i >= 0; i--)
                {
                    if (string.IsNullOrEmpty(multiValuedProperty[i]) || multiValuedProperty[i].StartsWith(text, StringComparison.Ordinal))
                    {
                        multiValuedProperty.RemoveAt(i);
                    }
                }
            }
            if (!object.Equals(quota, adPropertyDefinition.DefaultValue))
            {
                string arg  = ValueConvertor.ConvertValueToString(quota, null);
                string item = string.Format("{0}{1}", text, arg);
                multiValuedProperty.Add(item);
            }
            propertyBag[DataClassificationConfigSchema.DataClassificationConfigQuotaSettings] = multiValuedProperty;
        }
コード例 #2
0
        public override string ToString()
        {
            NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(string.Empty);

            foreach (object obj in this.propertyBag.Keys)
            {
                string text = (string)obj;
                object obj2 = this.propertyBag[text];
                if (obj2 != null)
                {
                    nameValueCollection[text] = ValueConvertor.ConvertValueToString(obj2, null);
                }
            }
            return(Convert.ToBase64String(Encoding.UTF8.GetBytes(nameValueCollection.ToString())));
        }
コード例 #3
0
        public static string ConvertToString(object item, Type type)
        {
            if (item != null)
            {
                type = (type ?? item.GetType());
                if (type == typeof(ExchangeObjectVersion))
                {
                    return(((ExchangeObjectVersion)item).ToInt64().ToString());
                }
                if (typeof(Enum).IsAssignableFrom(type))
                {
                    return(item.ToString());
                }
                if (type == typeof(ProxyAddressCollection))
                {
                    ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)item;
                    if (proxyAddressCollection.Count <= 0)
                    {
                        goto IL_21C;
                    }
                    StringBuilder stringBuilder = new StringBuilder();
                    using (MultiValuedProperty <ProxyAddress> .Enumerator enumerator = proxyAddressCollection.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            ProxyAddress item2 = enumerator.Current;
                            stringBuilder.Append(SearchHelper.ConvertToString(item2, typeof(ProxyAddress)));
                            stringBuilder.Append(',');
                        }
                        goto IL_21C;
                    }
                }
                if (type == typeof(ADObjectId))
                {
                    return(SearchHelper.ConvertToString(((ADObjectId)item).GetBytes(), typeof(byte[])));
                }
                if (type == typeof(OrganizationId))
                {
                    return(SearchHelper.ConvertToString(((OrganizationId)item).GetBytes(Encoding.Unicode), typeof(byte[])));
                }
                if (type == typeof(string))
                {
                    return((string)item);
                }
                if (type == typeof(ProxyAddress))
                {
                    return(((ProxyAddress)item).ProxyAddressString);
                }
                if (type == typeof(SmtpAddress))
                {
                    return(SearchHelper.ConvertToString(((SmtpAddress)item).GetBytes(), typeof(byte[])));
                }
                if (type == typeof(Guid))
                {
                    return(((Guid)item).ToString());
                }
                if (type == typeof(SmtpDomain))
                {
                    return(((SmtpDomain)item).ToString());
                }
                if (type == typeof(SecurityIdentifier))
                {
                    return(((SecurityIdentifier)item).ToString());
                }
                if (type == typeof(byte[]))
                {
                    return(Convert.ToBase64String((byte[])item));
                }
                return(ValueConvertor.ConvertValueToString(item, null));
            }
IL_21C:
            return(string.Empty);
        }