home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / ClsView / NativeConstructorInfo.cs < prev    next >
Encoding:
Text File  |  2000-06-23  |  4.5 KB  |  138 lines

  1. /*=====================================================================
  2.   File:      NativeConstructorInfo.cs
  3.  
  4.   Summary:   For language-neutral reflection information.
  5.  
  6. ---------------------------------------------------------------------
  7.   This file is part of the Microsoft NGWS SDK Code Samples.
  8.  
  9.   Copyright (C) 2000 Microsoft Corporation.  All rights reserved.
  10.  
  11. This source code is intended only as a supplement to Microsoft
  12. Development Tools and/or on-line documentation.  See these other
  13. materials for detailed information regarding Microsoft code samples.
  14.  
  15. THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  16. KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  17. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  18. PARTICULAR PURPOSE.
  19. =====================================================================*/
  20.  
  21. namespace LangUtil {
  22.  
  23. using System;
  24. using System.Text;
  25. using System.Reflection;
  26. using System.Collections;
  27.  
  28.    public class NativeConstructorInfo : LangConstructorInfo
  29.    {
  30.       public NativeConstructorInfo( ConstructorInfo myConstructor ): base( myConstructor )
  31.       {
  32.       }
  33.  
  34.       protected override ArrayList GetParamList( ParameterInfo[] ParamArray )
  35.       {
  36.          ArrayList ParamList = new ArrayList( ParamArray.Length );
  37.          for ( int x = 0; x < ParamArray.Length; x++ )           
  38.          {
  39.             ParamList.Add( new NativeLangType( ParamArray[x] ) );
  40.          }
  41.          return ParamList; 
  42.       }
  43.  
  44.       public ArrayList Parameters
  45.       {
  46.          get { return m_Parameters; }      
  47.       }
  48.  
  49.       public Type ThisType
  50.       {
  51.          override get { return m_ThisType; }
  52.       }
  53.    
  54.       public String Attributes
  55.       {
  56.          override get
  57.          {
  58.             throw new Exception( "NativeConstructorInfo.NativeAttributes is not yet implemented." );
  59.  
  60.          }
  61.       }
  62.  
  63.       public String TextDeclaration
  64.       {
  65.          override get
  66.          {
  67.             StringBuilder Syntax = new StringBuilder( this.Attributes + m_ThisConstructorInfo.ReflectedType.Name + "(" );
  68.             for ( int i = 0; i < m_Parameters.Count; i++ ) 
  69.             { 
  70.                if ( ( (NativeLangType)m_Parameters[i] ).m_IsByRef )
  71.                   Syntax.Append( "ref " );
  72.                Syntax.Append( ( (NativeLangType)m_Parameters[i] ).ClassName );
  73.                Syntax.Append( " " + ( (NativeLangType)m_Parameters[i] ).ParamVarName + "" );
  74.  
  75.                // Writes the comma, or the last break
  76.                if ( i != ( m_Parameters.Count - 1 ) )
  77.                   Syntax.Append( ", " );
  78.             } 
  79.             Syntax.Append( ")" );
  80.             Syntax.Append( ";" );
  81.             return Syntax.ToString();
  82.          }
  83.       }
  84.  
  85.       public String HTMLDeclaration
  86.       {
  87.          override get
  88.          {
  89.             StringBuilder Syntax = new StringBuilder( "<PRE class=\"Syntax\">" );
  90.             Syntax.Append( "<span style=\"color:red\">[CSharp]</span><BR>" );
  91.             
  92.             Syntax.Append( "<B>" );
  93.             Syntax.Append( this.Attributes + m_ThisConstructorInfo.ReflectedType.Name + "(" );
  94.             for ( int i = 0; i < m_Parameters.Count; i++ ) 
  95.             {                
  96.                Syntax.Append( "<BR>    " );
  97.                if ( ( (NativeLangType)m_Parameters[i]).m_IsByRef )
  98.                   Syntax.Append( "ref " );
  99.                Syntax.Append( ( (NativeLangType)m_Parameters[i] ).ClassName );
  100.                Syntax.Append( " <I>" + ((NativeLangType)m_Parameters[i]).ParamVarName + "</I>" );
  101.  
  102.                // Writes the comma, or the last break
  103.                if ( i != ( m_Parameters.Count - 1 ) )
  104.                   Syntax.Append( ", " );
  105.                else 
  106.                   Syntax.Append( "<BR>" );
  107.             } 
  108.             Syntax.Append( ")" );
  109.             Syntax.Append( ";" );
  110.             Syntax.Append( "</B></PRE>" );
  111.          
  112.             return Syntax.ToString();
  113.          }
  114.       }
  115.  
  116.       public VisualBasicConstructorInfo VisualBasicLangObject
  117.       {
  118.          get { return new VisualBasicConstructorInfo( m_ThisConstructorInfo ); }
  119.       }
  120.  
  121.       public CSharpConstructorInfo CSharpLangObject
  122.       {
  123.          get { return new CSharpConstructorInfo( m_ThisConstructorInfo ); }
  124.       }
  125.  
  126.       public MCConstructorInfo MCLangObject
  127.       {
  128.          get { return new MCConstructorInfo( m_ThisConstructorInfo ); }
  129.       }
  130.  
  131.       public override bool IsConstructor()
  132.       {
  133.          return true;
  134.       }
  135.    }
  136.  
  137. } // namespace LangUtil
  138.