コード例 #1
0
        public Task Initialize(IIndexWorkflowQueue oldParentSystemTarget)
        {
            if (_base == null)
            {
                GrainReference oldParentSystemTargetRef = oldParentSystemTarget.AsWeaklyTypedReference();
                string[] parts = oldParentSystemTargetRef.GetPrimaryKeyString().Split('-');
                if (parts.Length != 2)
                {
                    throw new Exception("The primary key for IndexWorkflowQueueSystemTarget should only contain a single special character '-', while it contains multiple. The primary key is '" + oldParentSystemTargetRef.GetPrimaryKeyString() + "'");
                }

                Type grainInterfaceType = TypeUtils.ResolveType(parts[0]);
                int queueSequenceNumber = int.Parse(parts[1]);

                GrainReference thisRef = this.AsWeaklyTypedReference();
                _base = new IndexWorkflowQueueHandlerBase(grainInterfaceType, queueSequenceNumber, oldParentSystemTargetRef.SystemTargetSilo, true /*otherwise it shouldn't have reached here!*/, thisRef);
            }
            return TaskDone.Done;
        }
        public Task Initialize(IIndexWorkflowQueue oldParentGrainService)
        {
            if (_base == null)
            {
                GrainReference oldParentGrainServiceRef = oldParentGrainService.AsWeaklyTypedReference();
                string[]       parts = oldParentGrainServiceRef.GetPrimaryKeyString().Split('-');
                if (parts.Length != 2)
                {
                    throw new WorkflowIndexException("The primary key for IndexWorkflowQueueGrainService should only contain a single special character '-', while it contains multiple." +
                                                     " The primary key is '" + oldParentGrainServiceRef.GetPrimaryKeyString() + "'");
                }

                Type grainInterfaceType  = this.SiloIndexManager.CachedTypeResolver.ResolveType(parts[0]);
                int  queueSequenceNumber = int.Parse(parts[1]);

                _base = new IndexWorkflowQueueBase(this.SiloIndexManager, grainInterfaceType, queueSequenceNumber,
                                                   oldParentGrainServiceRef.GrainServiceSiloAddress, isDefinedAsFaultTolerantGrain: true,
                                                   parentFunc: () => this.AsWeaklyTypedReference());
            }
            return(Task.CompletedTask);
        }