Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kenelin committed Aug 22, 2020
1 parent 5a23fb4 commit 89d299f
Showing 1 changed file with 50 additions and 5 deletions.
55 changes: 50 additions & 5 deletions source/Htc.Vita.Core/Net/WebUserAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Htc.Vita.Core.Net
{
/// <summary>
/// Class WebUserAgent.
/// </summary>
public class WebUserAgent
{
private const string Chrome43 = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36";
Expand All @@ -15,45 +18,71 @@ public class WebUserAgent
private readonly StringBuilder _optionalSection = new StringBuilder();

private static readonly Assembly ModuleAssembly = Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly();
private static string name = DefaultName;

private static string _name = DefaultName;

/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public static string Name
{
get { return name; }
get { return _name; }
set
{
if (!string.IsNullOrWhiteSpace(value))
{
name = value;
_name = value;
}
}
}

/// <summary>
/// Act as Chrome.
/// </summary>
/// <returns>WebUserAgent.</returns>
public WebUserAgent AsChrome()
{
_mandatorySection.Clear().Append(Chrome43);
return this;
}

/// <summary>
/// Act as Firefox.
/// </summary>
/// <returns>WebUserAgent.</returns>
public WebUserAgent AsFirefox()
{
_mandatorySection.Clear().Append(Firefox35);
return this;
}

/// <summary>
/// Act as IE.
/// </summary>
/// <returns>WebUserAgent.</returns>
public WebUserAgent AsIe()
{
_mandatorySection.Clear().Append(Msie11);
return this;
}

/// <summary>
/// Resets this instance.
/// </summary>
/// <returns>WebUserAgent.</returns>
public WebUserAgent Reset()
{
_mandatorySection.Clear();
_optionalSection.Clear();
return this;
}

/// <summary>
/// Appends the specified part.
/// </summary>
/// <param name="part">The part.</param>
/// <returns>WebUserAgent.</returns>
public WebUserAgent Append(string part)
{
if (string.IsNullOrWhiteSpace(part))
Expand All @@ -62,11 +91,15 @@ public WebUserAgent Append(string part)
}
if (_optionalSection.Length > 0)
{
_optionalSection.Append(" " + part + ";");
_optionalSection.Append($" {part};");
}
return this;
}

/// <summary>
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <returns>A <see cref="string" /> that represents this instance.</returns>
public override string ToString()
{
if (_mandatorySection.Length > 0)
Expand All @@ -84,14 +117,22 @@ public override string ToString()
GetModuleInstanceName()
));
}
return _mandatorySection + " " + _optionalSection;
return $"{_mandatorySection} {_optionalSection}";
}

/// <summary>
/// Gets the module name.
/// </summary>
/// <returns>System.String.</returns>
public static string GetModuleName()
{
return Name;
}

/// <summary>
/// Gets the module version.
/// </summary>
/// <returns>System.String.</returns>
public static string GetModuleVersion()
{
var result = "0.0.0.0";
Expand All @@ -115,6 +156,10 @@ public static string GetModuleVersion()
return result;
}

/// <summary>
/// Gets the module instance name.
/// </summary>
/// <returns>System.String.</returns>
public static string GetModuleInstanceName()
{
var result = "UnknownInstance";
Expand Down

0 comments on commit 89d299f

Please sign in to comment.