Prev | Current Page 120 | Next

Satheesh, N Kumar

"LINQ Quickly"

Changed += new XObjectChangeEventHandler(
Chapter 3
[ 73 ]
delegate(object objSend, XObjectChangeEventArgs args)
{
XElement eleSend = (XElement)objSend;
MessageBox.Show(" XML Changed " + "\n " +
" Sender: " + eleSend.Name.LocalName +
" Change: " + args.ObjectChange.ToString(), "Changed Event");
}
);
Now create a new XML element which has the same number of elements and
attributes. We will use this new element to raise events on the original
XML element.
// Create a new XML element
XElement NewIcecream = new XElement("Icecream1",
new XElement("Name", "Vanilla Icecream"),
new XElement("Ingredients", "vanilla extract, guar gum,
cream, nonfat milk, sugar, locust bean gum, carrageenan,
annatto color..."),
new XElement("Cholesterol", "65mg")
);
Now add the new element to the existing ClassicIcecream element so the event
gets fired.
// Add the new element to the ClassicIcecreams so that
the events get fired
ClassicIcecreams.Add(NewIcecream);
At once, when we try to add new elements to the existing ClassicIcecream
element, the changing event fires just before the change happens.


Pages:
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
wierszyki dakolen dieta light pozycjonowanie zarządzanie nieruchomościami