protected WorkflowGrain(Func <WorkflowIdentity, Activity> workflowDefinitionFactory, WorkflowIdentity workflowDefinitionIdentity)
        {
            // TODO
            // it's not possible to force at compile time that the WorkflowGrain implementation should implement TWorkflowCallbackInterface
            // it would be great to check all the WorkflowGrain implementations at assembly load time (Orleans bootstrap? DI? module initilizer .cctor?)
            // WorkflowInterfaceProxy<> and WorkflowCallbackInterfaceProxy<> cctor also executes checks on TWorkflowInterface and TWorkflowCallbackInterface 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 TWorkflowCallbackInterface))
            {
                throw new InvalidProgramException($"Type '{GetType().GetFriendlyName()}' must explicitly implement interface '{typeof(TWorkflowCallbackInterface).GetFriendlyName()}'!");
            }

            workflowHost           = new WorkflowHost(new WorkflowHostCallback(this), workflowDefinitionFactory, workflowDefinitionIdentity);
            workflowInterfaceProxy = WorkflowInterfaceProxy <TWorkflowInterface> .CreateProxy(workflowHost);
        }
Пример #2
0
        public void WorkflowInterfaceProxy()
        {
            ITestWorkflowInterface2 proxy = WorkflowInterfaceProxy <ITestWorkflowInterface2> .CreateProxy(new WorkflowInterface());

            proxy.SayHello1(null);
            proxy.SayHello2(null);
            proxy.SayHello3(null);
            proxy.SayHello4(null);
            proxy.SayHello44(null);
            proxy = WorkflowInterfaceProxy <ITestWorkflowInterface2> .CreateProxy(new WorkflowInterface());

            proxy.SayHello1(null);
            proxy.SayHello2(null);
            proxy.SayHello3(null);
            proxy.SayHello4(null);
            proxy.SayHello44(null);
            ITestWorkflowInterfaceBase proxyBase = WorkflowInterfaceProxy <ITestWorkflowInterfaceBase> .CreateProxy(new WorkflowInterface());

            proxyBase.SayHello1(null);
            proxyBase.SayHello2(null);
            proxyBase.SayHello3(null);
            proxyBase.SayHello4(null);
        }