Extract XML Literal to Resource (VB)
In This Article
Extracts a selected XML literal to a new or existing resource file. Extracted code is replaced with the appropriate resource extraction statement.
#Purpose
This refactoring encourages XML code reuse, as well as code and data separation.
#Availability
Available from the context menu or via shortcuts:
- when the caret is on an XML tag. In this case, this tag and its children will be extracted.
- when an XML code fragment is selected. In this case, the selected fragment will be extracted.
- when the caret is on a variable that is being assigned an XML code fragment. In this case, the entire right-side part of the assignment will be extracted.
Note
This refactoring is only available in Visual Studio 2008, in VB code.
#Example
Dim MyXElement As XElement = _
<contact>
<name>Patrick Hines</name>
<phone type="home">206-555-0144</phone>
<phone type="work">425-555-0145</phone>
</contact>│
Result:
Dim MyXElement As XElement = _
XElement.Parse(My.Resources.│MyXMLElementValue)