CodeTypeDeclaration
メンバ
コンストラクタ
- public CodeTypeDeclaration();
-
- 概要
- System.CodeDom.CodeTypeDeclaration クラスの新しいインスタンスを初期化します。
- public CodeTypeDeclaration( string name );
-
- 概要
- 指定した名前を使用して、System.CodeDom.CodeTypeDeclaration クラスの新しいインスタンスを初期化します。
- パラメーター
-
- name
- 新しい型の名前。
- 例
-
System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass" ); // public class SampleClass { // }
プロパティ
- public TypeAttributes TypeAttributes{ get; set; }
-
- 概要
- 型の属性を取得または設定します。
- 戻り値
- A System.Reflection.TypeAttributes 型の属性を示すオブジェクト。
- 例
-
全種類1つづつ設定してみた。値が変わってもできあがるソースが変わらないものもある。
System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass001" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.Abstract; // internal abstract class SampleClass001 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass002" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.AnsiClass; // internal class SampleClass002 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass003" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.AutoClass; // internal class SampleClass003 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass004" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.AutoLayout; // internal class SampleClass004 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass005" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.BeforeFieldInit; // internal class SampleClass005 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass006" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.Class; // internal class SampleClass006 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass007" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.ClassSemanticsMask; // internal interface SampleClass007 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass008" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.CustomFormatClass; // internal class SampleClass008 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass009" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.CustomFormatMask; // internal class SampleClass009 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass010" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.ExplicitLayout; // internal class SampleClass010 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass011" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.HasSecurity; // internal class SampleClass011 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass012" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.Import; // internal class SampleClass012 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass013" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.Interface; // internal interface SampleClass013 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass014" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.LayoutMask; // internal class SampleClass014 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass015" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.NestedAssembly; // internal class SampleClass015 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass016" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.NestedFamANDAssem; // internal class SampleClass016 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass017" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.NestedFamily; // protected class SampleClass017 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass018" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.NestedFamORAssem; // protected internal class SampleClass018 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass019" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.NestedPrivate; // private class SampleClass019 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass020" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.NestedPublic; // public class SampleClass020 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass021" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.NotPublic; // internal class SampleClass021 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass022" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.Public; // public class SampleClass022 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass023" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.ReservedMask; // internal class SampleClass023 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass024" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.RTSpecialName; // internal class SampleClass024 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass025" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.Sealed; // internal sealed class SampleClass025 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass026" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.SequentialLayout; // internal class SampleClass026 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass027" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.Serializable; // internal class SampleClass027 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass028" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.SpecialName; // internal class SampleClass028 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass029" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.StringFormatMask; // internal class SampleClass029 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass030" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.UnicodeClass; // internal class SampleClass030 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass031" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.VisibilityMask; // protected internal class SampleClass031 { // } System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass032" ); ctd.TypeAttributes = System.Reflection.TypeAttributes.WindowsRuntime; // internal class SampleClass032 { // }
-
public
CodeTypeReferenceCollection
BaseTypes{ get; }
【 CodeTypeReference 】 -
- 概要
- 型の基本型を取得します。
- 戻り値
- A System.CodeDom.CodeTypeReferenceCollection 型の基本型を示すオブジェクト。
- 例
-
System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleClass" ); ctd.BaseTypes.Add( "SampleClass032" ); // public class SampleClass : SampleClass032 { // }
- public bool IsClass{ get; set; }
-
- 概要
- 型がクラスまたは参照型かどうかを示す値を取得または設定します。
- 戻り値
- true 型がクラスまたは参照型である場合それ以外の場合、 falseです。
- 例
-
System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleIsClass" ); ctd.IsClass = true; // public class SampleIsClass { // }
- public bool IsStruct{ get; set; }
-
- 概要
- 型が値型 (構造体) かどうかを示す値を取得または設定します。
- 戻り値
- true 型が値型である場合それ以外の場合、 falseです。
- 例
-
System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleIsStruct" ); ctd.IsStruct = true; // public struct SampleIsStruct { // }
- public bool IsEnum{ get; set; }
-
- 概要
- 型が列挙体かどうかを示す値を取得または設定します。
- 戻り値
- true 型が列挙体である場合それ以外の場合、 falseです。
- 例
-
System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleIsEnum" ); ctd.IsEnum = true; // public enum SampleIsEnum { // }
- public bool IsInterface{ get; set; }
-
- 概要
- 型がインターフェイスかどうかを示す値を取得または設定します。
- 戻り値
- true 型がインターフェイスである場合それ以外の場合、 falseです。
- 例
-
System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleIsInterface" ); ctd.IsInterface = true; // public interface SampleIsInterface { // }
- public bool IsPartial{ get; set; }
-
- 概要
- 型宣言が完全か部分的かを示す値を取得または設定します。
- 戻り値
- true クラスまたは構造体の宣言が、実装の部分的な表現である場合 false 宣言がクラスまたは構造体の完全な実装である場合。 既定値は、false です。
- 例
-
System.CodeDom.CodeTypeDeclaration ctd = new System.CodeDom.CodeTypeDeclaration( "SampleIsPartial" ); ctd.IsPartial = true; // public partial class SampleIsPartial { // }
-
public
CodeTypeMemberCollection
Members{ get; }
【 CodeTypeMember 】 -
- 概要
- 表される型のクラス メンバーのコレクションを取得します。
- 戻り値
- A System.CodeDom.CodeTypeMemberCollection クラスのメンバーを示すオブジェクト。
-
[ComVisible( false )]
public CodeTypeParameterCollection TypeParameters{ get; }
【 CodeTypeParameter 】 -
- 概要
- 型宣言の型パラメーターを取得します。
- 戻り値
- A System.CodeDom.CodeTypeParameterCollection 型宣言の型パラメーターを格納します。
- Name
- メンバーの名前を取得または設定します。 (Inherited from CodeTypeMember )
- Comments
- 型メンバーのコメント コレクションを取得します。 (Inherited from CodeTypeMember )
- Attributes
- メンバーの属性を取得または設定します。 (Inherited from CodeTypeMember )
- CustomAttributes
- メンバーのカスタム属性を取得または設定します。 (Inherited from CodeTypeMember )
- StartDirectives
- メンバーの開始ディレクティブを取得します。 (Inherited from CodeTypeMember )
- EndDirectives
- メンバーの終了ディレクティブを取得します。 (Inherited from CodeTypeMember )
- LinePragma
- 型メンバーのステートメントが発生する行を取得または設定します。 (Inherited from CodeTypeMember )
- UserData
- 現在のオブジェクトのユーザー定義可能なデータを取得します。 (Inherited from CodeObject )
メソッド
- Equals(Object)
- 指定したオブジェクトが、現在のオブジェクトと等しいかどうかを判断します。 (Inherited from Object)
- GetHashCode()
- 既定のハッシュ関数として機能します。 (Inherited from Object)
- GetType()
- 現在のインスタンスの Type を取得します。 (Inherited from Object)
- MemberwiseClone()
- 現在の Object の簡易コピーを作成します。 (Inherited from Object)
- ToString()
- 現在のオブジェクトを表す文字列を返します。 (Inherited from Object)
イベント
- public event EventHandler PopulateBaseTypes;
-
- 概要
- System.CodeDom.CodeTypeDeclaration.BaseTypes コレクションが最初にアクセスされたときに発生します。
- public event EventHandler PopulateMembers;
-
- 概要
- System.CodeDom.CodeTypeDeclaration.Members コレクションが最初にアクセスされたときに発生します。
例
この例では、CodeTypeDeclaration型を宣言します。
// Creates a new type declaration.
// 新しい型宣言を作成する。
CodeTypeDeclaration newType =
new CodeTypeDeclaration(
// name parameter indicates the name of the type.
// 名前パラメータはタイプの名前を示す。
"TestType"
);
// Sets the member attributes for the type to private.
// セット タイプ に 秘密 のためのメンバー属性 。
newType.Attributes = MemberAttributes.Private;
// Sets a base class which the type inherits from.
// セット タイプがそれから引き継ぐベースクラス 。
newType.BaseTypes.Add( "BaseType" );
// A C# code generator produces the following source code for the preceeding example code:
// A C#コードジェネレータはpreceeding例コードのための以下のソースコードを作り出す:
// class TestType : BaseType
// {
// }
定義
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeTypeDeclaration : System.CodeDom.CodeTypeMember
クラス
#region アセンブリ System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// C:¥Program Files (x86)¥Reference Assemblies¥Microsoft¥Framework¥.NETFramework¥v4.6.1¥System.dll
#endregion
using System.Reflection;
using System.Runtime.InteropServices;
namespace System.CodeDom
{
//
// 概要:
// クラス、構造体、インターフェイス、または列挙型宣言を表します。
[ClassInterface( ClassInterfaceType.AutoDispatch )]
[ComVisible( true )]
public class CodeTypeDeclaration : CodeTypeMember
{
//
// 概要:
// System.CodeDom.CodeTypeDeclaration クラスの新しいインスタンスを初期化します。
public CodeTypeDeclaration();
//
// 概要:
// 指定した名前を使用して、System.CodeDom.CodeTypeDeclaration クラスの新しいインスタンスを初期化します。
//
// パラメーター:
// name:
// 新しい型の名前。
public CodeTypeDeclaration( string name );
//
// 概要:
// 取得または型の属性を設定します。
//
// 戻り値:
// A System.Reflection.TypeAttributes 型の属性を示すオブジェクト。
public TypeAttributes TypeAttributes
{
get;
set;
}
//
// 概要:
// 型の基本型を取得します。
//
// 戻り値:
// A System.CodeDom.CodeTypeReferenceCollection 型の基本型を示すオブジェクト。
public CodeTypeReferenceCollection BaseTypes
{
get;
}
//
// 概要:
// 取得または型がクラスまたは参照型であるかどうかを示す値を設定します。
//
// 戻り値:
// true 型がクラスまたは参照型である場合それ以外の場合、 falseです。
public bool IsClass
{
get;
set;
}
//
// 概要:
// 取得または型が値型 (struct) かどうかを示す値を設定します。
//
// 戻り値:
// true 型が値型である場合それ以外の場合、 falseです。
public bool IsStruct
{
get;
set;
}
//
// 概要:
// 取得または型が列挙体であるかどうかを示す値を設定します。
//
// 戻り値:
// true 型が列挙体である場合それ以外の場合、 falseです。
public bool IsEnum
{
get;
set;
}
//
// 概要:
// 取得または型がインターフェイスであるかどうかを示す値を設定します。
//
// 戻り値:
// true 型がインターフェイスである場合それ以外の場合、 falseです。
public bool IsInterface
{
get;
set;
}
//
// 概要:
// 取得または型の宣言が完全または部分的なのかどうかを示す値を設定します。
//
// 戻り値:
// true クラスまたは構造体の宣言が、実装の部分的な表現である場合 false 宣言がクラスまたは構造体の完全な実装である場合。 既定値は、false です。
public bool IsPartial
{
get;
set;
}
//
// 概要:
// 表される型のクラス メンバーのコレクションを取得します。
//
// 戻り値:
// A System.CodeDom.CodeTypeMemberCollection クラスのメンバーを示すオブジェクト。
public CodeTypeMemberCollection Members
{
get;
}
//
// 概要:
// 型宣言の型パラメーターを取得します。
//
// 戻り値:
// A System.CodeDom.CodeTypeParameterCollection 型宣言の型パラメーターを格納します。
[ComVisible( false )]
public CodeTypeParameterCollection TypeParameters
{
get;
}
//
// 概要:
// 発生したときに、 System.CodeDom.CodeTypeDeclaration.BaseTypes コレクションには、最初にアクセスします。
public event EventHandler PopulateBaseTypes;
//
// 概要:
// 発生したときに、 System.CodeDom.CodeTypeDeclaration.Members コレクションには、最初にアクセスします。
public event EventHandler PopulateMembers;
}
}