public Subscriptions Remove(BlazorStateComponent aBlazorStateComponent) { Logger.LogDebug($"Removing Subscription for {aBlazorStateComponent.Id}"); BlazorStateComponentReferencesList.RemoveAll(aRecord => aRecord.ComponentId == aBlazorStateComponent.Id); return(this); }
public Subscriptions Add(Type aType, BlazorStateComponent aBlazorStateComponent) { if (!(BlazorStateComponentReferencesDictionary.TryGetValue(aType, out List <WeakReference <BlazorStateComponent> > blazorStateComponentReferences))) { blazorStateComponentReferences = new List <WeakReference <BlazorStateComponent> >(); BlazorStateComponentReferencesDictionary.Add(aType, blazorStateComponentReferences); } blazorStateComponentReferences.Add(new WeakReference <BlazorStateComponent>(aBlazorStateComponent)); return(this); }
public Subscriptions Add(Type aType, BlazorStateComponent aBlazorStateComponent) { // Add only once. if (!BlazorStateComponentReferencesList.Any(aSubscription => aSubscription.StateType == aType && aSubscription.ComponentId == aBlazorStateComponent.Id)) { var subscription = new Subscription( aType, aBlazorStateComponent.Id, new WeakReference <BlazorStateComponent>(aBlazorStateComponent)); BlazorStateComponentReferencesList.Add(subscription); } return(this); }
public Subscriptions Add(Type aType, BlazorStateComponent aBlazorStateComponent) { //if (!typeof(IState).IsAssignableFrom(aStateType)) //{ // throw new ArgumentException("Type must implement IState"); //} if (!(BlazorStateComponentReferencesDictionary.TryGetValue(aType, out List <WeakReference <BlazorStateComponent> > blazorStateComponentReferences))) { blazorStateComponentReferences = new List <WeakReference <BlazorStateComponent> >(); BlazorStateComponentReferencesDictionary.Add(aType, blazorStateComponentReferences); } blazorStateComponentReferences.Add(new WeakReference <BlazorStateComponent>(aBlazorStateComponent)); return(this); }
public Subscriptions Add <T>(BlazorStateComponent aBlazorStateComponent) { Type type = typeof(T); return(Add(type, aBlazorStateComponent)); }