예제 #1
0
        public void Visit(int nestingLevel, int pathId, ContextStatePathValueBinding binding, Object payload, ContextController contextController, ContextControllerInstanceHandle instanceHandle)
        {
            var key             = new ContextStatePathKey(nestingLevel, pathId, instanceHandle.SubPathId);
            int maxNestingLevel = _nestedFactories.Length;

            int contextPartitionOrSubPath = instanceHandle.ContextPartitionOrPathId;

            if (contextController.Factory.FactoryContext.NestingLevel == maxNestingLevel)
            {
                var agentInstances = ControllerAgentInstances.Get(contextController);
                if (agentInstances == null)
                {
                    agentInstances = new List <LeafDesc>();
                    ControllerAgentInstances.Put(contextController, agentInstances);
                }
                var value = new ContextStatePathValue(contextPartitionOrSubPath, binding.ToByteArray(payload), instanceHandle.Instances.State);
                agentInstances.Add(new LeafDesc(key, value));

                // generate a nice payload text from the paths of keys
                var entry      = _subcontexts.Get(contextController);
                var keys       = ContextManagerNested.GetTreeCompositeKey(_nestedFactories, payload, entry, _subcontexts);
                var descriptor = new ContextPartitionDescriptor(contextPartitionOrSubPath, new ContextPartitionIdentifierNested(keys), value.State);
                AgentInstanceInfo.Put(contextPartitionOrSubPath, descriptor);
                States.Put(key, value);
            }
            else
            {
                // handle non-leaf
                Subpaths.Add(contextPartitionOrSubPath);
                States.Put(key, new ContextStatePathValue(contextPartitionOrSubPath, binding.ToByteArray(payload), ContextPartitionState.STARTED));
            }
        }
예제 #2
0
 public void ResetSubPaths()
 {
     Subpaths.Clear();
 }