Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

UDDI Explorer: Tool for searching web services

, 20 Dec 2005
Tool for searching web service(s) and viewing their WSDL information.
uddiexplorer_demo.zip
UDDIExplorer_demo
WSDLParser.dll
microsoft.uddi.sdk.dll
ServiceRanking.dll
UDDI Explorer.exe
WSDLCache
Weather data from the National Digital Forecast Database NOAA's NWS.wsdl
uddiexplorer_src.zip
UDDIExplorer_src
ServiceRanking
ServiceRanking.csproj.user
UDDI Explorer
microsoft.uddi.sdk.dll
UDDI Explorer.csproj.user
UDDI Explorer.resharperoptions
WSDLParser
App.ico
WSDLParser.csproj.user
using System;
using System.Collections;
using System.Reflection;
using System.ComponentModel;
using System.Windows.Forms;

namespace UDDI_Explorer
{
	public interface ICopyable: ICloneable
	{
		void CopyFrom(object ptrFrom);
	}
	/// <summary>
	/// Summary description for BaseObject.
	/// </summary>
	[Serializable]
	public class Copyable : ICopyable
	{
		public Copyable()
		{
		}

		public object Clone()
		{
			object result = Activator.CreateInstance(this.GetType());
			(result as ICopyable).CopyFrom(this);
			return result;
		}

		public void CopyFrom(object ptrFrom)
		{
			Copy(ptrFrom, this);
		}	
		
		private static bool HasNonParameterContructor(Type tfType)
		{
			bool bRet = false;
			ConstructorInfo []colInfos = tfType.GetConstructors();
			for(int i = 0; i< colInfos.Length; i++)
			{
				ParameterInfo []colParameters = colInfos[i].GetParameters();
				if(colParameters.Length==0)
				{
					bRet = true;
					break;
				}
			}
			return bRet;
		}

		public static void Copy(object ptrFrom,object ptrTo)
		{
			Type fromType = ptrFrom.GetType();
			Type toType = ptrTo.GetType();

			if(!(toType.GetInterface("ICloneable") == typeof(System.ICloneable)||toType.GetInterface("ICopyable") == typeof(UDDI_Explorer.ICopyable)) 
				|| !(fromType.GetInterface("ICopyable") == typeof(UDDI_Explorer.ICopyable)||fromType.GetInterface("ICloneable") == typeof(System.ICloneable))
				)
				throw new Exception("CopyFrom not allows different types");
			ArrayList fromFields = new ArrayList();
			Type currType = fromType;
			do
			{
				FieldInfo []Fields = currType.GetFields(
					BindingFlags.NonPublic|BindingFlags.Public|BindingFlags.GetField|BindingFlags.Instance);
				fromFields.AddRange(Fields);
				currType = currType.BaseType;
			}while(currType != null);

			for(int i=0; i<fromFields.Count; i++)
			{
				FieldInfo fromField = fromFields[i] as FieldInfo;
				Type currToType = toType;
				FieldInfo toField = null;
				do
				{
					toField = currToType.GetField(fromField.Name,
						BindingFlags.NonPublic|BindingFlags.Public|BindingFlags.GetField|BindingFlags.Instance);
					currToType = currToType.BaseType;

				}while(toField == null || currToType == null);

				Type tfType = toField.FieldType;
				object fromValue = fromField.GetValue(ptrFrom);
				object toValue = toField.GetValue(ptrTo);
				if(null!=fromValue&&HasNonParameterContructor(tfType))
				{
					MethodInfo mi;
					if(tfType.GetInterface("ICopyable") == typeof(UDDI_Explorer.ICopyable)||tfType.IsSubclassOf(typeof(Copyable)))
					{
						mi = tfType.GetMethod("CopyFrom");
						object []parameters = {fromValue};
						if(toValue == null)
						{
							toValue = Activator.CreateInstance(tfType);
							toField.SetValue(ptrTo,toValue);
						}    
						mi.Invoke(toValue, parameters);
					}
					else if(tfType.GetInterface("ICloneable") == typeof(System.ICloneable))
					{
						mi = tfType.GetMethod("Clone");	
						object []parameters = {};
						if(toValue == null)
						{
							toValue = Activator.CreateInstance(tfType);
							toField.SetValue(ptrTo,toValue);
						}    
						toValue = mi.Invoke(fromValue, parameters);
						toField.SetValue(ptrTo, toValue);
					}
					else
					{
						toField.SetValue(ptrTo, fromField.GetValue(ptrFrom));
					}
				}
				else
				{
					toField.SetValue(ptrTo, fromField.GetValue(ptrFrom));
				}
			}
		}	
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Thanh Dao
Software Developer
Vietnam Vietnam
I'm still alive...but temporarily moved to work on mobile & web stuffs(j2me/brew/php/flash...something not M$). things have just been very busy, and probably will continue...so don't have chance to maintain & respond. Hope will have time to try to write again, because many ideas with WPF &silver light are waiting. wish me luck Smile | :)
 
FYI:
- MESHSimPack project(c# library for measuring similarity among concepts of the MESH ontology):
http://sourceforge.net/projects/meshsimpack.

| Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 21 Dec 2005
Article Copyright 2005 by Thanh Dao
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid