Pages
Partial Classes
Interfaces
Interface are a type similar to class, where it cannot have the Method Content, rather it has the definition of Method. It will not have properties and members variables. The class which inherits the interface should implement all the methods of the interface. The interface forces the derived class to implement; otherwise it will not get compiled.
The below lists some of common interfaces of .Net
1. IComparable - Implemented by types whose value can be ordered, it is used for sorting.
2. Idisposable - Defines this method to dispose of an object manually, this is important most commonly used Interface when dealing with more big objects, and also to release the object which holds the resource like database.
3. IConvertible - Enables the class to base type such as string, int or bool.
4. IClonable - Supports object copying
5. IEquatable - Allows comparing to object instances.
6. IFormatable - Provides way to convert the value of object into a formatted string. This is similar to ToString() method, but provides greater flexibility than it.
Interfaces
1. IComparable - Implemented by ttypes whose value can be ordered, it is ued for sorting.
2. Idisposable - Defines this method to dispose of a object manually, this is important most commonly used Interface when dealing with more big objects, and also to release the object which holds the resource like database.
3. IConvertible - Enables the class to to base type such as string, int or bool.
4. IClonable - Supports object copying
5. IEquatable - Allows to compare to object instances.
6. IFormatable - Provides way to convert the value of object into an formatted string. This is similar to ToString() method, but provides greater flexibility than it.
Nullable type in .Net 2.0
In VB.Net,
Dim b as Nullable(Of Boolean) = Nothing
.....
If b.HasValue Then
Do if b has some value and not null
Else
Do if b is null
End If
In C#,
Nullableb = null;
Otherwise it can be used this way also, only applicable for C#,
bool? b = null;
.....
if (b.HasValue) {Do if it is not null} else {Do if it null}
Optimizing performance with built-in types .Net
ImageMap Control - ASP.Net 2.0
<asp:ImageMap ID="ImageMap1" runat="server" HotSpotMode="PostBack" ImageUrl="~/Images/spaces.gif" OnClick="ImageMap1_Click" >
<asp:CircleHotSpot Radius="30" PostBackValue="Circle" AccessKey="c" AlternateText="some text" HotSpotMode="PostBack"
NavigateUrl="~/Trial.aspx" TabIndex="1" Target="_blank"/>
<asp:PolygonHotSpot Coordinates="0,0;0,30;30,30;30,0;" PostBackValue="Polygon" />
<asp:RectangleHotSpot Bottom="20" Right="20" PostBackValue="Rectangle" />
</asp:ImageMap>
protected void ImageMap1_Click(object sender, ImageMapEventArgs e)
{
Response.Write(e.PostBackValue.ToString());
}
The Properties used in the controls are listed:
PostBackValue - this value can be retrived by the EventArgs of ImageMap Click Event(e.PostBackValue).
AccessKey - combination alt + Specified Key makes the event triggered.
AlternateText - text in the region specified if image is not available.
HotSpotMode - decides the behavior of the event, listed below are the description of this Mode
> NotSet - No HotSpot set
> Inactive - Region set and restricted to stop firing the event.
> Navigate - Navigates to the url set by the NavigateUrl property.
> PostBack - Submits the page with PostBackValue set, triggers the Click Event.
NavigateUrl - set to get navigated to the specified URL Value, when triggered.
Target - Open the redirected url in specified target(Like same window or new window).
Image Map supports three types of region specification. Apart from the properties, the HotSpot region specifies will have a shape oriented property like Circle has radius, x and y; Rectangle has top, left, bottom and right; polygan has coordinates. a single Image map can have any no. of HotSpot's in any combinations. if same region is mention twice then the priority goes for the first specified one. the HotSpot is basically a collection, all these propeties can be set by design mode also using Property Window.
The HotSpotMode can be set in Imagemap Tag, so that the same will be applicable for all, if required it can be specified in each individual HotSpot. The PostBackValue can be set for each HotSpot, that enable to identify the region get triggered, when HotSpotMode is PostBack. the EventArgs gives the PostBackValue.
ForEach File Enumerator
.Create a new package.
.Drag and Drop the Foreach Loop Container from the Toolbar.
.Right Click, Edit the Container Properties.
.In General tab, set the name of the container
.In Collection Tab, set the Enumerator to Foreach File Enumerator. Set the Folder path to the required path. the Files field can be used to filter the type of files. the file name retrieval format can be set. suppose if the specified contains sub folders and if we want to check inside those folders also then check the "Traverse subfolders" Check Box.
.In Variable Mappings tab, Create a new variable, for example "Var" with datatype as string.
also set the index to 0, as the collection manipulates with one object in a loop cycle.
.The Container is set and ready to use, let us check the container using script task.
.Place a Script Task inside the Foreach Loop Container.
.Right Click, Edit the task.
.Goto to Script tab, and set the ReadOnly Variable Field with the variable used in the Foreach Loop. here set to "Var".
.Click Design Script from the Script tab, a new VS window environment opens with pre set already.
.Type the content, as given below in the existing function
Public Sub Main()
MsgBox(Dts.Variables("User::Var").Value.ToString())
Dts.TaskResult = Dts.Results.Success
End Sub
.Save it, close the environment and click OK in the container Property box.
.The sript task will be evaluvated on every loop cycle. the loop object is passed as a read only parameter for script task. the main functioin in the task displays the value stored in the variable. In this way we can do file or manipulation kind of task through the SSIS. when the package is runed, the files in the specfied folder are displayed as message box to the end user.