簡體   English   中英

如何在接口c#中獲取屬性的類型

[英]How to get types of an attribute in an interface c#

使用Enterprise Architect(EA)的加載項我需要獲得Test在EA中可以擁有的所有不同類型。

我的意思是EA命名空間中的Test類繼承自IDualTest接口,該接口具有名為“Type”的字符串屬性的get / set方法。 標准EA有3種不同的類型(標准,回歸,加載),但可以添加自己的類型。 我需要得到所有這些類型。

我相信這是可能的反射,但這不是我最強的網站,所以我真的可以在這里使用一些幫助。 如果需要更多信息,請評論。

編輯:

我有以下代碼:

List<string> typeList = new List<string>();

            foreach (string type in Test.Types)
            {
                typeList.Add(type);
            }

上面的代碼不可編譯,但我希望它能說明我的需求。

 foreach (Test t in elm.Tests)
        {
            string type = t.Type; //It is this type that can be the standards from EA and your own added types
        }

// - 輸出

//標准

//回歸

//加載

// CustomType1

// CustomType2

這里沒有反思。 這些值存儲在EA數據庫中。 查詢API的“正確”方法是使用Repository.GetReferencType(),如下所示:

EA.Reference testTypes = Repository.GetReferenceList("Test");
for (short i = 0; i < testTypes.Count; i++)
{
    string testType = testTypes.GetAt(i);
}

如果您需要更多,那么只有您可以直接查詢數據庫的名稱: Repository.SQLQuery("select * from t_testtypes")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM