home *** CD-ROM | disk | FTP | other *** search
- /*=====================================================================
- File: CSharpConstructorInfo.cs
-
- Summary: Brief summary of the file contents and purpose.
-
- ---------------------------------------------------------------------
- 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.
- =====================================================================*/
-
- namespace LangUtil {
-
- using System;
- using System.Text;
- using System.Reflection;
- using System.Collections;
-
- public class CSharpConstructorInfo : LangConstructorInfo
- {
- public CSharpConstructorInfo( ConstructorInfo myConstructor ): base( myConstructor )
- {
- }
-
- protected override ArrayList GetParamList( ParameterInfo[] ParamArray )
- {
- ArrayList ParamList = new ArrayList( ParamArray.Length );
- for ( int x = 0; x < ParamArray.Length; x++ )
- {
- ParamList.Add( new CSharpLangType( ParamArray[x] ) );
- }
- return ParamList;
- }
-
- public Type ThisType
- {
- override get
- {
- return m_ThisType;
- }
- }
-
- public String Attributes
- {
- override get
- {
- StringBuilder sb = new StringBuilder();
-
- if ( m_ThisConstructorInfo.IsPublic )
- sb.Append( "public " );
- else if ( m_ThisConstructorInfo.IsPrivate )
- sb.Append( "private " );
- else if ( m_ThisConstructorInfo.IsFamily )
- sb.Append( "protected " );
- else if ( m_ThisConstructorInfo.IsAssembly )
- sb.Append( "internal " );
- else if ( m_ThisConstructorInfo.IsFamilyAndAssembly )
- sb.Append( "FamilyAndAssembly " );
- else if ( m_ThisConstructorInfo.IsFamilyOrAssembly )
- sb.Append( "FamilyOrAssembly " );
-
- // This information is implicit in interfaces....
-
- if ( !m_ThisConstructorInfo.DeclaringType.IsInterface )
- {
- if ( m_ThisConstructorInfo.IsAbstract )
- sb.Append( "abstract " );
- if ( m_ThisConstructorInfo.IsVirtual && !m_ThisConstructorInfo.IsAbstract )
- {
- ParameterInfo[] p = m_ThisConstructorInfo.GetParameters();
- Type[] param_types = new Type[p.Length];
- for ( int i = 0; i < param_types.Length; i++ )
- {
- param_types[i] = p[i].ParameterType;
- }
-
- Type superClass = m_ThisConstructorInfo.ReflectedType.BaseType;
-
- MethodInfo baseImpl = ( superClass == null ) ? null :
- superClass.GetMethod( m_ThisConstructorInfo.Name, param_types );
-
- if ( baseImpl == null )
- {
- sb.Append( "virtual " );
- }
- else if ( m_ThisConstructorInfo.DeclaringType == m_ThisConstructorInfo.ReflectedType )
- {
- sb.Append( "override " );
- }
- }
- }
- if ( m_ThisConstructorInfo.IsStatic )
- sb.Append ( "static " );
- return sb.ToString();
- }
- }
-
- public String ShortTextDeclaration
- {
- get
- {
- StringBuilder Syntax = new StringBuilder( m_ThisConstructorInfo.ReflectedType.Name + "(" );
- for ( int i = 0; i < m_Parameters.Count; i++ )
- {
- Syntax.Append( ( (CSharpLangType)m_Parameters[i] ).ClassName );
- if ( ( (CSharpLangType)m_Parameters[i] ).IsRealArray )
- Syntax.Append( "[]" );
-
- // writes the comma, or the last break.
- if ( i != ( m_Parameters.Count - 1 ) )
- Syntax.Append( ", " );
- }
- Syntax.Append( ")" );
- return Syntax.ToString();
- }
- }
-
- public String TextDeclaration
- {
- override get
- {
- StringBuilder Syntax = new StringBuilder( Attributes + m_ThisConstructorInfo.ReflectedType.Name + "(" );
- for ( int i = 0; i < m_Parameters.Count; i++ )
- {
- if ( ((CSharpLangType)m_Parameters[i]).m_IsByRef )
- Syntax.Append( "ref " );
- Syntax.Append( ((CSharpLangType)m_Parameters[i]).ClassName );
- if ( ((CSharpLangType)m_Parameters[i]).IsRealArray )
- Syntax.Append( "[]" );
-
- Syntax.Append( " " + ((CSharpLangType)m_Parameters[i]).ParamVarName );
-
- // writes the comma, or the last break.
- if ( i != ( m_Parameters.Count - 1 ) )
- Syntax.Append( ", " );
- }
- Syntax.Append( ")" );
- Syntax.Append( ";" );
- return Syntax.ToString();
- }
- }
-
- public String HTMLDeclaration
- {
- override get
- {
- StringBuilder Syntax = new StringBuilder( "<PRE class=\"Syntax\">" );
- Syntax.Append( "<span style=\"color:red\">[CSharp]</span><BR/>" );
-
- Syntax.Append( "<B>" );
- Syntax.Append( Attributes + m_ThisConstructorInfo.ReflectedType.Name + "(" );
- for ( int i = 0; i < m_Parameters.Count; i++ )
- {
- Syntax.Append( "<BR/> " );
- if ( ( (CSharpLangType)m_Parameters[i] ).m_IsByRef )
- Syntax.Append( "ref " );
- Syntax.Append( ( (CSharpLangType)m_Parameters[i] ).ClassName );
- if ( ( (CSharpLangType)m_Parameters[i] ).IsRealArray )
- Syntax.Append( "[]" );
-
- Syntax.Append( " <I>" + ( (CSharpLangType)m_Parameters[i] ).ParamVarName + "</I>" );
-
- // Writes the comma, or the last break
- if ( i != ( m_Parameters.Count - 1 ) )
- Syntax.Append( ", " );
- else
- {
- Syntax.Append( "<BR/>" );
- }
- }
- Syntax.Append( ")" );
- Syntax.Append( ";" );
- Syntax.Append( "</B></PRE>" );
-
- return Syntax.ToString();
- }
- }
-
- public String Name
- {
- override get { return m_Name; }
- }
- }
-
- } // namespace LangUtil
-