public static T To <T>(this RelicItem item) { if (item == null) { return(default(T)); } return((T)Convert.ChangeType(item.Value, typeof(T))); }
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); } }
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); } } }
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 { } } }
public void OnRemoved(RelicItem item) { ExecuteHandlers(item, Removed); }
public void OnChanged(RelicItem item) { ExecuteHandlers(item, Changed); }