Exemple #1
0
        public static void PerformTest()
        {
            var client = new EnumerationClient(Optimize, "http://localhost:12345/Enumeration");

            client.BindFilterDialect(FilterMap.DefaultDialect, typeof(JmxNotificationFilter));

            int countEstimate = client.EstimateCount("http://tempuri.org", new Filter(FilterMap.DefaultDialect, new JmxNotificationFilter()));

            Console.WriteLine("Client: Total items estimate: {0}", countEstimate);

            foreach (EndpointReference item in client.EnumerateEPR("http://tempuri.org", new Filter(FilterMap.DefaultDialect, new JmxNotificationFilter()), BatchSize))
            {
                Console.WriteLine("Client: Got item {0}", item);
            }
        }
        private EnumerationClient CreateClient(NativeDestinationOptions options, string queryDialect)
        {
            string serverName = string.IsNullOrEmpty(options.ServerName) ? "localhost" : options.ServerName;

            serverName = "localhost";
            int    port    = options.DestinationPort <= 0 ? 5985 : options.DestinationPort;
            string prefix  = string.IsNullOrEmpty(options.UrlPrefix) ? "http://" : options.UrlPrefix;
            var    binding = new WSManBinding();
            ChannelFactory <IWSEnumerationContract> cf = new ChannelFactory <IWSEnumerationContract>(binding);

            cf.Credentials.UserName.UserName = options.UserName;
            cf.Credentials.UserName.Password = options.Password;

            EnumerationClient client = new EnumerationClient(true, new Uri(string.Format("{0}{1}:{2}/wsman", prefix, serverName, port)), cf);

            client.BindFilterDialect(queryDialect, typeof(CimEnumerationFilter));
            return(client);
        }