اشتراک‌ها
تفاوت اعتبارسنجی ورودی ها با اعتبارسنجی مرتبط با قواعد تجاری

Input Validation for me is about validating the user input. Some people call "Name must not be empty" a business rule, I think about it as input validation. Business Rules validation is more complex, because a business rule for me is not "Name must not be empty", it is a definition of a state in the system that requires an action. Here is a definition of a business rule:

An order should be payed within 30 days, this duration can be extended, to a maximum of three times. 

تفاوت اعتبارسنجی ورودی ها با اعتبارسنجی مرتبط با قواعد تجاری
اشتراک‌ها
کتاب کار با XML در SQL Server

Stairway to XML

XML has been part of the SQL Standard since 2003, and is essential for any DBA because so many of the dynamic management views return XML data. Now that the industry is more used to data defined by document markup, it is becoming more important than ever for Database Developers and DBAs to understand the technology and to know where it makes sense to use XML. In this book, originally a series of articles on SQLServerCentral.com, Robert Sheldon flexes his talent to make the complicated seem simple. 

کتاب کار با XML در SQL Server
اشتراک‌ها
خبرنامه هفتگی ASP.NET Core News

ASP.NET Core News is the only weekly newsletter dedicated to ASP.NET Core. Whether you build Razor Pages, MVC applications, Web APIs, SignalR awesomeness, or anything else available on the ASP.NET Core platform, we've got you covered. Every Friday you will receive a weekly digest of the most interesting posts and articles from the last seven days.  

خبرنامه هفتگی ASP.NET Core News
مطالب
ویژگی های کمتر استفاده شده در NET. - بخش چهارم

Parallel.For & Parallel.ForEach

Parallel.For – اجرای یک حلقه for که در آن عملیات تکرار  ممکن است به صورت موازی انجام شود.
var nums = Enumerable.Range( 0, 1000000 ).ToArray();
long total = 0;

// Use type parameter to make subtotal a long, not an int
Parallel.For< long >( 0, nums.Length, () => 0,
                      ( j, loop, subtotal ) =>
                      {
                          subtotal += nums[j];
                          return subtotal;
                      },
                      x => Interlocked.Add( ref total, x ) );
Console.WriteLine( "The total is {0:N0}", total ); 
Interlocked.Add با استفاده از این متد می‌توان دو عدد صحیح را با هم جمع کرد (به صورت thread safe) و نتیجه را در عدد اول ذخیره کرد.
Parallel.ForEach – اجرای یک حلقه foreach که در آن عملیات تکرار ممکن است به صورت موازی انجام شود.
var nums = Enumerable.Range( 0, 1000000 ).ToArray();
long total = 0;
Parallel.ForEach< int, long >( nums, // source collection
                               () => 0, // method to initialize the local variable
                               ( j, loop, subtotal ) => // method invoked by the loop on each iteration
                               {
                                   subtotal += j; //modify local variable
                                   return subtotal; // value to be passed to next iteration
                               },

                               // Method to be executed when each partition has completed.
                               // finalResult is the final value of subtotal for a particular partition.
                               finalResult => Interlocked.Add( ref total, finalResult ) );
Console.WriteLine( "The total from Parallel.ForEach is {0:N0}", total );


IsInfinity

تابع  IsInfinity  جهت ارزیابی یک مقدار اعشاری که به سمت مثبت یا منفی بی نهایت می‌باشد، استفاده می‌شود.
Console.WriteLine("IsInfinity(3.0 / 0) == {0}.", double.IsInfinity(3.0 / 0) ? "true" : "false");
مقدار خروجی مثال بالا true می‌باشد.

dynamic Type

با استفاده از نوع dynamic می توان عملیات چک کردن نوع در زمان کامپایل را پشت سر گذاشت و در عوض این عملیات را به زمان اجرا، موکول داد.

نکته: نوع dynamic همانند نوع object در بسیاری از شرایط، یکسان رفتار می‌کند. اگرچه عملیات‌هایی که شامل عبارت‌هایی از نوع dynamic هستند، یا نوع آن توسط کامپایلر بررسی می‌شوند و یا پذیرفته نمی‌شوند. کامپایلر اطلاعات مربوط به یک پردازش (روند) را یکجا بسته بندی می‌کند و این اطلاعات را بعداً در زمان اجرا ارزیابی می‌کند. به عنوان بخشی از این پردازش، متغیرهایی از نوع dynamic به متغیرهایی از نوع object کامپایل می‌شوند. بنابراین نوع dynamic فقط در زمان کامپایل وجود دارند (نه در زمان اجرا).

var i = 20;
dynamic dynamicVariable = i;
Console.WriteLine( dynamicVariable );

var stringVariable = "Example string.";
dynamicVariable = stringVariable;
Console.WriteLine( dynamicVariable );

var dateTimeVariable = DateTime.Today;
dynamicVariable = dateTimeVariable;
Console.WriteLine( dynamicVariable );

// The expression returns true unless dynamicVariable has the value null.
if ( dynamicVariable is dynamic )
    Console.WriteLine( "dynamicVariable variable is dynamic" );

// dynamic and the as operator.
dynamicVariable = i as dynamic;

// throw RuntimeBinderException if the associated object doesn't have the specified method.
// The code is still compiling successfully.
Console.WriteLine( dynamicVariable.ToNow1 );

همانطور که در مثال بالا مشاهده می‌کنید، شما می‌توانید متغیرهایی از نوع‌های مختلف را به یک شی از نوع dynamic اختصاص دهید. همچنین می‌توانید برای بررسی یک متغیر که از نوع dynamic است یا خیر، از عملگر is استفاده کنید. اگر یک خصوصیت را که وجود ندارد، درخواست کنید (خط آخر مثال بالا)، خطای RuntimeBinderException پرتاب می‌شود.


ExpandoObject

ExpandoObject  این امکان را فراهم می‌آورد که  در زمان اجرا، اعضای یک شیء به صورت پویا، اضافه و حذف شوند (همانند DataTableها).
dynamic sampleObject = new ExpandoObject();
sampleObject.FirstName = "Vahid";
sampleObject.LastName = "Mohammad Taheri";
sampleObject.Age = "28";
sampleObject.TestRemoveProperty = DateTime.Now;
sampleObject.AsString = new Action( () => Console.WriteLine( "{0} {1} is {2} years old.",
                                                                sampleObject.FirstName,
                                                                sampleObject.LastName,
                                                                sampleObject.Age ) );
sampleObject.AsString();
همانطور که در مثال بالا مشاهده می‌کنید، یک شیء با 4 خصوصیت و یک متد را ایجاد کردیم. حال برای حذف یکی از خصوصیت‌ها از روش زیر استفاده می‌کنیم.
( (IDictionary< String, Object >)sampleObject ).Remove( "TestRemoveProperty" );
و در صورت استفاده از خصوصیت حذف شده، خطای  RuntimeBinderException  پرتاب می‌شود.
اشتراک‌ها
مقدمه ای بر برنامه نویسی همزمان

What is concurrent programing? Simply described, it’s when you are doing more than one thing at the same time. Not to be confused with parallelism, concurrency is when multiple sequences of operations are run in overlapping periods of time. In the realm of programming, concurrency is a pretty complex subject. Dealing with constructs such as threads and locks and avoiding issues like race conditions and deadlocks can be quite cumbersome, making concurrent programs difficult to write. Through concurrency, programs can be designed as independent processes working together in a specific composition. Such a structure may or may not be made parallel; however, achieving such a structure in your program offers numerous advantages. 

مقدمه ای بر برنامه نویسی همزمان
اشتراک‌ها
پیاده سازی Material Design Stopwatch, Alarm and Timer
Use the modern Materialize framework, together with jQuery , jQuery Timepicker and Hammer.js for touch events. Materialize turns the plain looking standard HTML input fields into these awesome Android-like switches and check boxes. It also adds the the on-click wave ink effect as it has Waves.js included in it’s package.  Demo
پیاده سازی Material Design Stopwatch, Alarm and Timer
نظرات مطالب
فعال سازی قسمت ارسال فایل و تصویر ویرایشگر آنلاین RedActor در ASP.NET MVC
با سلام؛ من یک ویو دارم که در آن از دوتا redactor استفاده کردم. در واقع سناریوی من به این شکل است. یکی از این redactor برای ورود خلاصه‌ی متن است و در زیر آن یک لینک ایجکسی وجود دارد که میره و یک partial را می‌یاره. توی partial اونredactor دومی قرار دارد و جالب وقتی که من یک فایلی را در red actor که در پارشال هست آپلود می‌کنم فایل آپلود می‌شود ولی هنگامی که در صفحه‌ی سایتم می‌خوام دانلود کنم Error زیر را می‌دهد.
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
حالا باید چه کار کنم؟ ممنون