Monday, September 15, 2008
XML Comments in C#
An example of a function documented with XML comments is shown below:
/// <summary>
///<para>Non-HTML files like Adobe Acrobat PDF files and Word
///documents are stored with their original URLs partially
///encoded in their filenames. This function will return the
///original URL of the file.</para>
///<para>The encoding done by the Index Server Companion removes
///characters that cannot be present in Windows filenames
///(these are: \/:*?"<>|). The decoding performed is:</para>
/// <list type="table">
/// <listheader><term>Find</term><description>Replace</description></listheader>
/// <item><term>^f</term><description>\</description></item>
/// <item><term>^b</term><description>/</description></item>
/// <item><term>^c</term><description>:</description></item>
/// <item><term>^s</term><description>*</description></item>
/// <item><term>^q</term><description>?</description></item>
/// <item><term>^d</term><description>\</description></item>
/// <item><term>^l</term><description><</description></item>
/// <item><term>^g</term><description>></description></item>
/// <item><term>^p</term><description>|</description></item>
/// </list>
/// </summary>
/// <param name="FileName">The document's original filename.</param>
/// <returns>Decoded filename</returns>
/// <exception cref="System.Exception">Throws an exception when something goes wrong.</exception>
private string CreateURLFromFileName(string FileName)
{
}
To get the resulting XML Documentation file, we call the csc compiler with the /doc option.
csc /doc:HelloWorld.xml helloworld.cs
HTML Web Pages
You may be asking yourself: how do I get nicely formatted web pages? Well, you could write your own XSL to transform the XML documentation file, or you could use Visual Studio.NET. By using the Tools -> Build Comment Web Pages option, you can get a set of html files detailing your entire project or solution. Here is a screen shot by building web pages for our HelloWorld example:
Predefined Tag Used for
<c> a way to indicate that text within a description should be marked as code
<code> a way to indicate multiple lines as code
<example> lets you specify an example of how to use a method or other library member
<exception> lets you document an exception class
<include> lets you refer to comments in another file, using XPath syntax, that describe the types and members in your source code.
<list> Used to insert a list into the documentation file
<para> Used to insert a paragraph into the documentation file
<param> Describes a parameter
<paramref> gives you a way to indicate that a word is a parameter
<permission> lets you document access permissions
<remarks> where you can specify overview information about the type
<returns> describe the return value of a method
<see> lets you specify a link
<seealso> lets you specify the text that you might want to appear in a See Also section
<summary> used for a general description
<value> lets you describe a property
Reference : http://www.dotnetcoders.com/web/Articles/ShowArticle.aspx?article=21
http://www.winnershtriangle.com/w/Articles.XMLCommentsInCSharp.asp
Friday, September 12, 2008
Wireless Markup Language(WML)
WML markup
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml" >
<wml>
<card id="main" title="First Card">
<p mode="wrap">This is a sample WML page.</p>
</card>
</wml>
Wireless Markup Language is a lot like HTML (Hyper Text Markup Language) in that it provides navigational support, data input, hyperlinks, text and image presentation, and forms. A WML document is known as a “deck”. Data in the deck is structured into one or more “cards” (pages) – each of which represents a single interaction with the user. The introduction of the terms "deck" and "card" into the internet and mobile phone communities was a result of the user interface software and its interaction with wireless communications services having to comply with the requirements of the laws of two or more nations.
WML decks are stored on an ordinary web server trivially configured to serve the text/vnd.wap.wml MIME type in addition to plain HTML and variants. The WML cards when requested by a device are accessed by a bridge WAP gateway, which sits between mobile devices and the World Wide Web, passing pages from one to the other much like a proxy. The gateways radio the WML pages in a form suitable for mobile device reception. This process is hidden from the phone, so it may access the page in the same way as a browser accesses HTML, using a URL (for example, http://example.com/foo.wml), provided the mobile phone operator has not specifically locked the phone to prevent access of user-specified URLs.
Reference : http://en.wikipedia.org/wiki/Wireless_Markup_Language
Wednesday, September 10, 2008
XSLT(Extensible Stylesheet Language transformation)
Reference: http://www.topxml.com/dotnet/articles/xslt/default.asp
TCP/IP,SMTP,SSL,DNS
A communication protocol is a description of the rules computers must follow to communicate with each other. The Internet communication protocol defines the rules for computer communication over the Internet.
As with all other communications protocol, TCP/IP is composed of layers:
* IP - is responsible for moving packet of data from node to node. IP forwards each packet based on a four byte destination address (the IP number). The Internet authorities assign ranges of numbers to different organizations. The organizations assign groups of their numbers to departments. IP operates on gateway machines that move data from department to organization to region and then around the world.
* TCP - is responsible for verifying the correct delivery of data from client to server. Data can be lost in the intermediate network. TCP adds support to detect errors or lost data and to trigger retransmission until the data is correctly and completely received.
* Sockets - is a name given to the package of subroutines that provide access to TCP/IP on most systems.
SMTP
SMTP
Digg This! StumbleUpon Toolbar StumbleUpon Bookmark with Delicious Del.icio.us
DEFINITION - SMTP (Simple Mail Transfer Protocol) is a TCP/IP protocol used in sending and receiving e-mail. However, since it is limited in its ability to queue messages at the receiving end, it is usually used with one of two other protocols, POP3 or IMAP, that let the user save messages in a server mailbox and download them periodically from the server. In other words, users typically use a program that uses SMTP for sending e-mail and either POP3 or IMAP for receiving e-mail. On Unix-based systems, sendmail is the most widely-used SMTP server for e-mail. A commercial package, Sendmail, includes a POP3 server. Microsoft Exchange includes an SMTP server and can also be set up to include POP3 support.
SMTP usually is implemented to operate over Internet port 25. An alternative to SMTP that is widely used in Europe is X.400. Many mail servers now support Extended Simple Mail Transfer Protocol (ESMTP), which allows multimedia files to be delivered as e-mail.
SSL
(pronounced as separate letters) Short for Secure Sockets Layer, a protocol developed by Netscape for transmitting private documents via the Internet. SSL uses a cryptographic system that uses two keys to encrypt data − a public key known to everyone and a private or secret key known only to the recipient of the message. Both Netscape Navigator and Internet Explorer support SSL, and many Web sites use the protocol to obtain confidential user information, such as credit card numbers.By convention, URLs that require an SSL connection start with https: instead of http:.
Another protocol for transmitting data securely over the World Wide Web is Secure HTTP (S-HTTP). Whereas SSL creates a secure connection between a client and a server, over which any amount of data can be sent securely, S-HTTP is designed to transmit individual messages securely. SSL and S-HTTP, therefore, can be seen as complementary rather than competing technologies. Both protocols have been approved by the Internet Engineering Task Force (IETF) as a standard.
DNS
The Domain Name System (DNS) is a hierarchical naming system for computers, services, or any resource participating in the Internet. It associates various information with domain names assigned to such participants. Most importantly, it translates humanly-meaningful domain names to the numerical (binary) identifiers associated with networking equipment for the purpose of locating and addressing these devices world-wide.
MFC
MFC is bundled with several C++ compilers and is also available as part of the Microsoft Developer's Network (MSDN).
Monday, September 8, 2008
WWF(WorkFlow Foundation)
A simple definition would say a workflow is the series of steps, decisions, and rules needed to complete a specific task. workflow within line of business applications, user interface page-flow, document-centric workflow, human workflow, composite workflow for service oriented applications, business rule driven workflow and workflow for systems management.
wo Types of workflow is available in WWF.
· Sequential WorkFlow
· State Machine WorkFlow
What is Sequential WorkFlow?
A Sequential WorkFlow is a Top-Down process, also known as a Human Flow Process, where the activities transpire from a beginning situation and end after a predefined sequence of steps. Sequential WorkFlows are self-driven; once they are initiated, they have a totally predictable behavior throughout the execution of the activities.
What is Sequential State Machine?
The State Machine WorkFlow does not have a defined path but represents a set of states and transitions between these states. State Machine WorkFlows are event-driven: Each state can be activated after a predefined action has taken place; then, the engine executes the activities needed and stops after completion of the next state. There is no deterministic execution path between the steps because the WorkFlow does not execute in a chronological order.
WorkFlow Foundation uses a layered architecture within any application into which it is integrated It will contains three layer.
1. Model Layer
2. Runtime Layer
3. Hosting Layer
The Model Layer is the location where developers build the code to run a workflow. This layer provides the out-the-box Activities, the model for the construction of custom Activities, and the engine to build rules.
The Runtime layer ensures the execution aspects of the workflow and contains the mission-critical services required: for example, the state management and persistence service, the rules service that provides policy execution functionality, the scheduler service, and the tracking service.
The Hosting layer is the connecting link between the WorkFlow Foundation and the outside world and provides a package of services (Persistence, Timer, Tracking, Communication) needed to guarantee the control and management of the workflow.
What are the Conditions, Rules and RuleSet?
Conditions are chunks of logic that return true or false.
Rules are conditions with a set of actions to perform. Rules use a declarative if-then-else style, where the "if" is a condition to evaluate. If the condition evaluates to true, the runtime performs the "then" actions, otherwise the "else" actions.
A rule set is a collection of one or more rules.
Example Reference
http://channel9.msdn.com/posts/bruceky/Getting-started-Windows-Workflow-WF-100/
http://dotnetguts.blogspot.com/2008/02/video-tutorials-for-wwf-windows.html
WWF Resources : http://geekswithblogs.net/notesetc/articles/56260.aspx
AJAX = Asynchronous JavaScript and XML
AJAX is a type of programming made popular in 2005 by Google (with Google Suggest).
AJAX is not a new programming language, but a new way to use existing standards.
With AJAX you can create better, faster, and more user-friendly web applications.
AJAX is based on JavaScript and HTTP requests.
Internet Explorer uses an ActiveXObject, while other browsers uses the built-in JavaScript object called XMLHttpRequest.
The responseText Property
The data sent back from the server can be retrieved with the responseText property.
In our code, we will use the responseText to display result:
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.myForm.time.value=xmlHttp.responseText;
}
}
Here are the possible values for the readyState property:
State Description
0 The request is not initialized
1 The request has been set up
2 The request has been sent
3 The request is in process
4 The request is complete
Web Services, SOAP,WSDL
* Web services are small units of code
* Web services are designed to handle a limited set of tasks
* Web services use XML based communicating protocols
* Web services are independent of operating systems
* Web services are independent of programming languages
* Web services connect people, systems and devices
Small Units of Code
Web services are small units of code designed to handle a limited set of tasks.
An example of a web service can be a small program designed to supply other applications with the latest stock exchange prices. Another example can be a small program designed to handle credit card payment.
XML Based Web Protocols
Web services use the standard web protocols HTTP, XML, SOAP, WSDL, and UDDI.
HTTP
HTTP (Hypertext Transfer Protocol) is the World Wide Web standard for communication over the Internet. HTTP is standardized by the World Wide Web Consortium (W3C).
XML
XML (eXtensible Markup Language) is a well known standard for storing, carrying, and exchanging data. XML is standardized by the W3C.
SOAP
SOAP (Simple Object Access Protocol) is a lightweight platform and language neutral communication protocol that allows programs to communicate via standard Internet HTTP. SOAP is standardized by the W3C.
WSDL
WSDL (Web Services Description Language) is an XML-based language used to define web services and to describe how to access them. WSDL is a suggestion by Ariba, IBM and Microsoft for describing services for the W3C XML Activity on XML Protocols.
UDDI (Universal Description, Discovery and Integration) is a directory service where businesses can register and search for web services.
UDDI is a public registry, where one can publish and inquire about web services.
Independent of Operating Systems
Since web services use XML based protocols to communicate with other systems, web services are independent of both operating systems and programming languages.
An application calling a web service will always send its requests using XML, and get its answer returned as XML. The calling application will never be concerned about the operating system or the programming language running on the other computer.
Benefits of Web Services
* Easier to communicate between applications
* Easier to reuse existing services
* Easier to distribute information to more consumers
* Rapid development
Web services make it easier to communicate between different applications. They also make it possible for developers to reuse existing web services instead of writing new ones.
Example
FirstService.asmx
<%@ WebService language="C" class="FirstService" %>
using System;
using System.Web.Services;
using System.Xml.Serialization;
[WebService(Namespace="http://localhost/MyWebServices/")]
public class FirstService : WebService
{
[WebMethod]
public int Add(int a, int b)
{
return a + b;
}
[WebMethod]
public String SayHello()
{
return "Hello World";
}
}
Referred From: http://www.w3schools.com/ngws/ngws_webservices.asp
Sunday, September 7, 2008
XML CRUD using XPath
Xml File
--------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd country="USA">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
</cd>
<cd country="UK">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<price>10.0</price>
</cd>
<cd country="USA">
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<price>9.90</price>
</cd>
</catalog>
Load and Display XML File
using System.Xml;
using System.Xml.XPath;
....
string fileName = "data.xml";
XPathDocument doc = new XPathDocument(fileName);
XPathNavigator nav = doc.CreateNavigator();
// Compile a standard XPath expression
XPathExpression expr;
expr = nav.Compile("/catalog/cd/price");
XPathNodeIterator iterator = nav.Select(expr);
// Iterate on the node set
listBox1.Items.Clear();
try
{
while (iterator.MoveNext())
{
XPathNavigator nav2 = iterator.Current.Clone();
listBox1.Items.Add("price: " + nav2.Value);
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
Find and Update
XmlTextReader reader = new XmlTextReader(FILE_NAME);
XmlDocument doc = new XmlDocument();
doc.Load(reader);
reader.Close();
//Select the cd node with the matching title
XmlNode oldCd;
XmlElement root = doc.DocumentElement;
oldCd = root.SelectSingleNode("/catalog/cd[title='" + oldTitle + "']");
XmlElement newCd = doc.CreateElement("cd");
newCd.SetAttribute("country",country.Text);
newCd.InnerXml = "<title>" + this.comboBox1.Text + "</title>" +
"<artist>" + artist.Text + "</artist>" +
"<price>" + price.Text + "</price>";
root.ReplaceChild(newCd, oldCd);
//save the output to a file
doc.Save(FILE_NAME);
Insert NODE to XML file
XmlTextReader reader = new XmlTextReader(FILE_NAME);
XmlDocument doc = new XmlDocument();
doc.Load(reader);
reader.Close();
XmlNode currNode;
XmlDocumentFragment docFrag = doc.CreateDocumentFragment();
docFrag.InnerXml="<cd country=\"" + country.Text + "\">" +
"<title>" + this.comboBox1.Text + "</title>" +
"<artist>" + artist.Text + "</artist>" +
"<price>" + price.Text + "</price>" +
"</cd>";
// insert the availability node into the document
currNode = doc.DocumentElement;
currNode.InsertAfter(docFrag, currNode.LastChild);
//save the output to a file
doc.Save(FILE_NAME);
Remove NODE
XmlTextReader reader = new XmlTextReader(FILE_NAME);
XmlDocument doc = new XmlDocument();
doc.Load(reader);
reader.Close();
//Select the cd node with the matching title
XmlNode cd;
XmlElement root = doc.DocumentElement;
cd = root.SelectSingleNode("/catalog/cd[title='" + this.comboBox1.Text + "']");
root.RemoveChild(cd);
//save the output to a file
doc.Save(FILE_NAME);
XML CRUD Using DataSet
DataSet ds=new DataSet()
1) TO Insert To XML FIle.
ds.ReadXml(@"D:\ResumeSettings\Email.xml");
for (int i = 0; i <>
{
ds.Tables[0].Rows.Add(col[i].ToString(), "1");
}
ds.WriteXml(@"D:\ResumeSettings\Email.xml");
2) Delete From XML File.
ds.ReadXml(@"D:\ResumeSettings\Email.xml");
if (ds.Tables[0].Rows.Count > 0)
{
for (int d = 0; d <>
{
ds.Tables[0].Rows.Remove(ds.Tables[0].Rows[d]);
}
}
ds.WriteXml(@"D:\ResumeSettings\Email.xml");
3) TO Update XML FIle.
ds.ReadXml(@"D:\ResumeSettings\SettingsData.XML");
DataRow[] dr = ds.Tables[0].Select("foldername= '" + FolderName.Trim().ToString() + "'");
foreach (DataRow ChangeRow in dr)
{
ChangeRow.BeginEdit();
ChangeRow[1] = "1";
ChangeRow.EndEdit();
}
ds.GetChanges(DataRowState.Modified);
ds.WriteXml(@"D:\ResumeSettings\SettingsData.XML");
Make the necessary changes as per ur xml files.