اشتراک‌ها
نکاتی در رابطه با ویژگی‌های جدید C# 7.0

C# 7 is a major update with a lot of interesting new capabilities. And while there are plenty of articles on what you can do with it, there aren't quite as many on what you should do with it. Using the principles found in the .NET Framework Design Guidelines, we're going to take a first pass at laying down strategies for getting the most from these new features. 

نکاتی در رابطه با ویژگی‌های جدید C# 7.0
مطالب
دریافت خروجی Curl از HttpClient در دات‌نت (NET.)
در این مقاله قصد دارم راجع‌به یک Extension در دات نت صحبت کنم که خیلی وقت‌ها می‌تواند بسیار مفید و نجات بخش و همینطور در زمان کارتان تاثیر زیادی بگذارد. خیلی وقت‌ها پیش آمده که داریم با یک سرویس بیرونی ارتباط برقرار میکنیم، اما هنگام فراخوانی کردن، با خطا مواجه می‌شویم و ما متوجه دلیل خطای رخ داده در آن لحظه نمی‌شویم. برای خود من بار‌ها پیش آمده که Property‌های اطلاعات ورودی برای وب سرویس را بصورت Pascal Case داده باشم، ولی سرویس بیرونی فقط بصورت Camel Case برای آن قابل قبول بوده‌است و من بعد از ساعت‌ها بررسی متوجه این موضوع می‌شدم و یا ممکن بود یک Property با مقدار نادرست ارسال می‌کردم و یا ممکن بود یک Property را اصلا ارسال نمی‌کردم و یا حتی اینکه یک Header را درست نمی‌فرستادم و کلی از این موضوعات که با آن‌ها برخورد کردیم و با صرف زمان، مشکل را حل کردیم. این Extension کار ما را برای حل این مسائل خیلی راحت می‌کند.

حالا چطور و چگونه ازش استفاده کنیم؟!

این Extension کارش این است، وقتی HttpClient ما مقدار دهی شده و آماده‌ی برای ارسال درخواست به سرویس بیرونی است، می‌توانیم قبل ارسال، آن را فراخوانی کنیم و یک خروجی Curl از درخواستی را که داریم می‌فرستیم، ببینیم. سپس خروجی Curl را در ترمینال صدا بزنیم و نتیجه را ببینیم. همینطور می‌توانیم به Postman خود Import کنیم و با داکیومنتی که داده شده، بررسی کنیم و مشکل را دقیق‌تر بررسی کنیم.

نحوه Import کردن Curl در Postman
 open the Postman -> click on the Import button -> 
select the Raw text tab -> paste the curl script here -> 
then press the Continue button -> at the end press the button import.
جای دیگری که نقش این Extension می‌تواند تاثیر گذار باشد، زمانی است که ما از نحوه‌ی فراخوانی سرویس‌های بیرونی خود که در سیستم نوشته شده، هیچ داکیومنت یا Postman Collection ای نداریم. ما با این Extension با خروجی Curl که در اختیارمان می‌گذارد، می‌توانیم Collection خود را ایجاد کنیم و در اختیار هم تیمی‌های خود قرار دهیم. می‌بینید که چقدر کارها را ساده و راحت می‌کند!

استفاده از این Extension بسیار ساده و سریع است و شما با نوشتن یک خط می‌توانید آن را فراخوانی کنید: 
آدرس Nuget Package


این Extension سه(۳) راه برای نمایش Curl دارد:

۱- چاپ در Console
httpClient.GenerateCurlInConsole(httpRequestMessage, null);
پارامتر دوم، کانفیگ هست که شما می‌توانید بنا به نیاز، آنها را تغییر دهید (پیش فرض آن null است). مثال و توضیحات کانفیگ به شرح زیر است:
httpClient.GenerateCurlInConsole(
   httpRequestMessage,
   configs =>
   {
     configs.TurnOn = true;
     configs.NeedAddDefaultHeaders = true;
     configs.EnableCodeBeautification = false;
   });
- مقدارTurnOn پیش فرض فعال است؛ درصورت غیرفعال کردن جنریتور، غیر فعال می‌شود و عمل ایجاد اسکریپت را انجام نمی‌دهد.
- با مقدارNeedAddDefaultHeaders می‌توانید مشخص کنید در صورت داشتن هدر‌های پیش فرض، در خروجی Curl اضافه شود یا خیر. پیش فرض آن فعال هست.
- مقدارEnableCodeBeautification اگر فعال باشد اسکریپت‌های چاپ شده در Console را به ازای هر HttpMethod، با رنگ متفاوتی نشان می‌دهد؛ برای خوانایی بهتر اسکریپت. بصورت پیش فرض غیر فعال است.

۲- ذخیره در فایل

httpClient.GenerateCurlInFile(httpRequestMessage, null);
پارامتر دوم کانفیگ هست که شما می‌توانید بنا به نیاز، آنها را تغییر دهید (پیش فرض آن null است).
مثال و توضیحات کانفیگ به شرح زیر است:
httpClient.GenerateCurlInFile(
   httpRequestMessage,
   configs =>
   {
    configs.Filename = "your filename";
    configs.Path = "your path";
    configs.TurnOn = true;
    configs.NeedAddDefaultHeaders = true;
   });
- مقدارFilename را اگر وارد کنید، می‌توانید نام فایلی را که ایجاد می‌شود، مشخص کنید. در صورت مقدار ندادن، پیش فرض تاریخ روز جاری را اعمال میکند. مثال: 20220910.curl
- مقدارPath را می‌توانید در صورت داشتن مسیری خاص، مشخص کنید. در غیر این صورت بصورت پیش فرض اطلاعات را در مسیر ProjectDirectory\bin\Debug\netX ذخیره می‌کند.
- مقدارTurnOn پیش فرض آن فعال است. درصورت غیرفعال کردن جنریتور غیر فعال می‌شود و عمل ایجاد اسکریپت را انجام نمی‌دهد.
- با مقدار NeedAddDefaultHeaders می‌توانید مشخص کنید در صورت داشتن هدر‌های پیش فرض، در خروجی Curl اضافه شود یا خیر. پیش فرض آن فعال هست.

۳- ذخیره در متغیر

httpClient.GenerateCurlInString(httpRequestMessage);

لینک آدرس GitHub پروژه جهت دیدن سورس پروژه و دیدن مثال‌های بیشتر و همینطور برای دیدن قابلیت‌های بیشتر این extension.

خوشحال می‌شوم اگه نظری دارید راجع به پروژه و یا مشکلی دیدید در سورس کد به من اطلاع بدهید و خیلی خوشحال می‌شوم اگر در تکمیل و پیاده سازی این پروژه مشارکت کنید و اگر این پروژه براتون جذاب و یا مفید بود استار بدهید.

اشتراک‌ها
SDK چیست ؟

SDKs are the building blocks of app development. Here’s what non-devs need to know. 

SDK چیست ؟
اشتراک‌ها
بررسی نکات مخفی در NET Core 3.

You've likely heard about the headline features in .NET Core 3.0 including Blazor, gRPC, and Windows desktop app support, but what else is there? This is a big release so come and see David Fowler and Damian Edwards from the .NET Core team showcase their favorite new features you probably haven't heard about in this demo-packed session.


بررسی نکات مخفی در NET Core 3.
اشتراک‌ها
سورس نگارش کامل دات نت

The referencesource repository contains sources from Microsoft .NET Reference Source that represent a subset of the .NET Framework. This subset contains similar functionality to the class libraries that are being developed in .NET Core. We intend to consult the referencesource repository as we develop .NET Core. It is also for the community to leverage to enable more scenarios for .NET developers. 

سورس نگارش کامل دات نت
اشتراک‌ها
ReScript زبان پس از TypeScript؟

In the confusing jungle of transpiler languages for JavaScript, there are some gems. TypeScript is mainstream, ReScript is starting to establish itself, and Elm is still an insider tip. This article takes a detailed look at ReScript – but also sheds light on the limitations of the young language. In what projects does its use make sense? What projects should rather use TypeScript on the one hand or Elm on the other? 

ReScript زبان پس از TypeScript؟
اشتراک‌ها
رندر سمت سرور کامپوننت‌های Blazor در دات نت 8

  The "Blazor United" effort is really a collection of features we're adding to Blazor so that you can get the best of server & client based web development. These features include: Server-side rendering, streaming rendering, enhanced navigations & form handling, add client interactivity per page or component, and determining the client render mode at runtime. We've started delivering server-side rendering support for Blazor with .NET 8 Preview 3, which is now available to try out. We plan to deliver the remaining features in upcoming previews. We hope to deliver them all for .NET 8, but we'll see how far we get. 

رندر سمت سرور کامپوننت‌های Blazor در دات نت 8
اشتراک‌ها
همکاری با DevComponents در زمینه تولید کامپوننت!

سال‌هاست که از کامپوننت‌های DevComponents در کارهای خودم استفاده می‌کنم. شاید شما هم از طرفداران این کامپوننت‌ها باشید چرا که در بین شرکت‌های موجود، ارائه کیفیت در عین حفظ کمترین تعداد dllها از ویژگی‌های بارز DevComponents محسوب می‌شود.
در حالیکه برای بررسی نخسه‌های آخر سری به وب‌سایت و بعد وبلاگشون زدم، متوجه شدم که DevComponents علاقمند به همکاری با برنامه‌نویسان و طراحان از سرتاسر دنیاست. متن آغازین این همکاری برام خیلی جالب بود:

"There are three kinds of people in this world: Those who make things happen; those who watch things happen; and those who just wonder what a heck happened? "

خلاصه اگر به دسته اول تعلق دارید، می‌توانید از این فرصت بهره‌مند شوید. تنها چیزی که به آن احتیاج دارید بستر اینترنت خوب برای برقراری ارتباط می‌باشد.

You can be located anywhere in the world as long as you have internet connection. You can work any hours you want as long as work gets done. You have freedom and control over your working hours. All we ask for is that things get done. You will also get responsibility of supporting whatever you develop since we believe that is the best way to understand what our customers need. 

همکاری با DevComponents در زمینه تولید کامپوننت!
اشتراک‌ها
راهنمای جامعی از فریم ورک های جاوااسکریپتی

Keeping up with JavaScript frameworks can be a challenge. There are a lot of them, and seemingly another one every month. How do you know which ones might be right for your project? What are their strengths and weaknesses? How do you get started? 

راهنمای جامعی از فریم ورک های  جاوااسکریپتی
اشتراک‌ها
توصیه تیم کروم به عدم استفاده‌ی از alert/confirm/prompt

alert()/confirm()/prompt() dialogs are being changed. Rather than being app-modal, they will be dismissed when their tab is switched from. (Safari 9.1 already does this.) This is fully enabled on the canary and dev channels and partially enabled on the beta and stable channels, and will be enabled more in the future. 

توصیه تیم کروم به عدم استفاده‌ی از alert/confirm/prompt