internal static MbxPropertyDefinition CountryInfoFromStringPropertyDefinition(string name, MbxPropertyDefinition rawPropertyDefinition, bool multivalued = false)
 {
     return(new MbxPropertyDefinition(name, PropTag.Null, ExchangeObjectVersion.Exchange2003, typeof(CountryInfo), (multivalued ? PropertyDefinitionFlags.MultiValued : PropertyDefinitionFlags.None) | PropertyDefinitionFlags.Calculated, multivalued ? null : null, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new MbxPropertyDefinition[]
     {
         rawPropertyDefinition
     }, delegate(IPropertyBag propertyBag)
     {
         if (propertyBag[rawPropertyDefinition] != null)
         {
             return CountryInfo.Parse((string)propertyBag[rawPropertyDefinition]);
         }
         return null;
     }, delegate(object value, IPropertyBag propertyBag)
     {
         propertyBag[rawPropertyDefinition] = ((CountryInfo)value).ToString();
     }));
 }
        internal static MbxPropertyDefinition ProxyAddressFromStringPropertyDefinition(string name, MbxPropertyDefinition rawPropertyDefinition, bool multivalued = false)
        {
            GetterDelegate getterDelegate = delegate(IPropertyBag propertyBag)
            {
                if (propertyBag[rawPropertyDefinition] != null)
                {
                    return(ProxyAddress.Parse((string)propertyBag[rawPropertyDefinition]));
                }
                return(null);
            };
            SetterDelegate setterDelegate = delegate(object value, IPropertyBag propertyBag)
            {
                propertyBag[rawPropertyDefinition] = ((ProxyAddress)value).ToString();
            };
            GetterDelegate getterDelegate2 = delegate(IPropertyBag propertyBag)
            {
                MultiValuedProperty <string>       multiValuedProperty  = (MultiValuedProperty <string>)propertyBag[rawPropertyDefinition];
                MultiValuedProperty <ProxyAddress> multiValuedProperty2 = new MultiValuedProperty <ProxyAddress>();
                foreach (string proxyAddressString in multiValuedProperty)
                {
                    multiValuedProperty2.Add(ProxyAddress.Parse(proxyAddressString));
                }
                return(multiValuedProperty2);
            };
            SetterDelegate setterDelegate2 = delegate(object value, IPropertyBag propertyBag)
            {
                MultiValuedProperty <ProxyAddress> multiValuedProperty  = (MultiValuedProperty <ProxyAddress>)value;
                MultiValuedProperty <string>       multiValuedProperty2 = (MultiValuedProperty <string>)propertyBag[rawPropertyDefinition];
                for (int i = multiValuedProperty2.Count - 1; i >= 0; i--)
                {
                    if (!string.IsNullOrEmpty(multiValuedProperty2[i]))
                    {
                        multiValuedProperty2.RemoveAt(i);
                    }
                }
                foreach (ProxyAddress proxyAddress in multiValuedProperty)
                {
                    multiValuedProperty2.Add(proxyAddress.ToString());
                }
            };

            return(new MbxPropertyDefinition(name, PropTag.Null, ExchangeObjectVersion.Exchange2003, typeof(ProxyAddress), (multivalued ? PropertyDefinitionFlags.MultiValued : PropertyDefinitionFlags.None) | PropertyDefinitionFlags.Calculated, multivalued ? null : null, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new MbxPropertyDefinition[]
            {
                rawPropertyDefinition
            }, multivalued ? getterDelegate2 : getterDelegate, multivalued ? setterDelegate2 : setterDelegate));
        }
 internal static MbxPropertyDefinition GuidFromNullableGuidPropertyDefinition(string name, MbxPropertyDefinition rawPropertyDefinition, bool multivalued = false)
 {
     return(new MbxPropertyDefinition(name, PropTag.Null, ExchangeObjectVersion.Exchange2003, typeof(Guid), (multivalued ? PropertyDefinitionFlags.MultiValued : PropertyDefinitionFlags.None) | PropertyDefinitionFlags.Calculated, multivalued ? null : Guid.Empty, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new MbxPropertyDefinition[]
     {
         rawPropertyDefinition
     }, (IPropertyBag propertyBag) => (propertyBag[rawPropertyDefinition] == null) ? Guid.Empty : ((Guid)propertyBag[rawPropertyDefinition]), delegate(object value, IPropertyBag propertyBag)
     {
         propertyBag[rawPropertyDefinition] = value;
     }));
 }
 internal static MbxPropertyDefinition BoolFromNullableBoolPropertyDefinition(string name, MbxPropertyDefinition rawPropertyDefinition, bool multivalued = false)
 {
     return(new MbxPropertyDefinition(name, PropTag.Null, ExchangeObjectVersion.Exchange2003, typeof(bool), (multivalued ? PropertyDefinitionFlags.MultiValued : PropertyDefinitionFlags.None) | PropertyDefinitionFlags.Calculated, false, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new MbxPropertyDefinition[]
     {
         rawPropertyDefinition
     }, (IPropertyBag propertyBag) => propertyBag[rawPropertyDefinition] != null && (bool)propertyBag[rawPropertyDefinition], delegate(object value, IPropertyBag propertyBag)
     {
         propertyBag[rawPropertyDefinition] = value;
     }));
 }
 internal static MbxPropertyDefinition EnhancedTimeSpanFromNullableInt64PropertyDefinition(string name, MbxPropertyDefinition rawPropertyDefinition, bool multivalued = false)
 {
     return(new MbxPropertyDefinition(name, PropTag.Null, ExchangeObjectVersion.Exchange2003, typeof(EnhancedTimeSpan), (multivalued ? PropertyDefinitionFlags.MultiValued : PropertyDefinitionFlags.None) | PropertyDefinitionFlags.Calculated, multivalued ? null : EnhancedTimeSpan.FromDays(90.0), PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new MbxPropertyDefinition[]
     {
         rawPropertyDefinition
     }, (IPropertyBag propertyBag) => (propertyBag[rawPropertyDefinition] == null) ? default(EnhancedTimeSpan) : new TimeSpan((long)propertyBag[rawPropertyDefinition]), delegate(object value, IPropertyBag propertyBag)
     {
         propertyBag[rawPropertyDefinition] = ((TimeSpan)value).Ticks;
     }));
 }
 internal static MbxPropertyDefinition NullableEnumFromNullableInt32PropertyDefinition <T>(string name, MbxPropertyDefinition rawPropertyDefinition, bool multivalued = false) where T : struct
 {
     if (!typeof(T).IsEnum)
     {
         throw new ArgumentException("T must be an enum type");
     }
     return(new MbxPropertyDefinition(name, PropTag.Null, ExchangeObjectVersion.Exchange2003, typeof(T?), (multivalued ? PropertyDefinitionFlags.MultiValued : PropertyDefinitionFlags.None) | PropertyDefinitionFlags.Calculated, null, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new MbxPropertyDefinition[]
     {
         rawPropertyDefinition
     }, (IPropertyBag propertyBag) => (T?)propertyBag[rawPropertyDefinition], delegate(object value, IPropertyBag propertyBag)
     {
         propertyBag[rawPropertyDefinition] = value;
     }));
 }
 internal static MbxPropertyDefinition EnumFromNullableInt32PropertyDefinition <T>(string name, MbxPropertyDefinition rawPropertyDefinition, bool multivalued = false) where T : struct
 {
     return(new MbxPropertyDefinition(name, PropTag.Null, ExchangeObjectVersion.Exchange2003, typeof(T), (multivalued ? PropertyDefinitionFlags.MultiValued : PropertyDefinitionFlags.None) | PropertyDefinitionFlags.Calculated, multivalued ? null : default(T), PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new MbxPropertyDefinition[]
     {
         rawPropertyDefinition
     }, (IPropertyBag propertyBag) => (propertyBag[rawPropertyDefinition] == null) ? default(T) : ((T)((object)propertyBag[rawPropertyDefinition])), delegate(object value, IPropertyBag propertyBag)
     {
         propertyBag[rawPropertyDefinition] = (int)value;
     }));
 }
        internal static MbxPropertyDefinition Int32FromNullableInt32PropertyDefinition(string name, MbxPropertyDefinition rawPropertyDefinition, bool multivalued = false)
        {
            GetterDelegate getterDelegate = (IPropertyBag propertyBag) => (propertyBag[rawPropertyDefinition] == null) ? 0 : ((int)propertyBag[rawPropertyDefinition]);
            SetterDelegate setterDelegate = delegate(object value, IPropertyBag propertyBag)
            {
                propertyBag[rawPropertyDefinition] = (((int?)value) ?? 0);
            };
            GetterDelegate getterDelegate2 = delegate(IPropertyBag propertyBag)
            {
                MultiValuedProperty <int> multiValuedProperty  = (MultiValuedProperty <int>)propertyBag[rawPropertyDefinition];
                MultiValuedProperty <int> multiValuedProperty2 = new MultiValuedProperty <int>();
                foreach (int value in multiValuedProperty)
                {
                    int?num = new int?(value);
                    if (num != null)
                    {
                        multiValuedProperty2.Add(num.Value);
                    }
                }
                return(multiValuedProperty2);
            };
            SetterDelegate setterDelegate2 = delegate(object value, IPropertyBag propertyBag)
            {
                MultiValuedProperty <int> multiValuedProperty  = (MultiValuedProperty <int>)value;
                MultiValuedProperty <int> multiValuedProperty2 = (MultiValuedProperty <int>)propertyBag[rawPropertyDefinition];
                for (int i = multiValuedProperty2.Count - 1; i >= 0; i--)
                {
                    multiValuedProperty2.RemoveAt(i);
                }
                foreach (int item in multiValuedProperty)
                {
                    multiValuedProperty2.Add(item);
                }
            };

            return(new MbxPropertyDefinition(name, PropTag.Null, ExchangeObjectVersion.Exchange2003, typeof(int), (multivalued ? PropertyDefinitionFlags.MultiValued : PropertyDefinitionFlags.None) | PropertyDefinitionFlags.Calculated, multivalued ? null : 0, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new MbxPropertyDefinition[]
            {
                rawPropertyDefinition
            }, multivalued ? getterDelegate2 : getterDelegate, multivalued ? setterDelegate2 : setterDelegate));
        }
 internal static MbxPropertyDefinition UnlimitedInt32FromStringPropertyDefinition(string name, MbxPropertyDefinition rawPropertyDefinition, bool multivalued = false)
 {
     return(new MbxPropertyDefinition(name, PropTag.Null, ExchangeObjectVersion.Exchange2003, typeof(Unlimited <int>), (multivalued ? PropertyDefinitionFlags.MultiValued : PropertyDefinitionFlags.None) | PropertyDefinitionFlags.Calculated, multivalued ? null : default(Unlimited <int>), PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new MbxPropertyDefinition[]
     {
         rawPropertyDefinition
     }, (IPropertyBag propertyBag) => (propertyBag[rawPropertyDefinition] == null) ? default(Unlimited <int>) : Unlimited <int> .Parse((string)propertyBag[rawPropertyDefinition]), delegate(object value, IPropertyBag propertyBag)
     {
         propertyBag[rawPropertyDefinition] = ((Unlimited <int>)value).ToString();
     }));
 }