Monday, April 29, 2013

Published 10:21 PM by with 0 comment

Abstract methods



Abstract methods

When an instance method declaration includes an abstract modifier, that method is said to be an abstract method. Although an abstract method is implicitly also a virtual method, it cannot have the modifier virtual.

An abstract method declaration introduces a new virtual method but does not provide an implementation of that method. Instead, non-abstract derived classes are required to provide their own implementation by overriding that method. Because an abstract method provides no actual implementation, the method-body of an abstract method simply consists of a semicolon.

Abstract method declarations are only permitted in abstract classes

public abstract class AbstractClass
{
public abstract void PrintName();
}

Implementation

public sealed class AbstractImp1:AbstractClass
{
public override void PrintName()
       {
           Console.WriteLine("Im Aruna");
}
}

Calling

AbstractClass abs = new AbstractImp1();
abs.PrintName();

Read More
    email this       edit
Published 12:33 AM by with 0 comment

Abstract

Abstract

The abstract modifier can be used with classes, methods, properties, indexers, and events.
Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes.
Abstract classes have the following features:
  • An abstract class cannot be instantiated.
  • An abstract class may contain abstract methods and accessors.
  • It is not possible to modify an abstract class with the sealed modifier, which means that the class cannot be inherited.
  • A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
Use the abstract modifier in a method or property declaration to indicate that the method or property does not contain implementation.
Abstract methods have the following features:
  • An abstract method is implicitly a virtual method.
  • Abstract method declarations are only permitted in abstract classes.
  • Because an abstract method declaration provides no actual implementation, there is no method body; the method declaration simply ends with a semicolon and there are no braces ({ }) following the signature. For example:
·         The implementation is provided by an overriding method, which is a member of a non-abstract class.
  •  It is an error to use the static or virtual modifiers in an abstract method declaration.

public abstract void MyMethod();
An abstract class must provide implementation for all interface members.
An abstract class that implements an interface might map the interface methods onto abstract methods. For example:
interface I
{
    void M();
}
abstract class C : I
{
    public abstract void M();
}

Example

In this example, the class MyDerivedC is derived from an abstract class MyBaseC. The abstract class contains an abstract method, MyMethod(), and two abstract properties, GetX() and GetY().
// abstract_keyword.cs
// Abstract Classes
using System;
abstract class MyBaseC   // Abstract class
{
   protected int x = 100;
   protected int y = 150;
   public abstract void MyMethod();   // Abstract method

   public abstract int GetX   // Abstract property
   {
      get;
   }

   public abstract int GetY   // Abstract property
   {
      get;
   }
}

class MyDerivedC: MyBaseC
{
   public override void MyMethod()
   {
      x++;
      y++;  
   }  

   public override int GetX   // overriding property
   {
      get
      {
         return x+10;
      }
   }

   public override int GetY   // overriding property
   {
      get
      {
         return y+10;
      }
   }

   public static void Main()
   {
      MyDerivedC mC = new MyDerivedC();
      mC.MyMethod();
      Console.WriteLine("x = {0}, y = {1}", mC.GetX, mC.GetY);   
   }
}

Output

x = 111, y = 161

In the preceding example, if you attempt to instantiate the abstract class by using a statement like this:

MyBaseC mC1 = new MyBaseC();   // Error
 
you will get the following error message:

Cannot create an instance of the abstract class 'MyBaseC'.




Read More
    email this       edit

Sunday, April 28, 2013

Published 11:01 PM by with 0 comment

Singleton - [Creational Patterns]


Singleton Definition

Ensure a class has only one instance and provide a global point of access to it.

This structural code demonstrates the Singleton pattern which assures only a single instance (the singleton) of the class can be created.

namespace Singleton
{
    class Program
    {
        static void Main(string[] args)
        {
            Singleton s1 = Singleton.Instance();
            Singleton s2 = Singleton.Instance();
            if (s1 == s2)
            {
                Console.WriteLine("Indenticle Instances");
            }
            Console.ReadKey();
        }
    }
}

Singleton Class
namespace Singleton
{
    class Singleton
    {
        public static Singleton _instance;

        protected Singleton()
        {
        }

        public static Singleton Instance()
        {
            if (_instance == null)
            {
                _instance = new Singleton();
            }
            return _instance;
        }
    }
}

Read More
    email this       edit

Thursday, April 18, 2013

Published 2:46 AM by with 0 comment

Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

To solve the issue try to repair the .net framework 4 and then run the command
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
Read More

    email this       edit

Tuesday, April 9, 2013

Published 12:09 AM by with 0 comment

How to edit email address for sharepoint 2010 user

A user's Email Address is stored within a profile property. By default a user isn't allowed to change his or her own e-mail address. The email address (Work e-mail) and whether or not user's can change their own can be specified in the settings of the User Profile Service Application.
  1. (As an administrator) open Central Admin
  2. Under "Application Management"  click "Manage Service Applications"
  3. Locate and click the link "User Profile Service Application". If this one is not there you haven't created a User Profile Service Application yet.
  4. Under "People"  there are two relevant links here. The first is "Manage User Properties", the second is "Manage User Profiles"
  5. Under "Manage User Properties" you can specify the settings for the Work e-mail property (i.e. whether or not the user is allowed to edit his or her own e-mail address).
  6. Under "Manage User Profiles" you can locate a user's profile and edit the e-mail address from there
By default it could take up to one hour to "see" the new e-mail address througout all web applications bound to the user profile service application. A timer job is taking care of this and you could kick this one of to run manually once by going to "Check Job Status" screen in Central Admin (_admin/Timer.aspx). Here locate the job definition with the title "User Profile Service Application - User Profile to SharePoint Full Synchronization", open the "Edit Timer Job Page" by clicking on the Job's name and then click the "Run Now" button.

1


2


3


4


5

Read More
    email this       edit