コード例 #1
0
 public static ContextControllerFactory WithFactoryEnv(
     this ContextControllerFactory factory,
     ContextControllerFactoryEnv contextControllerFactoryEnv)
 {
     factory.FactoryEnv = contextControllerFactoryEnv;
     return factory;
 }
コード例 #2
0
 public static ContextControllerFactory[] GetFactory(ContextControllerFactoryServiceContext serviceContext,
                                                     ContextStateCache contextStateCache)
 {
     if (!(serviceContext.Detail is ContextDetailNested))
     {
         ContextControllerFactory factory = BuildContextFactory(
             serviceContext, serviceContext.ContextName, serviceContext.Detail, 1, null, contextStateCache);
         factory.ValidateFactory();
         return(new ContextControllerFactory[]
         {
             factory
         });
     }
     return(BuildNestedContextFactories(serviceContext, contextStateCache));
 }
コード例 #3
0
        public ContextManagerImpl(ContextControllerFactoryServiceContext factoryServiceContext)
        {
            _uLock                     = LockManager.CreateLock(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            _contextName               = factoryServiceContext.ContextName;
            _servicesContext           = factoryServiceContext.ServicesContext;
            _factory                   = factoryServiceContext.AgentInstanceContextCreate.StatementContext.ContextControllerFactoryService.GetFactory(factoryServiceContext)[0];
            _rootContext               = _factory.CreateNoCallback(0, this); // single instance: created here and activated/deactivated later
            _contextPartitionIdManager = factoryServiceContext.AgentInstanceContextCreate.StatementContext.ContextControllerFactoryService.AllocatePartitionIdMgr(_contextName, factoryServiceContext.AgentInstanceContextCreate.StatementContext.StatementId);

            var resourceRegistryFactory = _factory.StatementAIResourceRegistryFactory;

            var contextProps     = _factory.ContextBuiltinProps;
            var contextPropsType = _servicesContext.EventAdapterService.CreateAnonymousMapType(_contextName, contextProps, true);
            var registry         = new ContextPropertyRegistryImpl(_factory.ContextDetailPartitionItems, contextPropsType);

            _contextDescriptor = new ContextDescriptor(_contextName, _factory.IsSingleInstanceContext, registry, resourceRegistryFactory, this, _factory.ContextDetail);
        }
コード例 #4
0
        private static ContextControllerFactory[] BuildNestedContextFactories(
            ContextControllerFactoryServiceContext serviceContext, ContextStateCache contextStateCache)
        {
            var nestedSpec = (ContextDetailNested)serviceContext.Detail;
            // determine nested filter use
            IDictionary <CreateContextDesc, IList <FilterSpecCompiled> > filtersPerNestedContext = null;

            for (int i = 0; i < nestedSpec.Contexts.Count; i++)
            {
                CreateContextDesc contextParent = nestedSpec.Contexts[i];
                for (int j = i + 1; j < nestedSpec.Contexts.Count; j++)
                {
                    CreateContextDesc          contextControlled = nestedSpec.Contexts[j];
                    IList <FilterSpecCompiled> specs             = contextControlled.FilterSpecs;
                    if (specs == null)
                    {
                        continue;
                    }
                    if (filtersPerNestedContext == null)
                    {
                        filtersPerNestedContext = new Dictionary <CreateContextDesc, IList <FilterSpecCompiled> >();
                    }
                    IList <FilterSpecCompiled> existing = filtersPerNestedContext.Get(contextParent);
                    if (existing != null)
                    {
                        existing.AddAll(specs);
                    }
                    else
                    {
                        filtersPerNestedContext.Put(contextParent, specs);
                    }
                }
            }

            // create contexts
            ICollection <String> namesUsed = new HashSet <String>();
            var hierarchy = new ContextControllerFactory[nestedSpec.Contexts.Count];

            for (int i = 0; i < nestedSpec.Contexts.Count; i++)
            {
                CreateContextDesc context = nestedSpec.Contexts[i];

                if (namesUsed.Contains(context.ContextName))
                {
                    throw new ExprValidationException(
                              "Context by name '" + context.ContextName +
                              "' has already been declared within nested context '" + serviceContext.ContextName + "'");
                }
                namesUsed.Add(context.ContextName);

                int nestingLevel = i + 1;

                IList <FilterSpecCompiled> optFiltersNested = null;
                if (filtersPerNestedContext != null)
                {
                    optFiltersNested = filtersPerNestedContext.Get(context);
                }

                hierarchy[i] = BuildContextFactory(
                    serviceContext, context.ContextName, context.ContextDetail, nestingLevel, optFiltersNested,
                    contextStateCache);
                hierarchy[i].ValidateFactory();
            }
            return(hierarchy);
        }