Skip to content

Commit

Permalink
REF: Updated documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Automation51D authored and Automation51D committed Jan 15, 2024
1 parent efae423 commit 9156550
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>51Degrees Pipeline .NET: ExampleCoreWebsite/Startup.cs</title>
<title>51Degrees Pipeline .NET: NetCore/Startup.cs</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
Expand Down Expand Up @@ -57,25 +57,26 @@ <h1 class="c-brand">
<div class="g-docs__sidenav"> <nav id="nav-tree-contents" class="c-sidenav"> <h4 class="c-sidenav__heading">Documentation</h4> <div id="nav-sync" class="sync"></div>
<ul class="c-sidenav__list"> </ul> </nav> </div><script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_example_core_website_2_startup_8cs-example.html','');});
$(document).ready(function(){initNavTree('_net_core_2_startup_8cs-example.html','');});
/* @license-end */
</script>
<div id="doc-content" class="g-docs__content">
<div class="g-docs__header">
<h2 class="g-docs__page-title">ExampleCoreWebsite/Startup.cs</h2></div><!--header-->
<h2 class="g-docs__page-title">NetCore/Startup.cs</h2></div><!--header-->
<div class="g-docs__inner">
<div class="g-docs__primary" id="primary">
<p>ASP.NET core exampleThis example shows how to:</p>
<h2>ASP.NET core example</h2>
<p>This example shows how to:</p>
<ol type="1">
<li>Set up configuration options to add elements to the 51Degrees Pipeline. <div class="c-code__block c-code__block--outline"><div class="c-code__line">{</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;Logging&quot;</span>: {</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;LogLevel&quot;</span>: {</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;Default&quot;</span>: <span class="c-code__stringliteral">&quot;Information&quot;</span>,</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;Microsoft&quot;</span>: <span class="c-code__stringliteral">&quot;Warning&quot;</span>,</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;Microsoft.Hosting.Lifetime&quot;</span>: <span class="c-code__stringliteral">&quot;Information&quot;</span></div><div class="c-code__line"> }</div><div class="c-code__line"> },</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;AllowedHosts&quot;</span>: <span class="c-code__stringliteral">&quot;*&quot;</span>,</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;PipelineOptions&quot;</span>: {</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;Elements&quot;</span>: [</div><div class="c-code__line"> {</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;BuilderName&quot;</span>: <span class="c-code__stringliteral">&quot;math&quot;</span></div><div class="c-code__line"> }</div><div class="c-code__line"> <span class="c-code__comment">// None of the following configuration is needed. It is included </span></div><div class="c-code__line"> <span class="c-code__comment">// here to illustrate the possible options and default values.</span></div><div class="c-code__line"> <span class="c-code__comment">//{</span></div><div class="c-code__line"> <span class="c-code__comment">//},</span></div><div class="c-code__line"> ]</div><div class="c-code__line"> }</div><div class="c-code__line">}</div></div></li>
<li>Configure HostBuilder to use Startup class. <div class="c-code__block c-code__block--outline"><div class="c-code__line"><span class="c-code__keyword">namespace </span><a class="code" href="namespace_asp_net_core___example.html">AspNetCore_Example</a></div><div class="c-code__line">{</div><div class="c-code__line"> <span class="c-code__keyword">public</span> <span class="c-code__keyword">class </span>Program</div><div class="c-code__line"> {</div><div class="c-code__line"> <span class="c-code__keyword">public</span> <span class="c-code__keyword">static</span> <span class="c-code__keywordtype">void</span> Main(<span class="c-code__keywordtype">string</span>[] args)</div><div class="c-code__line"> {</div><div class="c-code__line"> CreateHostBuilder(args).Build().Run();</div><div class="c-code__line"> }</div><div class="c-code__line"></div><div class="c-code__line"> <span class="c-code__keyword">public</span> <span class="c-code__keyword">static</span> IHostBuilder CreateHostBuilder(<span class="c-code__keywordtype">string</span>[] args) =&gt;</div><div class="c-code__line"> Host.CreateDefaultBuilder(args)</div><div class="c-code__line"> .ConfigureWebHostDefaults(webBuilder =&gt;</div><div class="c-code__line"> {</div><div class="c-code__line"> webBuilder.UseStartup&lt;Startup&gt;();</div><div class="c-code__line"> });</div><div class="c-code__line"> }</div><div class="c-code__line">}</div></div></li>
<li>Populate ViewData in HomeController. <div class="c-code__block c-code__block--outline"><div class="c-code__line"><span class="c-code__keyword">namespace </span><a class="code" href="namespace_example___website_1_1_controllers.html">Example_Website.Controllers</a></div><div class="c-code__line">{</div><div class="c-code__line"> <span class="c-code__keyword">public</span> <span class="c-code__keyword">class </span>HomeController : Controller</div><div class="c-code__line"> {</div><div class="c-code__line"> <span class="c-code__keyword">private</span> IFlowDataProvider _flow;</div><div class="c-code__line"></div><div class="c-code__line"> <span class="c-code__keyword">public</span> HomeController(IFlowDataProvider flow)</div><div class="c-code__line"> {</div><div class="c-code__line"> _flow = flow;</div><div class="c-code__line"> }</div><div class="c-code__line"></div><div class="c-code__line"> <span class="c-code__keyword">public</span> IActionResult Index()</div><div class="c-code__line"> {</div><div class="c-code__line"> var math = _flow.GetFlowData()?.Get(MathElement.math);</div><div class="c-code__line"> <span class="c-code__keywordflow">if</span> (math != <span class="c-code__keyword">null</span>)</div><div class="c-code__line"> {</div><div class="c-code__line"> ViewData[<span class="c-code__stringliteral">&quot;Message&quot;</span>] = $<span class="c-code__stringliteral">&quot;{math.Operation} = {math.Result}&quot;</span>;</div><div class="c-code__line"> }</div><div class="c-code__line"> <span class="c-code__keywordflow">else</span></div><div class="c-code__line"> {</div><div class="c-code__line"> ViewData[<span class="c-code__stringliteral">&quot;Message&quot;</span>] = <span class="c-code__stringliteral">&quot;No &#39;FlowData&#39; found. This is usually &quot;</span> +</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;because the 51Degrees middleware component has not run, &quot;</span> +</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;possibly due to being after some other middleware &quot;</span> +</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;component that has blocked further execution &quot;</span> +</div><div class="c-code__line"> <span class="c-code__stringliteral">&quot;(For example, requiring HTTPS).&quot;</span>;</div><div class="c-code__line"> }</div><div class="c-code__line"> <span class="c-code__keywordflow">return</span> View();</div><div class="c-code__line"> }</div><div class="c-code__line"> }</div><div class="c-code__line">}</div></div></li>
<li>Add the MathElemenetBuilder to the services collection so that the Pipeline creation process knows where to find it. <div class="c-code__block c-code__block--outline"><div class="c-code__line"><span class="c-code__keyword">public</span> <span class="c-code__keyword">class </span>HomeController : Controller</div><div class="c-code__line">{</div><div class="c-code__line"> ...</div><div class="c-code__line"> <span class="c-code__keyword">public</span> <span class="c-code__keywordtype">void</span> ConfigureServices(IServiceCollection services)</div><div class="c-code__line"> {</div><div class="c-code__line"> ...</div><div class="c-code__line"> services.AddSingleton&lt;MathElementBuilder&gt;();</div><div class="c-code__line"> ...</div></div></li>
<li>Call AddFiftyOne to add all the things the Pipeline will need to the services collection and create it based on the supplied configruation. <div class="c-code__block c-code__block--outline"><div class="c-code__line"> ...</div><div class="c-code__line"> services.AddFiftyOne(Configuration);</div><div class="c-code__line"> ...</div><div class="c-code__line">}</div></div></li>
<li>Call AddFiftyOne to add all the things the Pipeline will need to the services collection and create it based on the supplied configruation. <div class="c-code__block c-code__block--outline"><div class="c-code__line"> ...</div><div class="c-code__line"> services.AddFiftyOne(Configuration);</div><div class="c-code__line"> ...</div><div class="c-code__line"> }</div><div class="c-code__line">...</div></div></li>
<li>Call UseFiftyOne to add the Middleware component that will send any requests through the 51Degrees pipeline. <div class="c-code__block c-code__block--outline"><div class="c-code__line">...</div><div class="c-code__line"> <span class="c-code__keyword">public</span> <span class="c-code__keywordtype">void</span> Configure(IApplicationBuilder app, IWebHostEnvironment env)</div><div class="c-code__line"> {</div><div class="c-code__line"> ...</div><div class="c-code__line"> app.UseFiftyOne();</div><div class="c-code__line"> ...</div><div class="c-code__line"> }</div><div class="c-code__line">...</div></div></li>
</ol>
<h2>Startup</h2>
<div class="c-code__block c-code__block--outline"></div> </div><!-- primary -->
<div class="c-code__block c-code__block--outline"><div class="c-code__line"><span class="c-code__comment">/* *********************************************************************</span></div><div class="c-code__line"><span class="c-code__comment"> * This Original Work is copyright of 51 Degrees Mobile Experts Limited.</span></div><div class="c-code__line"><span class="c-code__comment"> * Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,</span></div><div class="c-code__line"><span class="c-code__comment"> * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.</span></div><div class="c-code__line"><span class="c-code__comment"> *</span></div><div class="c-code__line"><span class="c-code__comment"> * This Original Work is licensed under the European Union Public Licence</span></div><div class="c-code__line"><span class="c-code__comment"> * (EUPL) v.1.2 and is subject to its terms as set out below.</span></div><div class="c-code__line"><span class="c-code__comment"> *</span></div><div class="c-code__line"><span class="c-code__comment"> * If a copy of the EUPL was not distributed with this file, You can obtain</span></div><div class="c-code__line"><span class="c-code__comment"> * one at https://opensource.org/licenses/EUPL-1.2.</span></div><div class="c-code__line"><span class="c-code__comment"> *</span></div><div class="c-code__line"><span class="c-code__comment"> * The &#39;Compatible Licences&#39; set out in the Appendix to the EUPL (as may be</span></div><div class="c-code__line"><span class="c-code__comment"> * amended by the European Commission) shall be deemed incompatible for</span></div><div class="c-code__line"><span class="c-code__comment"> * the purposes of the Work and the provisions of the compatibility</span></div><div class="c-code__line"><span class="c-code__comment"> * clause in Article 5 of the EUPL shall not apply.</span></div><div class="c-code__line"><span class="c-code__comment"> *</span></div><div class="c-code__line"><span class="c-code__comment"> * If using the Work as, or as part of, a network application, by</span></div><div class="c-code__line"><span class="c-code__comment"> * including the attribution notice(s) required under Article 5 of the EUPL</span></div><div class="c-code__line"><span class="c-code__comment"> * in the end user terms of the application under an appropriate heading,</span></div><div class="c-code__line"><span class="c-code__comment"> * such notice(s) shall fulfill the requirements of that article.</span></div><div class="c-code__line"><span class="c-code__comment"> * ********************************************************************* */</span></div><div class="c-code__line"></div><div class="c-code__line"><span class="c-code__keyword">using</span> <a class="code" href="namespace_fifty_one.html">FiftyOne</a>.<a class="code" href="namespace_fifty_one_1_1_pipeline.html">Pipeline</a>.<a class="code" href="namespace_fifty_one_1_1_pipeline_1_1_math.html">Math</a>;</div><div class="c-code__line"><span class="c-code__keyword">using</span> Microsoft.AspNetCore.Builder;</div><div class="c-code__line"><span class="c-code__keyword">using</span> Microsoft.AspNetCore.Hosting;</div><div class="c-code__line"><span class="c-code__keyword">using</span> Microsoft.Extensions.Configuration;</div><div class="c-code__line"><span class="c-code__keyword">using</span> Microsoft.Extensions.DependencyInjection;</div><div class="c-code__line"><span class="c-code__keyword">using</span> Microsoft.Extensions.Hosting;</div><div class="c-code__line"></div><div class="c-code__line"></div><div class="c-code__line"><span class="c-code__keyword">namespace </span><a class="code" href="namespace_asp_net_core___example.html">AspNetCore_Example</a></div><div class="c-code__line">{</div><div class="c-code__line"> <span class="c-code__keyword">public</span> <span class="c-code__keyword">class </span>Startup</div><div class="c-code__line"> {</div><div class="c-code__line"> <span class="c-code__keyword">public</span> Startup(IConfiguration configuration)</div><div class="c-code__line"> {</div><div class="c-code__line"> Configuration = configuration;</div><div class="c-code__line"> }</div><div class="c-code__line"></div><div class="c-code__line"> <span class="c-code__keyword">public</span> IConfiguration Configuration { <span class="c-code__keyword">get</span>; }</div><div class="c-code__line"></div><div class="c-code__line"> <span class="c-code__comment">// This method gets called by the runtime. Use this method to add services to the container.</span></div><div class="c-code__line"> <span class="c-code__keyword">public</span> <span class="c-code__keywordtype">void</span> ConfigureServices(IServiceCollection services)</div><div class="c-code__line"> {</div><div class="c-code__line"> services.AddControllersWithViews();</div><div class="c-code__line"></div><div class="c-code__line"> <span class="c-code__comment">// Add the MathElemenetBuilder to the services collection so that</span></div><div class="c-code__line"> <span class="c-code__comment">// the Pipeline creation process knows where to find it.</span></div><div class="c-code__line"> services.AddSingleton&lt;MathElementBuilder&gt;();</div><div class="c-code__line"></div><div class="c-code__line"> <span class="c-code__comment">// Call AddFiftyOne to add all the things the Pipeline will need</span></div><div class="c-code__line"> <span class="c-code__comment">// to the services collection and create it based on the supplied</span></div><div class="c-code__line"> <span class="c-code__comment">// configruation.</span></div><div class="c-code__line"> services.AddFiftyOne(Configuration);</div><div class="c-code__line"> }</div><div class="c-code__line"></div><div class="c-code__line"> <span class="c-code__comment">// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.</span></div><div class="c-code__line"> <span class="c-code__keyword">public</span> <span class="c-code__keywordtype">void</span> Configure(IApplicationBuilder app, IWebHostEnvironment env)</div><div class="c-code__line"> {</div><div class="c-code__line"> <span class="c-code__keywordflow">if</span> (env.IsDevelopment())</div><div class="c-code__line"> {</div><div class="c-code__line"> app.UseDeveloperExceptionPage();</div><div class="c-code__line"> }</div><div class="c-code__line"> <span class="c-code__keywordflow">else</span></div><div class="c-code__line"> {</div><div class="c-code__line"> app.UseExceptionHandler(<span class="c-code__stringliteral">&quot;/Home/Error&quot;</span>);</div><div class="c-code__line"> <span class="c-code__comment">// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.</span></div><div class="c-code__line"> app.UseHsts();</div><div class="c-code__line"> }</div><div class="c-code__line"></div><div class="c-code__line"> <span class="c-code__comment">// Call UseFiftyOne to add the Middleware component that will send any</span></div><div class="c-code__line"> <span class="c-code__comment">// requests through the 51Degrees pipeline. </span></div><div class="c-code__line"> app.UseFiftyOne();</div><div class="c-code__line"></div><div class="c-code__line"> app.UseHttpsRedirection();</div><div class="c-code__line"> app.UseStaticFiles();</div><div class="c-code__line"></div><div class="c-code__line"> app.UseRouting();</div><div class="c-code__line"></div><div class="c-code__line"> app.UseAuthorization();</div><div class="c-code__line"></div><div class="c-code__line"> app.UseEndpoints(endpoints =&gt;</div><div class="c-code__line"> {</div><div class="c-code__line"> endpoints.MapControllerRoute(</div><div class="c-code__line"> name: <span class="c-code__stringliteral">&quot;default&quot;</span>,</div><div class="c-code__line"> pattern: <span class="c-code__stringliteral">&quot;{controller=Home}/{action=Index}/{id?}&quot;</span>);</div><div class="c-code__line"> });</div><div class="c-code__line"> }</div><div class="c-code__line"> }</div><div class="c-code__line">}</div></div> </div><!-- primary -->
</div><!-- inner-->
<!-- HTML footer for doxygen 1.8.15-->
<!-- start footer part -->
Expand Down
4 changes: 2 additions & 2 deletions 4.4/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ <h2 class="g-docs__page-title">Examples</h2></div><!--header-->
<div class="g-docs__inner">
<div class="g-docs__primary" id="primary">
<section class="g-docs__section">51Degrees Pipeline API examples. These show how the API can be used for a few example use cases.</section><ul>
<li><a class="el" href="_example_core_website_2_startup_8cs-example.html">ExampleCoreWebsite/Startup.cs</a></li>

<li><a class="el" href="_example_framework_website_2_controllers_2_home_controller_8cs-example.html">ExampleFrameworkWebsite/Controllers/HomeController.cs</a></li>

<li><a class="el" href="_net_core_2_startup_8cs-example.html">NetCore/Startup.cs</a></li>

<li><a class="el" href="_result_caching_2_program_8cs-example.html">ResultCaching/Program.cs</a></li>

<li><a class="el" href="_usage_sharing_2_program_8cs-example.html">UsageSharing/Program.cs</a></li>
Expand Down
Loading

0 comments on commit 9156550

Please sign in to comment.