<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Debashish Pal</title>
    <description>The latest articles on DEV Community by Debashish Pal (@debashish2014).</description>
    <link>https://dev.to/debashish2014</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F142408%2F69ac5244-b6db-4402-8523-7c02cd9b8b61.jpeg</url>
      <title>DEV Community: Debashish Pal</title>
      <link>https://dev.to/debashish2014</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/debashish2014"/>
    <language>en</language>
    <item>
      <title>Solve the scenario - using Thread synchronization in Dotnet - CountDownEvent</title>
      <dc:creator>Debashish Pal</dc:creator>
      <pubDate>Fri, 23 Apr 2021 19:46:47 +0000</pubDate>
      <link>https://dev.to/debashish2014/solve-the-scenario-using-thread-synchronization-in-dotnet-3g01</link>
      <guid>https://dev.to/debashish2014/solve-the-scenario-using-thread-synchronization-in-dotnet-3g01</guid>
      <description>&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Consider this hypothetical scenario. We need to simulate a Marathon Race. So, we have two entities &lt;strong&gt;Race&lt;/strong&gt; &amp;amp; &lt;strong&gt;Player&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Following are the requirements of each entity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Race&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Should be able to add the players&lt;/li&gt;
&lt;li&gt;Should be able to start the race&lt;/li&gt;
&lt;li&gt;It should inform when race starts&lt;/li&gt;
&lt;li&gt;It should inform when race ends&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Player&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It should have a name&lt;/li&gt;
&lt;li&gt;It should declare the fatigue level. &lt;em&gt;Lower is the fatigue, faster the player will run&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;It should notify when player starts running&lt;/li&gt;
&lt;li&gt;It should notify when player finishes the race&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Scenario 1&lt;/strong&gt;:&lt;br&gt;
When race starts it should wait for all the players to finish the race. Race will only end after that.&lt;/p&gt;

&lt;p&gt;All players have a consolation price !!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 2&lt;/strong&gt;:&lt;br&gt;
When race starts it should wait for the first three winners !! Race ends after it.&lt;/p&gt;

&lt;p&gt;Only first three winners will get a price!! Sorry about other folks.&lt;/p&gt;

&lt;p&gt;Take a pause&lt;/p&gt;

&lt;p&gt;Think about the solution&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Think again&lt;/p&gt;

&lt;p&gt;Scroll down for the solution&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;
&lt;h1&gt;
  
  
  Solution
&lt;/h1&gt;

&lt;p&gt;Run the below code in Linqpad (&lt;a href="https://www.linqpad.net/" rel="noopener noreferrer"&gt;https://www.linqpad.net/&lt;/a&gt;), to see it action. You can create a console project in VS and copy this code as well.&lt;/p&gt;

&lt;p&gt;Make sure you press Ctrl+Shift+M, and add the namespace imports i.e. System.Threading &amp;amp; System.Threading.Tasks&lt;/p&gt;

&lt;p&gt;We will be using &lt;strong&gt;TPL&lt;/strong&gt; (Task Parallel Library) and &lt;strong&gt;Thread Synchronization&lt;/strong&gt; constructs to solve the problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 1&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fslrxg4y1xzr81qmdtvdt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fslrxg4y1xzr81qmdtvdt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you see the output above, the player who is having the lowest fatigue level comes first and one who comes last is having the highest fatigue.&lt;/p&gt;

&lt;p&gt;In this solution we are using Task.WaitAll() to wait for all the players to finish the race, before we end it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 2&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7qnrdaywm8amst7w4c5g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7qnrdaywm8amst7w4c5g.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this solution we are using &lt;strong&gt;CountDownEvent&lt;/strong&gt;. When a player finishes the race it signal's the CountDownEvent by calling the Signal function/method on it. When it get's the signal, it's counter is decremented by 1. When first 3 players finishes the race, the counter would have been decremented thrice, so the counter would be 0 at this point. Since the Race is waiting on CountDownEvent, as soon as it's counter reaches 0, the race would end.&lt;/p&gt;

&lt;p&gt;I hope you have understood how to use synchronization to solve these type of problems.&lt;/p&gt;

&lt;p&gt;Happy Coding !!&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>threading</category>
      <category>synchronization</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Solve the scenario - using JObject in Dotnet</title>
      <dc:creator>Debashish Pal</dc:creator>
      <pubDate>Fri, 23 Apr 2021 16:13:18 +0000</pubDate>
      <link>https://dev.to/debashish2014/solve-the-scenario-using-jobject-21fp</link>
      <guid>https://dev.to/debashish2014/solve-the-scenario-using-jobject-21fp</guid>
      <description>&lt;h1&gt;
  
  
  Use Case:
&lt;/h1&gt;

&lt;p&gt;We have this Object and you want to convert it into JSON.&lt;br&gt;
Sounds simple. Right !!&lt;/p&gt;

&lt;p&gt;However, the trick here is that you need to add couple of fields dynamically to the object, before converting.&lt;/p&gt;

&lt;p&gt;Take a pause&lt;/p&gt;

&lt;p&gt;Think about the solution&lt;/p&gt;
&lt;h1&gt;
  
  
  ?
&lt;/h1&gt;

&lt;p&gt;Think again&lt;/p&gt;

&lt;p&gt;Scroll down for the solution &lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;
&lt;h1&gt;
  
  
  Solution
&lt;/h1&gt;

&lt;p&gt;Run the below code in Linqpad (&lt;a href="https://www.linqpad.net/" rel="noopener noreferrer"&gt;https://www.linqpad.net/&lt;/a&gt;), to see it working.&lt;/p&gt;

&lt;p&gt;Make sure you press F4, and add the Nuget package i.e. Newtonsoft.Json&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;I have created this extension method &lt;strong&gt;AddFieldsAndConvertToJson&lt;/strong&gt;. We are simply passing array of tuple's with the required field name &amp;amp; data to the extension.&lt;/p&gt;

&lt;p&gt;Check the output below. The fields are getting added to the employee object dynamically, and the JSON is being outputted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhcye8sc25zhiqf5b9lzy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhcye8sc25zhiqf5b9lzy.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There might be a specific situation, where this extension might come in handy.&lt;/p&gt;

&lt;p&gt;Hope you find it useful.&lt;/p&gt;

&lt;p&gt;Happy Coding !!&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>json</category>
      <category>jobject</category>
    </item>
    <item>
      <title>Pamper your windows terminal - Customize Prompt</title>
      <dc:creator>Debashish Pal</dc:creator>
      <pubDate>Thu, 22 Apr 2021 19:19:33 +0000</pubDate>
      <link>https://dev.to/debashish2014/pamper-your-windows-terminal-41jn</link>
      <guid>https://dev.to/debashish2014/pamper-your-windows-terminal-41jn</guid>
      <description>&lt;p&gt;&lt;strong&gt;Windows Terminal&lt;/strong&gt; (WT) came as a revolution. It was a refreshing delight for all those windows users, who used to stare at the Linux Terminal and wished, can we have it on windows, until now.&lt;/p&gt;

&lt;p&gt;Love for Windows Terminal !!&lt;/p&gt;

&lt;p&gt;Those who have not tried, what are you waiting for. Give it a try. Trust me it's a game changer.&lt;br&gt;
&lt;a href="https://www.microsoft.com/en-in/p/windows-terminal/9n0dx20hk701?activetab=pivot:overviewtab" rel="noopener noreferrer"&gt;https://www.microsoft.com/en-in/p/windows-terminal/9n0dx20hk701?activetab=pivot:overviewtab&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;WT supports Windows PowerShell (Old one that comes installed with windows by default), PowerShell, WSL, CMD, Azure CLI etc. So, whatever terminals are installed on you machine are all integrated under one roof, which you can choose from the drop-down, as you can see in the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkv9omjev1n9ebqlxnpxt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkv9omjev1n9ebqlxnpxt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Can we make the terminal look even better like this, with a fancy prompt? YEAH !!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1nphjko2huxxoc0jodf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1nphjko2huxxoc0jodf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please follow the steps below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: A separate article will be posted soon for WSL users&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For Windows Powershell &amp;amp; &lt;a href="https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-7.1" rel="noopener noreferrer"&gt;Powershell&lt;/a&gt; Only&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Install Git for Windows from&lt;br&gt;
&lt;a href="https://git-scm.com/downloads" rel="noopener noreferrer"&gt;https://git-scm.com/downloads&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run below command on the command prompt&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This would install post-git &amp;amp; oh-my-posh&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Script execution policy must be set to either RemoteSigned or Unrestricted in order for the profile script to run.&lt;/p&gt;

&lt;p&gt;Run this command to check your current execution policy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Get-ExecutionPolicy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the below command for setting it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-ExecutionPolicy Unrestricted -Scope CurrentUser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it does not work you can try the Force flag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/dahlbyk/posh-git" rel="noopener noreferrer"&gt;Posh-Git&lt;/a&gt; adds Git status information to your prompt and tab completion for Git commands, parameters, remotes, and branch names. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JanDeDobbeleer/oh-my-posh" rel="noopener noreferrer"&gt;Oh-My-Posh&lt;/a&gt; provides theme capabilities for your PowerShell prompt.&lt;/p&gt;

&lt;p&gt;3.Now, we need to add some lines to your profile, which would be executed every time you open a new tab.&lt;/p&gt;

&lt;p&gt;Type the below command on the command prompt&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;notepad $PROFILE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will open up the profile file in notepad. If a profile file does not exist, it will create a new one. If it exists then same will open.&lt;/p&gt;

&lt;p&gt;Add below lines to the end of the file, and Save. The file might be empty initially.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme paradox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.Now we need to add the required fonts&lt;/p&gt;

&lt;p&gt;Download &lt;a href="https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip" rel="noopener noreferrer"&gt;Meslo&lt;/a&gt;, and save it at a convenient location.&lt;/p&gt;

&lt;p&gt;Navigate to the path were the file was downloaded. Unzip Meslo.zip and install the highlighted fonts as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fike3dpzc8ope6crx01wm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fike3dpzc8ope6crx01wm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Double click each of the font file and install. &lt;br&gt;
Click the Install button on the window which pops up for the same, as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6kkfyb6z5fg8j1lmcjdt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6kkfyb6z5fg8j1lmcjdt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5.Let's perform the last step.&lt;/p&gt;

&lt;p&gt;Open up settings in WT.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8dlpn4spq6u3amnw70kx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8dlpn4spq6u3amnw70kx.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will open up settings.json file in the default editor.&lt;/p&gt;

&lt;p&gt;Add below lines to the defaults section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"fontSize": 9,
"fontFace": "MesloLGM NF"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fak1nxn0enoruzavexucl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fak1nxn0enoruzavexucl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are using latest version of WT, you might get the below screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F73cx91vi4y4o59hwqzyu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F73cx91vi4y4o59hwqzyu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don't fret, click on the gear icon as shown above. It will open up settings.json file.&lt;/p&gt;

&lt;p&gt;That's It !!&lt;/p&gt;

&lt;p&gt;You have patiently followed all the steps.&lt;/p&gt;

&lt;p&gt;Enjoy your terminal.&lt;/p&gt;

&lt;p&gt;Tip !!&lt;/p&gt;

&lt;p&gt;If you want to list down all the themes supported by Oh My Posh, run the below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Get-PoshThemes 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get output like below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpoxozv6t9vq1o9vv7nol.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpoxozv6t9vq1o9vv7nol.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdfk0f2jiwcs4f5o2dxoe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdfk0f2jiwcs4f5o2dxoe.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you wish to change a theme, open up the profile file, and change the theme name.&lt;/p&gt;

&lt;p&gt;Ex. If I want to change the theme to bubbles&lt;/p&gt;

&lt;p&gt;Type below command on the command prompt to open up profile&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;notepad $PROFILE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the theme name to bubbles as shown below, and save the file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9l8iyex27oljgom5gciy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9l8iyex27oljgom5gciy.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open up another tab now, the theme would be applied.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr185a6ctencx351ut8de.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr185a6ctencx351ut8de.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repeat the steps for each of the terminals&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For WSL, WSL2 I will be adding another post soon.&lt;/p&gt;

&lt;p&gt;Enjoy the customization !!&lt;/p&gt;

</description>
      <category>windowsterminal</category>
      <category>terminal</category>
    </item>
    <item>
      <title>Linq - How to write your own version of Sum extension</title>
      <dc:creator>Debashish Pal</dc:creator>
      <pubDate>Thu, 22 Apr 2021 16:35:47 +0000</pubDate>
      <link>https://dev.to/debashish2014/linq-how-to-write-your-own-version-of-sum-5ja</link>
      <guid>https://dev.to/debashish2014/linq-how-to-write-your-own-version-of-sum-5ja</guid>
      <description>&lt;h1&gt;
  
  
  Sum Extension
&lt;/h1&gt;

&lt;p&gt;I am sure those who know about &lt;strong&gt;Linq&lt;/strong&gt;, must have used Sum extension method in their logic, in some way.&lt;/p&gt;

&lt;p&gt;A basic example showing the use of Sum extension method.&lt;/p&gt;

&lt;p&gt;Ex. Sum up the salary of employees in a generic list&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And, why we wouldn't use it. It is powerful &amp;amp; simple to use.&lt;/p&gt;

&lt;p&gt;But, have you ever wondered how to mimic the same functionality in your own extension method??&lt;/p&gt;

&lt;p&gt;Sounds Interesting, Right !!&lt;/p&gt;

&lt;p&gt;Let's get ready for the challenge !!&lt;/p&gt;

&lt;p&gt;Let's see how....&lt;/p&gt;

&lt;p&gt;I would be creating an extension method named &lt;strong&gt;SumEx&lt;/strong&gt;. The signature would be same, so this version will be totally compatible with the previous example. We will see it in action.&lt;/p&gt;

&lt;p&gt;This extension is a perfect example of how to make delegates into work, in a real world use case.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Our extension method is ready now, let put it to test.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmw17vbgqe7djilt9yllr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmw17vbgqe7djilt9yllr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you see the code is perfectly working fine, and results do tally up.&lt;/p&gt;

&lt;p&gt;I hope this gives a good idea of how to write an extension method in a way the configuration can be passed from outside. Here, the configuration is which field you want to sum up i.e. Salary &amp;amp; Stock.&lt;/p&gt;

&lt;p&gt;Happy Coding !!&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>linq</category>
      <category>delegate</category>
    </item>
    <item>
      <title>Solve the scenario - using Delegates &amp; Interfaces in Dotnet</title>
      <dc:creator>Debashish Pal</dc:creator>
      <pubDate>Thu, 22 Apr 2021 13:13:09 +0000</pubDate>
      <link>https://dev.to/debashish2014/solve-the-scenario-delegates-interfaces-in-dotnet-kkm</link>
      <guid>https://dev.to/debashish2014/solve-the-scenario-delegates-interfaces-in-dotnet-kkm</guid>
      <description>&lt;h1&gt;
  
  
  Use Case:
&lt;/h1&gt;

&lt;p&gt;We have this hypothetical reporting system where 2 entities are involved &lt;strong&gt;Report Generator&lt;/strong&gt; &amp;amp; &lt;strong&gt;Report&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Report Generator&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Report generator would have a single behavior. 

&lt;ul&gt;
&lt;li&gt;It should take 2 inputs as integers.&lt;/li&gt;
&lt;li&gt;It Returns a string back as an output which is basically the report presentation.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(So, basically above 2 point forms the contract that need to be fulfilled by any report generator)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Report&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Report should take report generator object or report generation logic in the form of function as an input.&lt;/li&gt;
&lt;li&gt;Give call to the report generator by passing input1 &amp;amp; input2.&lt;/li&gt;
&lt;li&gt;Get the string Output back from generator.&lt;/li&gt;
&lt;li&gt;Will have the functionality to write the Output to console or file system.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Whenever, I introduce a new Report Generator, neither Report entity nor existing Report Generator's, should be modified.&lt;/p&gt;

&lt;p&gt;Take a pause&lt;/p&gt;

&lt;p&gt;Think about the solution&lt;/p&gt;

&lt;h1&gt;
  
  
  ?
&lt;/h1&gt;

&lt;p&gt;Think again&lt;/p&gt;

&lt;p&gt;Scroll down for the solution &lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution
&lt;/h1&gt;

&lt;p&gt;Run the below code in Linqpad (&lt;a href="https://www.linqpad.net/"&gt;https://www.linqpad.net/&lt;/a&gt;), to see it working.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  Motivation
&lt;/h1&gt;

&lt;p&gt;Generally every one understands the theoretical aspect of Delegates and Interfaces, but when it comes to actual use of the same, beginner's lacks the understanding of when such constructs need be used and in which scenario. This problem based illustration might be of some help to understand the concept better.&lt;/p&gt;

&lt;p&gt;Happy Coding !!&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>delegate</category>
      <category>interface</category>
    </item>
  </channel>
</rss>
