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); }
public override Task OnActivateAsync(CancellationToken cancellationToken) { if (extender == null) { extender = new SimpleExtension("A"); _grainContext.SetComponent <ISimpleExtension>(extender); } return(base.OnActivateAsync(cancellationToken)); }
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); }
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); }
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); }