.NET CIL Browser - CilBrowser.Core

Type: CilBrowser.Core.SourceServer

Types in CilBrowser.Core namespace:

AssemblyServer

CilBrowserOptions

FileUtils

HtmlAttribute

HtmlBuilder

HtmlGenerator

ServerBase

SourceServer

Utils

WebsiteGenerator

.class public auto ansi sealed beforefieldinit CilBrowser.Core.SourceServer
extends CilBrowser.Core.ServerBase
{

 .field private string _baseDirectory
 .field private class CilBrowser.Core.HtmlGenerator _gen
 .field private class CilBrowser.Core.CilBrowserOptions _options
 .field private class [netstandard]System.Collections.Generic.HashSet`1<string> _sourceExtensions
 .field private class [netstandard]System.Collections.Generic.Dictionary`2<string, uint8[]> _resources

 .method public hidebysig specialname rtspecialname instance void .ctor(
     string baseDirectory, 
     class CilBrowser.Core.CilBrowserOptions options, 
     string urlHost, 
     string urlPrefix
 ) cil managed
 {
  .maxstack  3
  .locals  init (class [netstandard]System.Reflection.Assembly V_0,
     uint8[] V_1)

           ldarg.0      
           ldarg.3      
           ldarg.s      urlPrefix
           call         instance void CilBrowser.Core.ServerBase::.ctor(string, string)
           nop          
           nop          
           ldarg.0      
           ldarg.1      
           stfld        string CilBrowser.Core.SourceServer::_baseDirectory
           ldarg.0      
           ldarg.2      
           stfld        class CilBrowser.Core.CilBrowserOptions CilBrowser.Core.SourceServer::_options
           ldarg.0      
           newobj       instance void CilBrowser.Core.HtmlGenerator::.ctor()
           stfld        class CilBrowser.Core.HtmlGenerator CilBrowser.Core.SourceServer::_gen
           ldarg.0      
           ldarg.0      
           ldfld        class CilBrowser.Core.CilBrowserOptions CilBrowser.Core.SourceServer::_options
           callvirt     instance class [netstandard]System.Collections.Generic.HashSet`1<string> CilBrowser.Core.CilBrowserOptions::get_SourceExtensions()
           stfld        class [netstandard]System.Collections.Generic.HashSet`1<string> CilBrowser.Core.SourceServer::_sourceExtensions
           ldarg.0      
           ldc.i4.2     
           newobj       instance void class [netstandard]System.Collections.Generic.Dictionary`2<string, uint8[]>::.ctor(int32)
           stfld        class [netstandard]System.Collections.Generic.Dictionary`2<string, uint8[]> CilBrowser.Core.SourceServer::_resources
           ldtoken      CilBrowser.Core.WebsiteGenerator
           call         class [netstandard]System.Type [netstandard]System.Type::GetTypeFromHandle(valuetype [netstandard]System.RuntimeTypeHandle)
           callvirt     instance class [netstandard]System.Reflection.Assembly [netstandard]System.Type::get_Assembly()
           stloc.0      
           ldloc.0      
           ldstr        "CilBrowser.Core.Images"
           ldstr        "dir.png"
           call         uint8[] CilBrowser.Core.FileUtils::ReadFromResource(class [netstandard]System.Reflection.Assembly, string, string)
           stloc.1      
           ldarg.0      
           ldfld        class [netstandard]System.Collections.Generic.Dictionary`2<string, uint8[]> CilBrowser.Core.SourceServer::_resources
           ldstr        "dir.png"
           ldloc.1      
           callvirt     instance void class [netstandard]System.Collections.Generic.Dictionary`2<string, uint8[]>::set_Item(!0, !1)
           nop          
           ldloc.0      
           ldstr        "CilBrowser.Core.Images"
           ldstr        "file.png"
           call         uint8[] CilBrowser.Core.FileUtils::ReadFromResource(class [netstandard]System.Reflection.Assembly, string, string)
           stloc.1      
           ldarg.0      
           ldfld        class [netstandard]System.Collections.Generic.Dictionary`2<string, uint8[]> CilBrowser.Core.SourceServer::_resources
           ldstr        "file.png"
           ldloc.1      
           callvirt     instance void class [netstandard]System.Collections.Generic.Dictionary`2<string, uint8[]>::set_Item(!0, !1)
           nop          
           ret          
 }

 .method family hidebysig virtual instance void OnStart() cil managed
 {
  .maxstack  8

           nop          
           ldstr        "Base source directory: "
           ldarg.0      
           ldfld        string CilBrowser.Core.SourceServer::_baseDirectory
           call         string [netstandard]System.String::Concat(string, string)
           call         void [netstandard]System.Console::WriteLine(string)
           nop          
           ret          
 }

 .method private hidebysig instance void RenderToc(
     string dir, 
     bool topLevel, 
     class [netstandard]System.Net.HttpListenerResponse response
 ) cil managed
 {
  .maxstack  4
  .locals  init (class [netstandard]System.IO.StreamWriter V_0,
     class CilBrowser.Core.HtmlBuilder V_1,
     bool V_2,
     class [netstandard]System.IO.StreamWriter V_3,
     string V_4,
     string[] V_5,
     string[] V_6,
     bool V_7,
     bool V_8,
     bool V_9,
     int32 V_10,
     string V_11,
     string V_12,
     bool V_13,
     bool V_14)

           nop          
           ldarg.1      
           call         bool [netstandard]System.IO.Directory::Exists(string)
           ldc.i4.0     
           ceq          
           stloc.2      
           ldloc.2      
           brfalse.s    IL_0001
           nop          
           ldarg.3      
           ldc.i4       404
           ldstr        "Not found"
           call         void CilBrowser.Core.ServerBase::SendErrorResponse(class [netstandard]System.Net.HttpListenerResponse, int32, string)
           nop          
           br           IL_0010
  IL_0001: ldarg.3      
           ldstr        "text/html; charset=utf-8"
           callvirt     instance void [netstandard]System.Net.HttpListenerResponse::set_ContentType(string)
           nop          
           ldarg.3      
           callvirt     instance class [netstandard]System.IO.Stream [netstandard]System.Net.HttpListenerResponse::get_OutputStream()
           newobj       instance void [netstandard]System.IO.StreamWriter::.ctor(class [netstandard]System.IO.Stream)
           stloc.0      
           ldloc.0      
           newobj       instance void CilBrowser.Core.HtmlBuilder::.ctor(class [netstandard]System.IO.TextWriter)
           stloc.1      
           ldloc.0      
           stloc.3      
  .try
  {
            nop          
            ldarg.1      
            call         string CilBrowser.Core.Utils::GetDirectoryNameFromPath(string)
            stloc.s      V_4
            ldloc.1      
            ldloc.s      V_4
            call         void CilBrowser.Core.HtmlGenerator::WriteTocStart(class CilBrowser.Core.HtmlBuilder, string)
            nop          
            ldarg.1      
            call         string[] [netstandard]System.IO.Directory::GetDirectories(string)
            stloc.s      V_5
            ldloc.s      V_5
            call         void [netstandard]System.Array::Sort<string>(!!0[])
            nop          
            ldloc.s      V_5
            ldlen        
            ldc.i4.0     
            cgt.un       
            stloc.s      V_7
            ldloc.s      V_7
            brfalse.s    IL_0002
            ldloc.1      
            ldstr        "h2"
            ldstr        "Subdirectories"
            callvirt     instance void CilBrowser.Core.HtmlBuilder::WriteTag(string, string)
            nop          
   IL_0002: ldarg.2      
            ldc.i4.0     
            ceq          
            stloc.s      V_8
            ldloc.s      V_8
            brfalse.s    IL_0003
            nop          
            ldloc.1      
            callvirt     instance void CilBrowser.Core.HtmlBuilder::StartParagraph()
            nop          
            ldloc.1      
            ldstr        "../index.html"
            ldstr        "(go to parent directory)"
            callvirt     instance void CilBrowser.Core.HtmlBuilder::WriteHyperlink(string, string)
            nop          
            ldloc.1      
            callvirt     instance void CilBrowser.Core.HtmlBuilder::EndParagraph()
            nop          
            nop          
   IL_0003: ldloc.s      V_5
            ldstr        "dir.png"
            ldloc.1      
            call         void CilBrowser.Core.WebsiteGenerator::RenderDirsList(string[], string, class CilBrowser.Core.HtmlBuilder)
            nop          
            ldarg.1      
            call         string[] [netstandard]System.IO.Directory::GetFiles(string)
            stloc.s      V_6
            ldloc.s      V_6
            call         void [netstandard]System.Array::Sort<string>(!!0[])
            nop          
            ldloc.s      V_6
            ldlen        
            ldc.i4.0     
            cgt.un       
            stloc.s      V_9
            ldloc.s      V_9
            brfalse.s    IL_0004
            ldloc.1      
            ldstr        "h2"
            ldstr        "Files"
            callvirt     instance void CilBrowser.Core.HtmlBuilder::WriteTag(string, string)
            nop          
   IL_0004: ldloc.1      
            ldstr        "table"
            ldstr        "cellpadding"
            ldstr        "2px"
            call         class CilBrowser.Core.HtmlAttribute[] CilBrowser.Core.HtmlBuilder::OneAttribute(string, string)
            callvirt     instance void CilBrowser.Core.HtmlBuilder::WriteTagStart(string, class CilBrowser.Core.HtmlAttribute[])
            nop          
            ldc.i4.0     
            stloc.s      V_10
            br.s         IL_0008
   IL_0005: nop          
            ldloc.s      V_6
            ldloc.s      V_10
            ldelem.ref   
            ldarg.0      
            ldfld        class [netstandard]System.Collections.Generic.HashSet`1<string> CilBrowser.Core.SourceServer::_sourceExtensions
            call         bool CilBrowser.Core.FileUtils::IsSourceFile(string, class [netstandard]System.Collections.Generic.HashSet`1<string>)
            ldc.i4.0     
            ceq          
            stloc.s      V_13
            ldloc.s      V_13
            brfalse.s    IL_0006
            br.s         IL_0007
   IL_0006: ldloc.s      V_6
            ldloc.s      V_10
            ldelem.ref   
            call         string [netstandard]System.IO.Path::GetFileName(string)
            stloc.s      V_11
            ldloc.s      V_11
            call         string CilBrowser.Core.FileUtils::FileNameToPageName(string)
            stloc.s      V_12
            ldloc.s      V_11
            ldloc.s      V_12
            ldstr        "file.png"
            ldloc.1      
            call         void CilBrowser.Core.WebsiteGenerator::RenderTocEntry(string, string, string, class CilBrowser.Core.HtmlBuilder)
            nop          
            nop          
   IL_0007: ldloc.s      V_10
            ldc.i4.1     
            add          
            stloc.s      V_10
   IL_0008: ldloc.s      V_10
            ldloc.s      V_6
            ldlen        
            conv.i4      
            clt          
            stloc.s      V_14
            ldloc.s      V_14
            brtrue.s     IL_0005
            ldloc.1      
            ldstr        "table"
            callvirt     instance void CilBrowser.Core.HtmlBuilder::WriteTagEnd(string)
            nop          
            ldarg.0      
            ldfld        class CilBrowser.Core.HtmlGenerator CilBrowser.Core.SourceServer::_gen
            ldloc.1      
            callvirt     instance void CilBrowser.Core.HtmlGenerator::WriteFooter(class CilBrowser.Core.HtmlBuilder)
            nop          
            ldloc.1      
            callvirt     instance void CilBrowser.Core.HtmlBuilder::EndDocument()
            nop          
            nop          
            leave.s      IL_0010
  }
  finally
  {
            ldloc.3      
            brfalse.s    IL_0009
            ldloc.3      
            callvirt     instance void [netstandard]System.IDisposable::Dispose()
            nop          
   IL_0009: endfinally   
  }
  IL_0010: ret          
 }

 .method family hidebysig virtual instance void RenderFrontPage(
     class [netstandard]System.Net.HttpListenerResponse response
 ) cil managed
 {
  .maxstack  4
  .locals  init (class [netstandard]System.Exception V_0)

           nop          
  .try
  {
            nop          
            ldarg.0      
            ldarg.0      
            ldfld        string CilBrowser.Core.SourceServer::_baseDirectory
            ldc.i4.1     
            ldarg.1      
            call         instance void CilBrowser.Core.SourceServer::RenderToc(string, bool, class [netstandard]System.Net.HttpListenerResponse)
            nop          
            nop          
            leave.s      IL_0001
  }
  catch [netstandard]System.Exception
  {
            stloc.0      
            nop          
            ldstr        "SourceServer error when rendering frontpage!"
            call         void [netstandard]System.Console::WriteLine(string)
            nop          
            ldloc.0      
            callvirt     instance string [netstandard]System.Object::ToString()
            call         void [netstandard]System.Console::WriteLine(string)
            nop          
            call         void [netstandard]System.Console::WriteLine()
            nop          
            ldarg.1      
            ldc.i4       500
            ldstr        "Internal server error"
            call         void CilBrowser.Core.ServerBase::SendErrorResponse(class [netstandard]System.Net.HttpListenerResponse, int32, string)
            nop          
            nop          
            leave.s      IL_0001
  }
  IL_0001: ret          
 }

 .method private hidebysig static bool IsUrlInvalid(
     string url
 ) cil managed
 {
  .maxstack  5
  .locals  init (string[] V_0,
     int32 V_1,
     bool V_2,
     bool V_3,
     bool V_4,
     bool V_5)

           nop          
           ldarg.0      
           ldc.i4.1     
           newarr       [netstandard]System.Char
           dup          
           ldc.i4.0     
           ldc.i4.s     47
           stelem.i2    
           callvirt     instance string[] [netstandard]System.String::Split(char[])
           stloc.0      
           ldc.i4.0     
           stloc.1      
           br.s         IL_0004
  IL_0001: nop          
           ldloc.0      
           ldloc.1      
           ldelem.ref   
           ldstr        ".."
           call         bool CilBrowser.Core.Utils::StrEquals(string, string)
           stloc.2      
           ldloc.2      
           brfalse.s    IL_0002
           ldc.i4.1     
           stloc.3      
           br.s         IL_0005
  IL_0002: ldloc.0      
           ldloc.1      
           ldelem.ref   
           ldstr        "\\"
           call         bool CilBrowser.Core.Utils::StrEquals(string, string)
           stloc.s      V_4
           ldloc.s      V_4
           brfalse.s    IL_0003
           ldc.i4.1     
           stloc.3      
           br.s         IL_0005
  IL_0003: nop          
           ldloc.1      
           ldc.i4.1     
           add          
           stloc.1      
  IL_0004: ldloc.1      
           ldloc.0      
           ldlen        
           conv.i4      
           clt          
           stloc.s      V_5
           ldloc.s      V_5
           brtrue.s     IL_0001
           ldc.i4.0     
           stloc.3      
           br.s         IL_0005
  IL_0005: ldloc.3      
           ret          
 }

 .method family hidebysig virtual instance void RenderPage(
     string url, 
     class [netstandard]System.Net.HttpListenerResponse response
 ) cil managed
 {
  .maxstack  5
  .locals  init (string V_0,
     bool V_1,
     bool V_2,
     string V_3,
     bool V_4,
     bool V_5,
     bool V_6,
     string V_7,
     uint8[] V_8,
     bool V_9,
     string V_10,
     string V_11,
     string V_12,
     string V_13,
     string V_14,
     bool V_15,
     class [netstandard]System.Exception V_16)

           nop          
  .try
  {
            nop          
            ldarg.1      
            call         string [netstandard]System.Net.WebUtility::UrlDecode(string)
            starg.s      1
            ldarg.0      
            ldarg.1      
            call         instance string CilBrowser.Core.ServerBase::StripURL(string)
            stloc.0      
            ldloc.0      
            call         bool CilBrowser.Core.SourceServer::IsUrlInvalid(string)
            stloc.1      
            ldloc.1      
            brfalse.s    IL_0001
            nop          
            ldarg.2      
            ldc.i4       404
            ldstr        "Not found"
            call         void CilBrowser.Core.ServerBase::SendErrorResponse(class [netstandard]System.Net.HttpListenerResponse, int32, string)
            nop          
            leave        IL_0012
   IL_0001: ldarg.1      
            ldstr        "index.html"
            ldc.i4.5     
            callvirt     instance bool [netstandard]System.String::EndsWith(string, valuetype [netstandard]System.StringComparison)
            stloc.2      
            ldloc.2      
            brfalse.s    IL_0003
            nop          
            ldloc.0      
            callvirt     instance int32 [netstandard]System.String::get_Length()
            ldc.i4.5     
            clt          
            stloc.s      V_4
            ldloc.s      V_4
            brfalse.s    IL_0002
            nop          
            ldarg.2      
            ldc.i4       404
            ldstr        "Not found"
            call         void CilBrowser.Core.ServerBase::SendErrorResponse(class [netstandard]System.Net.HttpListenerResponse, int32, string)
            nop          
            leave        IL_0012
   IL_0002: ldloc.0      
            ldc.i4.0     
            ldloc.0      
            callvirt     instance int32 [netstandard]System.String::get_Length()
            ldc.i4.5     
            sub          
            callvirt     instance string [netstandard]System.String::Substring(int32, int32)
            stloc.3      
            ldarg.0      
            ldarg.0      
            ldfld        string CilBrowser.Core.SourceServer::_baseDirectory
            ldloc.3      
            call         string [netstandard]System.IO.Path::Combine(string, string)
            ldc.i4.0     
            ldarg.2      
            call         instance void CilBrowser.Core.SourceServer::RenderToc(string, bool, class [netstandard]System.Net.HttpListenerResponse)
            nop          
            nop          
            br           IL_0011
   IL_0003: ldarg.1      
            callvirt     instance int32 [netstandard]System.String::get_Length()
            ldc.i4.0     
            ble.s        IL_0004
            ldarg.1      
            ldarg.1      
            callvirt     instance int32 [netstandard]System.String::get_Length()
            ldc.i4.1     
            sub          
            callvirt     instance char [netstandard]System.String::get_Chars(int32)
            ldc.i4.s     47
            ceq          
            br.s         IL_0005
   IL_0004: ldc.i4.0     
   IL_0005: stloc.s      V_5
            ldloc.s      V_5
            brfalse.s    IL_0006
            nop          
            ldarg.0      
            ldarg.0      
            ldfld        string CilBrowser.Core.SourceServer::_baseDirectory
            ldarg.0      
            ldarg.1      
            call         instance string CilBrowser.Core.ServerBase::StripPrefix(string)
            call         string [netstandard]System.IO.Path::Combine(string, string)
            ldc.i4.0     
            ldarg.2      
            call         instance void CilBrowser.Core.SourceServer::RenderToc(string, bool, class [netstandard]System.Net.HttpListenerResponse)
            nop          
            nop          
            br           IL_0011
   IL_0006: ldarg.1      
            ldstr        ".png"
            ldc.i4.5     
            callvirt     instance bool [netstandard]System.String::EndsWith(string, valuetype [netstandard]System.StringComparison)
            stloc.s      V_6
            ldloc.s      V_6
            brfalse.s    IL_0009
            nop          
            ldarg.0      
            ldarg.1      
            call         instance string CilBrowser.Core.ServerBase::StripPrefix(string)
            call         string [netstandard]System.IO.Path::GetFileName(string)
            callvirt     instance string [netstandard]System.String::ToLower()
            stloc.s      V_7
            ldarg.0      
            ldfld        class [netstandard]System.Collections.Generic.Dictionary`2<string, uint8[]> CilBrowser.Core.SourceServer::_resources
            ldloc.s      V_7
            ldloca.s     V_8
            callvirt     instance bool class [netstandard]System.Collections.Generic.Dictionary`2<string, uint8[]>::TryGetValue(!0, !1&)
            stloc.s      V_9
            ldloc.s      V_9
            brfalse.s    IL_0007
            nop          
            ldarg.2      
            ldstr        "image/png"
            callvirt     instance void [netstandard]System.Net.HttpListenerResponse::set_ContentType(string)
            nop          
            ldarg.2      
            callvirt     instance class [netstandard]System.IO.Stream [netstandard]System.Net.HttpListenerResponse::get_OutputStream()
            ldloc.s      V_8
            ldc.i4.0     
            ldloc.s      V_8
            ldlen        
            conv.i4      
            callvirt     instance void [netstandard]System.IO.Stream::Write(uint8[], int32, int32)
            nop          
            ldarg.2      
            callvirt     instance void [netstandard]System.Net.HttpListenerResponse::Close()
            nop          
            nop          
            br.s         IL_0008
   IL_0007: nop          
            ldarg.2      
            ldc.i4       404
            ldstr        "Not found"
            call         void CilBrowser.Core.ServerBase::SendErrorResponse(class [netstandard]System.Net.HttpListenerResponse, int32, string)
            nop          
            nop          
   IL_0008: nop          
            br           IL_0011
   IL_0009: nop          
            ldarg.0      
            ldfld        string CilBrowser.Core.SourceServer::_baseDirectory
            ldloc.0      
            call         string [netstandard]System.IO.Path::Combine(string, string)
            stloc.s      V_10
            ldloc.s      V_10
            call         bool [netstandard]System.IO.File::Exists(string)
            ldc.i4.0     
            ceq          
            stloc.s      V_15
            ldloc.s      V_15
            brfalse.s    IL_0010
            nop          
            ldarg.2      
            ldc.i4       404
            ldstr        "Not found"
            call         void CilBrowser.Core.ServerBase::SendErrorResponse(class [netstandard]System.Net.HttpListenerResponse, int32, string)
            nop          
            leave        IL_0012
   IL_0010: ldloc.s      V_10
            ldarg.0      
            ldfld        class CilBrowser.Core.CilBrowserOptions CilBrowser.Core.SourceServer::_options
            callvirt     instance class [netstandard]System.Text.Encoding CilBrowser.Core.CilBrowserOptions::GetEncoding()
            call         string [netstandard]System.IO.File::ReadAllText(string, class [netstandard]System.Text.Encoding)
            stloc.s      V_11
            ldloc.0      
            call         string [netstandard]System.IO.Path::GetFileName(string)
            stloc.s      V_12
            ldloc.s      V_10
            ldloc.s      V_12
            ldarg.0      
            ldfld        class [netstandard]System.Collections.Generic.HashSet`1<string> CilBrowser.Core.SourceServer::_sourceExtensions
            call         string CilBrowser.Core.WebsiteGenerator::RenderNavigationPanel(string, string, class [netstandard]System.Collections.Generic.HashSet`1<string>)
            stloc.s      V_13
            ldarg.0      
            ldfld        class CilBrowser.Core.HtmlGenerator CilBrowser.Core.SourceServer::_gen
            ldloc.s      V_11
            ldloc.s      V_12
            ldloc.s      V_13
            ldsfld       string [netstandard]System.String::Empty
            callvirt     instance string CilBrowser.Core.HtmlGenerator::VisualizeSourceFile(string, string, string, string)
            stloc.s      V_14
            ldarg.0      
            ldarg.1      
            ldloc.s      V_14
            call         instance void CilBrowser.Core.ServerBase::AddToCache(string, string)
            nop          
            ldarg.2      
            ldloc.s      V_14
            call         void CilBrowser.Core.ServerBase::SendHtmlResponse(class [netstandard]System.Net.HttpListenerResponse, string)
            nop          
            nop          
   IL_0011: nop          
            leave.s      IL_0012
  }
  catch [netstandard]System.Exception
  {
            stloc.s      V_16
            nop          
            ldstr        "SourceServer error when rendering page!"
            call         void [netstandard]System.Console::WriteLine(string)
            nop          
            ldloc.s      V_16
            callvirt     instance string [netstandard]System.Object::ToString()
            call         void [netstandard]System.Console::WriteLine(string)
            nop          
            call         void [netstandard]System.Console::WriteLine()
            nop          
            ldarg.2      
            ldc.i4       500
            ldstr        "Internal server error"
            call         void CilBrowser.Core.ServerBase::SendErrorResponse(class [netstandard]System.Net.HttpListenerResponse, int32, string)
            nop          
            nop          
            leave.s      IL_0012
  }
  IL_0012: ret          
 }

}

Back to table of contents


Generated by CIL Browser