CodeTypeDeclaration.cs :  » Development » devAdvantage » AnticipatingMinds » Genesis » CodeDOM » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » devAdvantage 
devAdvantage » AnticipatingMinds » Genesis » CodeDOM » CodeTypeDeclaration.cs
using System;

namespace AnticipatingMinds.Genesis.CodeDOM{
  /// <summary>
  /// Base type for all type declarations.
  /// </summary>
  /// <remarks>A type-declaration is a class-declaration (17.1), 
  /// a struct-declaration (18.1), an interface-declaration  (20.1), 
  /// an enum-declaration (21.1), or a delegate-declaration (22.1). 12
  /// </remarks>
  /// <remarks>ECMA 334 - p. 209, line 10.</remarks>
  /// <remarks>ECMA 335 - p. 40, line 38 and bellow.</remarks>
  [Serializable]
  public abstract class CodeTypeDeclaration : CodeElement
  {
    /// <summary>
    /// Represents type declaration modifiers.
    /// </summary>
    [Flags]
    public enum TypeDeclarationModifiers
    {
      /// <summary>
      /// Type hides an inherited class.
      /// </summary>
      New = 0x1,
      /// <summary>
      /// Abstract class.
      /// </summary>
      Abstract = 0x2,
      /// <summary>
      /// Type is sealed.
      /// </summary>
      Sealed = 0x4,
      /// <summary>
      /// Public type accessability.
      /// </summary>
      Public = 0x8,
      /// <summary>
      /// Family type accessability
      /// </summary>
      Family = 0x10,
      /// <summary>
      /// Private type accessability.
      /// </summary>
      Private = 0x20,
      /// <summary>
      /// Assembly accessability (Internal)
      /// </summary>
      Assembly = 0x40,
      /// <summary>
      /// Family &amp; assembly accessabilty (internal protected in C#)
      /// </summary>
      FamilyAndAssembly = 0x80,
      /// <summary>
      /// Family or assembly accessability (not supported in C#)
      /// </summary>
      FamilyOrAssembly = 0x100,
      /// <summary>
      /// 
      /// </summary>
      Unsafe = 0x200
    }
    
    /// <summary>
    /// Initializes new instance of <see cref="CodeTypeDeclaration"/> class.
    /// </summary>
    protected CodeTypeDeclaration()
    {
    }
    
    /// <summary>
    /// Reference to a namespace that declared this type.
    /// </summary>
    public CodeNamespace DeclaringNamespace
    {
      get
      {
        return Parent as CodeNamespace;
      }
    }
    
    /// <summary>
    /// Type declaration attributes.
    /// </summary>
    public CodeAttributeCollection Attributes
    {
      get
      {
        return attributes;
      }
    }

    /// <summary>
    /// Type declaration modifiers.
    /// </summary>
    public TypeDeclarationModifiers Modifiers
    {
      get
      {
        return modifiers;
      }
      set
      {
        modifiers = value;
      }
    }

    /// <summary>
    /// Declaring type if declartion is nested.
    /// </summary>
    public CodeTypeDeclaration DeclaringType 
    {
      get
      {
        return Parent as CodeTypeDeclaration;
      }
    }

    /// <summary>
    /// Type name
    /// </summary>
    public string Name
    {
      get
      {
        return name;
      }
      set
      {
        name= (value == null ? string.Empty:value);
      }
    }

    /// <summary>
    /// Gets type full name.
    /// </summary>
    public string FullName
    {
      get
      {
        if(DeclaringType != null)
          return DeclaringType.FullName.Length != 0 ? (DeclaringType.FullName + "." + Name) : Name;

        if(DeclaringNamespace != null)
          return DeclaringNamespace.FullName.Length != 0 ? (DeclaringNamespace.FullName + "." + Name) : Name;

        return Name;
      }
    }
      
    
    /// <summary>
    /// Gets code metadata type information if available.
    /// </summary>
    public CodeTypeInfo TypeInfo
    {
      get
      {
        if(CompileUnit == null || CompileUnit.Assembly == null)
          return null;
        else
          return CompileUnit.Assembly.TypeManager.FindType(FullName);
      }
    }

    /// <summary>
    /// Determines if the declared type is sublass of another type.
    /// </summary>
    /// <param name="baseTypeName"></param>
    /// <returns></returns>
    public bool IsSubclassOf(string baseTypeName)
    {
      return GetAssemblyTypeManager().IsTypeSubclassOf(FullName,baseTypeName);
    }
    private CodeAttributeCollection attributes = new CodeAttributeCollection();
    private TypeDeclarationModifiers modifiers = 0;
    private string name;
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.