Пример #1
0
        public override void Map(Routing.Route route, IContainer container)
        {
            route.ThrowIfNull("route");
            container.ThrowIfNull("container");

            route.RestrictByMethods(_methods);
        }
        public static bool IsRoutingEqual(Routing routing1, Routing routing2)
        {
            if (routing1 == null && routing2 == null)
            {
                return true;
            }

            if (routing1 == null && routing2 != null)
            {
                return false;
            }

            if (routing1 != null && routing2 == null)
            {
                return false;
            }

            if (routing1.Code == routing2.Code)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public override void Map(Routing.Route route, IContainer container)
        {
            route.ThrowIfNull("route");
            container.ThrowIfNull("container");

            route.ResolveRelativeUrlsUsingString(_relativeUrl);
        }
Пример #4
0
 /// <summary>
 /// 根据Message路由接收端
 /// </summary>
 /// <param name="serviceName"></param>
 /// <param name="msg"></param>
 /// <returns></returns>
 protected virtual Routing Routing(string serviceName, object msg)
 {
     PlugingItem plug = services[serviceName];
     WQMessage imsg = msg as WQMessage; 
     try
     {
         Routing routing = null;
         if (!routings.ContainsKey(plug.RoutingGroupName) || !routings[plug.RoutingGroupName].ContainsKey(imsg.RoutingKey))
         {
             if (plug.GroupName != "")
             {
                 Log.Write(LogAction.Info, className, "Routing", serviceName, -1, "没有找到路由,用GroupName默认代替:plug.GroupName:" + plug.GroupName);
                 routing = new Routing();
                 routing.GroupName = plug.GroupName;
                 return routing;
             }
             return null;
         }
         routing = routings[plug.RoutingGroupName][imsg.RoutingKey];
         Log.Write(LogAction.Info, className, "Routing" , serviceName, -1, imsg.TransactionID+":找到路由:Routing:" + routing);
         return routing;
     }
     catch (Exception e)
     {
         Log.Write(LogAction.Error, className, "Routing", serviceName, -1, "serviceName:" + serviceName + ",msg:" + imsg.TransactionID + ",没有找到路由:plug.RoutingGroupName:" + plug.RoutingGroupName + ",imsg.RoutingKey:" + imsg.RoutingKey + "," + e.ToString());
         return null;
     }
 }
        public void Map(Routing.Route route, IContainer container)
        {
            route.ThrowIfNull("route");
            container.ThrowIfNull("container");

            _mapper.Map(route, container);
        }
Пример #6
0
        public override void Map(Routing.Route route, IContainer container)
        {
            route.ThrowIfNull("route");
            container.ThrowIfNull("container");

            route.RestrictByRefererUrlPorts(_ports);
        }
Пример #7
0
		public override void Map(Routing.Route route, IContainer container)
		{
			route.ThrowIfNull("route");
			container.ThrowIfNull("container");

			route.RestrictByUrlHostTypes(_hostTypes);
		}
Пример #8
0
		private void ApplyOption(IAction action, bool convertToPdf, Routing routing)
        {
            if (!convertToPdf)
            {
                IPolicyChannel smtpChannel = Template[TemplatePolicy.PdfPolicy, ChannelType.SMTP];
                Template.RemoveAction(smtpChannel, routing, action);
            }
        }
Пример #9
0
        public void FindRoute_ThrowsAnExcpetionWhenNotRoutesMatched()
        {
            var routing = new Routing();

            routing.RegisterRoute(_simpleRoute);

            var matchedRoute = routing.FindRoute("ls", new Dictionary<string, string>() { { "path", @"c:\temp\" } });
        }
Пример #10
0
        public void RegisterRoute_ThorwsExceptionWithDuplicateRoutes()
        {
            var routing = new Routing();
            var count = routing.Count;

            routing.RegisterRoute(_simpleRoute);
            routing.RegisterRoute(_simpleRoute);
        }
Пример #11
0
 protected void ODS_Routing_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
 {
     Controls_TextBox tbRegion = ((Controls_TextBox)(this.FV_Routing.FindControl("tbRegion")));
     CodeMstrDropDownList ddlRoutingType = ((CodeMstrDropDownList)(this.FV_Routing.FindControl("ddlRoutingType")));
     routing = (Routing)e.InputParameters[0];
     routing.Type = ddlRoutingType.SelectedValue;
     routing.Region = TheRegionMgr.LoadRegion(tbRegion.Text);
 }
Пример #12
0
        public RouteMatchResult(Routing.Route route, MatchResult result)
        {
            route.ThrowIfNull("route");
            result.ThrowIfNull("result");

            _route = route;
            _matchResult = result;
        }
Пример #13
0
        public void RegisterRoute_CanRegisterASimpleRoute()
        {
            var routing = new Routing();
            var count = routing.Count;

            routing.RegisterRoute(_simpleRoute);

            Assert.AreEqual(count + 1, routing.Count);
        }
Пример #14
0
        public void FindRoute_CanFindASimpleRoute()
        {
            var routing = new Routing();
            routing.RegisterRoute(_simpleRoute);

            var matchedRoute = routing.FindRoute("ls", new Dictionary<string, string>());

            Assert.AreEqual(_simpleRoute, matchedRoute);
        }
Пример #15
0
        public void Map(Func<IContainer> container, Type type, MethodInfo method, Routing.Route route)
        {
            container.ThrowIfNull("container");
            type.ThrowIfNull("type");
            method.ThrowIfNull("method");
            route.ThrowIfNull("route");

            route.RespondWithNoContent();
        }
Пример #16
0
        public void FindRoute_CanFindARouteWithDashInName()
        {
            var routing = new Routing();

            routing.RegisterRoute("import-keys", new Dictionary<string, ParameterType>() { { "path", ParameterType.Required } }, (p, c, s) => { }, "");

            var matchedRoute = routing.FindRoute("import-keys", new Dictionary<string, string>() { { "path", @"c:\temp\" } });

            Assert.AreEqual("import-keys", matchedRoute.Name);
        }
Пример #17
0
        public void RegisterRoute_CanRegisterMultipleRoutesWithTheSameNameButDifferentParameteres()
        {
            var routing = new Routing();
            var count = routing.Count;

            routing.RegisterRoute(_simpleRoute);
            routing.RegisterRoute(_singleParamRoute);

            Assert.AreEqual(count + 2, routing.Count);
        }
Пример #18
0
        public void FindRoute_CanFindARouteWithARequiredParam()
        {
            var routing = new Routing();
            
            routing.RegisterRoute(_simpleRoute);
            routing.RegisterRoute(_singleParamRoute);

            var matchedRoute = routing.FindRoute("ls", new Dictionary<string, string>() { { "path", @"c:\temp\" } });

            Assert.AreEqual(_singleParamRoute, matchedRoute);
        }
Пример #19
0
        public Task MapAsync(Func<IContainer> container, Type type, MethodInfo method, Routing.Route route)
        {
            container.ThrowIfNull("container");
            type.ThrowIfNull("type");
            method.ThrowIfNull("method");
            route.ThrowIfNull("route");

            route.RespondWithNoContent();

            return Task.Factory.Empty();
        }
        public override void Map(Routing.Route route, IContainer container)
        {
            route.ThrowIfNull("route");
            container.ThrowIfNull("container");

            if (_fieldComparer != null && _valueComparer != null)
            {
                route.RestrictByUrlQueryString(_field, GetComparer(_fieldComparer.Value), _value, GetComparer(_valueComparer.Value), _optional);
            }
            else
            {
                route.RestrictByUrlQueryString(_field, _value, _optional);
            }
        }
Пример #21
0
        public override void Map(Routing.Route route, IContainer container)
        {
            route.ThrowIfNull("route");
            container.ThrowIfNull("container");

            if (_valueComparer != null)
            {
                route.RestrictByHeader(_field, _value, GetComparer(_valueComparer.Value));
            }
            else
            {
                route.RestrictByHeader(_field, _value);
            }
        }
        public override void Map(Routing.Route route, IContainer container)
        {
            route.ThrowIfNull("route");
            container.ThrowIfNull("container");

            if (_nameComparer != null && _valueComparer != null)
            {
                route.RestrictByCookie(_name, GetComparer(_nameComparer.Value), _value, GetComparer(_valueComparer.Value), _optional);
            }
            else
            {
                route.RestrictByCookie(_name, _value, _optional);
            }
        }
Пример #23
0
		public override void Map(Routing.Route route, IContainer container)
		{
			route.ThrowIfNull("route");
			container.ThrowIfNull("container");

			if (_comparer != null)
			{
				route.RestrictByRefererUrlHosts(_hosts, GetComparer(_comparer.Value));
			}
			else
			{
				route.RestrictByRefererUrlHosts(_hosts);
			}
		}
        public void Map(Type type, MethodInfo method, Routing.Route route, IContainer container)
        {
            type.ThrowIfNull("type");
            method.ThrowIfNull("method");
            route.ThrowIfNull("route");
            container.ThrowIfNull("container");

            IEnumerable<RelativeUrlResolverAttribute> attributes = method.GetCustomAttributes<RelativeUrlResolverAttribute>(false);

            foreach (RelativeUrlResolverAttribute attribute in attributes)
            {
                attribute.Map(route, container);
            }
        }
Пример #25
0
        public override void Map(Routing.Route route, IContainer container)
        {
            route.ThrowIfNull("route");
            container.ThrowIfNull("container");

            if (_comparer != null)
            {
                route.RestrictByUrlSchemes(_schemes, GetComparer(_comparer.Value));
            }
            else
            {
                route.RestrictByUrlSchemes(_schemes);
            }
        }
        public void Map(Type type, MethodInfo method, Routing.Route route, IContainer container)
        {
            type.ThrowIfNull("type");
            method.ThrowIfNull("method");
            route.ThrowIfNull("route");
            container.ThrowIfNull("container");

            HttpMethod httpMethod;

            if (Enum<HttpMethod>.TryParse(method.Name, true, out httpMethod))
            {
                route.RestrictByMethods(httpMethod);
            }
        }
Пример #27
0
		public override void Map(Routing.Route route, IContainer container)
		{
			route.ThrowIfNull("route");
			container.ThrowIfNull("container");

			var httpRuntime = container.GetInstance<IHttpRuntime>();

			if (_comparer != null)
			{
				route.RestrictByUrlRelativePaths(_relativePaths, GetComparer(_comparer.Value), httpRuntime);
			}
			else
			{
				route.RestrictByUrlRelativePaths(_relativePaths, httpRuntime);
			}
		}
		public Task MapAsync(Type type, MethodInfo method, Routing.Route route, IContainer container)
		{
			type.ThrowIfNull("type");
			method.ThrowIfNull("method");
			route.ThrowIfNull("route");
			container.ThrowIfNull("container");

			HttpMethod httpMethod;
			string methodName = method.Name.TrimEnd("Async");

			if (Enum<HttpMethod>.TryParse(methodName, true, out httpMethod))
			{
				route.RestrictByMethods(httpMethod);
			}

			return Task.Factory.Empty();
		}
        public Task<AuthenticationResult> AuthenticateAsync(HttpRequestBase request, HttpResponseBase response, Routing.Route route)
        {
            request.ThrowIfNull("request");
            response.ThrowIfNull("response");
            route.ThrowIfNull("route");

            if (!_helper.IsTicketValid(request))
            {
                return AuthenticationResult.AuthenticationFailed.AsCompletedTask();
            }

            Cookie cookie = _helper.RenewTicket(request);

            response.Cookies.Remove(cookie.Name);
            response.Cookies.Add(cookie.GetHttpCookie());

            return AuthenticationResult.AuthenticationSucceeded.AsCompletedTask();
        }
        public void Map(Func<IContainer> container, Type type, MethodInfo method, Routing.Route route)
        {
            container.ThrowIfNull("container");
            type.ThrowIfNull("type");
            method.ThrowIfNull("method");
            route.ThrowIfNull("route");

            if (method.ReturnType == typeof(void))
            {
                route.RespondWithNoContent();
                return;
            }
            if (!method.ReturnType.ImplementsInterface<IResponse>())
            {
                throw new ApplicationException(String.Format("The return type of '{0}.{1}' does not implement '{2}'.", type.FullName, method.Name, typeof(IResponse).Name));
            }

            route.RespondWith(
                request =>
                    {
                        object instance;

                        try
                        {
                            instance = container().GetInstance(type);
                        }
                        catch (Exception exception)
                        {
                            throw new ApplicationException(String.Format("Unable to resolve instance of type '{0}'.", type.FullName), exception);
                        }
                        if (instance == null)
                        {
                            throw new ApplicationException(String.Format("Unable to resolve instance of type '{0}'.", type.FullName));
                        }

                        var parameterValueRetriever = new ParameterValueRetriever(_parameterMappers);
                        IEnumerable<object> parameterValues = parameterValueRetriever.GetParameterValues(request, type, method);

                        return (IResponse)method.Invoke(instance, parameterValues.ToArray());
                    },
                method.ReturnType);
        }
Пример #31
0
 public AppShell()
 {
     InitializeComponent();
     Routing.RegisterRoute(nameof(EmptyCase), typeof(EmptyCase));
 }
Пример #32
0
 public AppShell()
 {
     InitializeComponent();
     Routing.RegisterRoute(nameof(LoginPage), typeof(LoginPage));
     BindingContext = App.Container.Resolve <AppShellViewModel>();
 }
Пример #33
0
        private void PopulateList()
        {
            Templates.Clear();

            var assembly = typeof(App).GetTypeInfo().Assembly;
            var stream   = assembly.GetManifestResourceStream(sampleListFile);

            using (var reader = new StreamReader(stream))
            {
                var xmlReader = XmlReader.Create(reader);
                xmlReader.Read();
                Category category        = null;
                var      hasAdded        = false;
                var      runtimePlatform = Device.RuntimePlatform.ToLower();

                while (!xmlReader.EOF)
                {
                    switch (xmlReader.Name)
                    {
                    case "Category" when xmlReader.IsStartElement() && xmlReader.HasAttributes:
                    {
                        if (!hasAdded && category != null)
                        {
                            Templates.Add(category);
                            category = null;
                            hasAdded = true;
                        }

                        var platform = GetDataFromXmlReader(xmlReader, "Platform");
                        if (string.IsNullOrEmpty(platform) || platform.ToLower().Contains(runtimePlatform))
                        {
                            var categoryName = GetDataFromXmlReader(xmlReader, "Name");
                            var description  = GetDataFromXmlReader(xmlReader, "Description");
                            var icon         =
                                $"EssentialUIKit.AppLayout.Icons.{GetDataFromXmlReader(xmlReader, "Icon")}";

                            string updateType = string.Empty;
                            bool   isUpdate   = false;

                            if (null != xmlReader.GetAttribute("IsUpdated"))
                            {
                                if (GetDataFromXmlReader(xmlReader, "IsUpdated") == "True")
                                {
                                    updateType = "Updated";
                                    isUpdate   = true;
                                }
                            }

                            if (null != xmlReader.GetAttribute("IsNew"))
                            {
                                if (GetDataFromXmlReader(xmlReader, "IsNew") == "True")
                                {
                                    updateType = "New";
                                    isUpdate   = true;
                                }
                            }

                            category = new Category(categoryName, icon, description, updateType, isUpdate);
                        }

                        break;
                    }

                    case "Page" when xmlReader.IsStartElement() && xmlReader.HasAttributes && category != null:
                    {
                        var platform = GetDataFromXmlReader(xmlReader, "Platform");

                        if (string.IsNullOrEmpty(platform) || platform.ToLower().Contains(runtimePlatform))
                        {
                            var templateName = GetDataFromXmlReader(xmlReader, "Name");
                            var description  = GetDataFromXmlReader(xmlReader, "Description");
                            var pageName     = GetDataFromXmlReader(xmlReader, "PageName");
                            bool.TryParse(GetDataFromXmlReader(xmlReader, "LayoutFullscreen"),
                                          out var layoutFullScreen);
                            string updateType = string.Empty;
                            bool   isUpdate   = false;

                            if (null != xmlReader.GetAttribute("IsUpdated"))
                            {
                                if (GetDataFromXmlReader(xmlReader, "IsUpdated") == "True")
                                {
                                    updateType = "Updated";
                                    isUpdate   = true;
                                }
                            }

                            if (null != xmlReader.GetAttribute("IsNew"))
                            {
                                if (GetDataFromXmlReader(xmlReader, "IsNew") == "True")
                                {
                                    updateType = "New";
                                    isUpdate   = true;
                                }
                            }

                            var template = new Template(templateName, description, pageName, layoutFullScreen, updateType, isUpdate);
                            Routing.RegisterRoute(templateName,
                                                  assembly.GetType($"EssentialUIKit.{pageName}"));

                            category.Pages.Add(template);
                            hasAdded = false;
                        }

                        break;
                    }
                    }

                    xmlReader.Read();
                }

                if (!hasAdded)
                {
                    Templates.Add(category);
                }
            }
        }
 public AppShell()
 {
     InitializeComponent();
     Routing.RegisterRoute(nameof(ContactDetailPage), typeof(ContactDetailPage));
     Routing.RegisterRoute(nameof(NewContactPage), typeof(NewContactPage));
 }
Пример #35
0
 public AppShell()
 {
     InitializeComponent();
     Routing.RegisterRoute(Constants.Navigation.Paths.Articles, typeof(ArticlesListPage));
     Routing.RegisterRoute(Constants.Navigation.Paths.ArticleDetail, typeof(ArticleDetailPage));
 }
Пример #36
0
 public void RegisterPage(string route, ContentPage contentPage)
 {
     Routing.SetRoute(contentPage, route);
     Routing.RegisterRoute(route, new ConcretePageFactory(contentPage));
 }
Пример #37
0
 private void Button_Clicked(object sender, EventArgs e)
 {
     Routing.RegisterRoute("sk1993", typeof(MainPage));
 }
Пример #38
0
        public AppShell()
        {
            InitializeComponent();

            Routing.RegisterRoute("continent", typeof(ContinentCitiesPage));
        }
Пример #39
0
 private static void RegisterRoute <TViewModel, TPage>(string route)
 {
     _viewModelRoutes.Add(typeof(TViewModel), route);
     Routing.RegisterRoute(route, typeof(TPage));
 }
Пример #40
0
 public AppShell()
 {
     InitializeComponent();
     Routing.RegisterRoute("SubPage", typeof(SubPage));
 }
Пример #41
0
        public void Inference()
        {
            // hide
            var client = TestClient.DisabledStreaming;
            var infer  = client.Infer;
            var parent = new MyParent {
                Id = 1337, MyJoinField = JoinField.Root <MyParent>()
            };

            infer.Routing(parent).Should().Be("1337");

            var child = new MyChild {
                Id = 1338, MyJoinField = JoinField.Link <MyChild>(parentId: "1337")
            };

            infer.Routing(child).Should().Be("1337");

            child = new MyChild {
                Id = 1339, MyJoinField = JoinField.Link <MyChild, MyParent>(parent)
            };
            infer.Routing(child).Should().Be("1337");

            /**
             * here we index `parent` and rather than fishing out the parent id by inspecting `parent` we just pass the instance
             * to `Routing` which can infer the correct routing key based on the JoinField property on the instance
             */
            var indexResponse = client.Index(parent, i => i.Routing(Routing.From(parent)));

            indexResponse.ApiCall.Uri.Query.Should().Contain("routing=1337");

            /**
             * The same goes for when we index a child, we can pass the instance directly to `Routing` and NEST will use the parent id
             * already specified on `child`. Here we use the static import `using static Nest.Infer` and it's `Route()` static method to
             * create an instance of `Routing`
             */
            indexResponse = client.Index(child, i => i.Routing(Route(child)));
            indexResponse.ApiCall.Uri.Query.Should().Contain("routing=1337");

            /** You can always override the default inferred routing though */
            indexResponse = client.Index(child, i => i.Routing("explicit"));
            indexResponse.ApiCall.Uri.Query.Should().Contain("routing=explicit");

            indexResponse = client.Index(child, i => i.Routing(null));
            indexResponse.ApiCall.Uri.Query.Should().NotContain("routing");

            var indexRequest = new IndexRequest <MyChild>(child)
            {
                Routing = Route(child)
            };

            indexResponse = client.Index(indexRequest);
            indexResponse.ApiCall.Uri.Query.Should().Contain("routing=1337");

            /**
             * Its important to note that the routing is resolved at request time, not instantiation time
             * here we update the `child`'s `JoinField` after already creating the index request for `child`
             */
            child.MyJoinField = JoinField.Link <MyChild>(parentId: "something-else");
            indexResponse     = client.Index(indexRequest);
            indexResponse.ApiCall.Uri.Query.Should().Contain("routing=something-else");
        }
Пример #42
0
 void Start()
 {
     Debug.Log("StartJump.JumpTo " + path);
     Routing.JumpTo(path);
 }
Пример #43
0
        public Menu()
        {
            InitializeComponent();

            Routing.RegisterRoute("establishment/detail", typeof(Views.EstablishmentDetail));
        }
Пример #44
0
        public static void Main()
        {
            Debug.EnableGCMessages(false);
            var radarInt = new RadarInterface();

            radarInt.TurnOff();
            Debug.Print(DebuggingSupport.SetupBorder);
            Debug.Print(VersionInfo.VersionBuild(Assembly.GetExecutingAssembly()));
            _lcd.Write("Clnt");

            Thread.Sleep(3000);
            try
            {
                var macBase = SystemGlobal.GetMAC();
                //#warning delete this when fixed
                //				macBase.OnReceive+=(mac, time) => { };
                Debug.Print(DebuggingSupport.MacInfo(macBase));
                Debug.Print(DebuggingSupport.SetupBorder);

                macBase.OnNeighborChange += Routing.Routing_OnNeighborChange;

                // Set up serial & pass it on to the components that need it
                var serialComm = new SerialComm("COM1", AppMsgHandler.SerialCallback_client_node);
                temComm = serialComm;
                serialComm.Open();

                if (macBase is OMAC)
                {
                    const int waitForMac = 30;
#if !DBG_LOGIC
                    Debug.Print("Waiting " + waitForMac + " sec");
#endif
                    Thread.Sleep(waitForMac * 1000);
                }

                // Initialize System Global
                SystemGlobal.Initialize(SystemGlobal.NodeTypes.Client);

                // Set up the local manager
                //LocalServer.Initialize(macBase, Lcd, SensorNodeGlobal.PinDefs.EnactResetPort);
                //LocalServer.Initialize(macBase, null);

                // Initialize shared vars
                VersionInfo.Initialize(Assembly.GetExecutingAssembly());

                // Set the app version
                //LocalManagerGlobal.Shared.SharedVars.ProgramVersion = VersionInfo.AppVersion;

                //Initialize routing
                var routing = new Routing(macBase, null, 1);

                // Allow additional sleep to "time-shift" routing and heartbeats (NetManager)
                const int additionalSleep = 60;
#if !DBG_LOGIC
                Debug.Print("Additional sleep to \"time-shift\" routing and heartbeats (NetManager)");
#endif
                Thread.Sleep(additionalSleep * 1000);

                // Initialize application message handler
                AppMsgHandler.Initialize(macBase, _lcd, serialComm, SendPacketInterval);

                // Initialize the Net Manager
                NetManager.Initialize(macBase);

                // Initialize the Neighborhood Manager
                NeighborInfoManager.Initialize(macBase);

                // Sleep forever
                Thread.Sleep(Timeout.Infinite);
            }

            catch (Exception ex)
            {
                Debug.Print("System exception " + ex);
            }
        }
Пример #45
0
 void RegisterRoutes()
 {
     Routing.RegisterRoute("countryDetailsPage", typeof(CountryDetailsPage));
     Routing.RegisterRoute("compareCountriesPage", typeof(CompareCountriesPage));
 }
Пример #46
0
 protected void OnStartPositionClick(object sender, RouteMapEventArgs e)
 {
     Routing.SetStartMarker(e.ClickPosition);
 }
Пример #47
0
 public override void TearDown()
 {
     base.TearDown();
     Routing.Clear();
 }
 private void Register()
 {
     Routing.RegisterRoute("RegisterPage", typeof(RegisterPage));
     Shell.Current.GoToAsync("registerpage");
 }
Пример #49
0
 public AppShell()
 {
     InitializeComponent();
     Routing.RegisterRoute(nameof(ItemDetailPage), typeof(ItemDetailPage));
     Routing.RegisterRoute(nameof(NewItemPage), typeof(NewItemPage));
 }
Пример #50
0
        public async Task RelativeGoTo()
        {
            Routing.RegisterRoute("RelativeGoTo_Page1", typeof(ContentPage));
            Routing.RegisterRoute("RelativeGoTo_Page2", typeof(ContentPage));

            var shell = new Shell
            {
            };

            var one = new ShellItem {
                Route = "one"
            };
            var two = new ShellItem {
                Route = "two"
            };

            var tab11 = MakeSimpleShellSection("tab11", "content");
            var tab12 = MakeSimpleShellSection("tab12", "content");
            var tab21 = MakeSimpleShellSection("tab21", "content");
            var tab22 = MakeSimpleShellSection("tab22", "content");
            var tab23 = MakeSimpleShellSection("tab23", "content");

            one.Items.Add(tab11);
            one.Items.Add(tab12);

            two.Items.Add(tab21);
            two.Items.Add(tab22);
            two.Items.Add(tab23);

            shell.Items.Add(one);
            shell.Items.Add(two);

            await shell.GoToAsync("//two/tab21/");

            await shell.NavigationManager.GoToAsync("/tab22", false, true);

            Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("//two/tab22/content"));

            await shell.NavigationManager.GoToAsync("tab21", false, true);

            Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("//two/tab21/content"));

            await shell.NavigationManager.GoToAsync("/tab23", false, true);

            Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("//two/tab23/content"));

            await shell.GoToAsync("RelativeGoTo_Page1", false);

            Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("//two/tab23/content/RelativeGoTo_Page1"));

            await shell.GoToAsync("../RelativeGoTo_Page2", false);

            Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("//two/tab23/content/RelativeGoTo_Page2"));

            await shell.GoToAsync("..", false);

            Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("//two/tab23/content"));

            /*
             * removing support for .. notation for now
             * await shell.GoToAsync("../one/tab11");
             * Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("app:///s/one/tab11/content/"));
             *
             * await shell.GoToAsync("/eee/hm../../../../two/../one/../two/tab21");
             * Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("app:///s/two/tab21/content/"));
             *
             * await shell.GoToAsync(new ShellNavigationState("../one/tab11"));
             * Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("app:///s/one/tab11/content/"));
             *
             * await shell.GoToAsync(new ShellNavigationState($"../two/tab23/content?{nameof(ShellTestPage.SomeQueryParameter)}=1234"));
             * Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("app:///s/two/tab23/content/"));
             * Assert.AreEqual("1234", (two.CurrentItem.CurrentItem.Content as ShellTestPage).SomeQueryParameter);
             *
             * await shell.GoToAsync(new ShellNavigationState($"../one/tab11#fragment"));
             * Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo("app:///s/one/tab11/content/"));
             */
        }
Пример #51
0
        void MapMenuItems()
        {
            // NavigationView makes a lot of changes to properties before it's been loaded
            // So we like to just wait until it's loaded to project our changes over it
            if (!ShellItemNavigationView.IsLoaded)
            {
                return;
            }

            IShellItemController shellItemController = VirtualView;
            var items = new List <BaseShellItem>();

            // only add items if we should be showing the tabs
            if (shellItemController.ShowTabs)
            {
                foreach (var item in shellItemController.GetItems())
                {
                    if (Routing.IsImplicit(item))
                    {
                        items.Add(item.CurrentItem);
                    }
                    else
                    {
                        items.Add(item);
                    }
                }
            }

            object?selectedItem = null;

            _mainLevelTabs.SyncItems(items, (navItem, baseShellItem) =>
            {
                SetValues(baseShellItem, navItem);

                if (baseShellItem is not ShellSection shellSection)
                {
                    navItem.MenuItemsSource = null;
                    if (baseShellItem.Parent == VirtualView.CurrentItem)
                    {
                        selectedItem = navItem;
                    }

                    return;
                }

                var shellSectionItems = ((IShellSectionController)shellSection).GetItems();

                if (shellSection == VirtualView.CurrentItem)
                {
                    selectedItem = navItem;
                }

                if (shellSectionItems.Count <= 1)
                {
                    if (navItem.MenuItemsSource != null)
                    {
                        navItem.MenuItemsSource = null;
                    }
                }
                else
                {
                    navItem.MenuItemsSource ??= new ObservableCollection <NavigationViewItemViewModel>();
                    navItem
                    .MenuItemsSource
                    .SyncItems(shellSectionItems, (shellContentNavItem, shellContent) =>
                    {
                        SetValues(shellContent, shellContentNavItem);

                        if (shellSection == VirtualView.CurrentItem &&
                            shellContent == VirtualView.CurrentItem.CurrentItem)
                        {
                            selectedItem = shellContentNavItem;
                        }
                    });
                }

                void SetValues(BaseShellItem bsi, NavigationViewItemViewModel vm)
                {
                    vm.Content     = bsi.Title;
                    var iconSource = bsi.Icon?.ToIconSource(MauiContext !);

                    if (iconSource != null)
                    {
                        if (vm.Foreground != null)
                        {
                            iconSource.Foreground = vm.Foreground;
                        }
                        else if (PlatformView.Resources.TryGetValue("NavigationViewItemForeground", out object nviForeground) &&
                                 nviForeground is WBrush brush)
                        {
                            iconSource.Foreground = brush;
                        }
                    }

                    vm.Icon = iconSource?.CreateIconElement();
                }
            });
Пример #52
0
 async private void CreateCharacterClick(object sender, EventArgs e)
 {
     Routing.RegisterRoute("NewCharacterPage", typeof(NewCharacterPage));
     await Shell.Current.GoToAsync("NewCharacterPage");
 }
Пример #53
0
        public static void Main()
        {
            Samraksh.eMote.RadarInterface radarInt = new Samraksh.eMote.RadarInterface();
            radarInt.TurnOff();
            Debug.Print(DebuggingSupport.SetupBorder); //===================
            Debug.EnableGCMessages(false);             // We don't want to see garbage collector messages in the Output window

            Debug.Print(VersionInfo.VersionBuild(Assembly.GetExecutingAssembly()));
            Thread.Sleep(3000);

            _lcd.Write("Base");

            try
            {
                var macBase = SystemGlobal.GetMAC();

                Debug.Print(DebuggingSupport.MacInfo(macBase));
                Debug.Print(DebuggingSupport.SetupBorder);                      //===================
                macBase.OnNeighborChange += Routing.Routing_OnNeighborChange;
                //macBase.OnReceiveAll += macBase_OnReceiveAll;

                // Set up serial & pass it on to the components that need it
                var serialComm = new SerialComm("COM1", AppMsgHandler.SerialCallback_base_node);
                serialComm.Open();

                // Periodically send Base Watchdog message to PC
                //		This is similar to Heartbeat in Net Manager but does not indicate network liveness.
                //		Instead, it is used
                //		- by the PC Visualizer Data Collector to determine if the Base node is connected to the PC and is running
                //		- by Visualizer to determine if Data Collector is running and connected to the Base node
                var baseWatchdogTimer = new SimplePeriodicTimer(callBackValue =>
                {
                    var msg = BaseGlobal.PCMessages.Compose.BaseWatchdog(_baseLiveMsgNum);
                    _baseLiveMsgNum++;
                    serialComm.Write(msg);
                }, null, 0, BaseGlobal.BaseWatchdogIntervalMs);
                baseWatchdogTimer.Start();

                if (macBase is OMAC)
                {
                    const int waitForMac = 30;
#if !DBG_LOGIC
                    Debug.Print("\tWaiting " + waitForMac + " sec");
#endif
                    Thread.Sleep(waitForMac * 1000);
                }

                // Initialize System Global
                SystemGlobal.Initialize(SystemGlobal.NodeTypes.Base);

                // Initialize routing
                var routing = new Routing(macBase, null);

                // Allow additional sleep to "time-shift" routing and heartbeats (NetManager)
                Thread.Sleep(60 * 1000);

                // Initialize application message handler
                AppMsgHandler.Initialize(macBase, _lcd, serialComm);

                // Initialize network manager
                NetManager.Initialize(macBase, serialComm);

                // Initialize neighborhood manager
                NeighborInfoManager.Initialize(macBase, serialComm);
            }
            catch
            {
                //Lcd.Write("Err");
                //Thread.Sleep(Timeout.Infinite);
            }

            // Sleep forever
            Thread.Sleep(Timeout.Infinite);
        }
Пример #54
0
 public AppShell()
 {
     InitializeComponent();
     Routing.RegisterRoute(nameof(ResultPage), typeof(ResultPage));
     Routing.RegisterRoute(nameof(ErrorPage), typeof(ErrorPage));
 }
Пример #55
0
 void RegisterRoutes()
 {
     Routing.RegisterRoute("Tasks/AddTask", typeof(AddTaskPage));
 }
 private void Recovery()
 {
     Routing.RegisterRoute("RecoverPswPage", typeof(RecoverPswPage));
     Shell.Current.GoToAsync("recoverpswpage");
 }
Пример #57
0
 public override RoutingDetail LoadRoutingDetail(Routing routing, int operation, string reference)
 {
     return(LoadRoutingDetail(routing.Code, operation, reference));
 }
Пример #58
0
 public IList <RoutingDetail> GetRoutingDetail(Routing routing, DateTime effectiveDate)
 {
     return(GetRoutingDetail(routing.Code, effectiveDate));
 }
Пример #59
0
        /// <summary>
        /// 获取映射
        /// </summary>
        /// <returns></returns>
        public static List <Routing> GetMapping()
        {
            List <Routing> routings = new List <Routing>();

            _areaCollection.RegistAll();

            var types = RouteTable.Types;

            foreach (var item in types)
            {
                var instance = Activator.CreateInstance(item);

                List <IFilter> iAttrs = null;

                //类上面的过滤
                var classAttrs = item.GetCustomAttributes(true);

                if (classAttrs != null && classAttrs.Length > 0)
                {
                    var actionAttrs = classAttrs.Where(b => b.GetType().BaseType.Name == ConstHelper.ACTIONFILTERATTRIBUTE).ToList().ConvertAll(b => b as IFilter);

                    if (actionAttrs != null && actionAttrs.Count > 0)
                    {
                        iAttrs = actionAttrs.OrderBy(b => b.Order).ToList();
                    }
                }

                var actions = item.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

                foreach (var action in actions)
                {
                    var getRouting = new Routing()
                    {
                        ActionName  = action.Name,
                        Instance    = (Controller)instance,
                        FilterAtrrs = iAttrs,
                        Action      = action,
                        IsPost      = false
                    };

                    var postRouting = new Routing()
                    {
                        ActionName  = action.Name,
                        Instance    = (Controller)instance,
                        FilterAtrrs = iAttrs,
                        Action      = action,
                        IsPost      = true
                    };

                    var pas = action.GetParameters();

                    if (pas != null && pas.Any())
                    {
                        getRouting.ParmaTypes  = new Dictionary <string, Type>();
                        postRouting.ParmaTypes = new Dictionary <string, Type>();
                        foreach (var pa in pas)
                        {
                            getRouting.ParmaTypes.Add(pa.Name, pa.ParameterType);
                            postRouting.ParmaTypes.Add(pa.Name, pa.ParameterType);
                        }
                    }


                    //action上面的过滤
                    var actionAttrs = action.GetCustomAttributes(true);

                    if (actionAttrs != null && actionAttrs.Length > 0)
                    {
                        var filterAttrs = actionAttrs.Where(b => b.GetType().BaseType.Name == ConstHelper.ACTIONFILTERATTRIBUTE).ToList();

                        if (filterAttrs != null && filterAttrs.Count > 0)
                        {
                            var ifilters = actionAttrs.ToList().ConvertAll(b => b as IFilter);
                            getRouting.ActionFilterAtrrs = postRouting.ActionFilterAtrrs = ifilters.OrderBy(b => b.Order).ToList();
                        }

                        var dPost = actionAttrs.Where(b => b.GetType().Name == ConstHelper.HTTPPOST).FirstOrDefault();
                        if (dPost != null)
                        {
                            routings.Add(postRouting);
                        }
                        var dGet = actionAttrs.Where(b => b.GetType().Name == ConstHelper.HTTPGET).FirstOrDefault();
                        if (dGet != null)
                        {
                            routings.Add(getRouting);
                        }
                    }
                    else
                    {
                        routings.Add(getRouting);
                        routings.Add(postRouting);
                    }
                }
            }
            return(routings);
        }
Пример #60
0
 public AppShell()
 {
     InitializeComponent();
     Routing.RegisterRoute(nameof(WorkoutDetailPage), typeof(WorkoutDetailPage));
     Routing.RegisterRoute(nameof(AllWorkoutsPage), typeof(AllWorkoutsPage));
 }