コード例 #1
0
        public override void ExecuteCmdlet()
        {
            IotHubDescription iotHubDescription;

            if (ParameterSetName.Equals(InputObjectTestRouteParameterSet) || ParameterSetName.Equals(InputObjectTestAllRouteParameterSet))
            {
                this.ResourceGroupName = this.InputObject.Resourcegroup;
                this.Name         = this.InputObject.Name;
                iotHubDescription = IotHubUtils.ConvertObject <PSIotHub, IotHubDescription>(this.InputObject);
            }
            else
            {
                if (ParameterSetName.Equals(ResourceIdTestRouteParameterSet) || ParameterSetName.Equals(ResourceIdTestAllRouteParameterSet))
                {
                    this.ResourceGroupName = IotHubUtils.GetResourceGroupName(this.ResourceId);
                    this.Name = IotHubUtils.GetIotHubName(this.ResourceId);
                }

                iotHubDescription = this.IotHubClient.IotHubResource.Get(this.ResourceGroupName, this.Name);
            }

            RoutingMessage routingMessage = new RoutingMessage(this.Body, this.AppProperty != null ? this.AppProperty.Cast <DictionaryEntry>().ToDictionary(kvp => (string)kvp.Key, kvp => (string)kvp.Value) : null, this.SystemProperty != null ? this.SystemProperty.Cast <DictionaryEntry>().ToDictionary(kvp => (string)kvp.Key, kvp => (string)kvp.Value) : null);

            switch (ParameterSetName)
            {
            case InputObjectTestRouteParameterSet:
            case ResourceIdTestRouteParameterSet:
            case TestRouteParameterSet:
                TestRouteInput testRouteInput = new TestRouteInput();
                testRouteInput.Message = routingMessage;
                testRouteInput.Route   = iotHubDescription.Properties.Routing.Routes.FirstOrDefault(x => x.Name.Equals(this.RouteName, StringComparison.OrdinalIgnoreCase));
                PSTestRouteResult psTestRouteResult = IotHubUtils.ToPSTestRouteResult(this.IotHubClient.IotHubResource.TestRoute(testRouteInput, this.Name, this.ResourceGroupName));
                if (this.ShowError.IsPresent && psTestRouteResult.Details != null)
                {
                    this.WriteObject(psTestRouteResult.Details.CompilationErrors, true);
                }
                else
                {
                    this.WriteObject(psTestRouteResult, false);
                }
                break;

            case InputObjectTestAllRouteParameterSet:
            case ResourceIdTestAllRouteParameterSet:
            case TestAllRouteParameterSet:
                TestAllRoutesInput testAllRoutesInput = new TestAllRoutesInput();
                testAllRoutesInput.RoutingSource = this.Source.ToString();
                testAllRoutesInput.Message       = routingMessage;
                this.WriteObject(IotHubUtils.ToPSRouteProperties(this.IotHubClient.IotHubResource.TestAllRoutes(testAllRoutesInput, this.Name, this.ResourceGroupName).Routes), true);
                break;
            }
        }
コード例 #2
0
 private void HandleNavigation(RoutingMessage navigationMessage)
 {
     Messenger.Default.Send(new RoutingMessage(navigationMessage.ViewModelName, navigationMessage.ItemId));
 }