home *** CD-ROM | disk | FTP | other *** search
- /*=====================================================================
- File: LangMember.cs
-
- Summary: LangMember declares or implements all the functionality
- generic to subclasses. These include returning attributes
- on the member, returning the name of the member, lang-based
- strings such as member attributes, and the declaration
- strings that all members must override.
-
- ---------------------------------------------------------------------
- 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;
-
- public abstract class LangMember
- {
- protected bool m_VarArgs = false;
-
- public LangMember()
- {
- }
-
- /*
- // GetAttributeArray takes an ICustomAttributeProvider, which is implemented by MemberInfo,
- // and returns an array of objects that represent each attribute that is defined on the
- // member.
- */
-
- public virtual Object[] GetAttributeArray( ICustomAttributeProvider MemInfo )
- {
- MemberInfo c_cap;
- try
- {
- c_cap = (MemberInfo)MemInfo;
- }
- catch ( Exception Ex )
- {
- throw new InvalidCastException( "c_cap can't be cast to MemberInfo.", Ex );
- }
- if ( c_cap == null )
- throw new ArgumentException( "MemberInfo passed to GetAttributeArray was null." );
-
- return c_cap.GetCustomAttributes();
- }
-
- /* Remove the comments around this method when possible.
- public bool IsOverridden{
- abstract get;
- }
- */
-
- public virtual bool IsProperty()
- {
- return false;
- }
-
- public virtual bool IsMethod()
- {
- return false;
- }
-
- public virtual bool IsConstructor()
- {
- return false;
- }
-
- public virtual bool IsField()
- {
- return false;
- }
-
- public virtual bool IsEvent()
- {
- return false;
- }
-
- /* ThisType will always be the Type object that implements or defines the member
- // that the caller is currently reflecting upon.
- //
- */
-
- public Type ThisType
- {
- abstract get;
- }
-
- public String Attributes
- {
- abstract get;
- }
-
- public string Name
- {
- abstract get;
- }
-
- public bool VarArgs
- {
- get { return false; } // m_VarArgs; Temporary disable the varargs
- }
-
- /*
- // The <FORMAT>Declaration properties must be overridden by children to return a string that
- // is a valid declaration in the language that the child class represents.
- */
-
- public string TextDeclaration
- {
- virtual get
- {
- throw new NotSupportedException( "TextDeclaration has not yet been implemented on this class." );
- }
- }
-
- public string HTMLDeclaration
- {
- virtual get
- {
- throw new NotSupportedException( "HTMLDeclaration has not yet been implemented on this class." );
- }
- }
-
- public string XMLDeclaration
- {
- virtual get
- {
- throw new NotSupportedException( "XMLDeclaration has not yet been implemented on this class." );
- }
- }
-
- // In here for meteor's use. Remove later.
- protected string MakeXRef( Type ThisType, string LangBasedClassName )
- {
- StringBuilder XREF = new StringBuilder( 200 );
- XREF.Append( "<XRef type=\"" );
- if ( ThisType.IsInterface )
- XREF.Append( "Interface\" " );
- else if ( ThisType.IsValueType )
- XREF.Append( "ValueType\" " );
- else if ( !ThisType.IsInterface && !ThisType.IsValueType )
- XREF.Append( "Class\" " );
- XREF.Append( "name=\"" + ThisType.FullName + "\">" );
- XREF.Append( LangBasedClassName );
- XREF.Append( "</XRef>" );
- return XREF.ToString();
- }
- }
-
- } // namespace LangUtil
-
-