/// <summary> /// Initializes static members of the <see cref="InvocationController"/> class. /// </summary> static InvocationController() { var assemblies = new List <Assembly> { typeof(ICalculatorActor).Assembly, typeof(IManagementGrain).Assembly }; Actors = new Lazy <Dictionary <string, ActorDescription> >( () => ActorDescriptionGenerator.GetActorDescriptions(assemblies)); var dispatcherCompletion = new TaskCompletionSource <IEventDispatcher>(); var sourceCompletion = new TaskCompletionSource <string>(); Dispatcher = dispatcherCompletion.Task; DispatcherSource = sourceCompletion.Task; // Generate the dispatchers asynchronously. Task.Run( () => { try { string source; var dispatcher = EventDispatcherGenerator.GetDispatcher(Actors.Value.Values.ToList(), out source); dispatcherCompletion.TrySetResult(dispatcher); sourceCompletion.TrySetResult(source); } catch (Exception e) { dispatcherCompletion.TrySetException(e); sourceCompletion.TrySetException(e); } }); }
/// <summary> /// Gets the compiled assembly for the provided actor assembly. /// </summary> /// <param name="actorAssembly"> /// The actor assembly. /// </param> /// <returns> /// The compiled assembly for the provided actor assembly. /// </returns> private static Tuple <Assembly, string> GetOrCompileAssembly(Assembly actorAssembly) { return(CompiledAssemblies.GetOrAdd( actorAssembly, assembly => { string source; var asm = CompileAssembly( ActorDescriptionGenerator.GetActorDescriptions(actorAssembly).Values.ToList(), out source); return Tuple.Create(asm, source); })); }