tag:blogger.com,1999:blog-61467530145718486862024-03-20T00:16:59.861-07:00ASP.NET CaffeASP.NET, JavaScript, Oracle and SQL articles and code.Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.comBlogger30125tag:blogger.com,1999:blog-6146753014571848686.post-56354299546601326192012-05-03T05:06:00.000-07:002012-05-03T05:06:03.427-07:00WCF - Enable custom session managementIn order to enable a custom management of a WCF session, the service contracts have to be decorated with the following attribute:
<b>[ServiceBehavior(AutomaticSessionShutdown=false)]</b>. By default the session will be terminated when the WCF call is completed.
When a session is established between a WCF service and a client, all client calls are handled by same WCF instance.
WCF supports the following types of sessions behaviors:
<br/>- <b>System.ServiceModel.Channels.SecurityBindingElement</b> (supports security based sessions)
<br/>- <b>System.ServiceModel.NetTcpBinding</b> (supports TCP/IP sessions)
<br/>- <b>System.ServiceModel.Channels.ReliableSessionBindingElement</b> (supports reliable sessions)
<br/>- <b>System.ServiceModel.NetMsmqBinding</b> (supposrts MSMQ datagram sessions)Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-76666564654001797952012-05-03T04:48:00.000-07:002012-05-03T04:48:04.572-07:00WCF - BasicHttpContextBinding & BasicHttpBinding<b>BasicHttpBinding</b> defines a binding used by <b>WCF</b> to configure and expose endpoints which provide compatibility with <b>ASMX</b> based services and clients, or to any other type of services which comply with <b>WS-I Basic Profile 1.1</b>. It makes use of HTTP transport protocol to deliver SOAP 1.1 messages.
<b>BasicHttpContextBinding</b> provides same functionality as <b>BasicHttpBinding</b> but with some extras. It ensures that the <b>WCF</b> service exposed through this endpoint biding is compatible with ASP.NET session state features.Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-14339708881388825092012-04-13T10:58:00.000-07:002012-04-13T10:58:20.146-07:00Microsoft Validation Block WCF REST callsRecently I have been involved and project which required a web service layer to allow various clients to communicate with our business end. <br />
For this WCF was as always the perfect candidate :D. The service layer had to support both SOAP and REST protocols; for validation of the requests Microsoft Enterprise Library Validation Block was used, having the DTO object decorated with the appropriate validation attributes. All worked fine for SOAP request, if the wrong data was present or if the data was missing from the DTO sent in the request a fault message was generated and sent to the client. But issues appeared with REST request, no validation being triggered and not exception thrown on the WCF service level to point out the issue. After searching on the internet for couple of minutes the solution popped up: <br />
<p><b><br />
Microsoft.Practices.ServiceLocation.dll<br />
Microsoft.Practices.Unity.dll<br />
Microsoft.Practices.Unity.Interception.dll<br />
</b><br />
</p>Where missing from the WCF service project references. Adding the above mentioned DLLs solved the issue.Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-60027059792194708882011-09-28T03:46:00.000-07:002011-09-28T03:50:24.181-07:00WCF Security Guide<span style="color:#ff0000;"><strong>Note:</strong> <span style="font-family:times new roman;">The content is procured from <a href="https://www.owasp.org/index.php/WCF_Security_Best_Practices">OWASP</a></span></span><br />
<br />
<br />
<div><h3 align="center">From OWASP</h3><p>From <a rel="nofollow" href="http://www.codeplex.com/WCFSecurity/Wiki/View.aspx?title=Guidelines">WCF 3.5 Security Guidelines</a><br />
<br />
(@Codeplex by J.D. Meier , Jason Taylor , Prashant Bansode , Carlos Farre, Madhu Sundararajan, Steve Gregersen.)<br />
</p><p><b>Design Considerations</b><br />
</p><ul><li> Design your service as a wrapper<br />
</li>
<li> If you are coming from ASMX then use basicHttpBinding to support your existing clients<br />
</li>
<li> If you are coming from DCOM then, use netTcpBinding<br />
</li>
<li> If your clients are deployed within intranet then choose transport security<br />
</li>
<li> If your clients are deployed over the internet then choose message security<br />
</li>
<li> Know your Authentication options<br />
</li>
<li> Know your binding options<br />
</li>
<li> If you need to Interop with non MS clients, use basicHttpBinding or wsHttpBinding<br />
</li>
<li> If your non-MS clients understand WS stack, use wsHttpBinding<br />
</li>
</ul><p><br />
<br />
<b>Auditing and Logging</b><br />
</p><ul><li> Use WCF auditing to audit your service<br />
</li>
<li> If non-repudiation is important, consider setting SuppressAuditFailure property to false<br />
</li>
<li> Use message logging to log operations on your service<br />
</li>
<li> Instrument for user management events<br />
</li>
<li> Instrument for significant business operations<br />
</li>
<li> Protect log files from unauthorized access<br />
</li>
<li> Do not log sensitive information<br />
</li>
</ul><p><br />
<br />
<b>Authentication</b><br />
</p><ul><li> Know your authentication options<br />
</li>
<li> Use Windows Authentication when you can<br />
</li>
<li> If you support non-WCF clients using windows authentication and message security, consider using the Kerberos direct option<br />
</li>
<li> If your users are in AD, but you can’t use windows authentication, consider using username authentication<br />
</li>
<li> If you are using username authentication, use Membership Provider instead of custom authentication<br />
</li>
<li> If your users are in a SQL membership store, use the SQL Membership Provider<br />
</li>
<li> If your users are in a custom store, consider using username authentication with a custom validator<br />
</li>
<li> If your clients have certificates, consider using client certificate authentication<br />
</li>
<li> If your partner applications need to be authenticated when calling WCF services, use client certificate authentication.<br />
</li>
<li> If you are using username authentication, validate user login information<br />
</li>
<li> Do not store passwords directly in the user store<br />
</li>
<li> Enforce strong passwords<br />
</li>
<li> Protect access to your credential store<br />
</li>
<li> If you are using Windows Forms to connect to WCF, do not cache credentials<br />
</li>
</ul><p><br />
<br />
<b>Authorization</b><br />
</p><ul><li> If you store role information in Windows Groups, consider using the WCF PrincipalPermissionAttribute class for roles authorization<br />
</li>
<li> If you use ASP.NET roles, use the ASP.NET Role Provider<br />
</li>
<li> If you use windows groups for authorization, use ASP.NET Role Provider with AspNetWindowsTokenRoleProvider<br />
</li>
<li> If you store role information in SQL, consider using the SQL Server Role Provider for roles authorization<br />
</li>
<li> If you store role information in ADAM, use the Authorization Store Role Provider for roles authorization<br />
</li>
<li> If you need to authorize access to WCF operations, use declarative authorization<br />
</li>
<li> If you need to perform fine-grained authorization based on business logic, use imperative authorization<br />
</li>
</ul><p><br />
<br />
<b>Binding</b><br />
</p><ul><li> If you need to support clients over the internet, consider using wsHttpBinding.<br />
</li>
<li> If you need to expose your WCF service to legacy clients as an ASMX web service, use basicHttpBinding<br />
</li>
<li> If you need to support remote WCF clients within an intranet, consider using netTcpBinding.<br />
</li>
<li> If you need to support local WCF clients, consider using netNamedPipeBinding.<br />
</li>
<li> If you need to support disconnected queued calls, use netMsmqBinding.<br />
</li>
<li> If you need to support bidirectional communication between WCF Client and WCF service, use wsDualHttpBinding.<br />
</li>
</ul><p><br />
<br />
<b>Configuration Management</b><br />
</p><ul><li> Use Replay detection to protect against message replay attacks<br />
</li>
<li> If you host your service in a Windows service, expose a metadata exchange (mex) binding<br />
</li>
<li> If you don’t want to expose your WSDL, turn off HttpGetEnabled and metadata exchange (mex)<br />
</li>
<li> Manage bindings and endpoints in config not code<br />
</li>
<li> Associate names with the service configuration when you create service behavior, endpoint behavior, and binding configuration<br />
</li>
<li> Encrypt configuration sections that contain sensitive data<br />
</li>
</ul><p><br />
<br />
<b>Exception Management</b><br />
</p><ul><li> Use structured exception handling<br />
</li>
<li> Do not divulge exception details to clients in production<br />
</li>
<li> Use a fault contract to return error information to clients<br />
</li>
<li> Use a global exception handler to catch unhandled exceptions<br />
</li>
</ul><p><br />
<br />
<b>Hosting</b><br />
</p><ul><li> If you are hosting your service in a Windows Service, use a least privileged custom domain account<br />
</li>
<li> If you are hosting your service in IIS, use a least privileged service account<br />
</li>
<li> Use IIS to host your service unless you need to use a transport that IIS does not support<br />
</li>
</ul><p><br />
<br />
<b>Impersonation and Delegation</b><br />
</p><ul><li> Know the impersonation options<br />
</li>
<li> If you have to flow the original caller, use constrained delegation<br />
</li>
<li> Consider LogonUser when you need to impersonate but you don’t have trusted delegation<br />
</li>
<li> Consider S4U when you need a Windows token and you don’t have the original caller’s credentials<br />
</li>
<li> Use programmatic impersonation to impersonate based on business logic<br />
</li>
<li> When impersonating programmatically be sure to revert to original context<br />
</li>
<li> Only impersonate on operations that require it<br />
</li>
<li> Use OperationBehavior to impersonate declaratively<br />
</li>
</ul><p><br />
<br />
<b>Input/Data Validation</b><br />
</p><ul><li> If you need to validate parameters, use parameter inspectors<br />
</li>
<li> If your service has operations that accept message or data contracts, use schemas to validate your messages<br />
</li>
<li> If you need to do schema validation, use message inspectors<br />
</li>
<li> Validate operation parameters for length, range, format and type<br />
</li>
<li> Validate parameter input on the server<br />
</li>
<li> Validate service responses on the client<br />
</li>
<li> Do not rely on client-side validation<br />
</li>
<li> Avoid user-supplied file name and path input<br />
</li>
<li> Do not echo untrusted input<br />
</li>
</ul><p><br />
<br />
<b>Proxy Considerations</b><br />
</p><ul><li> Publish your metadata over HTTPS to protect your clients from proxy spoofing<br />
</li>
<li> If you turn off mutual authentication, be aware of service spoofing<br />
</li>
</ul><p><br />
<br />
<b>Deployment considerations</b><br />
</p><ul><li> Do not use temporary certificates in production<br />
</li>
<li> If you are using a custom domain account in the identity pool for your WCF application, create an SPN for Kerberos to authenticate the client.<br />
</li>
<li> If you are using a custom service account and need to use trusted for delegation, create an SPN<br />
</li>
<li> If you are hosting your service in a Windows Service, using a custom domain identity, and ASP.NET needs to use constrained trusted for delegation when calling the service, create an SPN<br />
</li>
<li> Use IIS to host your service unless you need to use a transport that IIS does not support<br />
</li>
<li> Use a least privileged account to run your WCF service<br />
</li>
<li> Protect sensitive data in your configuration files<br />
</li>
</ul></div>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-22884096573061270202011-07-20T13:19:00.000-07:002011-07-20T22:57:21.909-07:00HTTP Data Client - An abstract way of web scraping<h2>Introduction</h2><p>The purpose of this article is to describe how you can implement a generic “HTTP Data Client” (I apologize if it sounds fussy) using C# which would allow you to query in an elegant manner any web based resources you would like (in one word it allows you to do <b>web scraping</b>). I would like to mention from the beginning that this is not “the perfect solution” and that for sure it can be improved in many ways, so, please feel free to do so. The entire concept it is based on HTTPWebRequest object offered by .NET under System.Net name space.</p><br />
<h2>Prerequisites</h2><p>Before I’ll start to dwell into architecture and code, there are some extra libraries which are used and required by the “HTTP Data Client” project.<br />
</br><br />
Here is the list of libraries:<br />
</br><br />
<ul><li><strong>Db4Object</strong> (this is a object oriented database, I am using it meanly for embedded applications; there are two assembly files which are referenced: Db4objects.Db4o.dll and Db4objects.Db4o.NativeQueries.dll; you can get the DB4Object from the following location: http://www.db4o.com/DownloadNow.aspx)</li>
<li><strong>Html Agility Pack</strong> (this is a library which allows you to process HTML content using various techniques, it is very handy when you would like to convert the HTML DOM to XML; there is one assembly file referenced: HtmlAgilityPack.dll; you can get the library from the following location: http://htmlagilitypack.codeplex.com)</li>
<li><strong>Microsoft mshtml</strong> (its purpose is to render and parse HTML and JavaScript content)</li>
</ul>If you are wondering why I have decided to use two different libraries to parse HTML content, the answer is straight forward. Html Agility Pack is performing really well most of the time; the output you get is usually what you are expecting, but not always. So if one library fails to provide the expected results I can switch to the other one. </br>The major drawback of MSHTML library in my opinion is the slow processing speed when it is integrated in a non desktop application (e.g.: web sites, web services, etc).</br><br />
The role of DB4Object in this project is to store configuration settings and cache content. One important thing that has to mentioned about DB4Object is that the non server version doesn’t support multi-threading (you can easily replace with any other storage which is suitable for you).<br />
</p><br />
<h2>Architecture</h2><p>My solution is contains four projects:<br />
<ul><li><strong>HtmlAgilityPack</strong> (the actual Html Agility Pack project with source code)</li>
<li><strong>HttpData.Client</strong> (main project which implements the rules of HTML processing)<br />
</li>
<li><strong>HttpData.Client.MsHtmlToXml</strong> (wrapper project over MSHTML and some extensions of it)<br />
</li>
<li><strong>HttpData.Client.Pdf</strong> (project which implements some PDF processing using IFilter; not important for this article)<br />
</li>
</ul>There is no point to discuss about HtmlAgilityPack since you can find all details and documentation about it on http://htmlagilitypack.codeplex.com.<br />
I will focus mainly on HttpData.Client and try to offer you as many details and explanations as possible. The http data client is design to work in a similar way with .NET SQL client (System.Data.SqlClient), you will notice that the classes included in project and their logic resembles a lot (I hope is not just my imagination). I will enumerate the interfaces and classes and provide details about their logic and purpose.<br />
</p><br />
<h2>IHDPAdapter and HDPAdapter</h2><p>The purpose of HDPAdapter class is to allow integration of XML data to with other data objects as DataTable and DataSet. The IHDPAdapter interface exposes two methods which convert XML data into either a DataTable or a DataSet. At current time only DataTable conversion method is implemented. </br>Here is the code snippet for the interface and class:<br />
</br><br />
</br><br />
<b>IHDPAdapter Code</b><br />
<pre lang="CS">using System.Data;
using System.Xml;
namespace HttpData.Client
{
/// <summary>
/// Provides functionality for integration with data objects (DataTable, DataSet, etc). Is implemented by HDPAdapter.
/// </summary>
public interface IHDPAdapter
{
#region
/// <summary>
/// Get or set the select HDPCommand object.
/// </summary>
IHDPCommand SelectCommand{ get; set; }
#endregion
#region METHODS
/// <summary>
/// Fill a data table with the content from a specified xml document object.
/// </summary>
/// <param name="table">Data table to be filled.</param>
/// <param name="source">Xml document object of which content will fill the data table.</param>
/// <param name="useNodes">True if nodes names should be used for columns names, otherwise attributes will be used.</param>
/// <returns>Number of filled rows.</returns>
int Fill(DataTable table, XmlDocument source, bool useNodes);
/// <summary>
/// (NOT IMPLEMENTED) Fill a data set with the content from a specified xml document object.
/// </summary>
/// <param name="dataset">Data set to be filled.</param>
/// <param name="source">Xml document object of which content will fill the data table.</param>
/// <param name="useNodes">True if nodes names should be used for columns names, otherwise attributes will be used.</param>
/// <returns>Number of filled rows.</returns>
int Fill(DataSet dataset, XmlDocument source, bool useNodes);
#endregion
}
}
</pre></br><br />
</br><br />
<b>HDPAdapter Code</b><br />
<pre lang="CS">using System;
using System.Xml;
using System.Xml.XPath;
using System.Data;
using System.Text;
namespace HttpData.Client
{
/// <summary>
/// Provides functionality for integration with data objects (DataTable, DataSet, etc).
/// </summary>
public class HDPAdapter : IHDPAdapter
{
#region PRIVATE VARIABLES
private IHDPCommand _selectCommand;
#endregion
#region Properties
/// <summary>
/// Get or set the select IHDPCommand object.
/// </summary>
IHDPCommand IHDPAdapter.SelectCommand
{
get{ return _selectCommand; }
set{ _selectCommand = value; }
}
/// <summary>
/// Get or set the select HDPCommand object.
/// </summary>
public HDPCommand SelectCommand
{
get{ return (HDPCommand)_selectCommand; }
set{ _selectCommand = value; }
}
/// <summary>
/// Get or set the connection string.
/// </summary>
public string ConnectionString { get; set; }
#endregion
#region .ctor
/// <summary>
/// Create a new instance of HDPAdapter.
/// </summary>
public HDPAdapter()
{
}
/// <summary>
/// Create a new instance of HDPAdapter.
/// </summary>
/// <param name="connectionString">Connection string associated with HDPAdapter object.</param>
public HDPAdapter(string connectionString)
{
this.ConnectionString = connectionString;
}
#endregion
#region Public Methods
/// <summary>
/// Fill a data table with the content from a specified xml document object.
/// </summary>
/// <param name="table">Data table to be filled.</param>
/// <param name="source">Xml document object of which content will fill the data table.</param>
/// <param name="useNodes">True if nodes names should be used for columns names, otherwise attributes will be used.</param>
/// <returns>Number of filled rows.</returns>
public int Fill(DataTable table, XmlDocument source, bool useNodes)
{
bool columnsCreated = false;
bool resetRow = false;
if(table == null || source == null)
return 0;
if (table.TableName.Length == 0)
return 0;
StringBuilder sbExpression = new StringBuilder("//");
sbExpression.Append(table.TableName);
XPathNavigator xpNav = source.CreateNavigator();
if (xpNav != null)
{
XPathNodeIterator xniNode = xpNav.Select(sbExpression.ToString());
while(xniNode.MoveNext())
{
XPathNodeIterator xniRowNode = xniNode.Current.SelectChildren(XPathNodeType.Element);
while (xniRowNode.MoveNext())
{
if(resetRow)
{
xniRowNode.Current.MoveToFirst();
resetRow = false;
}
DataRow row = null;
if (columnsCreated)
row = table.NewRow();
if(useNodes)
{
XPathNodeIterator xniColumnNode = xniRowNode.Current.SelectChildren(XPathNodeType.Element);
while (xniColumnNode.MoveNext())
{
if (!columnsCreated)
{
DataColumn column = new DataColumn(xniColumnNode.Current.Name);
table.Columns.Add(column);
}
else
row[xniColumnNode.Current.Name] = xniColumnNode.Current.Value;
}
}
else
{
XPathNodeIterator xniColumnNode = xniRowNode.Clone();
bool onAttribute = xniColumnNode.Current.MoveToFirstAttribute();
while (onAttribute)
{
if (!columnsCreated)
{
DataColumn column = new DataColumn(xniColumnNode.Current.Name);
table.Columns.Add(column);
}
else
row[xniColumnNode.Current.Name] = xniColumnNode.Current.Value;
onAttribute = xniColumnNode.Current.MoveToNextAttribute();
}
}
if (!columnsCreated)
{
columnsCreated = true;
resetRow = true;
}
if (row != null)
table.Rows.Add(row);
}
}
}
return table.Rows.Count;
}
/// <summary>
/// (NOT IMPLEMENTED) Fill a data set with the content from a specified xml document object.
/// </summary>
/// <param name="dataset">Data set to be filled.</param>
/// <param name="source">Xml document object of which content will fill the data table.</param>
/// <param name="useNodes">True if nodes names should be used for columns names, otherwise attributes will be used.</param>
/// <returns>Number of filled rows.</returns>
public int Fill(DataSet dataset, XmlDocument source, bool useNodes)
{
throw new NotImplementedException();
}
#endregion
#region Private Methods
#endregion
}
}
</pre></p><br />
<h2>IHDPConnection and HDPConnection</h2><p>As the name says this represents the connection class which will manage in an abstract way how a connection behaves. The interface exposes a set of methods and properties relevant to it. </br>There are only three methods exposed and implemented: <br />
<ul><li><i>Open</i> method (changes the connection state to open; this method has an override which accepts as parameter the URL of the web resource which will be opened)</li>
<li><i>Close</i> method (changes the connection state to close and if there is a cache storage in use it closes it)<br />
</li>
<li><i>CreateCommand</i> method (it creates a new HDPCommand object and assigns the current connection to it)</li>
</ul><br />
Now let us take a look at the properties exposed by IHDPConnection and implemented by HDPConnection:<br />
<ul><li><i>ConnectionURL</i> (represents the web resource URL which will be opened using current connection)</li>
<li><i>KeepAlive</i> (defines if the connection should be kept opened or not once the querying is done)</li>
<li><i>AutoRedirect</i> (defines if the connection allows any auto-redirects to be performed)</li>
<li><i>MaxAutoRedirects</i> (defines how many auto-redirects can be performed)</li>
<li><i>UserAgent</i> (defines what user agent will be associated with the connection, e.g.: Internet Explorer, Chrome, Opera, etc)</li>
<li><i>ConnectionState</i> (read only property which provides information about the connection state; is connection opened or closed)</li>
<li><i>Proxy</i> (defines what proxy will be used when querying is performed)</li>
<li><i>Cookies</i> (cookies associated with the connection currently or on when the querying takes place)</li>
<li><i>ContentType</i> (defines what content type is expected when querying takes place, e.g.: application/x-www-form-urlencoded, application/json, etc)</li>
<li><i>Headers</i> (contains the headers associated with the connection currently or when the querying takes place)</li>
<li><i>Referer</i> (contains the referrer which is going to be used when querying the connection URL)</li>
</ul><br />
</br><br />
</br><br />
<b>IHDPConnection Code</b><br />
<pre lang="CS">using System.Collections.Generic;
using System.Net;
namespace HttpData.Client
{
/// <summary>
/// Provides functionality for connection management of different web sources. Is implemented by HDPConnection.
/// </summary>
public interface IHDPConnection
{
#region MEMBERS
#region METHODS
/// <summary>
/// Open connection.
/// </summary>
void Open();
/// <summary>
/// Close connection.
/// </summary>
void Close();
/// <summary>
/// Create a new HDPCommand object associated with this connection.
/// </summary>
/// <returns>HDPCommand object associated with this connection.</returns>
IHDPCommand CreateCommand();
#endregion
#region PROPERTIES
/// <summary>
/// Get or set connection url.
/// </summary>
string ConnectionURL { get; set; }
/// <summary>
/// Get or set the value which specifies if the connection should be maintained openend.
/// </summary>
bool KeepAlive { get; set; }
/// <summary>
/// Get or set the value which specifies if auto redirection is allowed.
/// </summary>
bool AutoRedirect { get; set; }
/// <summary>
/// Get or set the value which specifies if maximum number of auto redirections.
/// </summary>
int MaxAutoRedirects { get; set; }
/// <summary>
/// Get or set the value which specifies the user agent to be used.
/// </summary>
string UserAgent { get; set; }
/// <summary>
/// Get the value which specifies the state of the connection.
/// </summary>
HDPConnectionState ConnectionState { get; }
/// <summary>
/// Get or set the value which specifies the connection proxy.
/// </summary>
HDPProxy Proxy { get; set; }
/// <summary>
/// Get or set the value which specifies the coockies used by connection.
/// </summary>
CookieCollection Cookies { get; set; }
/// <summary>
/// Get or set the value which specifies the content type.
/// </summary>
string ContentType { get; set; }
/// <summary>
/// Get or set headers details used in HttpWebRequest operations.
/// </summary>
List<HDPConnectionHeader> Headers { get; set; }
/// <summary>
/// Get or set Http referer.
/// </summary>
string Referer { get; set; }
#endregion
#endregion
}
}
</pre></br><br />
</br><br />
<b>HDPConnection Code</b><br />
<pre lang="CS">using System.Collections.Generic;
using System.Net;
namespace HttpData.Client
{
/// <summary>
/// Provides functionality for connection management of different web sources.
/// </summary>
public class HDPConnection : IHDPConnection
{
#region Private Variables
private HDPConnectionState _connectionState;
private string _connectionURL;
private HDPCache cache;
private bool useCache;
#endregion
#region Properties
/// <summary>
/// Get the value which specifies if caching will be used.
/// </summary>
public bool UseCahe
{
get { return useCache; }
}
/// <summary>
/// Get HDPCache object.
/// </summary>
public HDPCache Cache
{
get { return cache; }
}
#endregion
#region .ctor
/// <summary>
/// Instantiate a new HDPConnection object.
/// </summary>
public HDPConnection()
{
_connectionState = HDPConnectionState.Closed;
_connectionURL = "";
Cookies = new CookieCollection();
MaxAutoRedirects = 1;
}
/// <summary>
/// Instantiate a new HDPConnection object.
/// </summary>
/// <param name="connectionURL">Url of the web source.</param>
public HDPConnection(string connectionURL)
{
_connectionState = HDPConnectionState.Closed;
_connectionURL = connectionURL;
Cookies = new CookieCollection();
MaxAutoRedirects = 1;
}
/// <summary>
/// Instantiate a new HDPConnection object.
/// </summary>
/// <param name="cacheDefinitions">HDPCacheDefinition object used by caching mechanism.</param>
public HDPConnection(HDPCacheDefinition cacheDefinitions)
{
_connectionState = HDPConnectionState.Closed;
_connectionURL = "";
Cookies = new CookieCollection();
MaxAutoRedirects = 1;
cache = cacheDefinitions != null ? new HDPCache(cacheDefinitions) : null;
useCache = true;
}
/// <summary>
/// Instantiate a new HDPConnection object.
/// </summary>
/// <param name="connectionURL">Url of the web source.</param>
/// <param name="cacheDefinitions">HDPCacheDefinition object used by caching mechanism.</param>
public HDPConnection(string connectionURL, HDPCacheDefinition cacheDefinitions)
{
_connectionState = HDPConnectionState.Closed;
_connectionURL = connectionURL;
Cookies = new CookieCollection();
MaxAutoRedirects = 1;
cache = cacheDefinitions != null ? new HDPCache(cacheDefinitions) : null;
useCache = true;
}
#endregion
#region Public Methods
#endregion
#region IHDPConnection Members
#region Methods
/// <summary>
/// Open connection.
/// </summary>
public void Open()
{
_connectionState = HDPConnectionState.Open;
}
/// <summary>
/// Open connection using a specific url.
/// </summary>
/// <param name="connectionURL">Url of the web source.</param>
public void Open(string connectionURL)
{
_connectionURL = connectionURL;
_connectionState = HDPConnectionState.Open;
}
/// <summary>
/// Close connection.
/// </summary>
public void Close()
{
_connectionState = HDPConnectionState.Closed;
if (cache != null)
cache.CloseStorageConnection();
}
/// <summary>
/// Create a new IHDPCommand object associated with this connection.
/// </summary>
/// <returns>IHDPCommand object associated with this connection.</returns>
IHDPCommand IHDPConnection.CreateCommand()
{
HDPCommand command = new HDPCommand { Connection = this };
return command;
}
/// <summary>
/// Create a new HDPCommand object associated with this connection.
/// </summary>
/// <returns>HDPCommand object associated with this connection.</returns>
public HDPCommand CreateCommand()
{
HDPCommand command = new HDPCommand { Connection = this };
return command;
}
#endregion
#region Properties
/// <summary>
/// Get or set connection url.
/// </summary>
public string ConnectionURL
{
get { return _connectionURL; }
set { _connectionURL = value; }
}
/// <summary>
/// Get or set the value which specifies if auto redirection is allowed.
/// </summary>
public bool AutoRedirect { get; set; }
/// <summary>
/// Get or set the value which specifies if maximum number of auto redirections.
/// </summary>
public int MaxAutoRedirects { get; set; }
/// <summary>
/// Get or set the value which specifies if the connection should be maintained openend.
/// </summary>
public bool KeepAlive { get; set; }
/// <summary>
/// Get or set the value which specifies the user agent to be used.
/// </summary>
public string UserAgent { get; set; }
/// <summary>
/// Get or set the value which specifies the content type.
/// </summary>
public string ContentType { get; set; }
/// <summary>
/// Get or set the value which specifies the coockies used by connection.
/// </summary>
public CookieCollection Cookies { get; set; }
/// <summary>
/// Get the value which specifies the state of the connection.
/// </summary>
public HDPConnectionState ConnectionState
{
get { return _connectionState; }
}
/// <summary>
/// Get or set the value which specifies the connection proxy.
/// </summary>
public HDPProxy Proxy { get; set; }
/// <summary>
/// Get or set headers details used in HttpWebRequest operations.
/// </summary>
public List<HDPConnectionHeader> Headers { get; set; }
/// <summary>
/// Get or set Http referer.
/// </summary>
public string Referer { get; set; }
#endregion
#endregion
#region IDisposable Members
///<summary>
/// Dispose current object.
///</summary>
public void Dispose()
{
this.dispose();
System.GC.SuppressFinalize(this);
}
private void dispose()
{
if (_connectionState == HDPConnectionState.Open)
this.Close();
}
#endregion
}
}
</pre></p><h2>IHDPCommand and HDPCommand</h2><p>This represents our engine which provides functionality for querying web resources and processing the result (response). It offers a variety of way that can be used to process the response content of the query as: XPath, RegEx, XSLT, reflection, etc. I will discuss in detail only the main methods, rest of them are leveraged on those and I assume the comments which accompany the methods are suffice to provide guidance in the right direction. But before I’ll reach the methods, let me present you the properties.<br />
<br />
<ul><li><i>Connection</i> (defines the connection object associated with this command)<br />
</li>
<li><i>Parameters</i> (defines the parameters used in the querying process)<br />
</li>
<li><i>CommandType</i> (defines the command type used in querying process; it is either GET either POST)</li>
<li><i>CommandText</i> (defines the content of the command which is going to executed; if this is a GET command then the URL with query parameters are stored, if it is a POST command, then the body content of the post action is stored)</li>
<li><i>CommandTimeout</i> (defines the time period in which a response is expected from the web resource)</li>
<li><i>Response</i> (contains the response string received from the web resource based on a query action)</li>
<li><i>Uri</i> (contains the URI of the queried web resource)</li>
<li><i>Path</i> (contains the path of the web resource queried)</li>
<li><i>LastError</i> (contains the last error message encountered in the process)<br />
</li>
<li><i>ContentLength</i> (contains the length of the content received from the web resource based on a query action)</li>
</ul>We can move now to the exposed/implemented methods.<br />
<ul><li><i>GetParametersCount</i> (gets the number of parameters used in the query process)</li>
<li><i>CreateParameter</i> (create a new parameter to be used in the query process)<br />
</li>
<li><i>ExecuteNonQuery</i> (executes a query on a web resources using either GET or POST methods and it returns the number of results received. It has one parameter which specifies if the collection of parameters used in the query process should be cleaned at the end)</li>
<li><i>Execute</i>(executes a query on a web resources using either GET or POST methods and it returns a Boolean value, true if the query was executed with success, false if it failed)</li>
<li><i>ExecuteStream</i> (executes a query on a web resources using either GET or POST methods and it returns the underlying http response stream)</li>
<li><i>CloseResponse</i> (it closes the http response stream opened by ExecuteStream method)</li>
<li><i>ExecuteNavigator</i> (executes a query on a web resources using either GET or POST methods and it returns a XPathNavigator object used to navigate thru the response converted to XML. It has one parameter which specifies if the collection of parameters used in the query process should be cleaned at the end)</li>
<li><i>ExecuteDocument</i> (it has an override, executes a query on a web resources using either GET or POST methods and it returns a IXPathNavigable object used to navigate thru the response converted to XML, the “expression” parameter represents a XPath expression which will be used in the processing of the result)<br />
</li>
<li><i>ExecuteBinary</i> (executes a query on a web resources using either GET or POST methods and it returns a result in byte array format. This is mostly used when querying binary content from web resources e.g.: PDF files, images. One of the overridden method parameters imposes a limit on the output buffer)</li>
<li><i>ExecuteBinaryConversion</i> (executes a query on a web resources using either GET or POST methods and it returns a result as string. This is used when querying binary content from web resources e.g.: PDF files and the content of a PDF file is converted from binary to string)</li>
<li><i>ExecuteString</i> (executes a query on a web resources using either GET or POST methods and it returns a result as plain string)</li>
<li><i>ExecuteValue</i> (executes a query on a web resource using either GET or POST methods and it returns a result as string which is a representation of an XPath expression applied. Instead of an XPath expression it can be an RegEx)</li>
<li><i>ExecuteCollection</i> (executes a query on a web resource using either GET or POST methods and it returns a result as generic string collection. The result is a representation of an either XPath or RegEx expression applied on the result)</li>
<li><i>ExecuteArray</i> (executes a query on a web resource using either GET or POST methods and it returns a result as a string array. The result is a representation of an either XPath or RegEx expression applied on the result)</li>
</ul></br><br />
</br><br />
<b>IHDPCommand Code</b><br />
<pre lang="CS">using System.Collections.Generic;
using System.IO;
using System.Xml.XPath;
namespace HttpData.Client
{
/// <summary>
/// Provides functionality for querying and processing data from different web sources. Is implemented by HDPCommand.
/// </summary>
public interface IHDPCommand
{
#region Members
#region Properties
/// <summary>
/// Get or set the command connection object.
/// </summary>
IHDPConnection Connection { get; set; }
/// <summary>
/// Get or set the command parameters collection.
/// </summary>
IHDPParameterCollection Parameters { get; }
/// <summary>
/// Get or set the command type.
/// </summary>
HDPCommandType CommandType { get; set; }
/// <summary>
/// Get or set the command text.
/// </summary>
string CommandText { get; set; }
/// <summary>
/// Get or set the command timeout.
/// </summary>
int CommandTimeout { get; set; }
/// <summary>
/// Get the response retrieved from the server.
/// </summary>
string Response { get; }
/// <summary>
/// Get web resource URI.
/// </summary>
string Uri { get; }
/// <summary>
/// Get web resource absolute path.
/// </summary>
string Path { get; }
/// <summary>
/// Get the last error occurend.
/// </summary>
string LastError { get; }
/// <summary>
/// Get the content length of response.
/// </summary>
long ContentLength { get; }
#endregion
#region Methods
/// <summary>
/// Get the parameters number.
/// </summary>
/// <returns>Number of parameters.</returns>
int GetParametersCount();
/// <summary>
/// Create a new IHDPParameter object.
/// </summary>
/// <returns>IHDPParameter parameter object.</returns>
IHDPParameter CreateParameter();
/// <summary>
/// Execute a expression against the web server and return the number of results.
/// </summary>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>Number of results determined by the expression.</returns>
int ExecuteNonQuery(bool clearParams);
/// <summary>
/// Execute a query against the web server and does not read the response stream.
/// </summary>
/// <returns>True is the command executed with success otherwise false.</returns>
bool Execute();
/// <summary>
/// Execute a query against the web server.
/// </summary>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>True is the command executed with success otherwise false.</returns>
bool Execute(bool clearParams);
/// <summary>
/// Execute a query against the web server.
/// </summary>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>Returns the underlying http response stream.</returns>
Stream ExecuteStream(bool clearParams);
/// <summary>
/// Closes the http response object..
/// Usable only with ExecuteStream method.
/// </summary>
void CloseResponse();
/// <summary>
/// Execute a query against the web server and return a XPathNavigator object used to navigate thru the query result.
/// </summary>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>XPathNavigator object used to navigate thru the query result.</returns>
XPathNavigator ExecuteNavigator(bool clearParams);
/// <summary>
/// Execute a query against the web server and return a IXPathNavigable object used to navigate thru the query result.
/// </summary>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>IXPathNavigable object used to navigate thru the query result.</returns>
IXPathNavigable ExecuteDocument(bool clearParams);
/// <summary>
/// Execute a query against the web server, on query reult it will apply a xpath expression and return a IXPathNavigable object used to navigate thru query result.
/// </summary>
/// <param name="expression">XPath expression.</param>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>IXPathNavigable object used to navigate thru query result.</returns>
IXPathNavigable ExecuteDocument(string expression, bool clearParams);
/// <summary>
/// Execute a query against the web server and return a byte[] object which contains the binary query result. Used when querying binary content from web server (E.g: PDF files).
/// </summary>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>Byte array object which contains the binary query result.</returns>
byte[] ExecuteBinary(bool clearParams);
/// <summary>
/// Execute a query against the web server and return a byte[] object which contains the binary query result. Used when querying binary content from web server (E.g: PDF files).
/// </summary>
/// <param name="boundaryLimit">Specify the limit of the buffer which must be read.</param>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>Byte array object which contains the binary query result.</returns>
byte[] ExecuteBinary(int boundaryLimit, bool clearParams);
/// <summary>
/// Execute a query against the web server and return a string object which contains the representation of the binary query result. Used when querying binary content from web server (E.g: PDF files).
/// </summary>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>String object which contains the representation of the binary query result.</returns>
string ExecuteBinaryConversion(bool clearParams);
/// <summary>
/// Execute a query against the web server and return a string object which contains the representation of the query result.
/// </summary>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>String object which contains the representation of the query result.</returns>
string ExecuteString(bool clearParams);
/// <summary>
/// Execute a query against the web server, on query reult it will apply a xpath expression and return a string object which contains the representation of the query result value.
/// </summary>
/// <param name="expression">XPath expression.</param>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>String object which contains the representation of the query result value.</returns>
string ExecuteValue(string expression, bool clearParams);
/// <summary>
/// Execute a query against the web server, on query reult it will apply a regular expression and return a string object which contains the representation of the query result value.
/// </summary>
/// <param name="expression">Regular expression.</param>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <param name="isRegEx">Specify the a regular expression is used, it must always be to true.</param>
/// <returns>String object which contains the representation of the query result value.</returns>
string ExecuteValue(string expression, bool clearParams, bool isRegEx);
/// <summary>
/// Execute a query against the web server, on query reult it will apply a regular expression and return a List object which contains the representation of the query result.
/// </summary>
/// <param name="expression">Regular expression.</param>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <param name="isRegEx">Specify the a regular expression is used, it must always be to true.</param>
/// <returns>List object which contains the representation of the query result.</returns>
List<string> ExecuteCollection(string expression, bool clearParams, bool isRegEx);
/// <summary>
/// Execute a query against the web server, on query reult it will apply a xpath expression and return a List object which contains the representation of the query result.
/// </summary>
/// <param name="expression">XPath expression.</param>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>List object which contains the representation of the query result.</returns>
List<string> ExecuteCollection(string expression, bool clearParams);
/// <summary>
/// Execute a query against the web server, on query reult it will apply a regular expression and return a string array object which contains the representation of the query result.
/// </summary>
/// <param name="expression">Regular expression.</param>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <param name="isRegEx">Specify the a regular expression is used, it must always be to true.</param>
/// <returns>String array object which contains the representation of the query result.</returns>
string[] ExecuteArray(string expression, bool clearParams, bool isRegEx);
/// <summary>
/// Execute a query against the web server, on query reult it will apply a xpath expression and return a string array object which contains the representation of the query result.
/// </summary>
/// <param name="expression">XPath expression.</param>
/// <param name="clearParams">Specify if the parameters collection should be cleared after the query is executed.</param>
/// <returns>String array object which contains the representation of the query result.</returns>
string[] ExecuteArray(string expression, bool clearParams);
#endregion
#endregion
}
}
</pre></p><h2>HDPCache, HDPCacheDefinition, HDPCacheObject and HDPCacheStorage</h2><p>HDPCache, HDPCacheDefinition, HDPCacheObject and HDPCacheStorage are the classes which handle the cache. I will not insist on this subject since is not so important in this case. If you like you can study those classes in more detail by yourself. I think the code comments will help you to grasp they purpose and functionality quite fast.<br />
</br><br />
The class HDPCacheObject is straight forward; it contains a set of properties which define the cache behavior. Here are its properties:<br />
<ul><li><i>StorageActiveUntil</i> (defines the date until the cache is considered to be valid)<br />
</li>
<li><i>MemorySizeLimit</i> (imposes a memory size limit of the cache)</li>
<li><i>ObjectsNumberLimit</i> (imposes a objects number limit on the cache)</li>
<li><i>UseStorage</i> (defines if the cache should be persisted on disk)</li>
<li><i>RetrieveFromStorage</i> (defines if a specific value should be searched on the persisted cache on disk)</li>
<li><i>RealtimePersistance</i> (defines if the cache will be persisted on disk in real time, once a new value has been added to it)</li>
<li><i>StorageName</i> (defines the file name of the posited cache on disk)</li>
</ul><br />
The class HDPCacheObject is just a value pair set of properties and a time stamp field used to identify the cached object age. The caching system works in a very clear and simple manner. When a web resource is queried the URL of it represents the cache object key and the result of the query represents the cache object value. If the cache is activated when using HDPCommand object to query web resources each query URL and response content are stored in the memory cache. If same web resource is queried again using same URL the HTTP request is not performed and response content is retrieved from the memory cache. There are extra options defined in HDPCacheDefinition which allow you to control how the cache behaves. For example if you impose a cache memory limit of 1024Kb then every time a new value is added to the cache its memory footprint is calculated. In case the imposed limit is exceeded, based on other behavior definitions the cache content is either stored on disk or either deleted. I would like to mention that MemorySizeLimit and ObjectsNumberLimit are mutual exclusive. So if you define a value for the MemorySizeLimit greater than 0 then there is no point to define a value for ObjectsNumberLimit because it will not be taken into consideration and vice versa.<br />
<br />
</br><br />
</br><br />
<b>HDPCacheDefinition Code</b><br />
<pre lang="CS">using System;
namespace HttpData.Client
{
///<summary>
/// Defines the cache options.
///</summary>
public class HDPCacheDefinition
{
#region Public Variables
/// <summary>
/// Specifies the date until which the cache is valid.
/// </summary>
public DateTime StorageActiveUntil = DateTime.Now.AddDays(1);
/// <summary>
/// Specifies the limit size of the cache memory.
/// </summary>
public long MemorySizeLimit;
/// <summary>
/// Specifies the limit number of objects which can be stored in the cache.
/// </summary>
public int ObjectsNumberLimit = 10000;
/// <summary>
/// Specifies if disk storage will be used.
/// </summary>
public bool UseStorage = true;
///<summary>
/// Specifies if the data should be retrieved from the disk storage.
///</summary>
public bool RetrieveFromStorage;
/// <summary>
/// Specifies if the persistance of the cache on disk will be done in real time.
/// </summary>
public bool RealtimePersistance;
/// <summary>
/// Specifies the name of the file of the disk storage.
/// </summary>
public string StorageName = "HttpDataProcessorCahe.che";
#endregion
}
}
</pre><br />
</br><br />
</br><br />
<b>HDPCacheObject Code</b><br />
<pre lang="CS">using System;
namespace HttpData.Client
{
/// <summary>
/// Container for the cached data based on key value pair.
/// </summary>
[Serializable]
public class HDPCacheObject
{
#region Private Variables
private string key;
private object value;
private DateTime cacheDate;
#endregion
#region Properties
/// <summary>
/// Get or set the cache object key.
/// </summary>
public string Key
{
get { return key; }
set { key = value; }
}
/// <summary>
/// Get or set the cache object value.
/// </summary>
public object Value
{
get { return value; }
set { this.value = value; }
}
/// <summary>
/// Get or set the cache object date.
/// </summary>
public DateTime CacheDate
{
get { return cacheDate; }
}
#endregion
#region .ctor
/// <summary>
/// Instantiate a new HDPCacheObject object.
/// </summary>
public HDPCacheObject()
{
cacheDate = DateTime.Now;
}
/// <summary>
/// Instantiate a new HDPCacheObject object.
/// </summary>
/// <param name="key">Key for the cache object</param>
/// <param name="value">Value for the cache object</param>
public HDPCacheObject(string key, object value)
{
this.key = key;
this.value = value;
cacheDate = DateTime.Now;
}
#endregion
#region Public Methods
#endregion
#region Private Methods
#endregion
}
}
</pre></p><br />
<h2>Using the code</h2><p>I will provide a couple of examples so you can figure it out how things work. I consider this to be the best way to understand how the earth spins.<br />
Let us say for example that we would like to retrieve all Florida cities from the following page: http://www.stateofflorida.com/Portal/DesktopDefault.aspx?tabid=34.<br />
Here is the code to achieve the above mentioned task.<br />
<br />
<pre lang="CS">using System;
using System.Collections.Generic;
using HttpData.Client;
namespace CityStates
{
class Program
{
static void Main(string[] args)
{
private const string connectionUrl = "http://www.stateofflorida.com/Portal/DesktopDefault.aspx?tabid=34";
//Create a new instance of HDPCacheDefinition object.
HDPCacheDefinition cacheDefinition = new HDPCacheDefinition
{
UseStorage = false,
StorageActiveUntil = DateTime.Now,
ObjectsNumberLimit = 10000,
RealtimePersistance = false,
RetrieveFromStorage = false,
//We will not use a disk storage
StorageName = null
};
//Create a new instance of HDPConnection object.
//Pass as parameters the initial connection URL and the cache definition object.
HDPConnection connection = new HDPConnection(connectionUrl, cacheDefinition)
{
//Define the content type we would expect.
ContentType = HDPContentType.TEXT,
//We want to allow autoredirects
AutoRedirect = true,
//Do not perform more than 10 autoredirects
MaxAutoRedirects = 10,
//The user agent is FireFox 3
UserAgent = HDPAgents.FIREFOX_3,
//We do not want to use a proxy
Proxy = null // If you want to use a proxy: Proxy = new HDPProxy("http://127.0.0.1:999/"/*This is your proxy address and its port*/, "PROXY_USER_NAME", "PROXY_PASSWORD")
};
//Open the connection
connection.Open();
//Create a new instance of HDPCommand object.
//Pass as parameter the HDPConnection object.
HDPCommand command = new HDPCommand(connection)
{
//Activate the memory cache for fast access on same web resource multiple times
ActivatePool = true,
//We will perform an GET action
CommandType = HDPCommandType.Get,
//Set the time out period
CommandTimeout = 60000,
//Use MSHTML library instead of HtmlAgilityPack (if the value is false then HtmlAgilityPack would be used)
UseMsHtml = true
};
//Execute the query on the web resource. The received HTTPWebResponse content will be converted to XML and the XPath expression will be executed.
//The method will return the list of Florida state cities.
List<string> cities = command.ExecuteCollection("//ul/li/b//text()[normalize-space()]", true);
foreach (string city in cities)
Console.WriteLine(city);
connection.Close();
}
}
}
</pre><br />
Here is a different example now. Let us say that we would like to login on Linkedin network using an account user name and password. Here is the code to achieve that.<br />
<br />
<pre lang="CS">using System;
using System.Collections.Generic;
using HttpData.Client;
namespace CityStates
{
class Program
{
static void Main(string[] args)
{
private const string connectionUrl = "https://www.linkedin.com/secure/login?trk=hb_signin";
//Create a new instance of HDPCacheDefinition object.
HDPCacheDefinition cacheDefinition = new HDPCacheDefinition
{
UseStorage = false,
StorageActiveUntil = DateTime.Now,
ObjectsNumberLimit = 10000,
RealtimePersistance = false,
RetrieveFromStorage = false,
//We will not use a disk storage
StorageName = null
};
//Create a new instance of HDPConnection object.
//Pass as parameters the initial connection URL and the cache definition object.
HDPConnection connection = new HDPConnection(connectionUrl, cacheDefinition)
{
//Define the content type we would expect.
ContentType = HDPContentType.TEXT,
//We want to allow autoredirects
AutoRedirect = true,
//Do not perform more than 10 autoredirects
MaxAutoRedirects = 10,
//The user agent is FireFox 3
UserAgent = HDPAgents.FIREFOX_3,
//We do not want to use a proxy
Proxy = null // If you want to use a proxy: Proxy = new HDPProxy("http://127.0.0.1:999/"/*This is your proxy address and its port*/, "PROXY_USER_NAME", "PROXY_PASSWORD")
};
//Open the connection
connection.Open();
//Create a new instance of HDPCommand object.
//Pass as parameter the HDPConnection object.
HDPCommand command = new HDPCommand(connection)
{
//Activate the memory cache for fast access on same web resource multiple times
ActivatePool = true,
//We will perform an GET action
CommandType = HDPCommandType.Get,
//Set the time out period
CommandTimeout = 60000,
//Use HtmlAgilityPack (if the value is true then MSHTML would be used)
UseMsHtml = false
};
//Define the query parameters used in the POST action.
//The actual parameter name used by a browser to authenticate you on Linkedin is without '@' sign.
//Use a HTTP request analyzer and you will notice the difference.
//This is how the actual POST body will look like: csrfToken="ajax:-3801133150663455891"&session_key="YOUR_EMAIL@gmail.com"&session_password="YOUR_PASSWORD"&session_login="Sign+In"&session_login=""&session_rikey=""
HDPParameterCollection parameters = new HDPParameterCollection();
HDPParameter pToken = new HDPParameter("@csrfToken", "ajax:-3801133150663455891");
HDPParameter pSessionKey = new HDPParameter("@session_key", "YOUR_EMAIL@gmail.com");
HDPParameter pSessionPass = new HDPParameter("@session_password", "YOUR_PASSWORD");
HDPParameter pSessionLogin = new HDPParameter("@session_login", "Sign+In");
HDPParameter pSessionLogin_ = new HDPParameter("@session_login", "");
HDPParameter pSessionRiKey = new HDPParameter("@session_rikey", "");
parameters.Add(pToken);
parameters.Add(pSessionKey);
parameters.Add(pSessionPass);
parameters.Add(pSessionLogin);
parameters.Add(pSessionLogin_);
parameters.Add(pSessionRiKey);
//If everything went ok then linkeding will ask us to redirect (unfortunately autoredirect doesn't work in this case).
//Get the manual redirect URL value.
string value = command.ExecuteValue("//a[@id='manual_redirect_link']/@href", true);
if (value != null && String.Compare(value, "http://www.linkedin.com/home") == 0)
{
command.Connection.ConnectionURL = value;
command.CommandType = HDPCommandType.Get;
//Using the manual redirect URL, check if the opened web page contains the welcome message.
//If it does contain the message, then we are in.
string content = command.ExecuteString("//title[contains(.,'Welcome,')]", true);
if (content.Length > 0)
Console.WriteLine(content);
else
Console.WriteLine("Login failed!");
}
connection.Close();
}
}
}
</pre></p><p>On your sample project please add the following app.config content if you are going to use MSHTML.<br />
<pre lang="CS"><code>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="LogFilePath" value="..\Log\My-Log.txt"/>
<add key="HtmlTagsPath" value="HtmlTags.txt"/>
<add key="AttributesTagsPath" value="HtmlAttributes.txt"/>
</appSettings>
</configuration>
</code>
</pre></p><br />
<h2>Downloads and Source Code</h2><p>You can download the source code of the library and a sample project from <a href="http://www.codeproject.com/KB/library/httpdataclient.aspx">here</a></p>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-64184296097228858322011-05-23T06:13:00.000-07:002011-05-23T06:14:12.241-07:00ASP.NET/IIS7 Custom HTTP HandlersIt's been a while since I had to write custom HTTP handlers. One of my current projects required resourses to be provided using a custom HTTP handler. That was quite an easy job and for sure you will find many detailed posts related to HTTP handlers development under .NET. The only thing which gave me some headaches was the deployment of such a handler. There is a different approach under IIS7 (integrated mode) compared with IIS6. Here are the required steps:<br />
<br />
1. From IIS management interface create a web application which points to the root folder where you have your HTTP handler. Please note that the actual DLL (assembly) should be located under root directory in a "bin" folder (e.g.: C:\MyHandlerRootFolder\bin\myhandler.dll). Please be sure that you are configuring your web application to run under the correct application pool. So if your HTTP handler assembly is compiled with .NET 4.0 be sure that the web application is configured to run under ASP.NET v4.0 application pool. My issue was caused by a missconfiguration of the HTTP handler. Due to this, everyt time when I was trying to access the handler I was getting the following exception: <strong>"Could not load type 'MyHandlerClass'"</strong><br />
<br />
2. In the web.config file which should be hosted in your web application root folder add (or change if it is the case) the following configuration elements:<br />
<br />
<pre><system.webServer>
<handlers>
<add verb="*" path="*.myextension"
name="MyHttpHandler"
type=" MyFullNamespace.MyHandlerClass, MyFullHttpHandlerAssemblyName"/>
</handlers>
</system.webServer>
</pre><br />
That's all, now you handler should be up and running.Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-33072188647978726742010-09-09T08:55:00.000-07:002010-09-09T08:56:13.291-07:00Get Table Structure DescriptionUse the following script to get the structure description of a specific table:<br />
<br />
<code><br />
SELECT<br />
clmns.name AS [Name],<br />
usrt.name AS [DataType],<br />
ISNULL(baset.name, N'') AS [SystemType],<br />
CAST(CASE WHEN baset.name IN (N'nchar', N'nvarchar') AND clmns.max_length <> -1 THEN clmns.max_length/2 ELSE clmns.max_length END AS int) AS [Length],<br />
CAST(clmns.precision AS int) AS [NumericPrecision]<br />
FROM sys.tables AS tbl<br />
INNER JOIN sys.all_columns AS clmns ON clmns.object_id = tbl.object_id<br />
LEFT OUTER JOIN sys.types AS usrt ON usrt.user_type_id = clmns.user_type_id<br />
LEFT OUTER JOIN sys.types AS baset ON baset.user_type_id = clmns.system_type_id and <br />
baset.user_type_id = baset.system_type_id<br />
WHERE tbl.name='YOURTABLENAME' and SCHEMA_NAME(tbl.schema_id)=N'dbo'<br />
ORDER BY clmns.column_id ASC<br />
</code><br />
<br />
The source of the script is: <a href="http://www.geekzilla.co.uk/ViewF3E9658C-7B7A-472C-BE4A-5C25CD26C0E8.htm">www.geekzilla.co.uk</a>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com1tag:blogger.com,1999:blog-6146753014571848686.post-61213126017065497562010-07-09T00:35:00.000-07:002010-07-09T00:40:05.127-07:00Monster Website and XSS<span style="color: red;"><b>Note:</b><span style="font-family: times new roman;">All websites owners where informed more than a week ago about the vulnerabilities I have "accidentally" found.<br />
The purpose of this information is educational only!</span></span><br />
<span style="color: black;"></span><br />
<br />
<br />
In the last week I was playing with some websites trying to find out if they are exposed to any XSS attacks.<br />
Among those websites was also <a href="http://www.monster.com/">www.monster.com</a>. I know that in the past years Monster had big issues regarding security. They were hacked three times and a huge amount of data was stolen back then. Well...what I have discovered is that they still have vulnerabilities, specially XSS ones. Their filtering system has flaws, considering that it will remove with success <b><script>, <object>, <iframe></b> tags but it fails on removing <b><img>, <html>, <body></b> and <b><?import></b>.<br />
Based on the above mentioned things I created a "Job Seeker" account with a fake CV and in the content of that CV I have inserted the following script:<br />
<br />
<pre><HTML><BODY><?xml:namespace prefix='t' ns='urn:schemas-microsoft-com:time'><?import namespace='t' implementation='#default#time2'><t:set attributeName='innerHTML' to='XSS&lt;script DEFER&gt;(function(){alert("Here you can do very nasty things!")})()&lt;/script&gt;'></BODY></HTML>
</pre><br />
When I previewed the CV...voila, the alert dialog appeared. In this way I was able to hijack the user session by making use of cookies and extract any information I wanted. The most interesting thing is that in this way some one can hijack the session of any "Employer" which is going to take a look at the CV and with custom "POST" and "GET" commands, infest the job posts of the "Employer" with similar malicious code. In this way a real web could be created starting just from one malicious CV.<br />
<br />
There are also issues on Monster website in the section which allows you to upload your CV. You have the option to upload text files and Microsoft Word documents. In a text file I have inserted and <b><img></b> tag with an <b>'onload'</b> event. When the content was rendered on the page and the invisible image was loaded and the 'onload' event was triggered I was able to execute any JavaScript code.Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com1tag:blogger.com,1999:blog-6146753014571848686.post-82873777876234228672009-12-17T10:55:00.000-08:002009-12-17T10:57:13.071-08:00IIS - The worker process failed to preload .Net Runtime versionWhen I moved to windows 7 (clean install) I have done a mistake regarding the order in which I have set up the development environment. First, by mistake, I have installed Visual Studio 2008, .NET framework 3.5 and at the end .NET framework 2.0.*. This caused a big issue on IIS 7. Every virtual directory or application created on IIS caused an error on the application pool. I have tried different application pools but got same error: <b>“The worker process failed to preload .Net Runtime version v2.0.40607”</b> and <b>“The worker process failed to initialize correctly and therefore could not be started. The data is the error.”</b>. After some searched over the internet I have found a solution <a href="http://forums.iis.net/t/1053655.aspx">HERE</a>. The fix consists in removing from Windows\Microsoft.Net\Framework of any folder like v2.0.* which is different than v2.0.50727.Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-28181250079445612082009-12-14T01:41:00.000-08:002010-11-17T23:32:29.041-08:00JavaScript ArrayList, JavaScript Dictionay, JavaScript Strong Type ArrayI always felt the need to have in JavaScript a more robust set of collections, like those from .NET: ArrayList, Dictionary, strong typed collections. So, some time ago I have decided to implement them everything having as base the JavaScript array object. The code I assume is self explanatory except the class definition which makes use of the custom pattern presented earlier on this blog. It shouldn’t matter too much because it’s very easy for you to implement same functionality using any desired inheritance pattern, like Base2 and Prototype. I think it’s a matter of copy/paste in most cases. You will notice that I didn’t use any special tricks in the code, just the well known JavaScript array object methods and properties. I did not use closures in this case so the ‘_array ‘ property it is consider private base on ‘_’ notation. Using closures eats up more resources so I preferred to avoid them in his case. If you have any questions feel free to post them and I’ll try to give you an answer as fast as possible. You can download the source from <a href="http://38.107.67.35/jsmugen.zip">HERE</a>.<br />
<br />
<pre>if (typeof (MG) == 'undefined')
throw ("MG.Core.js is required!");
if (typeof (MG.Collections) == 'undefined')
MG.Collections = {};
MG.Collections.IComparer = function() {
throw ("IComparer is an interface. Interfaces can't be instantiated directly!");
};
MG.Collections.IComparer.prototype = {
Compare: function(object1, object2) { }
}
/******************************************************************************/
// IList interface definition.
/******************************************************************************/
MG.Collections.IList = function() {
throw ("IList is an interface. Interfaces can't be instantiated directly!");
};
MG.Collections.IList.prototype = {
___name: "IList",
Add: function(object) { },
Clear: function() { },
Contains: function(object) { },
Remove: function(object) { },
IsReadOnly: Boolean,
Item: function(index) { }
};
/******************************************************************************/
// ICollection interface definition.
/******************************************************************************/
MG.Collections.ICollection = function() {
throw ("ICollection is an interface. Interfaces can't be instantiated directly!");
};
MG.Collections.ICollection.prototype = {
___name: "ICollection",
CopyTo: function(array, arrayIndex) { },
Count: function() { }
};
/******************************************************************************/
// IDictionary interface definition.
/******************************************************************************/
MG.Collections.IDictionary = function() {
throw ("IDictionary is an interface. Interfaces can't be instantiated directly!");
};
MG.Collections.IDictionary.prototype = {
___name: "IDictionary",
Add: function(key, value) { },
Clear: function() { },
Contains: function(key) { },
Remove: function(key) { },
IsReadOnly: Boolean,
Item: function(key) { }
}
/******************************************************************************/
// ArrayList class definition.
// Implements interfaces: ICollection
/******************************************************************************/
MG.Collections.ArrayList = MG.Class.Create(
{
_array: null,
IsReadOnly: Boolean,
constructor: function() {
this._array = [];
this.IsReadOnly = false;
},
Add: function(object) {
if (!this.IsReadOnly)
this._array.push(object);
else
throw ("ArrayList is read only! Check IsReadOnly value.");
},
Clear: function() {
if (!this.IsReadOnly)
this._array = [];
else
throw ("ArrayList is read only! Check IsReadOnly value.");
},
Contains: function(object) {
for (var index = 0; index < this._array.length; index++) {
if (this._array[index] == object)
return true;
}
return false;
},
CopyTo: function(array, arrayIndex) {
if (!array)
throw ("Destination array is null!");
if (arrayIndex < 0 || arrayIndex > array.length)
throw ("Index of destination array out of bound! Index value is: " + arrayIndex);
for (var i = this._array.length - 1; i >= 0; i--)
array.splice(arrayIndex, 0, this._array[i]);
},
Remove: function(object) {
if (!this.IsReadOnly) {
for (var index = 0; index < this._array.length; index++) {
if (this._array[index] == object)
this._array.splice(index, 1);
}
}
else
throw ("ArrayList is read only! Check IsReadOnly value.");
},
Count: function() {
return this._array.length;
},
Item: function(index) {
if (index < 0 || index >= this._array.length)
throw ("Index out of bound! Index value is: " + index);
return this._array[index];
},
IndexOf: function(object) {
for (var index = 0; index < this._array.length; index++) {
if (this._array[index] == object)
return index;
}
return -1;
},
LastIndexOf: function(object) {
var lastIndex = -1;
for (var index = 0; index < this._array.length; index++) {
if (this._array[index] == object)
lastIndex = index;
}
return lastIndex;
},
RemoveAt: function(index) {
if (!this.IsReadOnly) {
if (index < 0 || index >= this._array.length)
throw ("Index out of bound! Index value is: " + index);
this._array.splice(index, 1);
}
else
throw ("ArrayList is read only! Check IsReadOnly value.");
},
RemoveRange: function(index, Count) {
if (!this.IsReadOnly) {
if (index < 0 || index >= this._array.length)
throw ("Index out of bound! Index value is: " + index);
if (Count < 0 || (Count + index) > this._array.length)
throw ("Range out of bound! Range value is: " + Count);
this._array.splice(index, Count);
}
else
throw ("ArrayList is read only! Check IsReadOnly value.");
},
InsertAt: function(index, object) {
if (!this.IsReadOnly) {
if (index < 0 || index >= this._array.length)
throw ("Index out of bound! Index value is: " + index);
this._array.splice(index, 0, object);
}
else
throw ("ArrayList is read only! Check IsReadOnly value.");
},
InsertRange: function(index, _ICollection) {
if (!this.IsReadOnly) {
if (index < 0 || index >= this._array.length)
throw ("Index out of bound! Index value is: " + index);
var _newarray = _ICollection.GetRange(0, _ICollection.Count());
for (var i = 0; i < _newarray.length; i++)
this.InsertAt(index, _newarray[i]);
}
else
throw ("ArrayList is read only! Check IsReadOnly value.");
},
GetRange: function(index, Count) {
if (index < 0 || index >= this._array.length)
throw ("Index out of bound! Index value is: " + index);
if (Count < 0 || (Count + index) > this._array.length)
throw ("Range out of bound! Range value is: " + Count);
var arrayList = new ArrayList();
arrayList._array = this._array.slice(index, (Count + index));
return arrayList;
},
Reverse: function() {
if (!this.IsReadOnly)
this._array.reverse();
else
throw ("ArrayList is read only! Check IsReadOnly value.");
},
Sort: function() {
this._array.sort();
}
}, null, [MG.Collections.ICollection]);
/******************************************************************************/
// DictionaryEntry class definition.
/******************************************************************************/
MG.Collections.DictionaryEntry = MG.Class.Create(
{
key: null,
value: null,
constructor: function(key, value) {
this.key = key;
this.value = value;
}
});
/******************************************************************************/
// Dictionary class definition.
// Implements interfaces: IDictionary
// ICollection
/******************************************************************************/
MG.Collections.Dictionary = MG.Class.Create(
{
_dictionary: null,
IsReadOnly: Boolean,
constructor: function() {
this._dictionary = [];
this.IsReadOnly = false;
},
Add: function(key, value) {
if (!this.IsReadOnly) {
if (this.Contains(key))
throw ("Dictionary does not allow duplicate keys!");
var dicEntry = new MG.Collections.DictionaryEntry(key, value);
this._dictionary.push(dicEntry);
}
else
throw ("Dictionary is read only! Check IsReadOnly value.");
},
Clear: function() {
if (!this.IsReadOnly)
this._dictionary = [];
else
throw ("Dictionary is read only! Check IsReadOnly value.");
},
Contains: function(key) {
for (var index = 0; index < this._dictionary.length; index++) {
if (this._dictionary[index].key == key)
return true;
}
return false;
},
Remove: function(key) {
if (!this.IsReadOnly) {
for (var index = 0; index < this._dictionary.length; index++) {
if (this._dictionary[index].key == key)
this._dictionary.splice(index, 1);
}
}
else
throw ("Dictionary is read only! Check IsReadOnly value.");
},
Item: function(key) {
if (!key)
throw ("Invalid key! Key value is: " + key);
for (var index = 0; index < this._dictionary.length; index++) {
if (this._dictionary[index].key == key)
return this._dictionary[index].value;
}
return null;
},
CopyTo: function(array, arrayIndex) {
if (!array)
throw ("Destination array is null!");
if (arrayIndex < 0 || arrayIndex > array.length)
throw ("Index of destination array out of bound! Index value is: " + arrayIndex);
for (var i = this._dictionary.length - 1; i >= 0; i--)
array.splice(arrayIndex, 0, this._dictionary[i]);
},
Count: function() {
return this._dictionary.length;
},
Keys: function() {
var keys = [];
for (var index = 0; index < this._dictionary.length; index++)
keys.push(this._dictionary[index].key);
return keys.reverse();
},
Values: function() {
var values = [];
for (var index = 0; index < this._dictionary.length; index++)
values.push(this._dictionary[index].value);
return values.reverse();
},
IndexOf: function(key) {
var keys = [];
for (var index = 0; index < this._dictionary.length; index++) {
if (this._dictionary[index].key == key)
return index;
}
},
InsertAt: function(index, key, value) {
if (!this.IsReadOnly) {
if (index < 0 || index >= this._dictionary.length)
throw ("Index out of bound! Index value is: " + index);
var dicEntry = new MG.Collections.DictionaryEntry(key, value);
this._dictionary.splice(index, 0, dicEntry);
}
else
throw ("Dictionary is read only! Check IsReadOnly value.");
},
Reverse: function() {
if (!this.IsReadOnly)
this._dictionary.reverse();
else
throw ("Dictionary is read only! Check IsReadOnly value.");
}
}, null, [MG.Collections.IDictionary, MG.Collections.ICollection]);
/******************************************************************************/
// Comparer class definition.
// Implements interfaces: IComparer
/******************************************************************************/
MG.Collections.Comparer = MG.Class.Create({
constructor: function() { },
Compare: function(object1, object2) {
var result = false;
var type = typeof object1;
if (type !== typeof object2)
throw ("Object 'object1' doesn't have same type as object 'object2'!");
else if (type === "object") {
switch (object1.constructor) {
case Array:
{
if (object1.length === object2.length) {
for (var index = 0; index < object1.length; index++) {
result = this.Compare(object1[index], object2[index]);
if (!result)
break;
}
}
}
break;
case Dictionary:
{
if (object1.Count() === object2.Count()) {
var keys = object1.Keys();
for (var index = 0; index < keys.length; index++) {
if (object2.Contains(keys[index])) {
result = this.Compare(object1.Item(keys[index]),
object2.Item(keys[index]));
if (!result)
break;
}
else {
result = false;
break;
}
}
}
}
break;
case ArrayList:
{
if (object1.Count() === object2.Count()) {
for (var index = 0; index < object1.Count(); index++) {
result = this.Compare(object1.Item(index), object2.Item(index));
if (!result)
break;
}
}
}
break;
default:
{
if (object1 === object2)
result = true;
}
break;
}
}
switch (type) {
case "string":
case "number":
case "boolean":
if (object1 === object2)
result = true;
break;
}
return result;
}
}, null, [MG.Collections.IComparer]);
MG.Collections.TypedCollection = MG.Class.Create({
Type: null,
Browser: null,
constructor: function(type) {
var _type = typeof type;
if (_type && _type === "function")
this.Type = type;
else
throw ("The 'type' parameter must be a function object.");
this.Browser = MG.Browser.getInstance();
},
Add: function() {
var key = null;
var value = null;
if (arguments.length == 2) {
key = arguments[0];
value = arguments[1];
}
else if (arguments.length == 1)
value = arguments[0];
else
throw ("Invalid number of parameters. Number of parameters expected is two or one.");
if (this.Browser.NS) {
if (value.constructor !== this.Type.constructor)
throw ("The 'value' parameter doesn't have same type as this collection.");
}
else if (this.Browser.IE) {
if (value.constructor !== this.Type)
throw ("The 'value' parameter doesn't have same type as this collection.");
}
if (!this.IsReadOnly) {
if (key) {
var dicEntry = new MG.Collections.DictionaryEntry(key, value);
this._dictionary.push(dicEntry);
}
else {
var dicEntry = new MG.Collections.DictionaryEntry("key", value);
this._dictionary.push(dicEntry);
}
}
else
throw ("Dictionary is read only! Check IsReadOnly value.");
},
Item: function() {
if (!arguments.length == 1)
throw ("Invalid number of parameters. Number of parameters expected is two or one.");
var arg = arguments[0];
var type = typeof arg;
var value = null;
if (type == "string")
value = this.___Item(arg);
else if (type == "number") {
if (this._dictionary.length > arg)
value = this._dictionary[arg].value;
else
throw ("Index is out of range.");
}
return value;
}
}, MG.Collections.Dictionary, null);
</pre>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com5tag:blogger.com,1999:blog-6146753014571848686.post-25480722940181869752009-12-13T09:51:00.000-08:002010-11-17T23:32:46.016-08:00JavaScript XML Document and XPathHere is a small library/wrapper for JavaScript XML. Some parts of it belong to other authors like the Opera serialization and the loading of the XML document from a string. I had to do a lot of work on the part related to namespaces, especially on Opera. At this time, the library doesn’t work under Chrome if the XML document makes use of namespaces. So you will not be able to create XPath expression for namespace-d XML documents under Chrome browser. You will notice that the library exposes two layers, first of them is an abstraction of the native DOM and of all its functionality and the second one is the native DOM its self. I have used this library for different XML related tasks; the most important one in my case is the SOAP library and the .NET DataSet serialization to JavaScript data objects. I’m too lazy to explain it in details, but if you have questions feel free to ask them and I’ll give you an answer as fast as possible. You can download the source from <a href="http://38.107.67.35/jsmugen.zip">HERE</a><br />
<br />
<pre>if (typeof (MG) == 'undefined')
throw ("MG.Core.js is required!");
if(typeof(MG.Collections) === 'undefined')
throw ("MG.Collections.js is required!");
if (typeof (MG.Xml) == 'undefined')
MG.Xml = {};
MG.Xml.XmlDocument = function(rootTagName, namespaceURL)
{
if(document.implementation && document.implementation.createDocument)
{
Document.prototype.loadXML = function(strXML)
{
var domParser = new DOMParser();
var xmlDoc = domParser.parseFromString(strXML, "text/xml");
while(this.hasChildNodes())
this.removeChild(this.lastChild);
for(var index = 0; index < xmlDoc.childNodes.length; index++)
{
var impNode = this.importNode(xmlDoc.childNodes[index], true);
this.appendChild(impNode);
}
var nsResolvers = new MG.Collections.Dictionary();
if(xmlDoc.childNodes.length > 0)
{
nsResolvers = fixNS(strXML);
}
function fixNS(xml)
{
var regEx = /<[a-z\dA-Z\d]+:/g;
var results = xml.match(regEx);
var prefixes = new MG.Collections.ArrayList();
var resolvedPrefixes = new MG.Collections.ArrayList();
var unresolvedPrefixes = new MG.Collections.ArrayList();
var count = results !== null ? results.length : 0;
for(var index = 0; index < count; index++)
{
var matchValue = results[index];
var value = matchValue.slice(1, matchValue.length - 1);
if(prefixes.IndexOf(value) < 0)
prefixes.Add(value);
}
regEx = /:[a-zA-Z]+=|[a-zA-Z]+=/g;
results = xml.match(regEx);
count = results !== null ? results.length : 0;
var prefixesCount = prefixes.Count();
for(var index = 0; index < prefixesCount; index++)
{
var resolved = false;
var prefix = prefixes.Item(index);
for(var j = 0; j < count; j++)
{
var attribute = results[j];
var value= null;
if(attribute.indexOf(":") === 0)
value = attribute.slice(1, attribute.length - 1);
else
value = attribute.slice(0, attribute.length - 1);
if(prefix === value)
{
if(resolvedPrefixes.IndexOf(value) < 0)
resolvedPrefixes.Add(prefixes.Item(index));
resolved = true;
}
else
{
if(resolvedPrefixes.IndexOf(value) < 0)
resolvedPrefixes.Add(value);
}
}
if(!resolved)
unresolvedPrefixes.Add(prefixes.Item(index));
}
var uniqueNamespaces = new MG.Collections.Dictionary();
var exPrefixesCount = resolvedPrefixes.Count();
for(var index = 0; index < exPrefixesCount; index++)
{
var prefix = resolvedPrefixes.Item(index);
var regexS = "\\b" + prefix + "=\s*\".*?\"";
var regex = new RegExp(regexS);
var results = regex.exec(xml);
if(results !== null && results.length > 0)
{
var prefixValues = new MG.Collections.ArrayList();
for(var j = 0; j < results.length; j++)
{
var value = results[j].substring(prefix.length + 2, results[j].length - 1);
prefixValues.Add(value);
}
uniqueNamespaces.Add(prefix, prefixValues);
}
}
return uniqueNamespaces;
}
function createNSResolvers(node)
{
var childNodes = node.childNodes;
for(var index = 0; index < childNodes.length; index++)
{
var prefix = childNodes[index].prefix;
var nsURI = childNodes[index].namespaceURI;
if(prefix && nsURI)
{
if(!nsResolvers.Item(prefix))
nsResolvers.Add(prefix, nsURI);
}
createNSResolvers(childNodes[index]);
}
}
this.nsResolvers = nsResolvers;
}
function __getXml()
{
var xmlSerializer = new XMLSerializer();
var xml = xmlSerializer.serializeToString(this);
return xml;
}
if(Node.prototype.__defineGetter__)
Node.prototype.__defineGetter__("xml", __getXml);
return new MG.Xml.XmlNode(document.implementation.createDocument(namespaceURL, rootTagName, null));
}
else
{
var doc = new ActiveXObject("MSXML2.DOMDocument");
if(rootTagName)
{
var prefix = "";
var tagName = rootTagName;
var pos = rootTagName.indexOf(":");
if(pos != -1)
{
rootTagName = rootTagName.substring(0, pos);
tagName = rootTagName.substring(pos + 1);
}
if (namespaceURL)
{
if (!prefix)
prefix = "a0";
}
else
prefix = "";
var text = "<" + (prefix?(prefix+":"):"") + tagName +
(namespaceURL?(" xmlns:" + prefix + '="' + namespaceURL +'"'):"") + "/>";
doc.loadXML(text);
}
return new MG.Xml.XmlNode(doc);
}
};
MG.Xml.XmlNode = function(nativeNode)
{
if(nativeNode)
{
this.NativeNode = nativeNode;
this.NativeAttributes = nativeNode.attributes;
this.NativeChildNodes = nativeNode.childNodes;
}
};
MG.Xml.XmlNode.prototype.mdcXPath = function(node, xpathExpression, queryType)
{
var xpe = new XPathEvaluator();
var nsResolver = function(prefix)
{
var nsResolvers = node.nsResolvers;
if(!nsResolvers)
nsResolvers = node.ownerDocument.nsResolvers;
var item = nsResolvers.Item(prefix);
if(item)
{
if (item.Count() > 0)
{
return item.Item(0);
}
}
else
return xpe.createNSResolver(node.ownerDocument == null ? node.documentElement : node.ownerDocument.documentElement);
};
var result = xpe.evaluate(xpathExpression, node, nsResolver, queryType, null);
return result;
};
MG.Xml.XmlNode.prototype.fixNameSpaces = function(node, nsResolvers, xml)
{
if(nsResolvers)
{
if(node.prefix)
{
var nsResolver = nsResolvers.Item(node.prefix);
if(nsResolver)
{
xml += " " + "xmlns:" + node.prefix + "=\"" + nsResolver + "\"";
nsResolvers.Remove(node.prefix);
}
}
for(var index = 0; index < node.childNodes.length; index++)
xml = this.fixNameSpaces(node.childNodes[index], nsResolvers, xml);
}
return xml;
}
</pre>
<pre>MG.Xml.XmlNode.prototype.operaSerialize = function(nativeNode)
{
var xml = null;
switch(nativeNode.nodeType)
{
case 1:
{
if(this.Name() === nativeNode.nodeName)
xml = "<" + nativeNode.localName;
else
xml = "<" + nativeNode.tagName;
var nsResolvers = null;
var xmlnsAdded = false;
for (var i = 0; i < nativeNode.attributes.length; i++)
{
var localName = nativeNode.attributes[i].localName;
var name = nativeNode.attributes[i].name;
var value = nativeNode.attributes[i].value;
if(this.Name() === nativeNode.nodeName)
{
if(nativeNode.ownerDocument)
{
nsResolvers = nativeNode.ownerDocument.nsResolvers;
if(nsResolvers && nativeNode.ownerDocument.nsResolvers.Contains(localName))
nsResolvers.Remove(localName);
}
else
{
nsResolvers = nativeNode.nsResolvers;
if(nsResolvers && nsResolvers.Contains(name))
nsResolvers.Remove(name);
}
}
if(name === "xmlns")
xmlnsAdded = true;
xml += " " + name + "=\"" + value + "\"";
}
if(this.Name() === nativeNode.nodeName)
{
if(!nsResolvers)
{
if(nativeNode.ownerDocument)
nsResolvers = nativeNode.ownerDocument.nsResolvers;
else
nsResolvers = nativeNode.nsResolvers;
}
if(nsResolvers)
{
var item = nsResolvers.Item("xmlns");
if(item)
xml += " " + "xmlns" + "=\"" + item + "\"";
else if(!xmlnsAdded)
xml += " " + "xmlns" + "=\"" + "http://tempuri.org/" + "\"";
xml = this.fixNameSpaces(nativeNode, nsResolvers, xml);
}
}
xml += ">";
for (var i = 0; i < nativeNode.childNodes.length; i++)
xml += this.operaSerialize(nativeNode.childNodes[i]);
if(this.Name() === nativeNode.nodeName)
xml += "</" + nativeNode.localName + ">";
else
xml += "</" + nativeNode.tagName + ">";
}
break;
case 3:
xml = nativeNode.nodeValue;
break;
case 4:
xml = "<![CDATA[" + nativeNode.nodeValue + "]]>";
break;
case 7:
xml = "<?" + nativeNode.nodevalue + "?>";
break;
case 8:
xml = "<!--" + nativeNode.nodevalue + "-->";
break;
case 9:
{
for (var i = 0; i < nativeNode.childNodes.length; i++)
xml += this.operaSerialize(nativeNode.childNodes[i]);
}
break;
}
return xml;
};
</pre><pre>MG.Xml.XmlNode.prototype.ChildNodes = function(index)
{
if(this.NativeChildNodes)
{
if(arguments.length === 0)
return new MG.Xml.XmlNodes(this.NativeChildNodes);
else
{
var nativeNode = this.NativeChildNodes[index];
return (new MG.Xml.XmlNode(nativeNode));
}
}
return null;
};
MG.Xml.XmlNode.prototype.NextSibling = function()
{
if(this.NativeNode)
return new MG.Xml.XmlNode(this.NativeNode.nextSibling);
return null;
};
MG.Xml.XmlNode.prototype.FirstChild = function()
{
if(this.NativeNode)
return new MG.Xml.XmlNode(this.NativeNode.firstChild);
return null;
};
MG.Xml.XmlNode.prototype.Name = function()
{
if(this.NativeNode)
{
var browser = MG.Browser.getInstance();
if(browser.NS || browser.OPERA)
return this.NativeNode.nodeName;
else if(browser.IE)
return this.NativeNode.nodeName;
}
return null;
};
MG.Xml.XmlNode.prototype.LocalName = function()
{
if(this.NativeNode)
{
var browser = MG.Browser.getInstance();
if(browser.NS || browser.OPERA)
return this.NativeNode.localName;
else if(browser.IE)
return this.NativeNode.baseName;
}
return null;
};
MG.Xml.XmlNode.prototype.Text = function()
{
if(this.NativeNode)
{
var browser = MG.Browser.getInstance();
if(arguments.length === 1)
{
if(browser.NS || browser.OPERA)
return this.NativeNode.textContent = arguments[0];
else if(browser.IE)
return this.NativeNode.text = arguments[0];
}
else if(arguments.length === 0)
{
if(browser.NS || browser.OPERA)
return this.NativeNode.textContent;
else if(browser.IE)
return this.NativeNode.text;
}
else
throw("Only one parameter is expected.");
}
return null;
};
MG.Xml.XmlNode.prototype.Value = function()
{
if(this.NativeNode)
{
if(arguments.length === 1)
this.NativeNode.nodeValue = arguments[0];
else if(arguments.length === 0)
return this.NativeNode.nodeValue;
else
throw("Only one parameter is expected.");
}
};
MG.Xml.XmlNode.prototype.Xml = function()
{
if(this.NativeNode)
{
var browser = MG.Browser.getInstance();
if(browser.NS || browser.IE)
return this.NativeNode.xml;
else if(browser.OPERA)
return this.NativeNode.xml;
}
return null;
};
MG.Xml.XmlNode.prototype.SelectSingleNode = function(xpathExpression)
{
if(this.NativeNode)
{
var nativeNode = null;
var browser = MG.Browser.getInstance();
if(browser.NS || browser.OPERA)
{
var result = this.mdcXPath(this.NativeNode, xpathExpression, XPathResult.FIRST_ORDERED_NODE_TYPE);
nativeNode = result ? result.singleNodeValue : null;
}
else if(browser.IE)
nativeNode = this.NativeNode.selectSingleNode(xpathExpression);
if(nativeNode)
return new MG.Xml.XmlNode(nativeNode);
}
return null;
};
MG.Xml.XmlNode.prototype.SelectNodes = function(xpathExpression)
{
if(this.NativeNode)
{
var nativeNodes = null;
var browser = MG.Browser.getInstance();
if(browser.NS || browser.OPERA)
{
var result = this.mdcXPath(this.NativeNode, xpathExpression, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
if(result)
{
var pseudoNodes = new MG.Collections.ArrayList();
for(var index = 0; index < result.snapshotLength; index++)
pseudoNodes.Add(new MG.Xml.XmlNode(result.snapshotItem(index)));
nativeNodes = pseudoNodes;
}
}
else if(browser.IE)
nativeNodes = this.NativeNode.selectNodes(xpathExpression);
if(nativeNodes)
return new MG.Xml.XmlNodes(nativeNodes);
}
return null;
};
MG.Xml.XmlNode.prototype.CreateNode = function(type, name, namespaceURI)
{
if(this.NativeNode)
{
var nativeNode = this.NativeNode.createNode(type, name, namespaceURI);
if(nativeNode)
return new MG.Xml.XmlNode(nativeNode);
}
return null;
};
MG.Xml.XmlNode.prototype.AppendChild = function(node)
{
if(this.NativeNode)
this.NativeNode.appendChild(node.NativeNode);
};
MG.Xml.XmlNode.prototype.RemoveChild = function(node)
{
if(this.NativeNode)
this.NativeNode.removeChild(node.NativeNode);
};
MG.Xml.XmlNode.prototype.ReplaceChild = function(newNode, oldNode)
{
if(this.NativeNode)
this.NativeNode.replaceChild(newNode.NativeNode, oldNode.NativeNode);
};
MG.Xml.XmlNode.prototype.ParentNode = function()
{
if(this.NativeNode)
return new MG.Xml.XmlNode(this.NativeNode.parentNode);
return null;
};
MG.Xml.XmlNode.prototype.Prefix = function()
{
if(this.NativeNode)
return this.NativeNode.prefix;
return null;
};
MG.Xml.XmlNode.prototype.LoadXML = function(xmlString)
{
this.NativeNode.loadXML(xmlString);
};
MG.Xml.XmlNode.prototype.SetAttributeNode = function(attributeNode)
{
if(this.NativeNode)
this.NativeNode.setAttributeNode(attributeNode.NativeAttribute);
};
MG.Xml.XmlNode.prototype.SetAttribute = function(name, value)
{
if(this.NativeNode)
this.NativeNode.setAttribute(name, value);
};
MG.Xml.XmlNode.prototype.Attributes = function()
{
if(this.NativeAttributes)
return new MG.Xml.Attributes(this.NativeAttributes);
return null;
};
MG.Xml.Attributes = function(nativeAttributes)
{
this.NativeAttributes = nativeAttributes;
};
MG.Xml.Attributes.prototype.GetNamedItem = function(itemName)
{
if(this.NativeAttributes)
return new MG.Xml.Attribute(this.NativeAttributes.getNamedItem(itemName));
return null;
};
MG.Xml.Attributes.prototype.Item = function(index)
{
if(this.NativeAttributes)
return new MG.Xml.Attribute(this.NativeAttributes[index]);
return null;
};
MG.Xml.Attributes.prototype.Length = function()
{
if(this.NativeAttributes)
return this.NativeAttributes.length;
return null;
};
MG.Xml.Attribute = function(nativeAttribute)
{
this.NativeAttribute = nativeAttribute;
};
MG.Xml.Attribute.prototype.Value = function()
{
if(this.NativeAttribute)
return this.NativeAttribute.value;
};
MG.Xml.Attribute.prototype.Name = function()
{
if(this.NativeAttribute)
return this.NativeAttribute.name;
};
MG.Xml.XmlNodes = function(nativeNodes)
{
var isPseudo = false;
var browser = MG.Browser.getInstance();
if(browser.NS || browser.OPERA)
{
if(nativeNodes.constructor === MG.Collections.ArrayList.constructor)
isPseudo = true;
}
else if(browser.IE)
{
if(nativeNodes.constructor === MG.Collections.ArrayList)
isPseudo = true;
}
if(!isPseudo)
{
this.NativeNodes = new MG.Collections.ArrayList();
for(var index = 0; index < nativeNodes.length; index++)
this.NativeNodes.Add(new MG.Xml.XmlNode(nativeNodes[index]));
}
else
this.NativeNodes = nativeNodes;
};
MG.Xml.XmlNodes.prototype.Length = function()
{
if(this.NativeNodes)
{
var browser = MG.Browser.getInstance();
if(browser.NS || browser.OPERA)
{
if(this.NativeNodes.constructor === MG.Collections.ArrayList.constructor)
return this.NativeNodes.Count();
else
return this.NativeNodes.length;
}
else if(browser.IE)
{
if(this.NativeNodes.constructor === MG.Collections.ArrayList)
return this.NativeNodes.Count();
else
return this.NativeNodes.length;
}
}
return null;
};
MG.Xml.XmlNodes.prototype.Item = function(index)
{
if(this.NativeNodes)
return this.NativeNodes.Item(index);
return null;
};
</pre>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com2tag:blogger.com,1999:blog-6146753014571848686.post-8812956398823822642009-12-09T06:09:00.000-08:002009-12-09T06:09:27.775-08:00Google - Google ShitToday I tried to create a Gmail account for a friend of mine. I was stupefied when I saw that they require you to provide your phone number to confirm that you are not a spammer. This is crap, the capcha is more than enough to do the job. They are going to far this time.<br />
<br />
BWOOOOO!!Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-17342653552677441312009-12-09T01:56:00.000-08:002009-12-28T06:30:37.659-08:00JavaScript Mugen Library BenchmarkHere are the benchmark results from JSLitmus for JavaScript inheritance from Mugen library which I have presented in the previous posts compared with other existing JavaScript libraries.<br />
<br />
1. Results for IE7<br />
<br />
<div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiceKzC7-g2gzf69dWGKKk-Gl8hSXNb7u0uhIy9CowcEk3zq696QgnP_f1qEbqcMU9xVwxvKCxQNecfps3Yq8ar9KYrFxmexS2OEvSSNpNDiOJdWgTvSvlCiVLD7S7dlbR3eVu0-5cXeKo/s1600-h/chart-baseclass2.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiceKzC7-g2gzf69dWGKKk-Gl8hSXNb7u0uhIy9CowcEk3zq696QgnP_f1qEbqcMU9xVwxvKCxQNecfps3Yq8ar9KYrFxmexS2OEvSSNpNDiOJdWgTvSvlCiVLD7S7dlbR3eVu0-5cXeKo/s320/chart-baseclass2.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-Js_pQXZ1m_YUsSJqpp9Von-LVwO07YWE66YZEd2G6gs2FRdfIxCLm7oJijxiRhfk8-RHCYSCxDNYxt0SUu8IORdKHvXMgz_ahnU3YMwAp0DWcVJjXaiaVABaEJQg9tOXkNYehXfDxXQ/s1600-h/chart-ajaxsoft.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-Js_pQXZ1m_YUsSJqpp9Von-LVwO07YWE66YZEd2G6gs2FRdfIxCLm7oJijxiRhfk8-RHCYSCxDNYxt0SUu8IORdKHvXMgz_ahnU3YMwAp0DWcVJjXaiaVABaEJQg9tOXkNYehXfDxXQ/s320/chart-ajaxsoft.png" /></a><br />
</div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><br />
</div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXFiFYexv7FtiddOXlVI3NYd66fiuoTKsctK531oQD6YuYCta9sBxUK5F6mRTmzCpKY70QaFd3cPyWX2mzLhrKbGDx8UKDdUEhbeePNiGGU3nEyF01-Vj7uerd5C8Wydv5M_gdl895M3o/s1600-h/chart-dojo.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXFiFYexv7FtiddOXlVI3NYd66fiuoTKsctK531oQD6YuYCta9sBxUK5F6mRTmzCpKY70QaFd3cPyWX2mzLhrKbGDx8UKDdUEhbeePNiGGU3nEyF01-Vj7uerd5C8Wydv5M_gdl895M3o/s320/chart-dojo.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJpvNXUlgfSth1Rq-CUtmG2MR_K6AliSkASGmgMjEl5YKislc9VetFnCvHfbnPJs94aErrZL_sE2SqezJJCQMJDOMRV5IphtRRs_teJwvEqDVg8J3p1Q4riYLZRG4Gzh75HTa_GDBjOvo/s1600-h/chart-defineclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJpvNXUlgfSth1Rq-CUtmG2MR_K6AliSkASGmgMjEl5YKislc9VetFnCvHfbnPJs94aErrZL_sE2SqezJJCQMJDOMRV5IphtRRs_teJwvEqDVg8J3p1Q4riYLZRG4Gzh75HTa_GDBjOvo/s320/chart-defineclass.png" /></a><br />
</div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKkNtSxqTexL3iOjNpNto4pFUg3x4MwIYbFEeSfgvQ1QgMs4Ti0r8C3-xZ2aL-cmNrZCDu_i80vsInivZLDWnWEOSL7fBFHXz8JJ86SxJ6TWRlx54CvO-nKmlanHAs1ukJAfXS4Q7cNp8/s1600-h/chart-j3class2.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKkNtSxqTexL3iOjNpNto4pFUg3x4MwIYbFEeSfgvQ1QgMs4Ti0r8C3-xZ2aL-cmNrZCDu_i80vsInivZLDWnWEOSL7fBFHXz8JJ86SxJ6TWRlx54CvO-nKmlanHAs1ukJAfXS4Q7cNp8/s320/chart-j3class2.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwg4D44sXDWbpvR9DDej4dO0xSaww0G-ra48cL8sm-G9HjWqnD1rcdNihyphenhyphenUss4stjQbq3kUX5SoqfBctZ7LcezzmRi8QxAv9L2a6vOGbKSjuPSuKrTsg1Yi42OOTkjKIq8S8fDwILR9ZI/s1600-h/chart-j3class.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwg4D44sXDWbpvR9DDej4dO0xSaww0G-ra48cL8sm-G9HjWqnD1rcdNihyphenhyphenUss4stjQbq3kUX5SoqfBctZ7LcezzmRi8QxAv9L2a6vOGbKSjuPSuKrTsg1Yi42OOTkjKIq8S8fDwILR9ZI/s320/chart-j3class.png" /></a><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3lVl63I7kAzMA7yp62R6AJYwnRPGHP5moF9I3S9SMzmPJUsXTqPs8mw8k5pIDrcL1fhqjA1A1ht-huJpP6jam9zgisXAj6VRJmlxjOhtzjwkq7yDBVnb2SheNZDlUAyiZnJjBjOMTpjQ/s1600-h/chart-mugen.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3lVl63I7kAzMA7yp62R6AJYwnRPGHP5moF9I3S9SMzmPJUsXTqPs8mw8k5pIDrcL1fhqjA1A1ht-huJpP6jam9zgisXAj6VRJmlxjOhtzjwkq7yDBVnb2SheNZDlUAyiZnJjBjOMTpjQ/s320/chart-mugen.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYOyw3IXVRuRfwwDeCzzHMcFsilwmJOeEAcW9sfBAzk2DZC7I0L-ZeXlbvOnDYAlhp9VsRq9S_31Q1PdFUwD4CJsnkA4YSke0AvWtmwiw-JXv-jHAjF3SXI1fw4ii-H0UVzS5qYPVWs1M/s1600-h/chart-prototype.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYOyw3IXVRuRfwwDeCzzHMcFsilwmJOeEAcW9sfBAzk2DZC7I0L-ZeXlbvOnDYAlhp9VsRq9S_31Q1PdFUwD4CJsnkA4YSke0AvWtmwiw-JXv-jHAjF3SXI1fw4ii-H0UVzS5qYPVWs1M/s320/chart-prototype.png" /></a><br />
</div><br />
2. Results for Mozilla<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhE53NNxRXF1vPN7zHDMsmrVk0HD-EowaRYaEj8DZyJ-xjvvlKK1pZiWlUp__oJ2gG9cN2DF_e6fee1KFrTYh5Zk4nUu9waYO5RTSSCgTBMtvmCaUW8alSx8c_LaFNHbpfa-Jg13GFjt7k/s1600-h/chart-ajaxsoftclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhE53NNxRXF1vPN7zHDMsmrVk0HD-EowaRYaEj8DZyJ-xjvvlKK1pZiWlUp__oJ2gG9cN2DF_e6fee1KFrTYh5Zk4nUu9waYO5RTSSCgTBMtvmCaUW8alSx8c_LaFNHbpfa-Jg13GFjt7k/s320/chart-ajaxsoftclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcDP-cDTDm1MGiuf6WCYotbGcbxU34tN8KWwgs9B8ykRQJIYiSNruiyhi8Qmlr1YO0oq9o8XMCspTrl6F3YRlGGVs6Bs3rmNWv10wB_r9o7Q6LfND_hTTj53ttxevGCQWTwFCHzOf2qoc/s1600-h/chart-base2class.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcDP-cDTDm1MGiuf6WCYotbGcbxU34tN8KWwgs9B8ykRQJIYiSNruiyhi8Qmlr1YO0oq9o8XMCspTrl6F3YRlGGVs6Bs3rmNWv10wB_r9o7Q6LfND_hTTj53ttxevGCQWTwFCHzOf2qoc/s320/chart-base2class.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMPZFh7_Ys9Pm3v1zIuHIm6NY2UPX_grhP3DtCvc0mOTFQ0H354nzogYkARqhqGt8yUoLhqAVXJuay3nEXeaB0X98MtPcBbnY3s-clSajL7-Dd4mCB8zpuZwHAGxKgr3VgZID46M_K_FE/s1600-h/chart-defineclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMPZFh7_Ys9Pm3v1zIuHIm6NY2UPX_grhP3DtCvc0mOTFQ0H354nzogYkARqhqGt8yUoLhqAVXJuay3nEXeaB0X98MtPcBbnY3s-clSajL7-Dd4mCB8zpuZwHAGxKgr3VgZID46M_K_FE/s320/chart-defineclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_4vO1VesVh5UilN8lsvfBY8Z1kgZfSzmwPm2P3JK62CWbBvauf2PGt9n1OKLeWgkWjGzGxXLB2N0emkKMsW38asUx86QPeICPEQezfgIlcM39rDMNmNcvVmvtme3hJLPTAYxBktrwY1o/s1600-h/chart-dojoclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_4vO1VesVh5UilN8lsvfBY8Z1kgZfSzmwPm2P3JK62CWbBvauf2PGt9n1OKLeWgkWjGzGxXLB2N0emkKMsW38asUx86QPeICPEQezfgIlcM39rDMNmNcvVmvtme3hJLPTAYxBktrwY1o/s320/chart-dojoclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUvyWOAKRrqpczzS8QJKyOU6xNYXrHP0INK0u2FSwYbp15BG9lu5b5AX0YNdkJ05chtgYWO8cK2NmDCnFUPvlvU2_TL1ElVs-DNNLqdXfOkEC9sb4yuMPT8kZG4lnvICLVEUweG3c_2Ps/s1600-h/chart-j3class.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUvyWOAKRrqpczzS8QJKyOU6xNYXrHP0INK0u2FSwYbp15BG9lu5b5AX0YNdkJ05chtgYWO8cK2NmDCnFUPvlvU2_TL1ElVs-DNNLqdXfOkEC9sb4yuMPT8kZG4lnvICLVEUweG3c_2Ps/s320/chart-j3class.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimDjnF02FI_No2Ed1kkjFLX8Vw6up5MAU3RyzHegexN_Lr9Wa9iKk_oEDl5UuRked-1DFhnFJJTyL7SmJVIgrmn04qs1_WnZH9nJtBIy7sJSOqVLZkJNOdk9ZKXgfgTBFhLchsTsyTl1M/s1600-h/chart-j3class2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimDjnF02FI_No2Ed1kkjFLX8Vw6up5MAU3RyzHegexN_Lr9Wa9iKk_oEDl5UuRked-1DFhnFJJTyL7SmJVIgrmn04qs1_WnZH9nJtBIy7sJSOqVLZkJNOdk9ZKXgfgTBFhLchsTsyTl1M/s320/chart-j3class2.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk16jB-j8voRU_xSn9XAfOTLCg7rhUyAiqB8jlPQJyT0vlHbcOsX6dF7g7wYupVmxPcbnxsuuppdrFxYFHbbbkZ_yZut6tUG-sljdHoqexLQPTZ1rvKhVEpky5qZNYqYTEXF2nf0L3zvw/s1600-h/chart-jclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk16jB-j8voRU_xSn9XAfOTLCg7rhUyAiqB8jlPQJyT0vlHbcOsX6dF7g7wYupVmxPcbnxsuuppdrFxYFHbbbkZ_yZut6tUG-sljdHoqexLQPTZ1rvKhVEpky5qZNYqYTEXF2nf0L3zvw/s320/chart-jclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH6Sc0dGN41CyYI_a9i0Qqoi4LyCT9HLN0r6kiXiYL_LcPYAdh5WiaPSkUE0NMIrOE8BN8AClg29Ni3kkWTGYXAFYV7UyqQF5yp4kc2LV1D5j03lCHzLuVhNDYXu7tfN7OLMyg27diwOw/s1600-h/chart-joosclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH6Sc0dGN41CyYI_a9i0Qqoi4LyCT9HLN0r6kiXiYL_LcPYAdh5WiaPSkUE0NMIrOE8BN8AClg29Ni3kkWTGYXAFYV7UyqQF5yp4kc2LV1D5j03lCHzLuVhNDYXu7tfN7OLMyg27diwOw/s320/chart-joosclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN01Vbd5vAE1IO_6YnPmhOXQLMMPbiRXCk4adv55c5d1LtL_9xaT48Fy1XC5PrfjW3TyOdvCtoA1FiKUAo6PjslDvu3Edt4UKXHiv2faia2AU1NJyBTNBusgvSJGvUFdwrxDX6OYEykTQ/s1600-h/chart-mootools.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN01Vbd5vAE1IO_6YnPmhOXQLMMPbiRXCk4adv55c5d1LtL_9xaT48Fy1XC5PrfjW3TyOdvCtoA1FiKUAo6PjslDvu3Edt4UKXHiv2faia2AU1NJyBTNBusgvSJGvUFdwrxDX6OYEykTQ/s320/chart-mootools.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL6NOadVk0ESvgHHUAbYcxW74Yg5JlGnKIvtlo6_WdZS1c_qG82rcNDs7lQCh2eSGCcb0TgFilg1m4cMguyfQagNsZtNhoH3ZXPFDg6mnInGyAbwo7-GkmhBHsiKDUQo06yybERRvJgWw/s1600-h/chart-prototypeclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL6NOadVk0ESvgHHUAbYcxW74Yg5JlGnKIvtlo6_WdZS1c_qG82rcNDs7lQCh2eSGCcb0TgFilg1m4cMguyfQagNsZtNhoH3ZXPFDg6mnInGyAbwo7-GkmhBHsiKDUQo06yybERRvJgWw/s320/chart-prototypeclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghsQ8hdzEi50UG2Ft9yZ8rrAeEaOqap-CGDWGsQrDXOOb98wqoe_QGA3jMcnLByYj5-fKw3P1TsmWL3Xj86fo7UsfVUTro91A_j-Mmvl9r1QZgSFky-z0pd_e3_MlOFXo-HhHrdjK9fO8/s1600-h/chart-wrclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghsQ8hdzEi50UG2Ft9yZ8rrAeEaOqap-CGDWGsQrDXOOb98wqoe_QGA3jMcnLByYj5-fKw3P1TsmWL3Xj86fo7UsfVUTro91A_j-Mmvl9r1QZgSFky-z0pd_e3_MlOFXo-HhHrdjK9fO8/s320/chart-wrclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNJHQfYNHVNpEIuxo9bBHVSRuDkaklt1XNwLmsxQpJqyQLhiVhAW4Np2QQIVLUm0wKp1_zmQmIJiRQvMd1v03aRUqAF-VQjhvIAfiiN60xYXWMHKxdpxDOi0sZFSDb15ygAhLs8PhEKwQ/s1600-h/chart-mugenclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNJHQfYNHVNpEIuxo9bBHVSRuDkaklt1XNwLmsxQpJqyQLhiVhAW4Np2QQIVLUm0wKp1_zmQmIJiRQvMd1v03aRUqAF-VQjhvIAfiiN60xYXWMHKxdpxDOi0sZFSDb15ygAhLs8PhEKwQ/s320/chart-mugenclass.png" /></a><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div> 3. Results for Opera<br />
<br />
<div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiybbpiH5x7xvBteYMBwsK6zhl6OtMrDpRACl8QqBYxVLihbZ_HOE8QQBmn-GesRmjuJifNBW9I3gd5Nf_W90q2j5HV4CKQIL3tGpTwYNzksbm5vrMlziA9d3vOCRm9Z2o9sgwpIwK8Wg8/s1600-h/chart-base2class.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiybbpiH5x7xvBteYMBwsK6zhl6OtMrDpRACl8QqBYxVLihbZ_HOE8QQBmn-GesRmjuJifNBW9I3gd5Nf_W90q2j5HV4CKQIL3tGpTwYNzksbm5vrMlziA9d3vOCRm9Z2o9sgwpIwK8Wg8/s320/chart-base2class.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjudJKho4GhF_03jgfUAmvJOmE-3Xbwo2fHJkGWRSzX4RhaXQA4sREiGF1RgruCuVCu84WS3VSlf0fvgcwhp1qrQJ6eCtWi_BzbE5JTjddVIGfufSep9CoYDK5HEPx-Pra91tPijXfnj7c/s1600-h/chart-ajaxsoftclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjudJKho4GhF_03jgfUAmvJOmE-3Xbwo2fHJkGWRSzX4RhaXQA4sREiGF1RgruCuVCu84WS3VSlf0fvgcwhp1qrQJ6eCtWi_BzbE5JTjddVIGfufSep9CoYDK5HEPx-Pra91tPijXfnj7c/s320/chart-ajaxsoftclass.png" /></a><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1II7qLhGI3nB5B7aR4xWPLeQ0xHupeu3hXZM88mmFQTlq9Q1pY3rmd3yFu-ebLnPRWY0ZMDG7gfS8MrvgQ0GBZ4Gsx8LrChAdPflK71NhyPDMg2K_-DHMuYDgx1rO4DBn2p5uZbHpKps/s1600-h/chart-dojoclass.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1II7qLhGI3nB5B7aR4xWPLeQ0xHupeu3hXZM88mmFQTlq9Q1pY3rmd3yFu-ebLnPRWY0ZMDG7gfS8MrvgQ0GBZ4Gsx8LrChAdPflK71NhyPDMg2K_-DHMuYDgx1rO4DBn2p5uZbHpKps/s320/chart-dojoclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzeGWhcBNFenHO9pjuXSVm5Oww8-Zr05KqWoXF2eLFDdt5eH9XQj3-RGRxkAO577wdMDVXH-Ebv4iwbGq784xPgH2LcfmZv4rg8CsX85GbnTZVdXZqN3CrgjMurrEl4Wf7kq-znie9tYE/s1600-h/chart-defineclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzeGWhcBNFenHO9pjuXSVm5Oww8-Zr05KqWoXF2eLFDdt5eH9XQj3-RGRxkAO577wdMDVXH-Ebv4iwbGq784xPgH2LcfmZv4rg8CsX85GbnTZVdXZqN3CrgjMurrEl4Wf7kq-znie9tYE/s320/chart-defineclass.png" /></a><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg03nfS_1DryAwtMZ4UrEsIbjJXoipKH_ucNtuW6GuqGuND92MBDWeH2dvIR9bz2nE4LTCvZrG36NhgWPRvZ0P1e05ojjD5Xr34C7F3c555S4MTCYAkI9YFOyg7YSMdIaMOvoAbrjZOTsY/s1600-h/chart-j3class2.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg03nfS_1DryAwtMZ4UrEsIbjJXoipKH_ucNtuW6GuqGuND92MBDWeH2dvIR9bz2nE4LTCvZrG36NhgWPRvZ0P1e05ojjD5Xr34C7F3c555S4MTCYAkI9YFOyg7YSMdIaMOvoAbrjZOTsY/s320/chart-j3class2.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisOT8WRGYbMTBifKB60ABNsco7ff9Mzvf7F8qQjWb_AIMZnWFZyVH8a7zDX6cR46M2gCMwr_YuIKd5u0vSDAZ3mKQRROKy7vR-w3kzcKaHWbz8ecqhV2TrSEkAtbTbSqmJm-EEgPUC8GI/s1600-h/chart-j3class.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisOT8WRGYbMTBifKB60ABNsco7ff9Mzvf7F8qQjWb_AIMZnWFZyVH8a7zDX6cR46M2gCMwr_YuIKd5u0vSDAZ3mKQRROKy7vR-w3kzcKaHWbz8ecqhV2TrSEkAtbTbSqmJm-EEgPUC8GI/s320/chart-j3class.png" /></a><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhClRORijpgxraqRx9dN4gl6V26Ag8x83nBCvpLTHcNAY0Jj3WTtUnOe5VUCtaj07w8wDI9MGq1sjvabUMSmAobToIWvx1Zzs0l3ux23T-3EDaQ8mA2dhelzU64vKQnrvxwhJgE1AVCmjU/s1600-h/chart-joosclass.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhClRORijpgxraqRx9dN4gl6V26Ag8x83nBCvpLTHcNAY0Jj3WTtUnOe5VUCtaj07w8wDI9MGq1sjvabUMSmAobToIWvx1Zzs0l3ux23T-3EDaQ8mA2dhelzU64vKQnrvxwhJgE1AVCmjU/s320/chart-joosclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSqQs70dTfRphjyUkNxATAl2_9pSFKmkIRr8s2jpVQ1gcycoP89saFF_EzA2_hZ5P1v1E3R4JDOMGgUhjQb-NYdJR4UyxjjBqlyxbQOTc1h6Ot4uFT5UMwsQBKZwqEoDPYgd1x-wqgouY/s1600-h/chart-jclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSqQs70dTfRphjyUkNxATAl2_9pSFKmkIRr8s2jpVQ1gcycoP89saFF_EzA2_hZ5P1v1E3R4JDOMGgUhjQb-NYdJR4UyxjjBqlyxbQOTc1h6Ot4uFT5UMwsQBKZwqEoDPYgd1x-wqgouY/s320/chart-jclass.png" /></a><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXS8Rf7IedVBwxtHdSA5z1SpL84F7MgJFYQgufW8nzqTQItLqmaJU1JyjiIu07-E4fSz7-t7C8Qtizn9HCqfP97MRoAI0V-cspPb8auWMpNxb3kgducKAAY5DsRqWxm8lpPRhuL9iA1TU/s1600-h/chart-prototypeclass.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXS8Rf7IedVBwxtHdSA5z1SpL84F7MgJFYQgufW8nzqTQItLqmaJU1JyjiIu07-E4fSz7-t7C8Qtizn9HCqfP97MRoAI0V-cspPb8auWMpNxb3kgducKAAY5DsRqWxm8lpPRhuL9iA1TU/s320/chart-prototypeclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3AKhJpKpRa_l5bcossEmqXahXsyVx9o1iIE21bQIL-yflIHx6Vfm0sWZ7mrLL80FA6w1GLnPXKpsZnPDyfhiPI5WE3bNgNJrhEGvv22MLJUaHqNeIY3nAjD50bI6DJ-b68I3W2mNRHRQ/s1600-h/chart-mootools.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3AKhJpKpRa_l5bcossEmqXahXsyVx9o1iIE21bQIL-yflIHx6Vfm0sWZ7mrLL80FA6w1GLnPXKpsZnPDyfhiPI5WE3bNgNJrhEGvv22MLJUaHqNeIY3nAjD50bI6DJ-b68I3W2mNRHRQ/s320/chart-mootools.png" /></a><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiklqTMtlzzfA5CdRMn1mGz4f7CNzM3G7QS9bMPnHgJtVJ4ivagKtlDnQFV87JNvZlOxkVV8r3FYs7s_gj5UY7U0yfpmJW56T14iAzhZzQMsJ3yY0Bbp30cH76FwDLmjh4Yvp3Zx36GwgQ/s1600-h/chart-mugenclass.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiklqTMtlzzfA5CdRMn1mGz4f7CNzM3G7QS9bMPnHgJtVJ4ivagKtlDnQFV87JNvZlOxkVV8r3FYs7s_gj5UY7U0yfpmJW56T14iAzhZzQMsJ3yY0Bbp30cH76FwDLmjh4Yvp3Zx36GwgQ/s320/chart-mugenclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA3aGhJ-3emf8cIHIdwYM7Y58iydZzFWj-sH2APBaE0XAR8GbIW8vS5YmFOfu3N60GNBEhI_-9q4RguG_Jkv1Pg3M-zWUtjy5j4tOmc3dBF2YtfgPFaPW7NjUZ4cgxOLmoA-i2xboivkM/s1600-h/chart-wrclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" er="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA3aGhJ-3emf8cIHIdwYM7Y58iydZzFWj-sH2APBaE0XAR8GbIW8vS5YmFOfu3N60GNBEhI_-9q4RguG_Jkv1Pg3M-zWUtjy5j4tOmc3dBF2YtfgPFaPW7NjUZ4cgxOLmoA-i2xboivkM/s320/chart-wrclass.png" /></a><br />
</div><br />
4. Results for Safari<br />
<br />
<div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi11eTXwyzQTx0hTN1SuKqn74tZO8I4NJ_tCzH-7ZBUs8Tic6gFLKxgqeXNGIDDAI1_2uNtEo9meiK11PqAjTnmWt2gn7oSi23Y2FRMsLEecq6A93LuC7Gc-4VRmyV5PQn_00HJZB47yo/s1600-h/char-ajaxsoftt.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi11eTXwyzQTx0hTN1SuKqn74tZO8I4NJ_tCzH-7ZBUs8Tic6gFLKxgqeXNGIDDAI1_2uNtEo9meiK11PqAjTnmWt2gn7oSi23Y2FRMsLEecq6A93LuC7Gc-4VRmyV5PQn_00HJZB47yo/s320/char-ajaxsoftt.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKhlIKW9OGnnsZOUmX6Ar6fiDeAjoWbY_YpiGs0aq7OlnA_ri0Gz29oWQKFPdxY2q-2objU7jrcffeucO-GB36z6YuyTVr6gAUHiABjZuVZAix1qJOzWcfIfICkP8D-YKKrsl6G2Y84N8/s1600-h/chart-base2class.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKhlIKW9OGnnsZOUmX6Ar6fiDeAjoWbY_YpiGs0aq7OlnA_ri0Gz29oWQKFPdxY2q-2objU7jrcffeucO-GB36z6YuyTVr6gAUHiABjZuVZAix1qJOzWcfIfICkP8D-YKKrsl6G2Y84N8/s320/chart-base2class.png" /></a><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNl7XnBCQoatHdjGLQtgGokkGJcQ-fPJlgL-4NWMgKDCuoUpZznBAU1azclXGojy9gA3aKLQs6Jq-0rTtdxx-lqdes9AsRTve5rdqW2OFf4cShD9lTL5_zkMHmfyYBkFtzd9FadaoHsYk/s1600-h/chart-dojo.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNl7XnBCQoatHdjGLQtgGokkGJcQ-fPJlgL-4NWMgKDCuoUpZznBAU1azclXGojy9gA3aKLQs6Jq-0rTtdxx-lqdes9AsRTve5rdqW2OFf4cShD9lTL5_zkMHmfyYBkFtzd9FadaoHsYk/s320/chart-dojo.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2fp0J-_bokvc-vKBynkyg6lr0V0R1llaRTe_Ha5CNyW27eYGP26rjHH_vcfcCc_kf5m0FSttmkW69byMCcALyLwHVtTEqiT-onUwbtudaGVpIT9nLoXQh26Gu93NAig_1Ue3_lqoesZE/s1600-h/chart-defineclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2fp0J-_bokvc-vKBynkyg6lr0V0R1llaRTe_Ha5CNyW27eYGP26rjHH_vcfcCc_kf5m0FSttmkW69byMCcALyLwHVtTEqiT-onUwbtudaGVpIT9nLoXQh26Gu93NAig_1Ue3_lqoesZE/s320/chart-defineclass.png" /></a><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhffHSh2mVskT04ZakPEVzkzP4vAbU7BCK9-VPYaCtAs1F73HDOPB8fNzcTiFLVoDWTSywjfigIJHWFIPteuqm-_u3FdXXR7s65cRbWzM3g1tW2t48tYGqgw-PwCafFbYR15Lq5T0W7fqg/s1600-h/chart-j3class2.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhffHSh2mVskT04ZakPEVzkzP4vAbU7BCK9-VPYaCtAs1F73HDOPB8fNzcTiFLVoDWTSywjfigIJHWFIPteuqm-_u3FdXXR7s65cRbWzM3g1tW2t48tYGqgw-PwCafFbYR15Lq5T0W7fqg/s320/chart-j3class2.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwGF3gUoDCgwwvdWP6x5msRNhTYvFaNAcUqEjzq1qLsf6Zztr58NDOL2GNZ956mlCWM2VPuTAGpI_aEAFXS_JWM_mXiH2PMX5DZSexUvtkzK2EpfAsOtGW59KNOXtVRGsMk2PymVMC6Y4/s1600-h/chart-j3class.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwGF3gUoDCgwwvdWP6x5msRNhTYvFaNAcUqEjzq1qLsf6Zztr58NDOL2GNZ956mlCWM2VPuTAGpI_aEAFXS_JWM_mXiH2PMX5DZSexUvtkzK2EpfAsOtGW59KNOXtVRGsMk2PymVMC6Y4/s320/chart-j3class.png" /></a><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX1SvkmZFEUC88wuFcdwLGG2wIR59Du-fEyXsbOG1fMljafRMD3cUPHWfvzkirV13p1k-oV8cIjmvfzI8tpgBuhZKfYH07fi5FBM97foiJkEa2uChcLUtwCXIoM9aiq5rii8G6c1z9e3M/s1600-h/chart-joosclass.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX1SvkmZFEUC88wuFcdwLGG2wIR59Du-fEyXsbOG1fMljafRMD3cUPHWfvzkirV13p1k-oV8cIjmvfzI8tpgBuhZKfYH07fi5FBM97foiJkEa2uChcLUtwCXIoM9aiq5rii8G6c1z9e3M/s320/chart-joosclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzt9c8ypEsfXbLYKbEgmZmALqcFHZQZu8VVun2Xwia-d2XXm4snwr5N3m9XSDifuNTdkazOP5rNTHBgl3B6U82hhl1Yo0xxa1qYKuqLWrNonv70aSAvNlUD4vVcWjAT8Aydca9L34V8tI/s1600-h/chart-jclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzt9c8ypEsfXbLYKbEgmZmALqcFHZQZu8VVun2Xwia-d2XXm4snwr5N3m9XSDifuNTdkazOP5rNTHBgl3B6U82hhl1Yo0xxa1qYKuqLWrNonv70aSAvNlUD4vVcWjAT8Aydca9L34V8tI/s320/chart-jclass.png" /></a><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNuDaj4pYZY2mmsmJsu2TZISrE559BXsDb4Hw8fawgrLdPKIVWM5V1B6X3WO4pKv2u-d5lV5WyobKzTDSi-3pXTHZ002Nrf_bkpQWmDOzSng0jsfFM6fVfvrJI66i0lIS97qZjKQ109rc/s1600-h/chart-mootools.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNuDaj4pYZY2mmsmJsu2TZISrE559BXsDb4Hw8fawgrLdPKIVWM5V1B6X3WO4pKv2u-d5lV5WyobKzTDSi-3pXTHZ002Nrf_bkpQWmDOzSng0jsfFM6fVfvrJI66i0lIS97qZjKQ109rc/s320/chart-mootools.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtd3a2GdXkL9hxpa-VFp6Kfg2nLxHfVserHbtfN3Y6LNHe7iRMym-Xv8P4L_0LHAUVm65HyGNz4W8g3eMZv-BYfAPL2eIj_cElvLrK4Tf7CIPGyByuK9k_dEhn2GQwQEY6Bqc1DiKZcWk/s1600-h/chart-prototype.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtd3a2GdXkL9hxpa-VFp6Kfg2nLxHfVserHbtfN3Y6LNHe7iRMym-Xv8P4L_0LHAUVm65HyGNz4W8g3eMZv-BYfAPL2eIj_cElvLrK4Tf7CIPGyByuK9k_dEhn2GQwQEY6Bqc1DiKZcWk/s320/chart-prototype.png" /></a><br />
</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9jG3KtFhj-aSmYWVkxkPBAl_38B0PkqWVDqx9U0Z1GOUOcVNez3pxJlmVBYvt-SeXBvbGcvN9mufRWVC_OHRlcfwynqU3MBlnAF-qzj-Cei8jkTpKGTnVog2Q7AAMz-8QoaIRVemBOL8/s1600-h/char-mugenclass.png" imageanchor="1" style="clear: right; cssfloat: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9jG3KtFhj-aSmYWVkxkPBAl_38B0PkqWVDqx9U0Z1GOUOcVNez3pxJlmVBYvt-SeXBvbGcvN9mufRWVC_OHRlcfwynqU3MBlnAF-qzj-Cei8jkTpKGTnVog2Q7AAMz-8QoaIRVemBOL8/s320/char-mugenclass.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJZ8Agle6EMXeho8fd_ibsoXmU6qBmJkYvUOoTNYNNvzAGoGxl5dSGOUgKHgYBNQs3MY9I4crVZCJvXOfjd-aQXaUARjrhC9u5Npv-oyqVMeJ5AJxQ5fjDy9QJ5GCJ_2fEbPIIae6WmCw/s1600-h/chart-wrclass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" ps="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJZ8Agle6EMXeho8fd_ibsoXmU6qBmJkYvUOoTNYNNvzAGoGxl5dSGOUgKHgYBNQs3MY9I4crVZCJvXOfjd-aQXaUARjrhC9u5Npv-oyqVMeJ5AJxQ5fjDy9QJ5GCJ_2fEbPIIae6WmCw/s320/chart-wrclass.png" /></a><br />
</div>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-88632858969671341942009-12-08T09:38:00.000-08:002009-12-28T06:30:54.496-08:00JavaScript Inheritance Part IIHere are two different approaches in using the previous motioned inheritance technique.<br />
<br />
1. Standard way where all members are public:<br />
<pre>var Human = MG.Class.Create({
Gender: null,
constructor: function(gender) {
this.Gender = gender;
},
IsMale: function() {
return this.Gender == 'F' ? false : true;
},
GenderString: function() {
return this.Gender == 'F' ? "female" : "male";
},
ToOverride: function() { return "Called from Human"; }
}, null, null);
var Individual = MG.Class.Create({
Unique: null,
constructor: function(unique) {
this.Unique = unique;
},
IsUnique: function() {
return this.Unique ? "Yes" : "No";
},
DummyMethod: function() {
return "Individual dummy method.";
},
ToOverride: function() { return "Called from Individual which is " + (this.Unique ? "unique" : "not unique") + " / " + this.base(); }
}, Human, null);
var Person = MG.Class.Create({
constructor: function(firstName, lastName, birthDate) {
this.FirstName = firstName;
this.LastName = lastName;
this.BirthDate = birthDate;
},
GetName: function() {
return this.FirstName + " " + this.LastName;
},
GetDetails: function() {
return this.GetName() + " it's a " + this.GenderString() + " borned on date " + this.BirthDate;
},
ToOverride: function() { return "Called from Person with first name " + this.FirstName + " / " + this.base(); }
}, Individual, null);
var Jhon = MG.Class.Create({
constructor: function(age) {
this.Age = age;
},
GetDetails: function() {
return this.GetName() + " it's a " + this.GenderString() + " borned on date " + this.BirthDate + ".";
},
ToOverride: function() { return "Called from Jhon/ " + this.base(); }
}, Person, null);
</pre><br />
2. Classes with private members:<br />
<br />
<pre>var Human = MG.Class.Create({
constructor: function(gender) {
this.Gender = gender;
return { IsMale: function() {
return this.Gender == 'F' ? false : true;
},
GenderString: function() {
return this.Gender == 'F' ? "female" : "male";
},
ToOverride: function() { return "Called from Human"; }
};
}
}, null, null);
var Individual = MG.Class.Create({
constructor: function(unique) {
this.Unique = unique;
var PrivateDummyMethod = function() {
return "Individual dummy method.";
};
return { IsUnique: function() {
return this.Unique ? "Yes" : "No";
},
ToOverride: function() { return "Called from Individual / " + this.base(); }
};
}
}, Human, null);
var Person = MG.Class.Create({
constructor: function(firstName, lastName, birthDate) {
this.FirstName = firstName;
this.LastName = lastName;
this.BirthDate = birthDate;
return { GetName: function() {
return this.FirstName + " " + this.LastName;
},
GetDetails: function() {
return this.GetName() + " it's a " + this.GenderString() + " borned on date " + this.BirthDate;
},
ToOverride: function() { return "Called from Person / " + this.base(); }
};
}
}, Individual, null);
var Kate = MG.Class.Create({
constructor: function(age) {
this.Age = age;
return { GetDetails: function() {
return this.GetName() + " it's a " + this.GenderString() + " borned on date " + this.BirthDate + ".";
},
ToOverride: function() { return "Called from Kate/ " + this.base(); }};
}
}, Person, null);
</pre><br />
I observed one thing about Base2 and Prototype. When you call a chain method and you reach the parent method, inside the method you have access to the derived object members using “this”. In my opinion once the call is navigating thru the chain on each base class the user should not be able to access the derived class members based on OOP definitions. In the future I'll fix this also in my technique.Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-64009709460052474942009-12-08T06:35:00.000-08:002009-12-28T06:31:09.102-08:00JavaScript Inheritance Part IAs a background I’m a .NET developer (C#) and I really like this technology :D. Since I got in contact with JavaScript, I always wanted to find an approach, a way to adapt it and used it as more as possible as an object oriented programming language. I found different approaches/techniques regarding this aspect of JavaScript (Crockford inheritance, Dean Edward with base2, Prototype, John Resig with a mixture of base2 and Prototype). After I studied the previous mentioned techniques I decided to have fun by trying to create a mixture and add new desired functionality. You can download the source from <a href="http://cypruscaffe.com/sourcecode/javascript/mg.core.zip">HERE</a> <br />
<br />
For example in the case of Base2 inheritance you can’t create an object which has private and public members in a elegant way. Let us assume that we have following object:<br />
<br />
<pre>var Human = base2.Base.extend({
constructor: function(name, hairColour, eyeColour, height, weight) {
this.Name = name;
this.HairColour = hairColour;
this.EyeColour = eyeColour;
this.Height = height;
this.Weight = weight},
IsHeavy: function() {
return this.Weight > 100 ? true : false;
},
Dance: function() {
return this.Name + " is dancing!";
}});
</pre><br />
In this case all members of the Human class are public. If I try to make Dace member private in the following way then all public members will not be available to the descendant of the Human class.<br />
<br />
<pre>var Human = base2.Base.extend({
constructor: function(name, hairColour, eyeColour, height, weight) {
var Dance = function() {
return this.Name + " is dancing!";};
return{Name: name,
HairColour: hairColour,
EyeColour: eyeColour,
Height: height,
Weight: weight,
IsHeavy: function() {
return this.Weight > 100 ? true : false;
}};
});
</pre><br />
To test this case I have created a class called Person which extends the Human. Here is the code:<br />
<br />
<pre>var Person = Human.extend({
constructor: function(name, hairColour, eyeColour, height, weight) {
this.base(name, hairColour, eyeColour, height, weight);
},
IsUnique: function() {
return true;
}});
var obj = new Person("Bob Doe", "brown'", "blue", 6, 12);
obj.IsHeavy();
</pre><br />
So, to extend the functionality to cover the above mentioned scenario I have used a different approach for inheritance. In this way the public members of a base class declared as in the above example and also those declared using prototype will be inherited by the derived class.<br />
<br />
Here is the code which I will discuss it later on:<br />
<pre>MG.Class.Create = function() {
var ___descendant = arguments[0];
var ___parent = arguments[1];
var interfaces = arguments[2];
var Implements = MG.Class.Implements;
var instance = function() {
// Copy 'base' (overridden) properties
this.base = instance.base;
// Copy properties from 'instance'
// structure object
for (var prop in instance) {
this[prop] = instance[prop];
}
var publicParentProps = [];
/**********************************************/
// Create the appropriate arguments and
// initialize ___parent/___descendant by calling
// their constructors
/**********************************************/
var args = arguments;
var desArgsCount = ___descendant.constructor.length;
var desArgs = new Array(desArgsCount);
for (var index = 0; index < desArgsCount; index++)
desArgs[index] = args[index];
if (this.base && this.base.inheritanceList) {
var length = this.base.inheritanceList.length;
var startParams = args.length;
for (var k = 0; k < length; k++) {
var ctor = this.base.inheritanceList[k];
var prnArgsCount = ctor.length;
var prnArgs = new Array(prnArgsCount);
startParams -= prnArgsCount;
var nextParams = prnArgsCount > startParams ? (startParams + prnArgsCount) : (startParams - prnArgsCount);
for (var index = startParams, i = 0; (prnArgsCount > startParams ? index < nextParams : index > nextParams); (prnArgsCount > startParams ? index++ : index--)) {
prnArgs[i] = args[Math.abs(index)];
i++;
}
var publicParentProp = ctor.apply(this, prnArgs);
if (publicParentProp) {
if (publicParentProps.length > 0)
publicParentProps[publicParentProps.length] = publicParentProp;
else
publicParentProps[0] = publicParentProp;
}
this.base.inheritanceList[k] = null;
}
this.base.inheritanceList = null;
delete this.base.inheritanceList;
}
var publicDescendant = instance.constructor.apply(this, desArgs);
if (publicDescendant) {
for (var prop in publicDescendant)
this[prop] = publicDescendant[prop];
}
if (publicParentProps) {
var length = publicParentProps.length;
for (var index = 0; index < length; index++) {
var publicParentProperty = publicParentProps[index];
for (var prop in publicParentProperty) {
if (!this[prop])
this[prop] = publicParentProperty[prop];
else {
this.base[prop] = publicParentProperty[prop];
}
}
}
}
return this;
};
/**************************************************/
// Create the structure of the object
// which will be instantiated
/**************************************************/
// Set the constructor from the ___descendant
instance.constructor = ___descendant.constructor;
// Copy peoperties from ___descendant
for (var prop in ___descendant)
instance[prop] = ___descendant[prop];
if (___parent) {
// Create a 'base' function which will hold properties
// overridden by the ___descendant
instance.base = function() {
var overrideFunction = null;
for (var prop in this) {
if (typeof (this[prop]) !== 'function')
instance.base[prop] = this[prop];
else if (this[prop] === arguments.caller.callee)
overrideFunction = prop;
}
if (overrideFunction)
instance.base[overrideFunction]();
};
var inheritanceList = new Array();
if (___parent.base && ___parent.base.inheritanceList) {
var parentInheritanceList = ___parent.base['inheritanceList'];
var length = parentInheritanceList.length;
for (var index = 0; index < length; index++)
inheritanceList[index] = parentInheritanceList[index];
}
var constructorExists = inheritanceList[inheritanceList.length - 1] === ___parent.constructor;
if (inheritanceList.length > 0 && !constructorExists)
inheritanceList[inheritanceList.length] = ___parent.constructor;
else if (!constructorExists)
inheritanceList[0] = ___parent.constructor;
instance.base.inheritanceList = inheritanceList;
// Copy properties from ___parent
for (var prop in ___parent) {
if (!instance[prop])
instance[prop] = ___parent[prop];
else {
if (typeof (___parent[prop]) == 'function')
instance.base[prop] = ___parent[prop];
}
}
// Copy properties from ___parent prototype
if (___parent.prototype) {
for (var prop in ___parent.prototype) {
if (!instance[prop])
instance[prop] = ___parent.prototype[prop];
else
instance.base[prop] = ___parent.prototype[prop];
}
}
}
instance.Compare = function(object) {
for (var prop in this) {
if (this[prop] === object[prop])
return false;
}
return true;
}
return instance;
};
</pre>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-89491059308112231262009-12-08T06:03:00.000-08:002009-12-08T06:03:59.805-08:00Oracle - Lost packageToday something very stupid happened. I’ve managed to lose the changes of an entire package. As you know if a package is opened in two different sessions, like session A and session B, if changes are made from session A to the package and session B still has the package opened, when session B will make its changes, all modifications performed by session A on the opened package will be lost. Thanks God that I was able to retrieve the lost changes by making use of SYS.SOURCE$ table. This table is composed from 3 columns: OBJ# which represents the object ID, LINE which is the line number of the source in the object, and SOURCE the column which store the line of code.<br />
<br />
SELECT * FROM SYS.SOURCE$;<br />
SELECT * FROM SYS.SOURCE$ WHERE SOURCE LIKE ‘%MYPACKAGE%’;<br />
<br />
After digging into the results returned, I was able to find 3 versions of my package. One of them contained the lost changes.<br />
<br />
You can find more details about SYS.SOURCE$ table <a href="http://docstore.mik.ua/orelly/oracle/advprog/ch15_04.htm">here</a>.Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-28450899916634371282009-12-02T04:52:00.000-08:002009-12-02T04:52:58.354-08:00PL/SQL & Oracle 64 bit ClientAt the office I’m using Windows Vista 64 bit, we had a lot of bad surprises when it came to combine 32 bit DLLs from Oracle client with 64 bit DLLs of the projects. The most common exception in which we bumped was “Invalid image format”. We were using Oracle 10.2.0.3 which is a 32 bit client. To solve the issue we had to migrate to Oracle 10.2.0.4 client which has support for 64 bit applications. Once we did this we have discovered other inconvenient, PL/SQL didn't worked at all, the reason…it required a 32 bit Oracle client to be installed on the machine. The only solution found by one of my colleagues is that beside Oracle 10.2.0.4 client we should install also 10.2.0.3. Until now everything works just fine. By the way, same thing applies also to TOAD.Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-54530123381608917812009-12-02T02:14:00.000-08:002009-12-28T06:31:57.578-08:00JavaScript Ajax CharactersetIn one of the project I have been involved, I had to create an Ajax menu. The issue showed up when the resource text of the menu items were in Greek. The response of the Ajax request was just junk. The issue resided in the fact that I have not specified on my Ajax request what character set it should be used. The problem was solved once I have specified that the value of charset it should be utf-8.<br />
<br />
<pre>var url = location.protocol + "//" + location.host + "/MyWebSite/Default.aspx/GetMenuXml";
xmlHttp = GetXmlHttpObject();
xmlHttp.open("POST", url, true);
xmlHttp.onreadystatechange = initializeMenu;
xmlHttp.setRequestHeader("Man", "POST" + url);
xmlHttp.setRequestHeader("MessageType", "CALL");
xmlHttp.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xmlHttp.send(null);
</pre>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-40609998947978180972009-12-02T00:40:00.000-08:002009-12-28T06:32:20.412-08:00JSLitmus creating JavaScript benchmark testsHere is a very useful tool which allows you to create nice benchmark tests for your JavaScript code. You can check all the details on their home page:<br />
<br />
<a href="http://www.broofa.com/Tools/JSLitmus/">JSLitmus</a>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-66915759056805998172009-12-01T12:13:00.000-08:002009-12-01T12:13:40.913-08:00JavaScript Get Current Date dd/mm/yyyyThe followinf function will return current date in dd/mm/yyyy format.<br />
<br />
<pre>/*Define the namespaces*/
var JavaScript = {};
JavaScript.Utils = {};
JavaScript.Utils.Date = {};
JavaScript.Utils.Date.Current = function(){
var current = new Date();
//In JavaScript Date object the months counter starts from 0, so
//we have to correct this.
current.setMonth(current.getMonth() + 1);
var changedDate = current.getDate() + "/" + current.getMonth() + "/" + current.getYear();
return changedDate;
}
</pre>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-87015594102335628822009-12-01T11:56:00.000-08:002009-12-01T12:03:39.418-08:00JavaScript Compare Two Dates<span style="color:#ff0000;"><strong>Note:</strong> <span style="font-family:times new roman;">Please check JavaScript Utility Functions Note.</span></span><br /><br />The following javascript function allows you to compare two dates. At this time only dd/mm/yyyy format is supported, but you can extend it very easily. The function will return -1 if first date is smaller than the second date, 1 if it is greater and 0 if both dates are equal.<br /><br /><pre><br />/*Define the namespaces*/<br />var JavaScript = {};<br />JavaScript.Utils = {};<br />JavaScript.Utils.Date = {};<br /><br />JavaScript.Utils.Date.Compare = function(firstDate, secondDate, format) {<br /> if (!(typeof firstDate === "string") || !(typeof secondDate === "string"))<br /> throw "Date must be a string.";<br /><br /> if (!format)<br /> throw "invalid date format specified.";<br /><br /> var result = -1;<br /> switch (format) {<br /> case "dd/mm/yyyy":<br /> {<br /> var fdate = firstDate.match(/^(\d{2})\/(\d{2})\/(\d{4})$/i);<br /> var ldate = secondDate.match(/^(\d{2})\/(\d{2})\/(\d{4})$/i);<br /><br /> if (parseInt(fdate[3]) < parseInt(ldate[3]))<br /> result = -1;<br /> else if (parseInt(fdate[3]) > parseInt(ldate[3]))<br /> result = 1;<br /> else<br /> result = 0;<br /><br /> if (result == 0) {<br /> if (parseInt(fdate[2]) < parseInt(ldate[2]))<br /> result = -1;<br /> else if (parseInt(fdate[2]) > parseInt(ldate[2]))<br /> result = 1;<br /> else<br /> result = 0;<br /> }<br /><br /> if (result == 0) {<br /> if (parseInt(fdate[1]) < parseInt(ldate[1]))<br /> result = -1;<br /> else if (parseInt(fdate[1]) > parseInt(ldate[1]))<br /> result = 1;<br /> else<br /> result = 0;<br /> }<br /> }<br /> break;<br /> }<br /><br /> return result;<br /> };<br /></pre>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-91804493930614386212009-12-01T11:39:00.000-08:002009-12-01T12:04:11.275-08:00JavaScript UTC Date Format<span style="color:#ff0000;"><strong>Note:</strong> <span style="font-family:times new roman;">Please check JavaScript Utility Functions Note.</span></span><br /><br />The following javascript function allows you to convert an UTC date into a user specified format. At this time the implementation will convert the UTC date into dd/mm/yyyy and dd/mm/yyyy hh:mm:ss formats. You can easily extend it's functionality.<br /><br /><pre><br />/*Define the namespaces*/<br />var JavaScript = {};<br />JavaScript.Utils = {};<br />JavaScript.Utils.Date = {};<br /><br />JavaScript.Utils.Date.UtcFormat = function(utcDate, format) {<br />if (!(typeof utcDate === "string"))<br />throw "UTC date must be a string.";<br /><br />if (!format)<br />throw "invalid date format specified.";<br /><br />//Extract UTC date components using regex.<br />var date = utcDate.match(/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z(([+-])(\d{2}):(\d{2}))?)$/i);<br /><br />if (!date)<br />throw "Invalid UTC date format.";<br /><br />var newDate = null;<br />switch (format) {<br />case "dd/mm/yyyy":<br />{<br />newDate = date[3] + "/" + date[2] + "/" + date[1];<br />}<br />break;<br />case "dd/mm/yyyy hh:mm:ss":<br />{<br />newDate = date[3] + "/" + date[2] + "/" + date[1] + " " + date[4] + ":" + date[5] + ":" + date[6];<br />}<br />break;<br />}<br /><br />return newDate;<br />};<br /></pre><br /><br />Next JavaScript function will convert date of dd/mm/yyyy format in UTC format. By default the time section will be ignored, being initialized with 00:00:00.<br /><br /><pre><br />JavaScript.Utils.Date.ToUtcFormat = function(date) {<br /> if (!(typeof date === "string"))<br /> throw "Date must be a string.";<br /><br /> var ndate = date.match(/^(\d{2})\/(\d{2})\/(\d{4})$/i);<br /><br /> if (!ndate)<br /> throw "Invalid date format. Format must be dd/mm/yyyy";<br /><br /> var newDate = ndate[3] + "-" + ndate[2] + "-" + ndate[1] + "T00:00:00Z";<br /><br /> return newDate;<br /> <br /></pre>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com1tag:blogger.com,1999:blog-6146753014571848686.post-55565424913077446262009-12-01T11:09:00.000-08:002009-12-01T11:53:15.516-08:00JavaScript Change URL Parameter Value<span style="color:#ff0000;"><strong>Note:</strong> <span style="font-family:times new roman;">Please check JavaScript Utility Functions Note.</span></span><span style="font-family:times new roman;"> </span><br /><br />The following function will allow you to change the value of a specified parameter from the URL. You just have to pass the parameter name and desired parameter value.<br /><br /><pre><br />/*Define the namespaces*/<br />var JavaScript = {};<br />JavaScript.Utils = {};<br />JavaScript.Utils.URL = {};<br /><br />JavaScript.Utils.URL.ReplaceUrlParam = function(name, value) {<br /> name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");<br /> var regexS = "[\\?&]" + name + "=([^&#]*)";<br /> var regex = new RegExp(regexS);<br /> var results = regex.exec(window.location.href);<br /> if (results == null)<br /> return false;<br /> else {<br /> var form = document.forms[0];<br /> if (form) {<br /> form.action = form.action.replace(results[0], results[0].replace(/=(.*)/, '=' + value));<br /> }<br /> }<br />};<br /></pre>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0tag:blogger.com,1999:blog-6146753014571848686.post-35371047560993707492009-12-01T10:57:00.000-08:002009-12-01T11:53:04.690-08:00JavaScript Extract URL Parameter<span style="color:#ff0000;"><strong>Note:</strong> <span style="font-family:times new roman;">Please check JavaScript Utility Functions Note.</span></span><br /><span style="color:#000000;"></span><br />The following two functions will allow you to extract a specified parameter from the URL.<br />To be more precise, only the first one will extract it automatically from the URL, the second function, which is an extension of the first one, will extract the specified parameter value from user defined source which is passed as a parameter.<br /><br /><pre><br />/*Define the namespaces*/<br />var JavaScript = {};<br />JavaScript.Utils = {};<br />JavaScript.Utils.URL = {};<br /><br />JavaScript.Utils.URL.GetURLParam = function(param) {<br /> param = param.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");<br /> var regexS = "[\\?&]" + param + "=([^&#]*)";<br /> var regex = new RegExp(regexS);<br /> var results = regex.exec(window.location.href);<br /><br /> if (results == null)<br /> return "";<br /> else<br /> return results[1];<br />};<br /><br /><br />JavaScript.Utils.URL .GetUrlParamEx = function(source, name) {<br /> name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");<br /> var regexS = "[\\?&]" + name + "=([^&#]*)";<br /> var regex = new RegExp(regexS);<br /> var results = regex.exec(source);<br /> if (results == null)<br /> return "";<br /> else<br /> <br /> return results[1];<br />};<br /></pre>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com1tag:blogger.com,1999:blog-6146753014571848686.post-20838483790155891632009-12-01T10:49:00.000-08:002009-12-01T11:09:09.186-08:00JavaScript Create Script Node<span style="color:#ff0000;"><strong>Note: </strong>Please check JavaScript Utility Functions Note.</span><br /><span style="color:#000000;"></span><br />Here is short JavaScript function which creates and returns a script node based on the string you specify as parameter:<br /><br /><pre><br />/*Define the namespaces*/<br />var JavaScript = {};<br />JavaScript.Utils = {};<br />JavaScript.Utils.DOM = {};<br /><br />JavaScript.Utils.DOM.CreateScriptElement = function(scriptValue) {<br /> var node = document.createElement("script");<br /> node.setAttribute('type', 'text/javascript');<br /><br /> if (node.canHaveChildren == null || node.canHaveChildren)<br /> node.appendChild(document.createTextNode(scriptValue));<br /> else<br /> node.text = scriptValue;<br /><br /> return node;<br />};<br /></pre>Michael Helisohttp://www.blogger.com/profile/18294901951415285299noreply@blogger.com0