public static EntityDeletedEvent Create(Type dataType, IJsonCacheable data) { var ctor = typeof(EntityDeletedEvent <>).MakeGenericType(dataType) .GetConstructors() .First(); return((EntityDeletedEvent)ctor.Invoke(new object[] { data })); }
public static EntityUpdatedEvent Create(Type dataType, IJsonCacheable data, IEnumerable <string> properties) { var ctor = typeof(EntityUpdatedEvent <>).MakeGenericType(dataType) .GetConstructors() .First(); return((EntityUpdatedEvent)ctor.Invoke(new object[] { data, properties })); }
public static ICacheable GetFromCache(this IJsonCacheable json, TrelloAuthorization auth) { if (json == null) { return(null); } return(TrelloConfiguration.Cache.Find <ICacheable>(o => o.Id == json.Id) ?? JsonFactory[JsonTypeMap[json.GetType()]](json, auth, null)); }
public static T GetFromCache <T>(this IJsonCacheable json, TrelloAuthorization auth) where T : class, ICacheable { if (json == null) { return(null); } return(TryGetFromCache <T>(json) ?? (T)JsonFactory[typeof(T)](json, auth, null)); }
public static T GetFromCache <T>(this IJsonCacheable json, TrelloAuthorization auth) where T : class, ICacheable { if (json == null) { return(null); } var cache = TryGetFromCache <T>(json); if (cache == null) { TrelloConfiguration.Log.Debug($"{typeof(T).Name} with ID {json.Id} not found. Building..."); return((T)JsonFactory[typeof(T)](json, auth, null)); } return(cache); }
public static ICacheable GetFromCache(this IJsonCacheable json, TrelloAuthorization auth) { if (json == null) { return(null); } Type jsonType = json.GetType(); if (!jsonType.IsInterface) { jsonType = JsonTypeMap.Keys.Intersect(jsonType.GetInterfaces()).FirstOrDefault(); if (jsonType == null) { throw new InvalidOperationException($"Type `{json.GetType().Name}` implements more than one Manatee.Trello.Json interface. " + $"Please provide separate classes for each interface."); } } return(TrelloConfiguration.Cache.Find <ICacheable>(json.Id) ?? JsonFactory[JsonTypeMap[jsonType]](json, auth, null)); }
public static T TryGetFromCache <T>(this IJsonCacheable json) where T : class, ICacheable { return(TrelloConfiguration.Cache.Find <T>(o => o.Id == json.Id)); }
public static T GetFromCache <T>(this IJsonCacheable json, TrelloAuthorization auth) where T : class, ICacheable { return(json == null ? null : TrelloConfiguration.Cache.Find <T>(o => o.Id == json.Id) ?? (T)_jsonFactory[typeof(T)](json, auth)); }