public void Initialize(InitializationEngine context)
 {
     AreaConfiguration.RegisterAllAreas(config =>
     {
         //config.EnableAreaDetectionByController = true;
         config.EnableAreaDetectionBySite = true;
     });
 }
 public void RegisterAreas_calls_RouterBuilder_Routes_Add()
 {
     SetupDependencies();
     _routerBuilderMock.Setup(routeBuilder => routeBuilder.Routes.Add(It.IsAny <Route>())).Verifiable();
     _systemUnderTest = AreaConfiguration.DefaultAreaConfiguration;
     _systemUnderTest = new AreaConfiguration
     {
         DefaultAreaRouteName     = "Test",
         DefaultAreaRouteTemplate = "Test2"
     };
     _systemUnderTest.RegisterAreas(_routerBuilderMock.Object);
     _routerBuilderMock.Verify(routeBuilder => routeBuilder.Routes.Add(It.IsAny <Route>()));
 }
示例#3
0
        /// <summary>
        /// Initializes the area.
        /// </summary>
        public AreaState(
            ISystemContext context,
            AreaState parent,
            NodeId nodeId,
            AreaConfiguration configuration) 
        : 
            base(parent)
        {
            Initialize(context);

            // initialize the area with the fixed metadata.
            this.SymbolicName = configuration.Name;
            this.NodeId = nodeId;
            this.BrowseName = new QualifiedName(Utils.Format("{0}", configuration.Name), nodeId.NamespaceIndex);
            this.DisplayName = BrowseName.Name;
            this.Description = null;
            this.ReferenceTypeId = ReferenceTypeIds.HasNotifier;
            this.TypeDefinitionId = ObjectTypeIds.FolderType;
            this.EventNotifier = EventNotifiers.SubscribeToEvents;
        }
        /// <summary>
        /// Creates and indexes an area defined for the server.
        /// </summary>
        private AreaState CreateAndIndexAreas(AreaState parent, AreaConfiguration configuration)
        {
            // create a unique path to the area.
            string areaPath = Utils.Format("{0}/{1}", (parent != null)?parent.SymbolicName:String.Empty, configuration.Name);
            NodeId areaId = ModelUtils.ConstructIdForArea(areaPath, NamespaceIndex);
            
            // create the object that will be used to access the area and any variables contained within it.
            AreaState area = new AreaState(SystemContext, parent, areaId, configuration);
            m_areas[areaPath] = area;
            
            if (parent != null)
            {
                parent.AddChild(area);
            }
            
            // create an index any sub-areas defined for the area.
            if (configuration.SubAreas != null)
            {
                for (int ii = 0; ii < configuration.SubAreas.Count; ii++)
                {
                    CreateAndIndexAreas(area, configuration.SubAreas[ii]);
                }
            }

            // add references to sources.
            if (configuration.SourcePaths != null)
            {
                for (int ii = 0; ii < configuration.SourcePaths.Count; ii++)
                {
                    string sourcePath = configuration.SourcePaths[ii];

                    // check if the source already exists because it is referenced by another area.
                    SourceState source = null;

                    if (!m_sources.TryGetValue(sourcePath, out source))
                    {
                        NodeId sourceId = ModelUtils.ConstructIdForSource(sourcePath, NamespaceIndex);
                        m_sources[sourcePath] = source = new SourceState(this, sourceId, sourcePath);
                    }

                    // HasEventSource and HasNotifier control the propagation of event notifications so
                    // they are not like other references. These calls set up a link between the source
                    // and area that will cause events produced by the source to be automatically 
                    // propagated to the area.
                    source.AddNotifier(SystemContext, ReferenceTypeIds.HasEventSource, true, area);
                    area.AddNotifier(SystemContext, ReferenceTypeIds.HasEventSource, false, source);
                }
            }

            return area;
        }