示例#1
0
        private void Run(Options options)
        {
            var iisManager = new ServerManager();

            _iis = new IisController(iisManager);

            var iif = new IISFilter(iisManager, options.Regex)
            {
                FilterBindings = options.UseBindingsView
            };
            var filtered = GetFiltered(options, iif)?.ToList();

            if (iif.HasResult)
            {
                Display(filtered, options);
                return;
            }

            // handle shordhand for "iis VALUE" = "iis -b VALUE"
            if (!string.IsNullOrEmpty(options.Value))
            {
                options.Binding = options.Value;
                iif.WhereBinding(options.ValueFilter);
                Display(iif.Result.ToList(), options);
            }

            // handle empty value
            if (string.IsNullOrEmpty(options.Value))
            {
                Console.WriteLine(options.GetUsage());
                return;
            }
        }
示例#2
0
        private IEnumerable <FilterSite> GetFiltered(Options options, IISFilter iif)
        {
            using (new Watch("Filter")) {
                iif.Condition = options.UseAndCondition ? FilterCondition.And : FilterCondition.Or;

                // single filter
                if (options.Id != null)
                {
                    iif.WhereId(options.IdFilter);
                }

                // multi filter
                if (options.Name.HasValue())
                {
                    iif.WhereName(options.NameFilter);
                }
                if (options.Binding.HasValue())
                {
                    iif.WhereBinding(options.BindingFilter);
                }
                if (options.State.HasValue())
                {
                    iif.WhereState(options.StateFilter);
                }
                if (options.Ip.HasValue())
                {
                    iif.WhereIp(options.IpFilter);
                }

                // search flags
                if (options.Https)
                {
                    iif.WhereHttps();
                }
                else if (options.Sni)
                {
                    iif.WhereSni();
                }
                else if (options.CentralCertStore)
                {
                    iif.WhereCentralCertStore();
                }
                else if (options.HttpsNone)
                {
                    iif.WhereHttpsNone();
                }

                return(iif.Result);
            }
        }