コード例 #1
0
ファイル: Extensions.cs プロジェクト: lozanotek/Relic
        public static T To <T>(this RelicItem item)
        {
            if (item == null)
            {
                return(default(T));
            }

            return((T)Convert.ChangeType(item.Value, typeof(T)));
        }
コード例 #2
0
        public void Set(string key, object value)
        {
            var item = new RelicItem {
                Key = key, Value = value
            };

            try {
                Provider.Set(key, value);
                Notifier.OnChanged(item);
            }
            catch (Exception exception) {
                Notifier.OnErrored(item, exception);
            }
        }
コード例 #3
0
        private void ExecuteHandlers(RelicItem item, RelicNotifyHandler tempNotifyHandler)
        {
            if (tempNotifyHandler == null)
            {
                return;
            }

            var handlerList = tempNotifyHandler.GetInvocationList();

            foreach (RelicNotifyHandler handler in handlerList)
            {
                try {
                    handler(item);
                }
                catch (Exception exception) {
                    OnErrored(item, exception);
                }
            }
        }
コード例 #4
0
        public void OnErrored(RelicItem item, Exception exception)
        {
            var tempHandler = Errored;

            if (tempHandler == null)
            {
                return;
            }

            var handlerList = tempHandler.GetInvocationList();

            foreach (RelicErrorHandler handler in handlerList)
            {
                try {
                    handler.BeginInvoke(item, exception, null, this);
                }
                catch {
                }
            }
        }
コード例 #5
0
 public void OnRemoved(RelicItem item)
 {
     ExecuteHandlers(item, Removed);
 }
コード例 #6
0
 public void OnChanged(RelicItem item)
 {
     ExecuteHandlers(item, Changed);
 }