اشتراک‌ها
روش های مقایسه اشیاء با null

Check

Code 

Description

Is Null
if(variable is null) return true;

  • 🙂 This syntax supports static analysis such that later code will know whether variable is null or not.
  • 🙁 Doesn’t produce a warning even when comparing against a non-nullable value type making the code to check pointless.
  • 😐 Requires C# 7.0 because it leverages type pattern matching.
Is Not Null
if(variable is { }) return false

  • 🙂 This syntax supports static analysis such that later code will know whether variable is null or not.
  • 😐 Requires C# 8.0 since this is the method for checking for not null using property pattern matching.
Is Not Null
if(variable is object) return false

  • 🙂 Triggers a warning when comparing a non-nullable value type which could never be null
  • 🙂 This syntax works with C# 8.0’s static analysis so later code will know that variable has been checked for null.
  • Checks if the value not null by testing whether it is of type object.  (Relies on the fact that null values are not of type object.)
Is Null
if(variable == null) return true

  • 🙂 The only way to check for null prior to C# 7.0.
  • 🙁 However, because the equality operator can be overridden, this has the (remote) possibility of failing or introducing a performance issue.
Is Not Null
if(variable != null) return false

  • 🙂 The only way to check for not null prior to C# 7.0.
  • 😐 Since the not-equal operator can be overridden, this has the (remote) possibility of failing or introducing a performance issue. 
روش های مقایسه اشیاء با null
اشتراک‌ها
بررسی <IAsyncEnumerable<T در NET Core 3.

One of the most exciting features of .NET Core 3 and C# 8.0 has been the addition of IAsyncEnumerable<T> (aka async streams). But what's so special about it? What can we do now that wasn't possible before? 

بررسی <IAsyncEnumerable<T در NET Core 3.
پرسش‌ها
آیا امکان اجرای API روی IIS تنها برای یک سرور وجود دارد؟

سلام

یک API دارم که قراره روی یک سرور و توسط IIS اجرا بشه. برنامه کلاینت یک برنامه WindowApp هستش. در حال حاضر این دو با هم ارتباط دارند و با بخوبی کار میکنند. ولی این امکان نیز وجود داره که API را در جای سرور دیگری نیز اجرا و مجددا استفاده کنند. آیا همانند برنامه های ویندوزی امکان این وجود داره که یک برنامه API جهت تشخیص سرور مورد نظر، اطلاعات سخت افزاری سرور را بررسی کند یا راه حل دیگه ای برای این موضوع وجود داره؟

تشکر

اشتراک‌ها
بررسی Native AOT در دات‌نت 8
Deep .NET - Ahead of Time Compilation (Native AOT) with Eric Erhardt

Scott Hanselman is joined by Eric Erhardt to go deep on all things Native AOT, that is right, Ahead of Time Compilation. Learn about everything Native AOT from start to finish and how .NET leverages this technology to make your apps and code super fast.

Chapters:
00:00:00 Intro
00:04:17 Understanding the Options and Restrictions of Publishing in .NET Apps
00:06:46 Limitations and Benefits of Native AOT
00:12:33 Development and Implementation of Web API AOT
00:16:28 Use of Create Small and Source Generators in Web Development
00:22:03 Role and Impact of Source Generators in Software Development
00:29:17 Application Performance Optimization and Role-Based Optimization in Web Development
00:33:27 Program Optimization Techniques and Trade-offs
00:37:28 Trade-offs and Considerations in Application Optimization
00:41:27 Understanding the Challenges and Limitations of Implementing AOT
00:46:34 Understanding and Implementing AOT
00:52:56 Understanding Model Streaming Extensions
00:55:50 C# 11 and AOT
01:03:49 Understanding and Addressing AOT Compatibility Issues
01:08:54 Understanding Trimming
01:10:35 Understanding and Addressing System Memory Data and Error Handling
01:16:16 Binary Data Compatibility and Source Generation in Visual Studio
01:24:25 Advanced Features
01:25:29 Wrap-up
بررسی Native AOT در دات‌نت 8
مطالب
خلاصه اشتراک‌های روز چهار شنبه 27 مهر 1390
مطالب
خواندنی‌ها روز 22 فروردین

سایت iplocationtools بانک اطلاعاتی موقعیت مکانی IP های خود را که ماهیانه نیز به روز خواهد شد، به رایگان برای دریافت قرار داده است. فرمت تعاریف جداول و عبارت insert آن مطابق دستورات بانک اطلاعاتی MySQL است.
تنها بازیگر شاخص یازده سال قبل در زمینه توسعه برنامه‌های مبتنی بر QT ، برنامه KDevelop بوده است. این وضعیت با ارائه Qt Creator‌ بهبود یافته است ...
  • شرکت Red gate که پیشتر برنامه‌ی معروف Reflector را در جهت اهداف تبلیغاتی خود تصاحب کرده بود، اکنون در ادامه‌ی همین سیاست، کتاب Illustrated C# 2008 را نیز به رایگان ارائه داده است.
  • سایت DelphiFeeds.com با طراحی جدید خود چند روزی است که متحول شده است. سایتی شبیه به سایت مهندس خودمان که بعد از عید معلوم نیست چه بلایی سرش آمده است و جای خالی آن احساس می‌شود، هر چند سایت IDevCenter نیز همین کار را به صورت تخصصی‌تری ارائه می‌دهد.
  • Microsoft MED-V 1.0 در جهت توسعه‌ی اهداف مجازی سازی مایکروسافت ارائه شد.

مطالب
فشرده سازی اسمبلی‌های دات نت

ابزارهای زیادی برای محافظت و یا فشرده سازی و رمزنگاری اسمبلی‌های دات نت موجود هستند که اکثر آنها تجاری هستند. برنامه netz نمونه‌ای است سورس باز و رایگان که تنها کار فشرده سازی اسمبلی موجود را انجام می‌دهد. همچنین با استفاده از آن سورس اسمبلی شما به‌وسیله برنامه reflector قابل مرور نخواهد بود. هر چند این برنامه سورس باز است و امکان unpack کردن نتیجه آن نیز احتمالا با اندکی سعی میسر خواهد بود اما باز هم یک مرحله پیشرفت محسوب می‌شود! خصوصا اینکه می‌توان برای آن Custom Compression Provider نوشت و برای مثال فایل زیپ شده نهایی را رمزنگاری نیز کرد.

قبل از عمل:



بعد از عمل:


نحوه استفاده:

فشردن کردن یک فایل exe توسط آن
netz app.exe

الحاق کردن فایل zip.dll همراه با فایل exe (بدون نیاز به توزیع فایل zip.dll):
netz -z app.exe

یکی کردن تمام dll های برنامه با فایل exe در قالب یک فایل نهایی:
netz -s app.exe lib1.dll lib2.dll

نکته:
در اینجا به صورت پیش فرض از فایل zip.dll برای فشرده سازی استفاده می‌شود (که برای تمام نگارش‌های دات نت قابل استفاده است). در نگارش‌های جدید دات نت، فشرده سازی نیز به کلاس‌های استاندارد اضافه شده است که امکان استفاده از آن نیز در اینجا مهیا است (و دیگر نیازی به استفاده از zip.dll آن نخواهد بود).
netz.exe -r net20comp.dll  app.exe

نحوه برنامه نویسی یک compression provider سفارشی برای آن در آدرس زیر توضیح داده شده است. (اعمال موارد امنیتی دلخواه و استفاده از آن)
http://madebits.com/netz/compress.php

و موارد دیگری که در راهنمای سایت آن توضیح داده شده‌اند.