Exemplo n.º 1
0
        public void Bindings(List <FilterSite> filterd, Options opt)
        {
            using (new Watch("print")) {
                var datas = filterd.SelectMany(x => x.Bindings.Select(b => new {
                    x.Id,
                    x.Name,
                    x.State,
                    b.Host,
                    b.EndPoint,
                    b.Protocol,
                    SslFlags = b.SslFlags()
                })).ToList();
                var nameLan     = filterd.Any() ? filterd.Max(x => x.Name.Length) : 0;
                var protocolLan = datas.Any() ? datas.Max(x => x.Protocol.Length) : 0;

                ConsoleEx.PrintWithPaging(
                    list: datas,
                    countAll: _iisManager.Sites.Count,
                    header: ConsoleWriter.CreateLine("   ID │"),
                    line: (x, i) => new ConsoleWriter()
                    .FormatLine("{id,5} │ {name,-" + nameLan + "} {protocol,-" + protocolLan + "} {ssl} {ip}:{port,-4} {host}", p => p
                                .Add("id", opt.IdFilter.GetMatch(x.Id), opt.Id.HasValue)
                                .Add("name", opt.NameFilter.GetMatch(x.Name), opt.Name.HasValue())
                                .Add("ip", opt.IpFilter.GetMatch(GetAddress(x.EndPoint)), opt.Ip.HasValue())
                                .Add("port", GetPort(x.EndPoint))
                                .Add("host", opt.BindingFilter.GetMatch(x.Host), opt.Binding.HasValue())
                                .Add("protocol", x.Protocol)
                                .Add("ssl", GetSslString(x.SslFlags))
                                )
                    );
            }
        }
Exemplo n.º 2
0
        public void List(List <FilterSite> filterd, Options opt)
        {
            using (new Watch("print")) {
                var protocolLan = filterd.Any() ? filterd.Max(x => x.Bindings.Max(b => b.Protocol.Length)) : 0;

                ConsoleEx.PrintWithPaging(
                    list: filterd,
                    countAll: _iisManager.Sites.Count,
                    header: ConsoleWriter.CreateLine("   ID │"),
                    line: (x, i) => new ConsoleWriter()
                    .FormatLine("{id,5} │ {state,-9} {name}", p => p
                                .Add("id", opt.IdFilter.GetMatch(x.Id), opt.Id.HasValue)
                                .Add("state", opt.StateFilter.GetMatch(x.State), opt.State.HasValue())
                                .Add("name", opt.NameFilter.GetMatch(x.Name), opt.Name.HasValue())
                                )
                    .FormatLines("      │   {protocol,-" + protocolLan + "} {ssl} {ip}:{port,-4} {host}", x.Bindings, (b, parms) => parms
                                 //.Add("schema", b.Schema.Name)
                                 .Add("ip", opt.IpFilter.GetMatch(GetAddress(b.EndPoint)), opt.Ip.HasValue())
                                 .Add("port", GetPort(b.EndPoint))
                                 .Add("host", opt.BindingFilter.GetMatch(b.Host), opt.Binding.HasValue())
                                 .Add("protocol", b.Protocol)
                                 .Add("ssl", GetSslString(b.SslFlags()))
                                 )
                    .WriteLine()
                    );
            }
        }
Exemplo n.º 3
0
        public void AppendTest()
        {
            var writer = new ConsoleWriter();

            writer.Append(ConsoleWriter.CreateLine("test-1"));
            writer.Append(ConsoleWriter.CreateLine("test-2.1").WriteLine("test-2.2").WriteLine("test-2.3"));
            writer.Append(ConsoleWriter.Create("test-3 - "));
            writer.Append(ConsoleWriter.CreateLine("test-4.1").Write("test-4.2 - ").WriteLine("test-4.3"));

            writer.Write("Hallo - ");
            writer.Write("Test ");
            writer.WriteLine("test {0}", "hoi");

            AssertLineEndings(writer);
        }
Exemplo n.º 4
0
 private void Print(List <HostModel> filterd, int countall, FilterProp what)
 {
     using (new Watch("print")) {
         ConsoleEx.PrintWithPaging(
             list: filterd,
             countAll: countall,
             header: ConsoleWriter.CreateLine(" Line |"),
             line: (x, nr) => new ConsoleWriter()
             .FormatLine("{line,6}|{disabled} {ip}   {domain}    {comment}", parms => parms
                         .Add("line", x.LineNumber, what == FilterProp.Line)
                         .Add("disabled", x.IsDisabled ? "#" : "")
                         .Add("ip", x.Ip, what == FilterProp.Domain)
                         .Add("domain", x.Domain, what == FilterProp.Domain)
                         .Add("comment", x.Commentar, what == FilterProp.Commentar)
                         )
             );
     }
 }
Exemplo n.º 5
0
        public void Sites(List <FilterSite> filterd, Options opt)
        {
            using (new Watch("print")) {
                var nameLan = filterd.Any() ? filterd.Max(x => x.Name.Length) : 0;

                ConsoleEx.PrintWithPaging(
                    list: filterd,
                    countAll: _iisManager.Sites.Count,
                    header: ConsoleWriter.CreateLine("   ID │"),
                    line: (x, i) => new ConsoleWriter()
                    .FormatLine("{id,5} │ {state,-9} {name,-" + nameLan + "} bindings: {bindins-count}", p => p
                                .Add("id", opt.IdFilter.GetMatch(x.Id), opt.Id.HasValue)
                                .Add("state", opt.StateFilter.GetMatch(x.State), opt.State.HasValue())
                                .Add("name", opt.NameFilter.GetMatch(x.Name), opt.Name.HasValue())
                                .Add("bindins-count", x.Bindings.Count)
                                )
                    );
            }
        }