2012-07-10 16 views

回答

3

看看裏面的working with XML document顯示使用AddAttributeBefore調用第一個是你想要插入的屬性。第二個是你想要插入的屬性。如果第二個屬性是NULL,則新屬性將插入到最後一個屬性之後。

+0

如果我想將字符串轉換爲C♯方法前的簡單屬性,例如*'[Obsolete]',該怎麼辦? – 2012-07-10 21:38:12

+2

@Matthew Piziak嘗試使用myClass.AddAttributeBefore(CSharpElementFactory.GetInstance(myClass.GetPsiModule())。CreateTypeMemberDeclaration(「[」+ yourAttribute +「] void Aaa(){}」)。Attributes [0],null)。雖然沒有測試過。 – 2012-07-10 21:48:44

+0

@DmitryOsinovskiy這個作品非常漂亮!謝謝! – 2012-07-11 12:28:51

2

基本上,param是你想要添加的東西,而anchor是你想要添加東西的元素。請記住,在大多數情況下,您可以使用anchor == null,這會導致元素最後添加。