示例#1
0
        public static Reminders <T> Get(IItem item, PropertyDefinition propertyDefinition)
        {
            Util.ThrowOnNullArgument(item, "item");
            Util.ThrowOnNullArgument(propertyDefinition, "propertyDefinition");
            ExTraceGlobals.RemindersTracer.TraceDebug <StoreObjectId, PropertyDefinition>(0L, "Reminders.Get - item={0}, propertyDefinition={1}", item.StoreObjectId, propertyDefinition);
            Reminders <T> result;

            try
            {
                using (Stream stream = item.OpenPropertyStream(propertyDefinition, PropertyOpenMode.ReadOnly))
                {
                    DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(Reminders <T>));
                    result = (Reminders <T>)dataContractSerializer.ReadObject(stream);
                }
            }
            catch (ObjectNotFoundException arg)
            {
                ExTraceGlobals.RemindersTracer.TraceError <ObjectNotFoundException>(0L, "Reminders.Get - object not found, exception={0}", arg);
                result = null;
            }
            catch (Exception ex)
            {
                ExTraceGlobals.RemindersTracer.TraceError <Exception>(0L, "Reminders.Get - exception={0}", ex);
                if (!Reminders <T> .IsCorruptDataException(ex))
                {
                    throw;
                }
                result = new Reminders <T>();
            }
            return(result);
        }