[12762] | 1 | using System;
|
---|
| 2 | using System.Xml;
|
---|
| 3 |
|
---|
| 4 | using SharpVectors.Dom.Events;
|
---|
| 5 |
|
---|
| 6 | namespace SharpVectors.Dom
|
---|
| 7 | {
|
---|
| 8 | /// <summary>
|
---|
| 9 | /// Summary description for Document.
|
---|
| 10 | /// </summary>
|
---|
| 11 | public class Document : XmlDocument, IDocument, INode, IEventTargetSupport, IDocumentEvent
|
---|
| 12 | {
|
---|
| 13 | #region Private Fields
|
---|
| 14 |
|
---|
| 15 | private EventTarget eventTarget;
|
---|
| 16 | private bool mutationEvents = false;
|
---|
| 17 |
|
---|
| 18 | #endregion
|
---|
| 19 |
|
---|
| 20 | #region Constructors
|
---|
| 21 |
|
---|
| 22 | public Document()
|
---|
| 23 | {
|
---|
| 24 | eventTarget = new EventTarget(this);
|
---|
| 25 |
|
---|
| 26 | NodeChanged += new XmlNodeChangedEventHandler(WhenNodeChanged);
|
---|
| 27 | NodeChanging += new XmlNodeChangedEventHandler(WhenNodeChanging);
|
---|
| 28 | NodeInserted += new XmlNodeChangedEventHandler(WhenNodeInserted);
|
---|
| 29 | NodeInserting += new XmlNodeChangedEventHandler(WhenNodeInserting);
|
---|
| 30 | NodeRemoved += new XmlNodeChangedEventHandler(WhenNodeRemoved);
|
---|
| 31 | NodeRemoving += new XmlNodeChangedEventHandler(WhenNodeRemoving);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | protected internal Document(
|
---|
| 35 | DomImplementation domImplementation)
|
---|
| 36 | : base(domImplementation)
|
---|
| 37 | {
|
---|
| 38 | eventTarget = new EventTarget(this);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | public Document(
|
---|
| 42 | XmlNameTable nameTable)
|
---|
| 43 | : base(nameTable)
|
---|
| 44 | {
|
---|
| 45 | eventTarget = new EventTarget(this);
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | #endregion
|
---|
| 49 |
|
---|
| 50 | #region Document interface
|
---|
| 51 |
|
---|
| 52 | #region Configuration Properties
|
---|
| 53 |
|
---|
| 54 | /// <summary>
|
---|
| 55 | /// Enables or disables mutation events.
|
---|
| 56 | /// </summary>
|
---|
| 57 | public bool MutationEvents
|
---|
| 58 | {
|
---|
| 59 | get
|
---|
| 60 | {
|
---|
| 61 | return mutationEvents;
|
---|
| 62 | }
|
---|
| 63 | set
|
---|
| 64 | {
|
---|
| 65 | mutationEvents = value;
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | #endregion
|
---|
| 70 |
|
---|
| 71 | #region System.Xml events to Dom events
|
---|
| 72 |
|
---|
| 73 | private void WhenNodeChanged(
|
---|
| 74 | object sender,
|
---|
| 75 | XmlNodeChangedEventArgs e)
|
---|
| 76 | {
|
---|
| 77 | if (mutationEvents)
|
---|
| 78 | {
|
---|
| 79 | throw new NotImplementedException();
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | private void WhenNodeChanging(
|
---|
| 85 | object sender,
|
---|
| 86 | XmlNodeChangedEventArgs e)
|
---|
| 87 | {
|
---|
| 88 | // Cannot perform ReplaceText/DeleteText/InsertText here because
|
---|
| 89 | // System.Xml events do not provide enough information.
|
---|
| 90 | if (mutationEvents)
|
---|
| 91 | {
|
---|
| 92 | throw new NotImplementedException();
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | private void WhenNodeInserted(
|
---|
| 98 | object sender,
|
---|
| 99 | XmlNodeChangedEventArgs e)
|
---|
| 100 | {
|
---|
| 101 | INode newParent = e.NewParent as INode;
|
---|
| 102 | INode node = e.Node as INode;
|
---|
| 103 |
|
---|
| 104 | if (newParent != null && node != null)
|
---|
| 105 | {
|
---|
| 106 | InsertedNode(newParent, node, false);
|
---|
| 107 | }
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | private void WhenNodeInserting(
|
---|
| 111 | object sender,
|
---|
| 112 | XmlNodeChangedEventArgs e)
|
---|
| 113 | {
|
---|
| 114 | INode node = e.Node as INode;
|
---|
| 115 |
|
---|
| 116 | if (node != null)
|
---|
| 117 | {
|
---|
| 118 | InsertingNode(node, false);
|
---|
| 119 | }
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | private void WhenNodeRemoved(
|
---|
| 123 | object sender,
|
---|
| 124 | XmlNodeChangedEventArgs e)
|
---|
| 125 | {
|
---|
| 126 | INode node = e.Node as INode;
|
---|
| 127 |
|
---|
| 128 | if (node != null)
|
---|
| 129 | {
|
---|
| 130 | RemovedNode(node, false);
|
---|
| 131 | }
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | private void WhenNodeRemoving(
|
---|
| 135 | object sender,
|
---|
| 136 | XmlNodeChangedEventArgs e)
|
---|
| 137 | {
|
---|
| 138 | INode oldParent = e.OldParent as INode;
|
---|
| 139 | INode node = e.NewParent as INode;
|
---|
| 140 |
|
---|
| 141 | if (oldParent != null && node != null)
|
---|
| 142 | {
|
---|
| 143 | RemovingNode(oldParent, node, false);
|
---|
| 144 | }
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | #endregion
|
---|
| 148 |
|
---|
| 149 | #region Notification Methods
|
---|
| 150 |
|
---|
| 151 | /// <summary>
|
---|
| 152 | /// A method to be called when some text was changed in a text node,
|
---|
| 153 | /// so that live objects can be notified.
|
---|
| 154 | /// </summary>
|
---|
| 155 | /// <param name="node">
|
---|
| 156 | /// </param>
|
---|
| 157 | protected internal virtual void ReplacedText(
|
---|
| 158 | INode node)
|
---|
| 159 | {
|
---|
| 160 | if (mutationEvents)
|
---|
| 161 | {
|
---|
| 162 | throw new NotImplementedException();
|
---|
| 163 | }
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | /// <summary>
|
---|
| 167 | /// A method to be called when some text was deleted from a text node,
|
---|
| 168 | /// so that live objects can be notified.
|
---|
| 169 | /// </summary>
|
---|
| 170 | /// <param name="node">
|
---|
| 171 | /// </param>
|
---|
| 172 | /// <param name="offset">
|
---|
| 173 | /// </param>
|
---|
| 174 | /// <param name="count">
|
---|
| 175 | /// </param>
|
---|
| 176 | protected internal virtual void DeletedText(
|
---|
| 177 | INode node,
|
---|
| 178 | int offset,
|
---|
| 179 | int count)
|
---|
| 180 | {
|
---|
| 181 | if (mutationEvents)
|
---|
| 182 | {
|
---|
| 183 | throw new NotImplementedException();
|
---|
| 184 | }
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | /// <summary>
|
---|
| 188 | /// A method to be called when some text was inserted into a text node,
|
---|
| 189 | /// so that live objects can be notified.
|
---|
| 190 | /// </summary>
|
---|
| 191 | /// <param name="node">
|
---|
| 192 | /// </param>
|
---|
| 193 | /// <param name="offset">
|
---|
| 194 | /// </param>
|
---|
| 195 | /// <param name="count">
|
---|
| 196 | /// </param>
|
---|
| 197 | protected internal virtual void InsertedText(
|
---|
| 198 | INode node,
|
---|
| 199 | int offset,
|
---|
| 200 | int count)
|
---|
| 201 | {
|
---|
| 202 | if (mutationEvents)
|
---|
| 203 | {
|
---|
| 204 | throw new NotImplementedException();
|
---|
| 205 | }
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | /// <summary>
|
---|
| 209 | /// A method to be called when a character data node has been modified.
|
---|
| 210 | /// </summary>
|
---|
| 211 | /// <param name="node">
|
---|
| 212 | /// </param>
|
---|
| 213 | protected internal virtual void ModifyingCharacterData(
|
---|
| 214 | INode node)
|
---|
| 215 | {
|
---|
| 216 | if (mutationEvents)
|
---|
| 217 | {
|
---|
| 218 | throw new NotImplementedException();
|
---|
| 219 | }
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | /// <summary>
|
---|
| 223 | /// A method to be called when a character data node has been modified.
|
---|
| 224 | /// </summary>
|
---|
| 225 | /// <param name="node">
|
---|
| 226 | /// </param>
|
---|
| 227 | /// <param name="oldvalue">
|
---|
| 228 | /// </param>
|
---|
| 229 | /// <param name="value">
|
---|
| 230 | /// </param>
|
---|
| 231 | protected internal virtual void ModifiedCharacterData(
|
---|
| 232 | INode node,
|
---|
| 233 | string oldvalue,
|
---|
| 234 | string value)
|
---|
| 235 | {
|
---|
| 236 | if (mutationEvents)
|
---|
| 237 | {
|
---|
| 238 | throw new NotImplementedException();
|
---|
| 239 | }
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | /// <summary>
|
---|
| 243 | /// A method to be called when a node is about to be inserted in the tree.
|
---|
| 244 | /// </summary>
|
---|
| 245 | /// <param name="node">
|
---|
| 246 | /// </param>
|
---|
| 247 | /// <param name="replace">
|
---|
| 248 | /// </param>
|
---|
| 249 | protected internal virtual void InsertingNode(
|
---|
| 250 | INode node,
|
---|
| 251 | bool replace)
|
---|
| 252 | {
|
---|
| 253 | if (mutationEvents)
|
---|
| 254 | {
|
---|
| 255 | throw new NotImplementedException();
|
---|
| 256 | }
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 | /// <summary>
|
---|
| 260 | /// A method to be called when a node has been inserted in the tree.
|
---|
| 261 | /// </summary>
|
---|
| 262 | /// <param name="node">
|
---|
| 263 | /// </param>
|
---|
| 264 | /// <param name="newInternal">
|
---|
| 265 | /// </param>
|
---|
| 266 | /// <param name="replace">
|
---|
| 267 | /// </param>
|
---|
| 268 | protected internal virtual void InsertedNode(
|
---|
| 269 | INode node,
|
---|
| 270 | INode newInternal,
|
---|
| 271 | bool replace)
|
---|
| 272 | {
|
---|
| 273 | if (mutationEvents)
|
---|
| 274 | {
|
---|
| 275 | throw new NotImplementedException();
|
---|
| 276 | }
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | /// <summary>
|
---|
| 280 | /// A method to be called when a node is about to be removed from the tree.
|
---|
| 281 | /// </summary>
|
---|
| 282 | /// <param name="node">
|
---|
| 283 | /// </param>
|
---|
| 284 | /// <param name="oldChild">
|
---|
| 285 | /// </param>
|
---|
| 286 | /// <param name="replace">
|
---|
| 287 | /// </param>
|
---|
| 288 | protected internal virtual void RemovingNode(
|
---|
| 289 | INode node,
|
---|
| 290 | INode oldChild,
|
---|
| 291 | bool replace)
|
---|
| 292 | {
|
---|
| 293 | if (mutationEvents)
|
---|
| 294 | {
|
---|
| 295 | throw new NotImplementedException();
|
---|
| 296 | }
|
---|
| 297 | }
|
---|
| 298 |
|
---|
| 299 | /// <summary>
|
---|
| 300 | /// A method to be called when a node has been removed from the tree.
|
---|
| 301 | /// </summary>
|
---|
| 302 | /// <param name="node"></param>
|
---|
| 303 | /// <param name="replace"></param>
|
---|
| 304 | protected internal virtual void RemovedNode(
|
---|
| 305 | INode node,
|
---|
| 306 | bool replace)
|
---|
| 307 | {
|
---|
| 308 | if (mutationEvents)
|
---|
| 309 | {
|
---|
| 310 | throw new NotImplementedException();
|
---|
| 311 | }
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | /// <summary>
|
---|
| 315 | /// A method to be called when a node is about to be replaced in the tree.
|
---|
| 316 | /// </summary>
|
---|
| 317 | /// <param name="node">
|
---|
| 318 | /// </param>
|
---|
| 319 | protected internal virtual void replacingNode(
|
---|
| 320 | INode node)
|
---|
| 321 | {
|
---|
| 322 | if (mutationEvents)
|
---|
| 323 | {
|
---|
| 324 | throw new NotImplementedException();
|
---|
| 325 | }
|
---|
| 326 | }
|
---|
| 327 |
|
---|
| 328 | /// <summary>
|
---|
| 329 | /// A method to be called when a node has been replaced in the tree.
|
---|
| 330 | /// </summary>
|
---|
| 331 | /// <param name="node">
|
---|
| 332 | /// </param>
|
---|
| 333 | protected internal virtual void ReplacedNode(
|
---|
| 334 | INode node)
|
---|
| 335 | {
|
---|
| 336 | if (mutationEvents)
|
---|
| 337 | {
|
---|
| 338 | throw new NotImplementedException();
|
---|
| 339 | }
|
---|
| 340 | }
|
---|
| 341 |
|
---|
| 342 | /// <summary>
|
---|
| 343 | /// A method to be called when an attribute value has been modified.
|
---|
| 344 | /// </summary>
|
---|
| 345 | /// <param name="attr">
|
---|
| 346 | /// </param>
|
---|
| 347 | /// <param name="oldvalue">
|
---|
| 348 | /// </param>
|
---|
| 349 | protected internal virtual void ModifiedAttrValue(
|
---|
| 350 | IAttribute attr,
|
---|
| 351 | string oldvalue)
|
---|
| 352 | {
|
---|
| 353 | if (mutationEvents)
|
---|
| 354 | {
|
---|
| 355 | throw new NotImplementedException();
|
---|
| 356 | }
|
---|
| 357 | }
|
---|
| 358 |
|
---|
| 359 | /// <summary>
|
---|
| 360 | /// A method to be called when an attribute node has been set.
|
---|
| 361 | /// </summary>
|
---|
| 362 | /// <param name="attribute">
|
---|
| 363 | /// </param>
|
---|
| 364 | /// <param name="previous">
|
---|
| 365 | /// </param>
|
---|
| 366 | protected internal virtual void SetAttrNode(
|
---|
| 367 | IAttribute attribute,
|
---|
| 368 | IAttribute previous)
|
---|
| 369 | {
|
---|
| 370 | if (mutationEvents)
|
---|
| 371 | {
|
---|
| 372 | throw new NotImplementedException();
|
---|
| 373 | }
|
---|
| 374 | }
|
---|
| 375 |
|
---|
| 376 | /// <summary>
|
---|
| 377 | /// A method to be called when an attribute node has been removed.
|
---|
| 378 | /// </summary>
|
---|
| 379 | /// <param name="attribute">
|
---|
| 380 | /// </param>
|
---|
| 381 | /// <param name="oldOwner">
|
---|
| 382 | /// </param>
|
---|
| 383 | /// <param name="name">
|
---|
| 384 | /// </param>
|
---|
| 385 | protected internal virtual void RemovedAttrNode(
|
---|
| 386 | IAttribute attribute,
|
---|
| 387 | INode oldOwner,
|
---|
| 388 | string name)
|
---|
| 389 | {
|
---|
| 390 | if (mutationEvents)
|
---|
| 391 | {
|
---|
| 392 | throw new NotImplementedException();
|
---|
| 393 | }
|
---|
| 394 | }
|
---|
| 395 |
|
---|
| 396 | /// <summary>
|
---|
| 397 | /// A method to be called when an attribute node has been renamed.
|
---|
| 398 | /// </summary>
|
---|
| 399 | /// <param name="oldAttribute">
|
---|
| 400 | /// </param>
|
---|
| 401 | /// <param name="newAttribute">
|
---|
| 402 | /// </param>
|
---|
| 403 | protected internal virtual void RenamedAttrNode(
|
---|
| 404 | IAttribute oldAttribute,
|
---|
| 405 | IAttribute newAttribute)
|
---|
| 406 | {
|
---|
| 407 | if (mutationEvents)
|
---|
| 408 | {
|
---|
| 409 | throw new NotImplementedException();
|
---|
| 410 | }
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | /// <summary>
|
---|
| 414 | /// A method to be called when an element has been renamed.
|
---|
| 415 | /// </summary>
|
---|
| 416 | /// <param name="oldElement">
|
---|
| 417 | /// </param>
|
---|
| 418 | /// <param name="newElement">
|
---|
| 419 | /// </param>
|
---|
| 420 | protected internal virtual void RenamedElement(
|
---|
| 421 | IElement oldElement,
|
---|
| 422 | IElement newElement)
|
---|
| 423 | {
|
---|
| 424 | if (mutationEvents)
|
---|
| 425 | {
|
---|
| 426 | throw new NotImplementedException();
|
---|
| 427 | }
|
---|
| 428 | }
|
---|
| 429 |
|
---|
| 430 | #endregion
|
---|
| 431 |
|
---|
| 432 | #endregion
|
---|
| 433 |
|
---|
| 434 | #region XmlDocument interface
|
---|
| 435 |
|
---|
| 436 | public override XmlAttribute CreateAttribute(
|
---|
| 437 | string prefix,
|
---|
| 438 | string localName,
|
---|
| 439 | string namespaceUri)
|
---|
| 440 | {
|
---|
| 441 | return new Attribute(prefix, localName, namespaceUri, this);
|
---|
| 442 | }
|
---|
| 443 |
|
---|
| 444 | public override XmlCDataSection CreateCDataSection(
|
---|
| 445 | string data)
|
---|
| 446 | {
|
---|
| 447 | return new CDataSection(data, this);
|
---|
| 448 | }
|
---|
| 449 |
|
---|
| 450 | public override XmlComment CreateComment(
|
---|
| 451 | string data)
|
---|
| 452 | {
|
---|
| 453 | return new Comment(data, this);
|
---|
| 454 | }
|
---|
| 455 |
|
---|
| 456 | public override XmlDocumentFragment CreateDocumentFragment()
|
---|
| 457 | {
|
---|
| 458 | return new DocumentFragment(this);
|
---|
| 459 | }
|
---|
| 460 |
|
---|
| 461 | public override XmlDocumentType CreateDocumentType(
|
---|
| 462 | string name,
|
---|
| 463 | string publicId,
|
---|
| 464 | string systemId,
|
---|
| 465 | string internalSubset)
|
---|
| 466 | {
|
---|
| 467 | return new DocumentType(name, publicId, systemId, internalSubset, this);
|
---|
| 468 | }
|
---|
| 469 |
|
---|
| 470 | public override XmlElement CreateElement(
|
---|
| 471 | string prefix,
|
---|
| 472 | string localName,
|
---|
| 473 | string namespaceUri)
|
---|
| 474 | {
|
---|
| 475 | return new Element(prefix, localName, namespaceUri, this);
|
---|
| 476 | }
|
---|
| 477 |
|
---|
| 478 | public override XmlEntityReference CreateEntityReference(
|
---|
| 479 | string name)
|
---|
| 480 | {
|
---|
| 481 | return new EntityReference(name, this);
|
---|
| 482 | }
|
---|
| 483 |
|
---|
| 484 | public override XmlProcessingInstruction CreateProcessingInstruction(
|
---|
| 485 | string target,
|
---|
| 486 | string data)
|
---|
| 487 | {
|
---|
| 488 | return new ProcessingInstruction(target, data, this);
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 | public override XmlSignificantWhitespace CreateSignificantWhitespace(
|
---|
| 492 | string text)
|
---|
| 493 | {
|
---|
| 494 | return new SignificantWhitespace(text, this);
|
---|
| 495 | }
|
---|
| 496 |
|
---|
| 497 | public override XmlText CreateTextNode(
|
---|
| 498 | string text)
|
---|
| 499 | {
|
---|
| 500 | return new Text(text, this);
|
---|
| 501 | }
|
---|
| 502 |
|
---|
| 503 | public override XmlWhitespace CreateWhitespace(
|
---|
| 504 | string text)
|
---|
| 505 | {
|
---|
| 506 | return new Whitespace(text, this);
|
---|
| 507 | }
|
---|
| 508 |
|
---|
| 509 | public override XmlDeclaration CreateXmlDeclaration(
|
---|
| 510 | string version,
|
---|
| 511 | string encoding,
|
---|
| 512 | string standalone)
|
---|
| 513 | {
|
---|
| 514 | return new Declaration(version, encoding, standalone, this);
|
---|
| 515 | }
|
---|
| 516 |
|
---|
| 517 | #endregion
|
---|
| 518 |
|
---|
| 519 | #region IEventTarget interface
|
---|
| 520 |
|
---|
| 521 | #region Methods
|
---|
| 522 |
|
---|
| 523 | #region DOM Level 2
|
---|
| 524 |
|
---|
| 525 | void IEventTarget.AddEventListener(
|
---|
| 526 | string type,
|
---|
| 527 | EventListener listener,
|
---|
| 528 | bool useCapture)
|
---|
| 529 | {
|
---|
| 530 | eventTarget.AddEventListener(type, listener, useCapture);
|
---|
| 531 | }
|
---|
| 532 |
|
---|
| 533 | void IEventTarget.RemoveEventListener(
|
---|
| 534 | string type,
|
---|
| 535 | EventListener listener,
|
---|
| 536 | bool useCapture)
|
---|
| 537 | {
|
---|
| 538 | eventTarget.RemoveEventListener(type, listener, useCapture);
|
---|
| 539 | }
|
---|
| 540 |
|
---|
| 541 | bool IEventTarget.DispatchEvent(
|
---|
| 542 | IEvent @event)
|
---|
| 543 | {
|
---|
| 544 | return eventTarget.DispatchEvent(@event);
|
---|
| 545 | }
|
---|
| 546 |
|
---|
| 547 | #endregion
|
---|
| 548 |
|
---|
| 549 | #region DOM Level 3 Experimental
|
---|
| 550 |
|
---|
| 551 | void IEventTarget.AddEventListenerNs(
|
---|
| 552 | string namespaceUri,
|
---|
| 553 | string type,
|
---|
| 554 | EventListener listener,
|
---|
| 555 | bool useCapture,
|
---|
| 556 | object eventGroup)
|
---|
| 557 | {
|
---|
| 558 | eventTarget.AddEventListenerNs(namespaceUri, type, listener, useCapture, eventGroup);
|
---|
| 559 | }
|
---|
| 560 |
|
---|
| 561 | void IEventTarget.RemoveEventListenerNs(
|
---|
| 562 | string namespaceUri,
|
---|
| 563 | string type,
|
---|
| 564 | EventListener listener,
|
---|
| 565 | bool useCapture)
|
---|
| 566 | {
|
---|
| 567 | eventTarget.RemoveEventListenerNs(namespaceUri, type, listener, useCapture);
|
---|
| 568 | }
|
---|
| 569 |
|
---|
| 570 | bool IEventTarget.WillTriggerNs(
|
---|
| 571 | string namespaceUri,
|
---|
| 572 | string type)
|
---|
| 573 | {
|
---|
| 574 | return eventTarget.WillTriggerNs(namespaceUri, type);
|
---|
| 575 | }
|
---|
| 576 |
|
---|
| 577 | bool IEventTarget.HasEventListenerNs(
|
---|
| 578 | string namespaceUri,
|
---|
| 579 | string type)
|
---|
| 580 | {
|
---|
| 581 | return eventTarget.HasEventListenerNs(namespaceUri, type);
|
---|
| 582 | }
|
---|
| 583 |
|
---|
| 584 | #endregion
|
---|
| 585 |
|
---|
| 586 | #endregion
|
---|
| 587 |
|
---|
| 588 | #endregion
|
---|
| 589 |
|
---|
| 590 | #region IDocument interface
|
---|
| 591 |
|
---|
| 592 | IDocumentType IDocument.Doctype
|
---|
| 593 | {
|
---|
| 594 | get
|
---|
| 595 | {
|
---|
| 596 | return (IDocumentType)DocumentType;
|
---|
| 597 | }
|
---|
| 598 | }
|
---|
| 599 |
|
---|
| 600 | IDomImplementation IDocument.Implementation
|
---|
| 601 | {
|
---|
| 602 | get
|
---|
| 603 | {
|
---|
| 604 | throw new DomException(DomExceptionType.NotSupportedErr);
|
---|
| 605 | }
|
---|
| 606 | }
|
---|
| 607 |
|
---|
| 608 | IElement IDocument.DocumentElement
|
---|
| 609 | {
|
---|
| 610 | get
|
---|
| 611 | {
|
---|
| 612 | return (IElement)DocumentElement;
|
---|
| 613 | }
|
---|
| 614 | }
|
---|
| 615 |
|
---|
| 616 | IElement IDocument.CreateElement(
|
---|
| 617 | string tagName)
|
---|
| 618 | {
|
---|
| 619 | return (IElement)CreateElement(tagName);
|
---|
| 620 | }
|
---|
| 621 |
|
---|
| 622 | IDocumentFragment IDocument.CreateDocumentFragment()
|
---|
| 623 | {
|
---|
| 624 | return (IDocumentFragment)CreateDocumentFragment();
|
---|
| 625 | }
|
---|
| 626 |
|
---|
| 627 | IText IDocument.CreateTextNode(
|
---|
| 628 | string data)
|
---|
| 629 | {
|
---|
| 630 | return (IText)CreateTextNode(data);
|
---|
| 631 | }
|
---|
| 632 |
|
---|
| 633 | IComment IDocument.CreateComment(
|
---|
| 634 | string data)
|
---|
| 635 | {
|
---|
| 636 | return (IComment)CreateComment(data);
|
---|
| 637 | }
|
---|
| 638 |
|
---|
| 639 | ICDataSection IDocument.CreateCDataSection(
|
---|
| 640 | string data)
|
---|
| 641 | {
|
---|
| 642 | return (ICDataSection)CreateCDataSection(data);
|
---|
| 643 | }
|
---|
| 644 |
|
---|
| 645 | IProcessingInstruction IDocument.CreateProcessingInstruction(
|
---|
| 646 | string target,
|
---|
| 647 | string data)
|
---|
| 648 | {
|
---|
| 649 | return (IProcessingInstruction)CreateProcessingInstruction(target, data);
|
---|
| 650 | }
|
---|
| 651 |
|
---|
| 652 | IAttribute IDocument.CreateAttribute(
|
---|
| 653 | string name)
|
---|
| 654 | {
|
---|
| 655 | return (IAttribute)CreateAttribute(name);
|
---|
| 656 | }
|
---|
| 657 |
|
---|
| 658 | IEntityReference IDocument.CreateEntityReference(
|
---|
| 659 | string name)
|
---|
| 660 | {
|
---|
| 661 | return (IEntityReference)CreateEntityReference(name);
|
---|
| 662 | }
|
---|
| 663 |
|
---|
| 664 | INodeList IDocument.GetElementsByTagName(
|
---|
| 665 | string tagname)
|
---|
| 666 | {
|
---|
| 667 | return new NodeListAdapter(GetElementsByTagName(tagname));
|
---|
| 668 | }
|
---|
| 669 |
|
---|
| 670 | INode IDocument.ImportNode(
|
---|
| 671 | INode importedNode,
|
---|
| 672 | bool deep)
|
---|
| 673 | {
|
---|
| 674 | return (INode)ImportNode((XmlNode)importedNode, deep);
|
---|
| 675 | }
|
---|
| 676 |
|
---|
| 677 | IElement IDocument.CreateElementNs(
|
---|
| 678 | string namespaceUri,
|
---|
| 679 | string qualifiedName)
|
---|
| 680 | {
|
---|
| 681 | return (IElement)CreateElement(qualifiedName, namespaceUri);
|
---|
| 682 | }
|
---|
| 683 |
|
---|
| 684 | IAttribute IDocument.CreateAttributeNs(
|
---|
| 685 | string namespaceUri,
|
---|
| 686 | string qualifiedName)
|
---|
| 687 | {
|
---|
| 688 | return (IAttribute)CreateAttribute(qualifiedName, namespaceUri);
|
---|
| 689 | }
|
---|
| 690 |
|
---|
| 691 | INodeList IDocument.GetElementsByTagNameNs(
|
---|
| 692 | string namespaceUri,
|
---|
| 693 | string localName)
|
---|
| 694 | {
|
---|
| 695 | return new NodeListAdapter(GetElementsByTagName(localName, namespaceUri));
|
---|
| 696 | }
|
---|
| 697 |
|
---|
| 698 | IElement IDocument.GetElementById(
|
---|
| 699 | string elementId)
|
---|
| 700 | {
|
---|
| 701 | object res = GetElementById(elementId);
|
---|
| 702 | if (res != null)
|
---|
| 703 | return (IElement)res;
|
---|
| 704 | else
|
---|
| 705 | return null;
|
---|
| 706 | }
|
---|
| 707 |
|
---|
| 708 | #endregion
|
---|
| 709 |
|
---|
| 710 | #region IDocumentEvent interface
|
---|
| 711 |
|
---|
| 712 | #region DOM Level 2
|
---|
| 713 |
|
---|
| 714 | public virtual IEvent CreateEvent(
|
---|
| 715 | string eventType)
|
---|
| 716 | {
|
---|
| 717 | switch (eventType)
|
---|
| 718 | {
|
---|
| 719 | case "Event":
|
---|
| 720 | case "Events":
|
---|
| 721 | case "HTMLEvents":
|
---|
| 722 | return new Event();
|
---|
| 723 | case "MutationEvent":
|
---|
| 724 | case "MutationEvents":
|
---|
| 725 | return new MutationEvent();
|
---|
| 726 | case "UIEvent":
|
---|
| 727 | case "UIEvents":
|
---|
| 728 | return new UiEvent();
|
---|
| 729 | case "MouseEvent":
|
---|
| 730 | case "MouseEvents":
|
---|
| 731 | return new MouseEvent();
|
---|
| 732 | default:
|
---|
| 733 | throw new DomException(DomExceptionType.NotSupportedErr,
|
---|
| 734 | "Event type \"" + eventType + "\" not suppoted");
|
---|
| 735 | }
|
---|
| 736 | }
|
---|
| 737 |
|
---|
| 738 | #endregion
|
---|
| 739 |
|
---|
| 740 | #region DOM Level 3 Experimental
|
---|
| 741 |
|
---|
| 742 | public virtual bool CanDispatch(string namespaceUri, string type)
|
---|
| 743 | {
|
---|
| 744 | throw new NotImplementedException();
|
---|
| 745 | }
|
---|
| 746 |
|
---|
| 747 | #endregion
|
---|
| 748 |
|
---|
| 749 | #endregion
|
---|
| 750 |
|
---|
| 751 | #region NON-DOM
|
---|
| 752 |
|
---|
| 753 | void IEventTargetSupport.FireEvent(
|
---|
| 754 | IEvent @event)
|
---|
| 755 | {
|
---|
| 756 | eventTarget.FireEvent(@event);
|
---|
| 757 | }
|
---|
| 758 |
|
---|
| 759 | #endregion
|
---|
| 760 | }
|
---|
| 761 | }
|
---|