Example #1
0
        protected WorkflowGrain(Func <WorkflowIdentity, Activity> workflowDefinitionFactory, WorkflowIdentity workflowDefinitionIdentity)
        {
            // TODO
            // it's not possible to force at compile time that the WorkflowGrain implementation should implement TEffector
            // it would be great to check all the WorkflowGrain implementations at assembly load time (Orleans bootstrap? DI? module initilizer .cctor?)
            // AffectorProxy<> and EffectorProxy<> cctor also executes checks on TAffector and TEffector method signatures, but called only at first usage and not load time
            // Fody/ModuleInit: https://github.com/fody/moduleinit
            // Module Initializer: http://einaregilsson.com/module-initializers-in-csharp/

            if (!(this is TEffector))
            {
                throw new InvalidProgramException($"Type '{GetType().GetFriendlyName()}' must explicitly implement interface '{typeof(TEffector).GetFriendlyName()}'!");
            }

            workflowHost         = new WorkflowHost(new WorkflowGrainEffector(this), workflowDefinitionFactory, workflowDefinitionIdentity);
            workflowHostAffector = AffectorProxy <TAffector> .CreateProxy(workflowHost);
        }
 public void AffectorProxy()
 {
     ITestAffector2 proxy = AffectorProxy<ITestAffector2>.CreateProxy(new Affector());
     proxy.SayHello1(null);
     proxy.SayHello2(null);
     proxy.SayHello3(null);
     proxy.SayHello4(null);
     proxy.SayHello44(null);
     proxy = AffectorProxy<ITestAffector2>.CreateProxy(new Affector());
     proxy.SayHello1(null);
     proxy.SayHello2(null);
     proxy.SayHello3(null);
     proxy.SayHello4(null);
     proxy.SayHello44(null);
     ITestAffectorBase proxyBase = AffectorProxy<ITestAffectorBase>.CreateProxy(new Affector());
     proxyBase.SayHello1(null);
     proxyBase.SayHello2(null);
     proxyBase.SayHello3(null);
     proxyBase.SayHello4(null);
 }