<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rasika Gayan Gunarathna on Medium]]></title>
        <description><![CDATA[Stories by Rasika Gayan Gunarathna on Medium]]></description>
        <link>https://medium.com/@rasikagayan?source=rss-1338dfbfee69------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Nv3IO1U16kvAEqDfLTETpA.jpeg</url>
            <title>Stories by Rasika Gayan Gunarathna on Medium</title>
            <link>https://medium.com/@rasikagayan?source=rss-1338dfbfee69------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:11:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rasikagayan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Please select your language…]]></title>
            <link>https://rasikagayan.medium.com/please-select-your-language-8f53f7f38e8c?source=rss-1338dfbfee69------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f53f7f38e8c</guid>
            <dc:creator><![CDATA[Rasika Gayan Gunarathna]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 16:40:52 GMT</pubDate>
            <atom:updated>2023-02-26T16:40:52.261Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://rasikagayan.medium.com/please-help-to-buy-a-macbook-pro-to-do-the-postproduction-of-my-photos-c42abb7ff95a">English</a></p><p><a href="https://rasikagayan.medium.com/bitte-helfen-sie-mit-ein-macbook-pro-f%C3%BCr-die-postproduktion-meiner-fotos-zu-kaufen-f387855d2601">Deutsch</a></p><p><a href="https://rasikagayan.medium.com/%D0%BF%D0%BE%D0%B6%D0%B0%D0%BB%D1%83%D0%B9%D1%81%D1%82%D0%B0-%D0%BF%D0%BE%D0%BC%D0%BE%D0%B3%D0%B8%D1%82%D0%B5-%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D1%8C-macbook-pro-%D0%B4%D0%BB%D1%8F-%D0%BE%D0%B1%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%BA%D0%B8-%D0%BC%D0%BE%D0%B8%D1%85-%D1%84%D0%BE%D1%82%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D0%B9-91878b09f084">Русский</a></p><p><a href="https://rasikagayan.medium.com/aidez-moi-%C3%A0-acheter-un-macbook-pro-pour-faire-la-postproduction-de-mes-photos-ebe28ef3d2a0">Français</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f53f7f38e8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Aidez-moi à acheter un MacBook Pro pour faire la postproduction de mes photos.]]></title>
            <link>https://rasikagayan.medium.com/aidez-moi-%C3%A0-acheter-un-macbook-pro-pour-faire-la-postproduction-de-mes-photos-ebe28ef3d2a0?source=rss-1338dfbfee69------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebe28ef3d2a0</guid>
            <dc:creator><![CDATA[Rasika Gayan Gunarathna]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 16:39:55 GMT</pubDate>
            <atom:updated>2023-02-26T16:39:55.413Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rHeQ-RmRTHIDmAqCblD39A.jpeg" /><figcaption>Une photo d’un singe feuille à face violette de l’Ouest que j’ai prise dans un parc local au Sri Lanka.</figcaption></figure><p>Bonjour,</p><p>Tout d’abord, merci beaucoup d’avoir scanné mon code QR. Je suis Rasika Gayan, et s’il vous plaît, donnez-moi une minute pour partager mon histoire avec vous.</p><p>Devenir photographe était un rêve que j’avais depuis de nombreuses années, mais ce n’est qu’il y a six mois que j’ai enfin sauté le pas. J’ai acheté des objectifs usagés et un boîtier d’appareil photo pour prendre des photos d’animaux sauvages et de paysages, et je suis rapidement tombé amoureux de l’art de capturer des moments à travers mon objectif. Cependant, le coût d’achat de ces objectifs me laissait des fonds limités et je savais que j’avais besoin d’un ordinateur portable approprié pour le travail de post-production.</p><p>Malgré les défis auxquels j’ai dû faire face, je suis resté sérieux dans ma passion pour la photographie. Il ne s’agissait pas seulement de prendre des photos pour moi; il s’agissait de la joie que cela m’a apportée de capturer un moment et de le partager avec d’autres. Je savais que je devais améliorer mes compétences et faire passer ma photographie au niveau supérieur, mais sans ordinateur portable approprié, mon potentiel créatif était limité.</p><p>C’est pourquoi je vous demande votre aide pour soutenir mon projet GoFundMe d’achat d’un Macbook Pro. Je suis très reconnaissant pour toute aide que vous pouvez fournir, car cela me permettra de produire des images de haute qualité qui capturent vraiment l’essence du moment. La photographie est devenue bien plus qu’un passe-temps pour moi; c’est une façon de se connecter avec le monde qui m’entoure et de partager la beauté que je vois. Votre soutien signifierait le monde pour moi, et je suis très reconnaissant pour votre gentillesse et votre générosité.</p><p>Merci beaucoup</p><p>Rasika Gayan</p><p>Ma page Facebook :</p><p><a href="https://www.facebook.com/rasikagayanphotography/">Rasika Gayan Photographie</a></p><p>Mon projet GoFundMe et QR :</p><p><a href="https://gofund.me/e74e3a89">Aidez Rasika à faire son travail de post-production — GoFundMe.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*DOOM5maSbyIwpiFf0F-9bg.png" /><figcaption>Lien du projet GoFundMe</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebe28ef3d2a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Пожалуйста, помогите купить MacBook Pro для обработки моих фотографий.]]></title>
            <link>https://rasikagayan.medium.com/%D0%BF%D0%BE%D0%B6%D0%B0%D0%BB%D1%83%D0%B9%D1%81%D1%82%D0%B0-%D0%BF%D0%BE%D0%BC%D0%BE%D0%B3%D0%B8%D1%82%D0%B5-%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D1%8C-macbook-pro-%D0%B4%D0%BB%D1%8F-%D0%BE%D0%B1%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%BA%D0%B8-%D0%BC%D0%BE%D0%B8%D1%85-%D1%84%D0%BE%D1%82%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D0%B9-91878b09f084?source=rss-1338dfbfee69------2</link>
            <guid isPermaLink="false">https://medium.com/p/91878b09f084</guid>
            <dc:creator><![CDATA[Rasika Gayan Gunarathna]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 16:20:52 GMT</pubDate>
            <atom:updated>2023-02-26T16:20:52.055Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rHeQ-RmRTHIDmAqCblD39A.jpeg" /><figcaption>Фотография западной пурпурнолицей листовой обезьяны, которую я сделал в местном парке на Шри-Ланке.</figcaption></figure><p>Привет,</p><p>Прежде всего, большое спасибо за сканирование моего QR-кода. Я Расика Гаян, и, пожалуйста, дайте мне минуту, чтобы поделиться с вами своей историей.</p><p>Стать фотографом было моей мечтой на протяжении многих лет, но только шесть месяцев назад я, наконец, сделал решительный шаг. Я купил несколько бывших в употреблении объективов и корпус камеры, чтобы делать фотографии дикой природы и пейзажей, и быстро влюбился в искусство запечатлевать моменты с помощью своего объектива. Однако стоимость покупки этих объективов оставила меня с ограниченными средствами, и я знал, что мне нужен подходящий ноутбук для постпродакшна.</p><p>Несмотря на трудности, с которыми я столкнулся, я продолжал серьезно относиться к своей страсти к фотографии. Для меня это было не просто фотографирование; речь шла о радости, которую мне доставило запечатлеть момент и поделиться им с другими. Я знал, что мне нужно улучшить свои навыки и вывести фотографию на новый уровень, но без подходящего ноутбука мой творческий потенциал был ограничен.</p><p>Вот почему я обращаюсь к вам за помощью в поддержке моего проекта GoFundMe по покупке Macbook Pro. Я так благодарен за любую помощь, которую вы можете оказать, поскольку это позволит мне создавать высококачественные изображения, которые действительно отражают суть момента. Фотография стала для меня намного больше, чем просто хобби; это способ соединиться с окружающим миром и поделиться красотой, которую я вижу. Ваша поддержка будет означать для меня мир, и я так благодарен за вашу доброту и щедрость.</p><p>Большое спасибо</p><p>Расика Гаян</p><p>Моя страница в Фейсбуке:</p><p><a href="https://www.facebook.com/rasikagayanphotography/">Расика Гаян Фотография</a></p><p>Мой проект GoFundMe и QR:</p><p><a href="https://gofund.me/e74e3a89">Помогите Расике с постпродакшном — GoFundMe.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*DOOM5maSbyIwpiFf0F-9bg.png" /><figcaption>Ссылка на проект GoFundMe</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91878b09f084" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bitte helfen Sie mit, ein MacBook Pro für die Postproduktion meiner Fotos zu kaufen.]]></title>
            <link>https://rasikagayan.medium.com/bitte-helfen-sie-mit-ein-macbook-pro-f%C3%BCr-die-postproduktion-meiner-fotos-zu-kaufen-f387855d2601?source=rss-1338dfbfee69------2</link>
            <guid isPermaLink="false">https://medium.com/p/f387855d2601</guid>
            <dc:creator><![CDATA[Rasika Gayan Gunarathna]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 16:14:35 GMT</pubDate>
            <atom:updated>2023-02-26T16:14:35.000Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rHeQ-RmRTHIDmAqCblD39A.jpeg" /><figcaption>Ein Foto von Western Purple-faced Leaf Monkey, das ich in einem örtlichen Park in Sri Lanka aufgenommen habe.</figcaption></figure><p>Hallo,</p><p>Zunächst einmal vielen Dank, dass Sie meinen QR-Code gescannt haben. Ich bin Rasika Gayan und bitte geben Sie mir eine Minute, um Ihnen meine Geschichte zu erzählen.</p><p>Fotograf zu werden war ein Traum, den ich viele Jahre hatte, aber erst vor sechs Monaten habe ich endlich den Sprung gewagt. Ich kaufte einige gebrauchte Objektive und ein Kameragehäuse, um Tier- und Landschaftsfotos zu machen, und ich verliebte mich schnell in die Kunst, Momente durch mein Objektiv festzuhalten. Die Kosten für den Kauf dieser Objektive ließen mich jedoch mit begrenzten Mitteln zurück, und ich wusste, dass ich einen richtigen Laptop für die Nachbearbeitung brauchte.</p><p>Trotz der Herausforderungen, denen ich gegenüberstand, blieb ich ernsthaft bei meiner Leidenschaft für die Fotografie. Es ging mir nicht nur darum, Fotos zu machen; Es ging um die Freude, die es mir bereitete, einen Moment festzuhalten und ihn mit anderen zu teilen. Ich wusste, dass ich meine Fähigkeiten verbessern und meine Fotografie auf die nächste Stufe heben musste, aber ohne einen richtigen Laptop war mein kreatives Potenzial begrenzt.</p><p>Aus diesem Grund bitte ich Sie um Ihre Hilfe bei der Unterstützung meines GoFundMe-Projekts zum Kauf eines Macbook Pro. Ich bin so dankbar für jede Hilfe, die Sie leisten können, da ich dadurch qualitativ hochwertige Bilder erstellen kann, die die Essenz des Augenblicks wirklich einfangen. Die Fotografie ist für mich so viel mehr als nur ein Hobby geworden; Es ist eine Möglichkeit, mich mit der Welt um mich herum zu verbinden und die Schönheit, die ich sehe, zu teilen. Ihre Unterstützung würde mir die Welt bedeuten, und ich bin so dankbar für Ihre Freundlichkeit und Großzügigkeit.</p><p>Vielen Dank</p><p>Rasika Gayan</p><p>Meine Facebook-Seite:</p><p><a href="https://www.facebook.com/rasikagayanphotography/">Rasika Gayan Photography</a></p><p>Mein GoFundMe-Projekt und QR:</p><p><a href="https://gofund.me/e74e3a89">Hilf Rasika bei seiner Postproduktionsarbeit — GoFundMe.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*DOOM5maSbyIwpiFf0F-9bg.png" /><figcaption>GoFundMe-Projektlink</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f387855d2601" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Please help to buy a MacBook Pro to do the postproduction of my photos.]]></title>
            <link>https://rasikagayan.medium.com/please-help-to-buy-a-macbook-pro-to-do-the-postproduction-of-my-photos-c42abb7ff95a?source=rss-1338dfbfee69------2</link>
            <guid isPermaLink="false">https://medium.com/p/c42abb7ff95a</guid>
            <dc:creator><![CDATA[Rasika Gayan Gunarathna]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 16:05:58 GMT</pubDate>
            <atom:updated>2023-02-26T16:05:58.367Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rHeQ-RmRTHIDmAqCblD39A.jpeg" /><figcaption>A photo of Western Purple-faced leaf monkey I took at a local park in Sri Lanka.</figcaption></figure><p>Hello there,</p><p>First of all, thank you very much for scanning my QR code. I am Rasika Gayan, and please give me a minute to share my story with you.</p><p>Becoming a photographer was a dream that I had for many years, but it wasn’t until six months ago that I finally took the plunge. I bought some used lenses and a camera body to take wildlife and landscape photos, and I quickly fell in love with the art of capturing moments through my lens. However, the cost of purchasing those lenses left me with limited funds, and I knew that I needed a proper laptop for post-production work.</p><p>Despite the challenges that I faced, I remained serious about my passion for photography. It wasn’t just about taking photos for me; it was about the joy that it brought me to capture a moment and share it with others. I knew that I needed to enhance my skills and take my photography to the next level, but without a proper laptop, my creative potential was limited.</p><p>That is why I am reaching out to you for your help in supporting my GoFundMe project to buy a Macbook Pro. I am so grateful for any help that you can provide, as it will allow me to produce high-quality images that truly capture the essence of the moment. Photography has become so much more than just a hobby for me; it’s a way to connect with the world around me and share the beauty that I see. Your support would mean the world to me, and I am so grateful for your kindness and generosity.</p><p>Thank you very much</p><p>Rasika Gayan</p><p>My Facebook page:</p><p><a href="https://www.facebook.com/rasikagayanphotography/">Rasika Gayan Photography</a></p><p>My GoFundMe project and QR:</p><p><a href="https://gofund.me/e74e3a89">Help Rasika to do his post-production work — GoFundMe.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*DOOM5maSbyIwpiFf0F-9bg.png" /><figcaption>GoFundMe Project Link</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c42abb7ff95a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C# Generics — 03]]></title>
            <link>https://rasikagayan.medium.com/c-generics-03-e9153b2195e7?source=rss-1338dfbfee69------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9153b2195e7</guid>
            <category><![CDATA[generics]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Rasika Gayan Gunarathna]]></dc:creator>
            <pubDate>Sun, 24 Jul 2022 11:14:29 GMT</pubDate>
            <atom:updated>2022-07-24T11:14:29.420Z</atom:updated>
            <content:encoded><![CDATA[<h3>C# Generics — 03</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*prcV4RExh1eUhRgrbleZxA.jpeg" /><figcaption>Photo by Sami Anas: <a href="https://www.pexels.com/photo/cliffs-in-sea-near-coast-at-sunset-5137664/">https://www.pexels.com/photo/cliffs-in-sea-near-coast-at-sunset-5137664/</a></figcaption></figure><p>Define genetic methods</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*NKoWe82vIwO3ts3zw1aOeQ.png" /></figure><p>So the use of the above methods is as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*EMqnAT0H1pcEN3apvpCvjQ.png" /></figure><p>Another example with a generic return value. This is an extension method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*tdePEzILjM_Hy6UE-DJafQ.png" /></figure><p>We can also define generic delegates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*GUDYZuxA0wLuqv9oBbO7QA.png" /></figure><p><strong>We can also define covariant and contravariant delegates using out and in keywords.</strong></p><p>We can have a generic method in the generic class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*xtGhs-rgwksH_OkE2kGrlg.png" /></figure><p>Reference:</p><ul><li><a href="https://app.pluralsight.com/library/courses/c-sharp-generics/table-of-contents">Sign In | Pluralsight</a></li><li><a href="https://docs.microsoft.com/en-us/dotnet/api/system.action-1?view=net-6.0">Action Delegate (System)</a></li><li><a href="https://docs.microsoft.com/en-us/dotnet/api/system.func-2?view=net-6.0">Func Delegate (System)</a></li><li><a href="https://docs.microsoft.com/en-us/dotnet/api/system.eventhandler-1?view=net-6.0">EventHandler Delegate (System)</a></li><li><a href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/generic-methods">Generic Methods - C# Programming Guide</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9153b2195e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C# Generic — 02]]></title>
            <link>https://rasikagayan.medium.com/c-generic-02-f21f61e17da3?source=rss-1338dfbfee69------2</link>
            <guid isPermaLink="false">https://medium.com/p/f21f61e17da3</guid>
            <category><![CDATA[generics]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Rasika Gayan Gunarathna]]></dc:creator>
            <pubDate>Sun, 24 Jul 2022 05:30:34 GMT</pubDate>
            <atom:updated>2022-07-24T05:30:34.357Z</atom:updated>
            <content:encoded><![CDATA[<h3>C# Generic — 02</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LK9XREP0JKJ4iQcK3j_qsg.jpeg" /><figcaption>Photo by Francesco Ungaro: <a href="https://www.pexels.com/photo/hot-air-ballons-in-the-sky-2325446/">https://www.pexels.com/photo/hot-air-ballons-in-the-sky-2325446/</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*dVo9YBa243sdpXh3DNQC6Q.png" /></figure><p>If the interface has generic constraints, its implemented class need to define these constraints too. See the below image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*vxucQo7FtD1N-G-3P3IRmQ.png" /></figure><h4>Invariant, Covariant and Contravarince</h4><p>What is Invariant?</p><p>In an interface, generic type parameters are invariant because Interface and class implementation have the same generic parameter type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*t7LjIDYWDLc1ZknDQ4eFmQ.png" /></figure><p>(See the same type parameter as Teacher type)</p><p>We can define covariant by using the “out” keyword because we can have a less specific type in methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*cWAMI36D7NTPl9F_ShonFw.png" /></figure><p>But other methods need to have contravariantly valid.</p><p>So we can divide it into 2 interfaces for this solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wZQwvpopttYF8ugs-sjL4A.png" /></figure><p>After fixing all solutions would be like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*1OAYHTvHW7WnOO7cByoYug.png" /></figure><p>The main point is that we have a PrintAll method that uses for all.</p><p>What is the importance of Generic Interfaces?</p><h4>Contravariance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*u26NINL4uAPBTOl2tKDK-A.png" /></figure><p>We can avoid the above by doing as following .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*1tvnAxLn9XgaedZKhCM_lQ.png" /></figure><p>But now we get a new error that we can’t pass IRepositoryType&lt;Teacher&gt; to the above method. Because it is default invariant.</p><p>To resolve that we can change the interfaces as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rmW5_FqEDmiqHGGs0sj4aw.png" /></figure><p>And change the method parameter to as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*yju7XSHW3kyGVRqCgr7bXQ.png" /></figure><p>Proof of D in SOLID: Component only deepened on abstraction, not in the implementation.</p><h4>Reference:</h4><ul><li><a href="https://app.pluralsight.com/library/courses/c-sharp-generics/table-of-contents">Sign In | Pluralsight</a></li><li><a href="https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/types/generics">Generic classes and methods</a></li><li><a href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/generic-type-parameters">Generic Type Parameters - C# Programming Guide</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f21f61e17da3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C# Generic — 01]]></title>
            <link>https://rasikagayan.medium.com/c-generic-01-17caac2283bc?source=rss-1338dfbfee69------2</link>
            <guid isPermaLink="false">https://medium.com/p/17caac2283bc</guid>
            <category><![CDATA[generics]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Rasika Gayan Gunarathna]]></dc:creator>
            <pubDate>Sat, 16 Jul 2022 05:33:32 GMT</pubDate>
            <atom:updated>2022-07-16T05:33:32.739Z</atom:updated>
            <content:encoded><![CDATA[<h3>C# Generic — 01</h3><p>First, check how to define a generic class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*14alAq8RZAg2SGfB-b2HNg.png" /></figure><p>We defined the generic class as above. We can call it Repository[Class name] of T.</p><p>So we can define some classes in a school management system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*NvkiDIjlF7Z2b0BodSf-Yg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*mSnGvye7EEwjSOFnD8o4RA.png" /></figure><p>So now we have two Entity classes.</p><p>Let’s create a generic repository class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*2FfdL7hUSDhSkbEKcESvaQ.png" /></figure><p>After creating instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*Pq73zQmPJUZuXKGKaTkt1w.png" /></figure><h4>Generic class inheritance</h4><p>If we inherited a generic class to a non-genric class, we need to define the type in there. (change the superclass _dataset access modifier to protected )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*xC5w9hAZK8nU0xIVBJJIhg.png" /></figure><p>But also we can create a generic sub-class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*Uxaz7En8qGwtWxhc0yMciw.png" /></figure><h4>Constraints on generic type parameters</h4><p><a href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters">Constraints on type parameters - C# Programming Guide</a></p><p>If we add the below method to the repository class, it will give an error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*E2erCxc1DsMfcTdCmpbx-A.png" /></figure><p>Because type T doesn’t know whether the concrete type will have an Id property or not, so we need to add a constraint that all the types that pass to this will have Id prop.</p><p>So we can encapsulate the Id and use it as a superclass</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*oqiS3SOVi944RS4QlfUtiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*e6AwMrfPwM7YY8tNIh9_bA.png" /></figure><p>Change the Repository class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*G00d-1SWnXUT8yo1wZnMJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*oYSNc-the1ukXxlUXxmuvw.png" /></figure><p>We only define IEntity type in type constraint. So that means T can be value type or reference type.</p><p>But if we added EntityBase , that means we need to be T as EntityBase type. That means T must be reference type.</p><p>If we only add IEntity , we can’t return null from a below method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*64IfjTXf230Yp6jy07IgpA.png" /></figure><p>Because T can be null-nullable value type.</p><p>So we can update as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*1LReLC3jzVneg9wxlaZ7ig.png" /></figure><p>As a important point if we want to return null as explicitly we need to define that T is a reference type. So we add that T is a reference type add class keyword.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*kxA2dDcqXx0ffzPyF-zr9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*buyXdi1iv6rHFDyVYrc4KQ.png" /></figure><p>We can add ? mark as this can be nullble reference type.</p><p>If we want to return a instance of type T we need to add new() to the end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*iCR2Gv8V8l-mf1QuJn-40Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*dtK7CO2av4mOWVZVRtmZgA.png" /></figure><p>Impotant thing is we need to make sure passing type need to have default constructor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*LpQSSw3XajngWdz87Hr1Lg.png" /></figure><p>References</p><ol><li><a href="https://app.pluralsight.com/library/courses/c-sharp-generics/table-of-contents">https://app.pluralsight.com/library/courses/c-sharp-generics/table-of-contents</a></li><li><a href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters">https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17caac2283bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Reddit Clone Using React and GraphQL — 19]]></title>
            <link>https://rasikagayan.medium.com/creating-a-reddit-clone-using-react-and-graphql-19-8a75dabc865d?source=rss-1338dfbfee69------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a75dabc865d</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[reddit-clone]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Rasika Gayan Gunarathna]]></dc:creator>
            <pubDate>Sat, 29 May 2021 14:07:33 GMT</pubDate>
            <atom:updated>2021-05-29T14:07:33.899Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating a Reddit Clone Using React and GraphQL — 19</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTcXOBVQ8tPfbFaX9AzkLw.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@ian-beckley-1278367?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Ian Beckley</a> from <a href="https://www.pexels.com/photo/lake-with-mountain-view-2440021/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><p>Before going back to this post, I was out of adding my content to Medium. The reason is it quite painful to manually add my code as Github Gists and come back and paste it here. Because my personal blog site and <a href="http://dev.to/">dev.to</a> that I re-blogging is support markdown and it is quite easy to maintain those two.</p><p>But later I thought that anyway I can paste my URLs in here and show it as a preview. So, from this blog post, you will redirect to my personal blog post or <a href="http://dev.to/">dev.to</a> site according to what you click.</p><p>Thank you very much for your kind understanding.</p><ul><li><a href="https://dev.to/rasikag/creating-a-reddit-clone-using-react-and-graphql-19-1md6">Creating a Reddit Clone Using React and GraphQL - 19</a></li><li><a href="https://www.rasikag.com/posts/creating-a-reddit-clone-using-react-and-graphql-19">Creating a Reddit Clone Using React and GraphQL - 19</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a75dabc865d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Reddit Clone Using React and GraphQL -12]]></title>
            <link>https://rasikagayan.medium.com/creating-a-reddit-clone-using-react-and-graphql-12-3b0a9ac80694?source=rss-1338dfbfee69------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b0a9ac80694</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Rasika Gayan Gunarathna]]></dc:creator>
            <pubDate>Tue, 16 Mar 2021 18:10:16 GMT</pubDate>
            <atom:updated>2021-03-16T18:10:16.385Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QASgDD_1Pp81V7J56flN5Q.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@pixabay?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pixabay</a> from <a href="https://www.pexels.com/photo/green-mountains-and-flowing-river-206660/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><p><strong>This blog post originally posted on my blog site and you can find it </strong><a href="https://www.rasikag.com/posts/creating-a-reddit-clone-using-react-and-graphql-12"><strong>here</strong></a><strong>.</strong></p><p>As I said in an earlier post we have to manage 2 scenarios here.<br>1. Refresh the cache for forgot password <br>2. Error handle for token errors.</p><p>Add below code lines to handle the token errors. We are using states here.</p><pre>const [tokenError, setTokenError]  = useState(&#39;&#39;);</pre><p>Then we are adding the below code to check that token error exist. If so we are. adding it to state.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/456e3747ab42b20f87dbdf4e202a9f98/href">https://medium.com/media/456e3747ab42b20f87dbdf4e202a9f98/href</a></iframe><p>Let’s display this error.</p><pre>{tokenError ? &lt;Box color=&quot;red&quot;&gt;{tokenError}&lt;/Box&gt; : null}</pre><p>Add this moment if you try, you will get 404 error. The issue in here, that we didn&#39;t wrap this with with withUrqlClient . Let’s cover the component with it.</p><pre>export default withUrqlClient(createUrqlClient)(ChangePassword);</pre><p>Now, we need to delete the token from the back-end once we use this token. Let’s do that next.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/685dc49d37deda6b6ff37dd7a1f6a421/href">https://medium.com/media/685dc49d37deda6b6ff37dd7a1f6a421/href</a></iframe><p>Now if you try to use the token 2nd time to change the password, you will get the token expired error. Cool. All working fine now.</p><p>Okay, now we only left here, if the token expired your need to get a new token. Let’s add that. First, we are adding a link to get a new token page.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38763b2248dc68b83c512240e1cee712/href">https://medium.com/media/38763b2248dc68b83c512240e1cee712/href</a></iframe><p>Once you click on the link it will bring you to forgot-password page. Let’s quickly add that page.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bf0e6026f4b15a7a0732d68886d024b/href">https://medium.com/media/2bf0e6026f4b15a7a0732d68886d024b/href</a></iframe><p>This also needs to add to Login page.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1209680c124ae08da976645056294f27/href">https://medium.com/media/1209680c124ae08da976645056294f27/href</a></iframe><p>As the last for this forgot-passward page, we need the user to insert an email address. Let’s copy from Login page and add it in here. Also we need to create a mutation for forgot-password .This will only return a boolean value.</p><pre>mutation ForgotPassword($email: String!) {<br>    forgotPassword(email: $email)<br>}</pre><p>In forgot-password.tsx page, we use state to set a success message.</p><pre>const [complete, setComplete] = userState(false);</pre><p>Here is the full code for forgot-password.tsx file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e48e4cfc8fd4c99629933d9667730802/href">https://medium.com/media/e48e4cfc8fd4c99629933d9667730802/href</a></iframe><p>At this point, we have done almost everything with user management and authentication tasks of this application. From the next blog post, let’s work on adding posts to the Reddit clone.</p><p>Thanks for reading this. If you have anything to ask regarding this please leave a comment here. Also, I wrote this according to my understanding. So if any point is wrong, don’t hesitate to correct me. I really appreciate you.<br>That’s for today friends. See you soon. Thank you.</p><p><strong>References:</strong></p><p>This article series based on the <a href="https://www.youtube.com/watch?v=I6ypD7qv3Z8">Ben Award — Fullstack React GraphQL TypeScript Tutorial</a>. This is an amazing tutorial and I highly recommend you to check that out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b0a9ac80694" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>