1

クラスのいくつかのプロパティを反復処理する次のコードがあります

IEnumerable<CodeProperty> properties = CodeParser.GetEntityProjectItem(this, EntityClassType.Entity).FileCodeModel.GetClassesByName(method.EntityPropertyClassName).First().GetIEnumerable<CodeProperty>().Where(property => property.Getter != null && property.Access == vsCMAccess.vsCMAccessPublic);

これで問題ありません。プロパティを取得します。次に、プロパティの名前とタイプを使用してカスタム クラスを作成します。これも、配列とは別に問題ありません。

文字列プロパティの場合、名前と「System.String」を取得します

string[] プロパティの場合、名前と "" を取得します

CodeProperty を使用して配列型を取得するにはどうすればよいですか

4

1 に答える 1

4

この拡張メソッドを使用して、再び機能するようになりました

 public static string GetFullName(this CodeTypeRef codeType)
        {
            string fullName;

            if (codeType.TypeKind == vsCMTypeRef.vsCMTypeRefArray)
            {
                CodeTypeRef arrayType = codeType.ElementType;
                fullName = arrayType.AsFullName + "[]";
            }
            else
            {
                fullName = codeType.AsFullName;
            }
            return fullName;
        } 
于 2010-08-16T12:36:27.393 に答える