SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 263 | Next

Scott Klein

"Professional LINQ"

In
LINQ to XML, annotations are provided linked lists of type Object on an XNode.
Annotations are added via the AddAnnotation method of an XElement or XAttribute. When the
AddAnnotation method is called, a new object is added to the corresponding XObject (element or
attribute) in the XML tree.
To utilize annotations, a mechanism for adding and defining annotations must first be created. For
example, the following code defines a mechanism for adding annotations of integer data types.
public class TestAnnotation
{
private int val1;
public int Val1 { get { return val1;} set { val1 = value;}}
public TestAnnotation(int val1)
{
this.val1 = val1;
}
}
With this class defined, any time you want to add an annotation of an integer type to an element or
attribute, you can simply call this class. For instance, the following code uses the TestAnnotation class
defined above to add an annotation to the root element. The code writes the new XML to a text box,
but be aware that the annotation is not visible. The last two lines of the following code illustrate how to
obtain the annotation from the element:
TestAnnotation ano1 = new TestAnnotation(500);
XElement root = new XElement("Root", "scott");
root.


Pages:
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6