/// <summary> /// Used by generated code for <see cref="IGrainExtension" /> interfaces. /// </summary> /// <typeparam name="TComponent"> /// The type of the component to get. /// </typeparam> /// <param name="context"> /// The grain context. /// </param> /// <returns> /// The grain extension. /// </returns> public static TComponent GetGrainExtension <TComponent>(this IGrainContext context) where TComponent : IGrainExtension { var binder = context.GetComponent <IGrainExtensionBinder>(); return(binder.GetExtension <TComponent>()); }
public IDisposable RegisterTimer(IGrainContext grainContext, Func <object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period) { var timer = GrainTimer.FromTaskCallback(this.timerLogger, asyncCallback, state, dueTime, period, grainContext: grainContext); grainContext?.GetComponent <IGrainTimerRegistry>().OnTimerCreated(timer); timer.Start(); return(timer); }
TComponent IGrainContext.GetComponent <TComponent>() { if (this.LocalObject.Target is TComponent component) { return(component); } return(_rootGrainContext.GetComponent <TComponent>()); }
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); }