diff --git a/BrowserDetector.sln b/BrowserDetector.sln index a0a1b0e..a52935f 100644 --- a/BrowserDetector.sln +++ b/BrowserDetector.sln @@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BrowserDetector.Benchmarks" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BrowserDetector.Net", "src\BrowserDetector.NetCore\BrowserDetector.Net.csproj", "{2E0D3C7A-98AA-475A-816B-3B51EA377C6A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BrowserDetector.WebApi", "sample\BrowserDetector.WebApi\BrowserDetector.WebApi.csproj", "{6369627B-5878-4CFE-A996-859D8663603C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BrowserDetector.WebApi", "sample\BrowserDetector.WebApi\BrowserDetector.WebApi.csproj", "{6369627B-5878-4CFE-A996-859D8663603C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{31BD75C3-015A-4308-9B08-07786C191BAC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/README.md b/README.md index 0f0cc76..60d8991 100644 --- a/README.md +++ b/README.md @@ -58,20 +58,14 @@ Install the [BrowserDetector nuget package](https://www.nuget.org/packages/Shyju Install-Package Shyjus.BrowserDetector ```` -**Step 2:** Enable the browser detection service inside the `ConfigureServices` method of `Startup.cs`. +**Step 2:** Enable the browser detection service by calling `AddBrowserDetection` method on `IServiceCollection` in your startup code. ```` -public void ConfigureServices(IServiceCollection services) -{ - // Add browser detection service - services.AddBrowserDetection(); - - services.AddMvc(); -} +services.AddBrowserDetection(); ```` **Step 3:** Inject `IBrowserDetector` to your controller class or view file or middleware and access the `Browser` property. -Example usage in controller code +#### Example usage in controller code ```` public class HomeController : Controller @@ -91,7 +85,7 @@ public class HomeController : Controller } ```` -Example usage in view code +#### Example usage in view code ```` @inject Shyjus.BrowserDetection.IBrowserDetector browserDetector @@ -103,7 +97,7 @@ Example usage in view code ```` -Example usage in custom middlware +#### Example usage in custom middleware You can inject the `IBrowserDetector` to the `InvokeAsync` method. diff --git a/docs/readme.md b/docs/readme.md new file mode 100644 index 0000000..6fc4323 --- /dev/null +++ b/docs/readme.md @@ -0,0 +1,95 @@ + +# BrowserDetector + +Browser detection capabilities for asp.net core. + + + +This library does + +1. Browser detection +2. Device type detection +3. Operating System detection + +**Step 1:** +Install the [BrowserDetector nuget package](https://www.nuget.org/packages/Shyjus.BrowserDetector/) + + +```` +Install-Package Shyjus.BrowserDetector +```` + +**Step 2:** Enable the browser detection service by calling `AddBrowserDetection` method on `IServiceCollection` in your startup code. + +```` +services.AddBrowserDetection(); +```` +**Step 3:** Inject `IBrowserDetector` to your controller class or view file or middleware and access the `Browser` property. + +### Example usage in controller code + +```` +public class HomeController : Controller +{ + private readonly IBrowserDetector browserDetector; + public HomeController(IBrowserDetector browserDetector) + { + this.browserDetector = browserDetector; + } + public IActionResult Index() + { + var browser = this.browserDetector.Browser; + // Use browser object as needed. + + return View(); + } +} +```` + +### Example usage in view code + +```` +@inject Shyjus.BrowserDetection.IBrowserDetector browserDetector + +