Translate

Thursday, 18 February 2016

Factory pattern Vs Abstract Factory pattern

Factory

Definition:

Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate.

Real Life Example,

Imagine you are constructing a house and you approach a carpenter for a door. You give the measurement for the door and your requirements, and he will construct a door for you. In this case, the carpenter is a factory of doors. Your specifications are inputs for the factory, and the door is the output or product from the factory.

Abstract Factory

Definition:

Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

Real Life Example,


Now, consider the same example of the door. You can go to a carpenter, or you can go to a plastic door shop or a PVC shop. All of them are door factories. Based on the situation, you decide what kind of factory you need to approach. This is like an Abstract Factory.

Sunday, 14 February 2016

.NET Framework 4 - New Features

Introduction:
The .NET Framework 4 introduces an improved security model, APIs, workflow models, inbuilt plug-in, workflow and VS designer for attract to end-users

Here they introduced many new features and environment,
  • Security Changes in the .NET Framework 4.
  • Application Compatibility and Deployment
  • Web
  • Client - Enhancements in WPF
  • Data
  • Communications and Workflow
Security Changes in the .NET Framework 4 :

They implemented two major changes in security the code that calls security policy APIs receives a NotSupportedException in addition to compiler warnings at run time and also they invoked obsolete request permissions.
  • Machine-wide security policy
  • Security transparency
Application Compatibility and Deployment

The .NET Framework 4 does not automatically use its version of the common language runtime to run applications that are built with earlier versions of the .NET Framework. To run older applications with .NET Framework 4, you must compile your application with the target .NET Framework version specified in the properties for your project in Visual Studio, or you can specify the supported runtime with the <supportedRuntime> Element in an application configuration file.
New features:
  • Diagnostics and Performance
  • Garbage Collection
  • Code Contracts
  • Design-Time-Only Interop Assemblies
  • Dynamic Language Runtime
  • Memory-Mapped Files
Features in Web:
  1. Web Forms controls, including a new Chart control.
  2. Microsoft Ajax, including additional support for client-based Ajax applications in the Microsoft Ajax Library.
  3. Multi-targeting, including better filtering for features that are not available in the target version of the .NET Framework.
  4. Web Forms, including more integrated support for ASP.NET routing, enhanced support for Web standards, updated browser support, new features for data controls, and new features for view state management.
  5. MVC, including new helper methods for views, support for partitioned MVC applications, and asynchronous controllers.
  6. Deployment, including new tools for automating typical deployment tasks.
  7. MVC, including new helper methods for views, support for partitioned MVC applications, and asynchronous controllers.
Enhancements in WPF:
  1. New Controls,
    1. DataGrid
    2. Calendar
    3. DatePicker
  2. Visual State Manager.
  3. Touch and Manipulation.
  4. Graphics and Animations,
    1. Layout Rounding
    2. Cached Composition
    3. Pixel Shader 3 Support
    4. Easing Functions
  5. Text,
    1. New Text Rendering Stack
    2. Selection and Caret Customization
  6. Binding,
    1. XAML Browser Applications
    2. HTML-XBAP Script Interop
    3. Full-Trust XBAP Deployment
  7. WPF and Windows.
  8. WPF and Silverlight Designer
    1. Improved Support for Silverlight.
    2. Support for Multiple Platform Versions.
    3. Visual Databinding.
    4. Auto Layout.
    5. Improved Property Editing.
    6. The Properties window now enables visually creating and editing Brush resources.
DATA:
  1. ADO.NET
    1. Foreign Keys in the Conceptual Model.
    2. New Methods for N-Tier Application Development.
    3. EntityDataSource Support for the QueryExtender Control.
    4. Testability with IObjectSet<T>.
    5. Direct Execution of Store Commands
    6. Persistence-Ignorant Objects.
    7. Lazy Loading of Related Objects.
    8. Functions in LINQ to Entities Queries.
    9. OrderBy Improvements in LINQ to Entities.
    10. Customized Object-Layer Code Generation.
    11. Model-First Support.
    12. Complex Type Support.
    13. Naming Service.
    14. Improved Model Browser Functionality.
    15. Entity Designer Extensibility.
    16. Entity Data Model Documentation.
  2. Dynamic Data
    1. Automatic validation that is based on constraints that are defined in the data model.
    2. The ability to easily change the markup that is generated for fields in the GridView and DetailsView controls by using field templates that are part of a Dynamic Data project.
Communications and Workflow:
  1. WCF
    1. Configuration Based Activation.
    2. System.Web.Routing Integration.
    3. Multiple IIS Site Bindings Support.
    4. Routing Service.
    5. Support for WS-Discovery.
    6. Standard Endpoints.
    7. Workflow Services.
    8. Target Framework Attribute.
  2. WorkFlow
    1. Workflow Activity Model.
    2. Rich Composite Activity Options.
    3. Expanded Built-In Activity Library.
    4. Explicit Activity Data Model.
    5. Enhanced Hosting, Persistence, and Tracking Options.
    6. Easier Ability to Extend WF Designer Experience.

Monday, 26 October 2015

Advantage to using ASP.Net MVC vs web forms

The main advantages of ASP.net MVC are:
  1. Enables the full control over the rendered HTML.
  2. Provides clean separation of concerns(SoC).
  3. Easy integration with JavaScript frameworks.
  4. Following the design of stateless nature of the web.
  5. RESTful urls that enables SEO.
  6. No ViewState and PostBack events
The main advantage of ASP.net Web Form are:
  1. It provides RAD development
  2. Easy development model for developers those coming from winform development.

Monday, 12 October 2015

Set a delay in a jQuery / Ajax function

// set your delay here, 2 seconds as an example...
var my_delay = 2000;

// call your ajax function when the document is ready...
$(function() {
    callAjax();
});

// function that processes your ajax calls...
function callAjax() {
    $.ajax({
        // ajax parameters here...
        // ...
        success: function() {
            setTimeout(callAjax, my_delay);
        }
    });
}

Tuesday, 8 September 2015

How do I convert a dictionary/List to a JSON String in C#?

using System.Web.Script.Serialization;

 Dictionary<string, string> name = new Dictionary<string, string>();
        name.Add("1", "GKSamy");
        name.Add("2", "Rakshitta");
        string myJsonString = (new JavaScriptSerializer()).Serialize(name);

How can I block F12 keyboard key, CTRL+SHIFT+i and Prevent from Right Click

<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
    <script language="JavaScript">

        //////////F12 disable code////////////////////////
        document.onkeypress = function (event) {
            event = (event || window.event);
            if (event.keyCode == 123) {
                //alert('No F-12');
                return false;
            }
            else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) {
                return false;  //Prevent from ctrl+shift+i
            }

        }
        document.onmousedown = function (event) {
            event = (event || window.event);
            if (event.keyCode == 123) {
                //alert('No F-keys');
                return false;
            }
            else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) {
                return false;  //Prevent from ctrl+shift+i
            }
        }
        document.onkeydown = function (event) {
            event = (event || window.event);
            if (event.keyCode == 123) {
                //alert('No F-keys');
                return false;
            }
            else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) {
                return false;  //Prevent from ctrl+shift+i
            }
        }

     ////////////////////Prevent from Right Click Inspect Element /////////////////////////////
        $(document).on("contextmenu", function (e) {
            e.preventDefault();
            alert('Right Click is not allowed');
        });
        /////////////////////end///////////////////////
    </script>