NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Common.Web.UriExtensions Class Reference

Static Public Member Functions

static Uri Append (this Uri uri, params string[] paths)
 
static Uri Append (this Uri uri, Uri relativeUri, params string[] paths)
 
static Uri Append (this Uri uri, Uri relativeUri, string path)
 
static Uri AppendExtension (this Uri uri, string extension)
 
static string DebugInfo (this Uri uri)
 
static string ToHtmlString (this Uri uri)
 

Static Private Member Functions

static void GetBase (Uri uri, out string basePath, out UriKind uriKind)
 

Detailed Description

Definition at line 29 of file UriExtensions.cs.

Member Function Documentation

static Uri Ntp.Common.Web.UriExtensions.Append ( this Uri  uri,
params string[]  paths 
)
inlinestatic

Definition at line 31 of file UriExtensions.cs.

32  {
33  string basePath;
34  UriKind uriKind;
35 
36  GetBase(uri, out basePath, out uriKind);
37  string resPath = paths.Aggregate(
38  basePath,
39  (current, path) => $"{current.TrimEnd('/')}/{path.TrimStart('/')}");
40  Uri newUri = new Uri(resPath, uriKind);
41 
42  return newUri;
43  }
static void GetBase(Uri uri, out string basePath, out UriKind uriKind)
static Uri Ntp.Common.Web.UriExtensions.Append ( this Uri  uri,
Uri  relativeUri,
params string[]  paths 
)
inlinestatic

Definition at line 45 of file UriExtensions.cs.

46  {
47  string relativeUriText = relativeUri.IsAbsoluteUri
48  ? relativeUri.AbsolutePath
49  : relativeUri.ToString();
50  var list = new List<string> {relativeUriText};
51  list.AddRange(paths);
52  return uri.Append(list.ToArray());
53  }
static Uri Ntp.Common.Web.UriExtensions.Append ( this Uri  uri,
Uri  relativeUri,
string  path 
)
inlinestatic

Definition at line 55 of file UriExtensions.cs.

56  {
57  string relativeUriText = relativeUri.IsAbsoluteUri
58  ? relativeUri.AbsolutePath
59  : relativeUri.ToString();
60  var list = new List<string> {relativeUriText, path};
61  return uri.Append(list.ToArray());
62  }
static Uri Ntp.Common.Web.UriExtensions.AppendExtension ( this Uri  uri,
string  extension 
)
inlinestatic

Definition at line 64 of file UriExtensions.cs.

65  {
66  string basePath;
67  UriKind uriKind;
68 
69  GetBase(uri, out basePath, out uriKind);
70  basePath = basePath.TrimEnd('/') + extension;
71  Uri newUri = new Uri(basePath, uriKind);
72 
73  return newUri;
74  }
static void GetBase(Uri uri, out string basePath, out UriKind uriKind)
static string Ntp.Common.Web.UriExtensions.DebugInfo ( this Uri  uri)
inlinestatic

Definition at line 76 of file UriExtensions.cs.

References b.

77  {
78  StringBuilder b = new StringBuilder();
79  b.AppendLine($"ToString(): {uri}");
80  b.AppendLine($"IsAbsoluteUri: {uri.IsAbsoluteUri}");
81  b.AppendLine($"OriginalString: {uri.OriginalString}");
82 
83  if (uri.IsAbsoluteUri)
84  {
85  b.AppendLine($"AbsolutePath: {uri.AbsolutePath}");
86  b.AppendLine($"AbsoluteUri: {uri.AbsoluteUri}");
87  b.AppendLine($"Authority: {uri.Authority}");
88  b.AppendLine($"DnsSafeHost: {uri.DnsSafeHost}");
89  b.AppendLine($"Fragment: {uri.Fragment}");
90  b.AppendLine($"Host: {uri.Host}");
91  b.AppendLine($"HostNameType: {uri.HostNameType}");
92  b.AppendLine($"IsDefaultPort {uri.IsDefaultPort}");
93  b.AppendLine($"IsFile: {uri.IsFile}");
94  b.AppendLine($"IsLoopback: {uri.IsLoopback}");
95  b.AppendLine($"IsUnc: {uri.IsUnc}");
96  b.AppendLine($"LocalPath: {uri.LocalPath}");
97  b.AppendLine($"PathAndQuery: {uri.PathAndQuery}");
98  b.AppendLine($"Port: {uri.Port}");
99  b.AppendLine($"Query: {uri.Query}");
100  b.AppendLine($"Scheme: {uri.Scheme}");
101  b.AppendLine($"Segments: {uri.Segments}");
102  b.AppendLine($"UserEscaped: {uri.UserEscaped}");
103  b.AppendLine($"UserInfo: {uri.UserInfo}");
104  }
105 
106  return b.ToString();
107  }
var b
Definition: bootstrap.min.js:6
static void Ntp.Common.Web.UriExtensions.GetBase ( Uri  uri,
out string  basePath,
out UriKind  uriKind 
)
inlinestaticprivate

Definition at line 114 of file UriExtensions.cs.

115  {
116  string orig = uri.OriginalString.TrimStart();
117  if (orig.StartsWith("/") && !orig.StartsWith("//"))
118  {
119  basePath = uri.IsAbsoluteUri
120  ? uri.AbsolutePath
121  : uri.ToString();
122  uriKind = UriKind.Relative;
123  }
124  else
125  {
126  basePath = uri.ToString();
127  uriKind = UriKind.Absolute;
128  }
129  }
static string Ntp.Common.Web.UriExtensions.ToHtmlString ( this Uri  uri)
inlinestatic

Definition at line 109 of file UriExtensions.cs.

110  {
111  return Uri.EscapeUriString(uri.ToString());
112  }

The documentation for this class was generated from the following file: