Tuesday, December 5, 2017

Visual Studio 2017 download

Visual Studio Community 2017

A free, fully featured, and extensible solution for individual developers to create applications for Android, iOS, Windows, and the web.
Download

Visual Studio Enterprise 2017

An integrated, end-to-end solution for developers looking for high productivity and seamless coordination across teams of any size.
Download

Visual Studio Professional 2017

Improve productivity with professional developer tools and services to build applications for any platform.
Download

Visual Studio Test Professional 2017

Drive quality and collaboration throughout the development process. 
Download

Visual Studio Team Explorer 2017

A free solution for non-developers to interact with Team Foundation Server and Visual Studio Team Services.
Download 

Sunday, November 12, 2017

.net 2.0 features

1 Partial class
2 Generics
3 Static classes
4 Generator functionality
5 Anonymous delegates
6 Delegate covariance and contravariance
7 The accessibility of property accessors can be set                  independently
8 Nullable types
9 Null-coalescing operator



Partial class
Partial classes allow implementation of a class to be spread between several files, with each file containing one or more class members. It is useful primarily when parts of a class are generated automatically. For example, the feature is heavily used by code-generating user interface designers in Visual Studio.

file1.cs:

public partial class MyClass
{
    public void MyMethod1()
    {
        // Manually written code
    }
}
file2.cs:

public partial class MyClass
{
    public void MyMethod2()
    {
        // Automatically generated code
    }
}


Generics
Generics, or parameterized types, or parametric polymorphism is a .NET 2.0 feature supported by C# and Visual Basic. Unlike C++ templates, .NET parameterized types are instantiated at runtime rather than by the compiler; hence they can be cross-language whereas C++ templates cannot. They support some features not supported directly by C++ templates such as type constraints on generic parameters by use of interfaces. On the other hand, C# does not support non-type generic parameters. Unlike generics in Java, .NET generics use reification to make parameterized types first-class objects in the CLI Virtual Machine, which allows for optimizations and preservation of the type information.[1]

Static classes
Static classes are classes that cannot be instantiated or inherited from, and that only allow static members. Their purpose is similar to that of modules in many procedural languages.

Generator functionality
The .NET 2.0 Framework allowed C# to introduce an iterator that provides generator functionality, using a yield return construct similar to yield in Python.[2] With a yield return, the function automatically keeps its state during the iteration.

// Method that takes an iterable input (possibly an array)
// and returns all even numbers.
public static IEnumerable<int> GetEven(IEnumerable<int> numbers)
{
    foreach (int i in numbers)
    {
        if (i % 2 == 0) 
            yield return i;
    }
}
There is also a yield break statement, in which control is unconditionally returned to the caller of the iterator. There is an implicit yield break at the end of each generator method.

Anonymous delegates
As a precursor to the lambda functions introduced in C# 3.0, C#2.0 added anonymous delegates. These provide closure-like functionality to C#.[3] Code inside the body of an anonymous delegate has full read/write access to local variables, method parameters, and class members in scope of the delegate, excepting out and ref parameters. For example:-

int SumOfArrayElements(int[] array)
{
    int sum = 0;
    Array.ForEach(array,
        delegate(int x)
        {
            sum += x;
        }
    );
    return sum;
}
Unlike some closure implementations, each anonymous delegate instance has access to the same relative memory location for each bound variable, rather than to the actual values at each creation. See a fuller discussion of this distinction.

Delegate covariance and contravariance
Conversions from method groups to delegate types are covariant and contravariant in return and parameter types, respectively.[4]

The accessibility of property accessors can be set independently
Example:

string status = string.Empty;

public string Status
{
    get { return status; }             // anyone can get value of this property,
    protected set { status = value; }  // but only derived classes can change it
}

Nullable types
Nullable value types (denoted by a question mark, e.g. int? i = null;) which add null to the set of allowed values for any value type. This provides improved interaction with SQL databases, which can have nullable columns of types corresponding to C# primitive types: an SQL INTEGER NULL column type directly translates to the C# int?.

Nullable types received an improvement at the end of August 2005, shortly before the official launch, to improve their boxing characteristics: a nullable variable which is assigned null is not actually a null reference, but rather an instance of struct Nullable<T> with property HasValue equal to false. When boxed, the Nullable instance itself is boxed, and not the value stored in it, so the resulting reference would always be non-null, even for null values. The following code illustrates the corrected flaw:

int? i = null;
object o = i;
if (o == null)
    System.Console.WriteLine("Correct behaviour - runtime version from September 2010 or later");
else
    System.Console.WriteLine("Incorrect behaviour - pre-release runtime (from before September 2010)");

When copied into objects, the official release boxes values from Nullable instances, so null values and null references are considered equal. The late nature of this fix caused some controversy[5] , since it required core-CLR changes affecting not only .NET2, but all dependent technologies (including C#, VB, SQL Server 2005 and Visual Studio 2005).

Null-coalescing operator
The ?? operator is called the null-coalescing operator and is used to define a default value for nullable value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.[6]

object nullObj = null; 
object obj = new Object(); 
return nullObj ?? obj; // returns obj
The primary use of this operator is to assign a nullable type to a non-nullable type with an easy syntax:

int? i = null;
int j = i ?? 0; // If i is not null, initialize j to i. Else (if i is null), initialize j to 0.

Sunday, September 17, 2017

Customized Authentication Filters in ASP.MVC5

As we studied in last article, Filters are used to inject logic at the different levels of request processing. Below is the filters execution sequence:
Authentication Filters ==>  Authorization filter ==> Action filter ==> Result filter ==> Exceptionfilter
  • The authentication filter executes before any other filter
  • The authorization filter executes after Authentication filter and action method, or before any other filter
  • The action filter executes before and after any action method
  • The result filter executes before and after the execution of any action result
  • The exception filter executes only if any action methods, filters, or results throws an exception
  • Create a new class
  • Implement IAuthenticationFilter Interface
  • Derive it from ActionFilterAttribute
  • Override the OnAuthentication method to run logic before the action methodg

  • OnAuthentication Method
  • The program invokes Authentication Filters by calling this method. This method creates the AuthenticationContext. AuthenticationContext has information about performing authentication. We can use this information to make authentication decisions based on the current context.

    OnAuthenticationChallenge Method

    This method executes after the OnAuthentication method. We can use the OnAuthenticationChallenge method to perform additional tasks on request. This method creates an AuthenticationChallengeContext the same way as OnAuthentication.
  • Opps Part 1 : Abstraction

      Abstraction in C# is a fundamental concept of object-oriented programming (OOP) that allows developers t...