Exemplo n.º 1
0
            void IGrainContext.SetComponent <TComponent>(TComponent value)
            {
                if (this.LocalObject.Target is TComponent component)
                {
                    throw new ArgumentException("Cannot override a component which is implemented by this grain");
                }

                _rootGrainContext.SetComponent(value);
            }
Exemplo n.º 2
0
        public override Task OnActivateAsync(CancellationToken cancellationToken)
        {
            if (extender == null)
            {
                extender = new SimpleExtension("A");
                _grainContext.SetComponent <ISimpleExtension>(extender);
            }

            return(base.OnActivateAsync(cancellationToken));
        }
Exemplo n.º 3
0
        public Task InstallExtension(T name)
        {
            if (extender == null)
            {
                extender = new GenericTestExtension <T>(this, this.GrainFactory);
                _grainContext.SetComponent <IGenericTestExtension <T> >(extender);
            }

            ExtensionProperty = name;
            return(Task.CompletedTask);
        }
Exemplo n.º 4
0
        public Task InstallExtension(string name)
        {
            if (extender == null)
            {
                extender = new TestExtension(this, GrainFactory);
                _grainContext.SetComponent <ITestExtension>(extender);
            }

            ExtensionProperty = name;
            return(Task.CompletedTask);
        }
        public void Configure(IGrainContext context)
        {
            var component = context.GetComponent <GrainCanInterleave>();

            if (component is null)
            {
                component = new GrainCanInterleave();
                context.SetComponent <GrainCanInterleave>(component);
            }

            component.MayInterleavePredicates.Add(_mayInterleavePredicate);
        }
Exemplo n.º 6
0
        public static ResourceFactoryRegistry <T> GetResourceFactoryRegistry <T>(this IGrainContext context, bool createIfNotExists = false)
        {
            ResourceFactoryRegistry <T> result = context.GetComponent <ResourceFactoryRegistry <T> >();

            if (createIfNotExists && result == null)
            {
                result = new ResourceFactoryRegistry <T>();
                context.SetComponent(result);
            }

            return(result);
        }