Пример #1
0
        private static bool HasTimerFired(ReliableTimer.Feature feature, IItem item)
        {
            StorePropertyDefinition storePropertyDefinition = ReliableTimer.featureToStorePropertyMapping[feature];

            item.Load(new List <PropertyDefinition>
            {
                storePropertyDefinition
            });
            object obj = item.TryGetProperty(storePropertyDefinition);

            if (PropertyError.IsPropertyNotFound(obj))
            {
                ExTraceGlobals.ReliableTimerTracer.TraceDebug <ReliableTimer.Feature>(0L, "Timer not set for feature={0}", feature);
                return(false);
            }
            if (PropertyError.IsPropertyError(obj))
            {
                PropertyError propertyError = (PropertyError)obj;
                ExTraceGlobals.ReliableTimerTracer.TraceError <ReliableTimer.Feature, PropertyErrorCode>(0L, "Property error for feature={0}, propertyErrorCode={1}", feature, propertyError.PropertyErrorCode);
                throw PropertyError.ToException(new PropertyError[]
                {
                    propertyError
                });
            }
            ExDateTime exDateTime = (ExDateTime)obj;

            ExTraceGlobals.ReliableTimerTracer.TraceDebug <ReliableTimer.Feature, ExDateTime>(0L, "Timer value for feature={0}, timerValue={1}", feature, exDateTime);
            return(exDateTime == ReliableTimer.FiredTimerPropertyValue);
        }
Пример #2
0
        internal static object CheckPropertyValue(object propertyValue)
        {
            PropertyError propertyError = propertyValue as PropertyError;

            if (propertyError == null)
            {
                return(propertyValue);
            }
            if (propertyError.PropertyErrorCode == PropertyErrorCode.NotFound)
            {
                return(null);
            }
            throw PropertyError.ToException(new PropertyError[]
            {
                propertyError
            });
        }
Пример #3
0
        public T GetValueOrDefault <T>(PropertyDefinition propertyDefinition, T defaultValue)
        {
            object        obj           = this.TryGetProperty(propertyDefinition);
            PropertyError propertyError = obj as PropertyError;

            if (obj == null || (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound))
            {
                return(defaultValue);
            }
            if (propertyError != null)
            {
                throw PropertyError.ToException(new PropertyError[]
                {
                    (PropertyError)obj
                });
            }
            return((T)((object)obj));
        }
Пример #4
0
        private object GetProperty(PropertyDefinition propertyDefinition)
        {
            object obj = this.TryGetProperty(propertyDefinition);

            if (obj == null)
            {
                throw PropertyError.ToException(new PropertyError[]
                {
                    new PropertyError(propertyDefinition, PropertyErrorCode.NullValue)
                });
            }
            if (PropertyError.IsPropertyError(obj))
            {
                throw PropertyError.ToException(new PropertyError[]
                {
                    (PropertyError)obj
                });
            }
            return(obj);
        }