home *** CD-ROM | disk | FTP | other *** search
Wrap
<% /*===================================================================== File: Member.aspx Summary: --------------------------------------------------------------------- This file is part of the Microsoft NGWS SDK Code Samples. Copyright (C) 2000 Microsoft Corporation. All rights reserved. This source code is intended only as a supplement to Microsoft Development Tools and/or on-line documentation. See these other materials for detailed information regarding Microsoft code samples. THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. =====================================================================*/ %> <%@ Page Language="C#"%> <%@ Assembly Name="System.Data.dll" %> <%@ Import Namespace="System.Data.XML"%> <%@ Import Namespace="System.Data.XML.DOM"%> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Reflection"%> <%@ Import Namespace="System.Collections"%> <%@ Import Namespace="System.IO"%> <%@ Import Namespace="System.Threading" %> <%@ Import Namespace="System.Text" %> <%@ Import Namespace="LangUtil" %> <Script runat=server> public String[] Descriptions = null; public Object TypeDetails = null; public String MemberName = ""; public String ClassName = ""; public String MemberType = ""; public String Description = ""; public String ContentVersion = ""; public String DocBuildTimestamp = ""; public Type[] Hierarchy = null; public Type ThisType = null; public NativeLangType ThisLangType = null; public System.Collections.ArrayList MyCurrentFields = new System.Collections.ArrayList(); public System.Collections.ArrayList MyCurrentEvents = new System.Collections.ArrayList(); public System.Collections.ArrayList MyCurrentMethods = new System.Collections.ArrayList(); public System.Collections.ArrayList MyCurrentProperties = new System.Collections.ArrayList(); public System.Collections.ArrayList MyCurrentConstructors = new System.Collections.ArrayList(); public System.Collections.ArrayList TheseMIs = new System.Collections.ArrayList(); public static String ClassViewPath = String.Empty; /******************************************************* Description GetDescriptionFromXML(Type myClass, System.Collections.ArrayList TheseMembers) This method takes a Type for the class and an System.Collections.ArrayList of MemberInfos that represent the member Types for the name of the member requested. If ThisMember is null, the function returns the description for the class. If ThisMember is an System.Collections.ArrayList of MemberInfos, then it should return the member info of the particular Member description. *******************************************************/ public String GetMemberDescriptionFromXML(Type myClass, String hash){ String Description = String.Format("<pre>This member resides in {0}</pre>", Assembly.GetAssembly(myClass).GetName()); /* This method will retrieve content from an XML file. The sample does not currently contain such content. int last = myClass.FullName.LastIndexOf("."); // Only build documentation for classes inside namespaces. if (last != -1) { String myPath = GetUEPath(myClass.FullName); if (!(File.FileExists(myPath))) Description = Description + "CONTENT NOT AVAILABLE.</pre>"; else{ XmlDocument XMLData = new XmlDocument(); // XmlDocuments require an XmlReader to load if you don't have a DataSet. // load the XmlReader for this file XMLData.Load(new XmlReader(myPath)); IDocument XMLdoc = XMLData.DomDocument; // to make sure there are no problems with loading files Monitor.Enter(XMLdoc); try { try { XMLdoc.load(myPath); Description = Description + "Content Updated " + XMLdoc.documentElement.attributes.getNamedItem("timestamp").nodeValue + ".</pre>"; INodeList Members = XMLdoc.documentElement.getElementsByTagName("MEMBER"); Description = Description + GetDescriptionFromMemberID(Members, hash); } catch(Exception e) { // if there was a parsing error. Description = Description + "CONTENT NOT AVAILABLE.</pre>"; } } finally { Monitor.Exit(XMLdoc); } } } */ return Description; } /******************************************************************************************* GetPath takes a string and returns a string for the path to the descriptive content. *******************************************************************************************/ public static String GetUEPath(String TempName){ int index; // reinsert when you decide how this is going to work. //String systemDrive = Runtime.GetEnvironmentVariable("SYSTEMDRIVE"); String systemDrive = "d:"; StringBuilder myPath = new StringBuilder(ClassViewPath); while ((index = TempName.IndexOf(".")) != -1){ myPath.Append("\\" + TempName.Substring(0, index)); TempName = TempName.Remove(0, index + 1); } myPath.Append("\\" + TempName + ".xml"); return myPath.ToString(); } /****************************************************** GetDescriptionFromMemberID(INodeList Members, String hash); ******************************************************/ public static String GetDescriptionFromMemberID(INodeList Members, String hash){ for (int i = 0; i < Members.length; ++i) { INode ThisMemberIDAttribute = Members.item(i).attributes.getNamedItem("memberid"); if (ThisMemberIDAttribute == null) return "There is an error. The MEMBERS elements must contain a memberid attribute, but this one does not:" + hash; else if (String.Equals(ThisMemberIDAttribute.text, hash)){ INodeList MemberElements = Members.item(i).childNodes; for (int j = 0; j < MemberElements.length; ++j){ if (String.Equals(MemberElements.item(j).nodeName, "DESCRIPTION")){ return MemberElements.item(j).text; } else continue; } } } return "Cannot find a description for this member. The documentation may not <BR>describe this particular build of the assembly. The ID used to find it was " + hash; } /************************************************* MakeClassLink takes a DataTypeDetails and a string and returns a string that represents an HREF for a class in a particular language and in metadata format if lang is null. TBD: Right now returns only native. **************************************************/ public String MakeClassLink(NativeLangType NatLangType, bool FullName){ StringBuilder link = new StringBuilder("<A HREF=\"Browser.aspx?class="); link.Append(NatLangType.FullClassName); link.Append("\" Title=\""); link.Append(NatLangType.FullClassName); link.Append("\">"); if (FullName) link.Append(NatLangType.FullClassName); else link.Append(NatLangType.ClassName); link.Append("</A>"); return link.ToString(); return NatLangType.FullClassName; } /********************************************************************************************** This function takes an System.Collections.ArrayList of either method, constructor, property, or field infos, along with a string for the type, and returns an array of strings containing the descriptions in the order that the System.Collections.ArrayList was passed. Can only be called with an array of MXXinfos, so this function is not how Browser is built. ***********************************************************************************************/ public String[] GetDescriptions(Type ThisType, System.Collections.ArrayList TheseMIs, String TypeofMember) { String[] tempDescriptions = new String[TheseMIs.Count]; MemberInfo tempMI = null; for (int i = 0; i < TheseMIs.Count; ++i){ tempMI = (MemberInfo)TheseMIs[i]; tempDescriptions[i] = GetMemberDescriptionFromXML(ThisType, Util.GetHKey(tempMI)); } return tempDescriptions; } /********************************************************************************************** PluralTypesGetShortNameTypeInsensitive ***********************************************************************************************/ public Type PluralTypesGetShortNameTypeInsensitive(String ClassName, TextWriter OutWriter){ System.Collections.ArrayList Assemblies = new System.Collections.ArrayList(); { Assemblies.Add(Assembly.Load("CustomMarshalers.dll")); Assemblies.Add(Assembly.Load("iiehost.dll")); Assemblies.Add(Assembly.Load("ISymWrapper.dll")); Assemblies.Add(Assembly.Load("MngdIST.dll")); Assemblies.Add(Assembly.Load("mscorlib.dll")); Assemblies.Add(Assembly.Load("System.ASP.dll")); Assemblies.Add(Assembly.Load("System.ASP.WebForms.Design.dll")); Assemblies.Add(Assembly.Load("System.ASP.WebForms.DLL")); Assemblies.Add(Assembly.Load("System.ComponentModel.Design.DLL")); Assemblies.Add(Assembly.Load("system.config.dll")); Assemblies.Add(Assembly.Load("system.config.objects.dll")); Assemblies.Add(Assembly.Load("System.Configuration.Design.DLL")); Assemblies.Add(Assembly.Load("System.Configuration.DLL")); Assemblies.Add(Assembly.Load("System.Core.DLL")); Assemblies.Add(Assembly.Load("System.Data.Adapter.Design.DLL")); Assemblies.Add(Assembly.Load("System.Data.Adapter.IndexServer.Design.DLL")); Assemblies.Add(Assembly.Load("System.Data.Design.DLL")); Assemblies.Add(Assembly.Load("System.Data.dll")); Assemblies.Add(Assembly.Load("System.Deprecated.DLL")); Assemblies.Add(Assembly.Load("System.DirectoryServices.DLL")); Assemblies.Add(Assembly.Load("system.drawing.design.dll")); Assemblies.Add(Assembly.Load("system.drawing.dll")); Assemblies.Add(Assembly.Load("System.Interop.DLL")); Assemblies.Add(Assembly.Load("System.IO.DLL")); Assemblies.Add(Assembly.Load("System.Messaging.MessageQueue.dll")); Assemblies.Add(Assembly.Load("System.Monitoring.Design.DLL")); Assemblies.Add(Assembly.Load("System.Monitoring.DLL")); Assemblies.Add(Assembly.Load("System.Net.dll")); Assemblies.Add(Assembly.Load("System.NTServices.DLL")); Assemblies.Add(Assembly.Load("System.RegularExpressions.dll")); Assemblies.Add(Assembly.Load("System.Serialization.Formatters.Soap.dll")); Assemblies.Add(Assembly.Load("System.SQLTypes.dll")); Assemblies.Add(Assembly.Load("System.Timers.Design.DLL")); Assemblies.Add(Assembly.Load("System.Timers.DLL")); Assemblies.Add(Assembly.Load("System.WebServices.Design.DLL")); Assemblies.Add(Assembly.Load("System.WebServices.DLL")); Assemblies.Add(Assembly.Load("System.WinForms.Design.DLL")); Assemblies.Add(Assembly.Load("System.WinForms.DLL")); Assemblies.Add(Assembly.Load("System.WinForms.Printing.Design.DLL")); Assemblies.Add(Assembly.Load("System.xml.dll")); Assemblies.Add(Assembly.Load("W3C.DOM.dll")); Assemblies.Add(Assembly.Load("msvbalib.dll")); Assemblies.Add(Assembly.Load("LangUtil.dll")); }; Type ThisType = null; Module ThisMod = null; Module[] TheseModules; bool FoundTypes = false; int iNumFoundTypes = 0; Type[] CurrentModTypes = null; System.Collections.ArrayList TypeLinkStrings = new System.Collections.ArrayList(); for (int i = 0; i < Assemblies.Count; ++i){ try{ TheseModules = ((Assembly)Assemblies[i]).GetModules(); if (TheseModules == null) continue; else{ for (int j = 0; j < TheseModules.Length; ++j){ CurrentModTypes = TheseModules[j].GetTypes(); for (int iTypeCount = 0; iTypeCount < CurrentModTypes.Length; ++iTypeCount){ if (CurrentModTypes[iTypeCount] != null && CurrentModTypes[iTypeCount].IsPublic && (String.Compare(CurrentModTypes[iTypeCount].Name, ClassName, true) == 0) ){ ++iNumFoundTypes; ThisType = CurrentModTypes[iTypeCount]; if (!FoundTypes){ FoundTypes = true; } TypeLinkStrings.Add(MakeClassLink(new NativeLangType(CurrentModTypes[iTypeCount]), true) + "<BR>"); } } } } } catch(Exception Ex){ continue; } } if (TypeLinkStrings.Count != 1){ OutWriter.WriteLine("The following classes were found: <BR>"); for (int iLinkCount = 0; iLinkCount < TypeLinkStrings.Count; ++iLinkCount) OutWriter.WriteLine((String)TypeLinkStrings[iLinkCount]); } return ThisType; } private Module mod = null; /*********************************************************************************************** Use Page_Load as the main for the Web request. ***********************************************************************************************/ void Page_Load(Object sender, EventArgs EvArgs){ // Determine path of this application ClassViewPath = Request.PhysicalApplicationPath; ClassViewPath = ClassViewPath.Remove(ClassViewPath.LastIndexOf('\\'), 1); // Obtain metainformation ClassName = Request.QueryString["class"]; MemberName = Request.QueryString["member"]; MemberType = Request.QueryString["type"]; try{ ThisType = Type.GetType(ClassName); if (ThisType == null) throw new TypeLoadException(String.Format("Unable to load {0}.", ClassName)); if (MemberType == null) throw new NullReferenceException("The type parameter within the query string cannot be null."); if (MemberName == null) throw new NullReferenceException("The member parameter within the query string cannot be null."); if ( !(MemberType.Equals("method") || MemberType.Equals("constructor") || MemberType.Equals("property") || MemberType.Equals("field") ) ) throw new ArgumentException("The value of the type parameter within the query string is invalid."); } catch(Exception e){ Response.Write(String.Format("<p>Unable to load {0}&member={1}&type={2}. Is the spelling and case correct?</p>", ClassName, MemberName, MemberType)); ClassName = "System.Object"; MemberName = "ToString"; MemberType = "method"; ThisType = Type.GetType("System.Object"); } ThisLangType = new NativeLangType(ThisType); if (MemberType.Equals("constructor")){ // Obtain Class Constructor Details for (int x=0; x < ThisLangType.OrderedConstructors.Length; x++) { NativeConstructorInfo temp = new NativeConstructorInfo(ThisLangType.OrderedConstructors[x]); if (String.Equals((ThisLangType.OrderedConstructors[x]).Name, MemberName)){ TheseMIs.Add(ThisLangType.OrderedConstructors[x]); MyCurrentConstructors.Add(temp); } } Descriptions = GetDescriptions(ThisType, TheseMIs, MemberType); } else if(MemberType.Equals("property")){ // Obtain Class Property Details for (int x=0; x < ThisLangType.OrderedProperties.Length; x++){ NativePropertyInfo temp = new NativePropertyInfo(ThisLangType.OrderedProperties[x]); if (String.Equals(temp.Name, MemberName)){ TheseMIs.Add(ThisLangType.OrderedProperties[x]); MyCurrentProperties.Add(temp); } } Descriptions = GetDescriptions(ThisType, TheseMIs, MemberType); } else if(MemberType.Equals("method")){ // Obtain Class Method Details for (int x=0; x < ThisLangType.OrderedMethods.Length; x++) { NativeMethodInfo temp = new NativeMethodInfo(ThisLangType.OrderedMethods[x]); // if names match, add to overloaded System.Collections.ArrayList. if (MemberName.Equals(temp.Name)){ TheseMIs.Add(ThisLangType.OrderedMethods[x]); MyCurrentMethods.Add(temp); } } Descriptions = GetDescriptions(ThisType, TheseMIs, MemberType); } else if (MemberType.Equals("field")){ // Obtain Class Field Details for (int x=0; x < ThisLangType.OrderedFields.Length; x++){ NativeFieldInfo temp = new NativeFieldInfo(ThisLangType.OrderedFields[x]); // if names match, add to overloaded System.Collections.ArrayList. if (String.Equals(temp.Name, MemberName)){ TheseMIs.Add(ThisLangType.OrderedFields[x]); MyCurrentFields.Add(temp); } } Descriptions = GetDescriptions(ThisType, TheseMIs, MemberType); } else { // Obtain Class Events Details for (int x=0; x < ThisLangType.OrderedEvents.Length; x++){ NativeEventInfo temp = new NativeEventInfo(ThisLangType.OrderedEvents[x]); // if names match, add to overloaded System.Collections.ArrayList. if (String.Equals(temp.Name, MemberName)){ TheseMIs.Add(ThisLangType.OrderedEvents[x]); MyCurrentEvents.Add(temp); } } Descriptions = GetDescriptions(ThisType, TheseMIs, MemberType); } } //END OF Load </Script> <HTML> <HEAD> <style type="text/css"> @import url(backSDK4.css); </style> <Title>ClassView: Microsoft NGWS SDK version <%=String.Empty%></Title> </HEAD> <Body> <H2><A Title="<%=ThisType.FullName%>" HREF="Browser.aspx?class=<%=ThisType.FullName%>"><%=ThisType.FullName%></A>.<% if (String.Equals(MemberName, ".ctor")) {Response.Write(ThisType.Name);} else Response.Write(MemberName); Response.Write(" " + MemberType);%></H2> <%=Description%> <!-- START OF REF PAGE METADATA --> <% if (MemberType.Equals("constructor")) { for (int i = 0; i < MyCurrentConstructors.Count; ++i) { %> <% NativeConstructorInfo temp = (NativeConstructorInfo)MyCurrentConstructors[i]; %> <%=temp.VisualBasicLangObject.HTMLDeclaration%> <%=temp.MCLangObject.HTMLDeclaration%> <%=temp.CSharpLangObject.HTMLDeclaration%> <HR style="color:blue"> <% } %> <% } // end constructor loop else if (String.Equals(MemberType, "method")){ for (int i = 0; i < MyCurrentMethods.Count; ++i) { %> <% NativeMethodInfo temp = (NativeMethodInfo)MyCurrentMethods[i]; %> <% if (i == 0) { ; } %> <%=temp.VisualBasicLangObject.HTMLDeclaration%> <%=temp.MCLangObject.HTMLDeclaration%> <%=temp.CSharpLangObject.HTMLDeclaration%> <HR style="color:blue"> <% } %> <% } else if (String.Equals(MemberType, "property")){ for (int i = 0; i < MyCurrentProperties.Count; ++i) { %> <% if (i == 0) { ; } %> <%if (MyCurrentProperties.Count != 1){ } %> <% if (i == MyCurrentProperties.Count - 1) { Response.Write(""); } %> <%=((NativePropertyInfo)MyCurrentProperties[i]).VisualBasicLangObject.HTMLDeclaration%> <%=((NativePropertyInfo)MyCurrentProperties[i]).MCLangObject.HTMLDeclaration%> <%=((NativePropertyInfo)MyCurrentProperties[i]).CSharpLangObject.HTMLDeclaration%> <HR style="color:blue"> <% } %> <% } else if (MemberType.Equals("field")){ for (int i = 0; i < MyCurrentFields.Count; ++i){ %> <%=((NativeFieldInfo)MyCurrentFields[i]).VisualBasicLangObject.HTMLDeclaration%> <%=((NativeFieldInfo)MyCurrentFields[i]).MCLangObject.HTMLDeclaration%> <%=((NativeFieldInfo)MyCurrentFields[i]).CSharpLangObject.HTMLDeclaration%> <% } } else { for (int i = 0; i < MyCurrentEvents.Count; ++i){ %> <%=((NativeEventInfo)MyCurrentEvents[i]).VisualBasicLangObject.HTMLDeclaration%> <%=((NativeEventInfo)MyCurrentEvents[i]).MCLangObject.HTMLDeclaration%> <%=((NativeEventInfo)MyCurrentEvents[i]).CSharpLangObject.HTMLDeclaration%> <% } } %> <!-- END OF THE REF PAGE METADATA --> </Body> </HTML>