Wednesday, May 19, 2010

Left Navigation for Weppart Page

Open the webpart page in the Sharepoint Designer and remove the following tags
<asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server"></asp:Content>
<&asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server"></asp:Content>

And save the file back, on the warning for customization press Yes

Wednesday, May 5, 2010

Serialization & De-serialization


Serialization & De-serialization The process of converting a data structure or object into a sequence of bits so that it can be stored in a file, a memory buffer, or transmitted across a network. The Process of serialization is also called Marshalling

To re-construct the object from the previously serialized instance of the same in the persistent or non-persistent storage media.The Process or de-serialization is called UnMarshalling

To make a class Serializable in C# tou need to add the attribute before the class definition
Eg.
[Serializable]
public class Employee
{   
 public int EmployeeId;
public string FirstName;
public string LastName;
public string Designation;
public int Salary;
}

Types of Serialization
Binary Serialization
Binary serialization is a mechanism which writes the data to the output stream such that it can be used to re-construct the object automatically. Exact binary copy of the object is saved onto the storage media.

fileStreamObject = new FileStream(filename, FileMode.Create();     
BinaryFormatter binaryFormatter = new BinaryFormatter();     
return (binaryFormatter.Serialize(fileStreamObject));

Advantages of using Binary Serialization in the
The object can be de-serialized from the same data you serialized it to.
Fast

Disadvantage
Portability is not simple

SOAP Serialization
The SOAP protocol is ideal for communicating between applications that use heterogeneous architectures. The SoapFormatter serializes objects into SOAP messages or parses SOAP messages and extracts serialized objects from the message.

FileStream fileStreamObject = new FileStream(filename, FileMode.Create);   
SoapFormatter soapFormatter = new SoapFormatter();   
soapFormatter.Serialize(fileStreamObject, employeeObject);  
fileStreamObject.Close();

The basic advantage of SOAP serialization is portability

XML Serialization
XML serialization converts (serializes) the public fields and properties of an object or the parameters and returns values of methods, into an XML stream that conforms to a specific XML Schema definition language (XSD) document

serializer = new XmlSerializer(typeof(Employee));     
stream = new FileStream(filename, FileMode.Create, FileAccess.Write);
     serializer.Serialize(stream, emp);

XML stream can be processed by any application, as needed, regardless of platform
slower compared to Binary serialization.