Esempio n. 1
0
        protected override IServiceManagement CreateChannel()
        {
            // If ShareChannel is set by a unit test, use the same channel that
            // was passed into out constructor.  This allows the test to submit
            // a mock that we use for all network calls.
            if (ShareChannel)
            {
                return(Channel);
            }

            var messageInspectors = new List <IClientMessageInspector>
            {
                new ServiceManagementClientOutputMessageInspector(),
                new HttpRestMessageInspector(this.WriteDebug)
            };

            var clientOptions = new ServiceManagementClientOptions(null, null, null, 0, RetryPolicy.NoRetryPolicy, ServiceManagementClientOptions.DefaultOptions.WaitTimeForOperationToComplete, messageInspectors);
            var smClient      = new ServiceManagementClient(new Uri(this.ServiceEndpoint), CurrentSubscription.SubscriptionId, CurrentSubscription.Certificate, clientOptions);

            Type         serviceManagementClientType = typeof(ServiceManagementClient);
            PropertyInfo propertyInfo = serviceManagementClientType.GetProperty("SyncService", BindingFlags.Instance | BindingFlags.NonPublic);
            var          syncService  = (IServiceManagement)propertyInfo.GetValue(smClient, null);

            return(syncService);
        }
Esempio n. 2
0
        private ManagementClient(string baseUrl, IRestConnection restConnection)
        {
            restConnection.Setup(baseUrl, null);

            User    = new UserManagementClient(baseUrl, restConnection);
            Company = new CompanyManagementClient(restConnection);
            Service = new ServiceManagementClient(restConnection);
            Network = new NetworkManagementClient(restConnection);
            Device  = new DeviceManagementClient(restConnection);
            TelemetryDataSinksMetadata = new TelemetryDataSinksMetadataClient(restConnection);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            // Create the client for the service
            var client = new ServiceManagementClient();

            Console.WriteLine("-------------WCF Client Application--------------\n");

            while (!ShouldQuitApplication())
            {
                try
                {
                    Console.WriteLine(client.ComputeResponse("Hello World"));
                }
                catch (CommunicationException e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    Exception ex = e.InnerException;
                    while (ex != null)
                    {
                        Console.WriteLine("===========================");
                        Console.WriteLine(ex.Message);
                        Console.WriteLine(ex.StackTrace);
                        ex = ex.InnerException;
                    }
                }
                catch (TimeoutException)
                {
                    Console.WriteLine("Timed out...");
                }
                catch (Exception e)
                {
                    Console.WriteLine("An unexpected exception occurred.");
                    Console.WriteLine(e.StackTrace);
                }
            }

            client.Close();

            if (client != null)
            {
                client.Abort();
            }
        }