public virtual bool ReadFromMessageItem(IAnchorStoreObject message)
 {
     AnchorUtil.ThrowOnNullArgument(message, "message");
     this.ExtendedProperties = AnchorHelper.GetDictionaryProperty(message, MigrationBatchMessageSchema.MigrationPersistableDictionary, true);
     this.ReadStoreObjectIdProperties(message);
     return(true);
 }
예제 #2
0
        private static ADObjectId GetADObjectIdImpl(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition, bool useTryGet)
        {
            AnchorUtil.ThrowOnNullArgument(item, "item");
            AnchorUtil.ThrowOnNullArgument(propertyDefinition, "propertyDefinition");
            Exception innerException = null;

            try
            {
                byte[] array;
                if (useTryGet)
                {
                    array = item.GetValueOrDefault <byte[]>(propertyDefinition, null);
                    if (array == null)
                    {
                        return(null);
                    }
                }
                else
                {
                    array = (byte[])item[propertyDefinition];
                }
                return(new ADObjectId(array));
            }
            catch (CorruptDataException ex)
            {
                innerException = ex;
            }
            catch (ArgumentNullException ex2)
            {
                innerException = ex2;
            }
            throw new InvalidDataException(AnchorHelper.GetPropertyErrorMessage(propertyDefinition, null), innerException);
        }
예제 #3
0
        internal static T GetProperty <T>(IAnchorStoreObject item, PropertyDefinition propertyDefinition, bool required) where T : class
        {
            Exception innerException = null;

            try
            {
                if (required)
                {
                    return((T)((object)item[propertyDefinition]));
                }
                return(item.GetValueOrDefault <T>(propertyDefinition, default(T)));
            }
            catch (PropertyErrorException ex)
            {
                innerException = ex;
            }
            catch (InvalidCastException ex2)
            {
                innerException = ex2;
            }
            catch (CorruptDataException ex3)
            {
                innerException = ex3;
            }
            catch (InvalidDataException ex4)
            {
                innerException = ex4;
            }
            throw new MigrationDataCorruptionException(AnchorHelper.GetPropertyErrorMessage(propertyDefinition, null), innerException);
        }
예제 #4
0
        internal static SmtpAddress GetSmtpAddressProperty(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition)
        {
            string property = AnchorHelper.GetProperty <string>(item, propertyDefinition, false);

            if (string.IsNullOrEmpty(property))
            {
                return(SmtpAddress.Empty);
            }
            return(AnchorHelper.GetSmtpAddress(property, propertyDefinition));
        }
예제 #5
0
        internal static Guid GetGuidProperty(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition, bool required)
        {
            Guid valueOrDefault = item.GetValueOrDefault <Guid>(propertyDefinition, Guid.Empty);

            if (required && valueOrDefault == Guid.Empty)
            {
                throw new InvalidDataException(AnchorHelper.GetPropertyErrorMessage(propertyDefinition, null));
            }
            return(valueOrDefault);
        }
예제 #6
0
        internal static T?GetEnumPropertyOrNull <T>(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition) where T : struct
        {
            object valueOrDefault = item.GetValueOrDefault <object>(propertyDefinition, null);

            if (valueOrDefault == null)
            {
                return(null);
            }
            return(new T?(AnchorHelper.GetEnumProperty <T>(propertyDefinition, valueOrDefault)));
        }
예제 #7
0
        internal static ExDateTime GetExDateTimePropertyOrDefault(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition, ExDateTime defaultTime)
        {
            ExDateTime?exDateTimePropertyOrNull = AnchorHelper.GetExDateTimePropertyOrNull(item, propertyDefinition);

            if (exDateTimePropertyOrNull != null)
            {
                return(exDateTimePropertyOrNull.Value);
            }
            return(defaultTime);
        }
예제 #8
0
        internal static ExTimeZone GetExTimeZoneProperty(IPropertyBag item, StorePropertyDefinition propertyDefinition)
        {
            Exception  ex              = null;
            object     objectValue     = item[propertyDefinition];
            ExTimeZone exTimeZoneValue = AnchorHelper.GetExTimeZoneValue(objectValue, ref ex);

            if (ex != null)
            {
                throw new InvalidDataException(AnchorHelper.GetPropertyErrorMessage(propertyDefinition, objectValue), ex);
            }
            return(exTimeZoneValue);
        }
예제 #9
0
        internal static CultureInfo GetCultureInfoPropertyOrDefault(IAnchorStoreObject item, PropertyDefinition propertyDefinition)
        {
            string      valueOrDefault = item.GetValueOrDefault <string>(propertyDefinition, "en-US");
            CultureInfo result;

            try
            {
                result = new CultureInfo(valueOrDefault);
            }
            catch (ArgumentException innerException)
            {
                throw new InvalidDataException(AnchorHelper.GetPropertyErrorMessage(propertyDefinition, valueOrDefault), innerException);
            }
            return(result);
        }
예제 #10
0
        internal static SmtpAddress GetSmtpAddress(string smtpAddress, StorePropertyDefinition propertyDefinition)
        {
            Exception innerException = null;

            try
            {
                return(SmtpAddress.Parse(smtpAddress));
            }
            catch (PropertyErrorException ex)
            {
                innerException = ex;
            }
            catch (FormatException ex2)
            {
                innerException = ex2;
            }
            throw new InvalidDataException(AnchorHelper.GetPropertyErrorMessage(propertyDefinition, null), innerException);
        }
예제 #11
0
        internal static Fqdn GetFqdnProperty(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition, bool required)
        {
            Exception innerException = null;

            try
            {
                string property = AnchorHelper.GetProperty <string>(item, propertyDefinition, required);
                if (property == null)
                {
                    return(null);
                }
                return(new Fqdn(property));
            }
            catch (FormatException ex)
            {
                innerException = ex;
            }
            throw new InvalidDataException(AnchorHelper.GetPropertyErrorMessage(propertyDefinition, null), innerException);
        }
예제 #12
0
        internal static StoreObjectId GetObjectIdProperty(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition, bool required)
        {
            Exception innerException = null;

            try
            {
                byte[] property = AnchorHelper.GetProperty <byte[]>(item, propertyDefinition, required);
                if (property == null)
                {
                    return(null);
                }
                return(MigrationHelperBase.GetStoreObjectId(property));
            }
            catch (CorruptDataException ex)
            {
                innerException = ex;
            }
            throw new InvalidDataException(AnchorHelper.GetPropertyErrorMessage(propertyDefinition, null), innerException);
        }
예제 #13
0
        private static T GetEnumProperty <T>(StorePropertyDefinition propertyDefinition, object objectValue) where T : struct
        {
            Exception innerException = null;

            try
            {
                return((T)((object)objectValue));
            }
            catch (PropertyErrorException ex)
            {
                innerException = ex;
            }
            catch (FormatException ex2)
            {
                innerException = ex2;
            }
            catch (InvalidCastException ex3)
            {
                innerException = ex3;
            }
            throw new InvalidDataException(AnchorHelper.GetPropertyErrorMessage(propertyDefinition, objectValue), innerException);
        }
예제 #14
0
        internal static PersistableDictionary GetDictionaryProperty(IAnchorStoreObject item, PropertyDefinition propertyDefinition, bool required)
        {
            AnchorUtil.ThrowOnNullArgument(item, "item");
            AnchorUtil.ThrowOnNullArgument(propertyDefinition, "propertyDefinition");
            string property = AnchorHelper.GetProperty <string>(item, propertyDefinition, required);

            if (property == null)
            {
                return(null);
            }
            PersistableDictionary result;

            try
            {
                result = PersistableDictionary.Create(property);
            }
            catch (XmlException innerException)
            {
                throw new InvalidDataException(AnchorHelper.GetPropertyErrorMessage(propertyDefinition, property), innerException);
            }
            return(result);
        }
예제 #15
0
 internal static T GetEnumProperty <T>(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition) where T : struct
 {
     return(AnchorHelper.GetEnumProperty <T>(propertyDefinition, item[propertyDefinition]));
 }
예제 #16
0
 internal static PropertyDefinition[] AggregateProperties(params IList <PropertyDefinition>[] items)
 {
     return(AnchorHelper.AggregateArrays <PropertyDefinition>(items));
 }
예제 #17
0
 internal static bool TryGetADObjectId(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition, out ADObjectId id)
 {
     id = AnchorHelper.GetADObjectIdImpl(item, propertyDefinition, true);
     return(id != null);
 }
예제 #18
0
 internal static ADObjectId GetADObjectId(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition)
 {
     return(AnchorHelper.GetADObjectIdImpl(item, propertyDefinition, false));
 }
예제 #19
0
        internal static ExDateTime?GetExDateTimePropertyOrNull(IAnchorStoreObject item, StorePropertyDefinition propertyDefinition)
        {
            object property = AnchorHelper.GetProperty <object>(item, propertyDefinition, false);

            return(MigrationHelperBase.GetValidExDateTime(property as ExDateTime?));
        }
 protected virtual void WriteExtendedPropertiesToMessageItem(IAnchorStoreObject message)
 {
     AnchorHelper.SetDictionaryProperty(message, MigrationBatchMessageSchema.MigrationPersistableDictionary, this.ExtendedProperties);
 }