Esempio n. 1
0
        public Subscriptions Remove(BlazorStateComponent aBlazorStateComponent)
        {
            Logger.LogDebug($"Removing Subscription for {aBlazorStateComponent.Id}");
            BlazorStateComponentReferencesList.RemoveAll(aRecord => aRecord.ComponentId == aBlazorStateComponent.Id);

            return(this);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        public Subscriptions Add <T>(BlazorStateComponent aBlazorStateComponent)
        {
            Type type = typeof(T);

            return(Add(type, aBlazorStateComponent));
        }