diff options
Diffstat (limited to 'src/WixBuildTools.XsdGen/ElementCollection.cs')
| -rw-r--r-- | src/WixBuildTools.XsdGen/ElementCollection.cs | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/WixBuildTools.XsdGen/ElementCollection.cs b/src/WixBuildTools.XsdGen/ElementCollection.cs index e364dd11..3f0bff16 100644 --- a/src/WixBuildTools.XsdGen/ElementCollection.cs +++ b/src/WixBuildTools.XsdGen/ElementCollection.cs | |||
| @@ -111,7 +111,7 @@ namespace WixToolset.Serialize | |||
| 111 | if (collectionItem.ElementType.IsAssignableFrom(element.GetType())) | 111 | if (collectionItem.ElementType.IsAssignableFrom(element.GetType())) |
| 112 | { | 112 | { |
| 113 | collectionItem.AddElement(element); | 113 | collectionItem.AddElement(element); |
| 114 | 114 | ||
| 115 | if (!containerUsed) | 115 | if (!containerUsed) |
| 116 | { | 116 | { |
| 117 | this.containersUsed++; | 117 | this.containersUsed++; |
| @@ -176,7 +176,7 @@ namespace WixToolset.Serialize | |||
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | collectionItem.RemoveElement(element); | 178 | collectionItem.RemoveElement(element); |
| 179 | 179 | ||
| 180 | if (collectionItem.Elements.Count == 0) | 180 | if (collectionItem.Elements.Count == 0) |
| 181 | { | 181 | { |
| 182 | this.containersUsed--; | 182 | this.containersUsed--; |
| @@ -277,7 +277,7 @@ namespace WixToolset.Serialize | |||
| 277 | { | 277 | { |
| 278 | return nestedFilter; | 278 | return nestedFilter; |
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | continue; | 281 | continue; |
| 282 | } | 282 | } |
| 283 | } | 283 | } |
| @@ -353,10 +353,10 @@ namespace WixToolset.Serialize | |||
| 353 | { | 353 | { |
| 354 | throw new ArgumentException( | 354 | throw new ArgumentException( |
| 355 | String.Format( | 355 | String.Format( |
| 356 | CultureInfo.InvariantCulture, | 356 | CultureInfo.InvariantCulture, |
| 357 | "Element must be a subclass of {0}, but was of type {1}.", | 357 | "Element must be a subclass of {0}, but was of type {1}.", |
| 358 | this.elementType.Name, | 358 | this.elementType.Name, |
| 359 | element.GetType().Name), | 359 | element.GetType().Name), |
| 360 | "element"); | 360 | "element"); |
| 361 | } | 361 | } |
| 362 | 362 | ||
| @@ -374,10 +374,10 @@ namespace WixToolset.Serialize | |||
| 374 | { | 374 | { |
| 375 | throw new ArgumentException( | 375 | throw new ArgumentException( |
| 376 | String.Format( | 376 | String.Format( |
| 377 | CultureInfo.InvariantCulture, | 377 | CultureInfo.InvariantCulture, |
| 378 | "Element must be a subclass of {0}, but was of type {1}.", | 378 | "Element must be a subclass of {0}, but was of type {1}.", |
| 379 | this.elementType.Name, | 379 | this.elementType.Name, |
| 380 | element.GetType().Name), | 380 | element.GetType().Name), |
| 381 | "element"); | 381 | "element"); |
| 382 | } | 382 | } |
| 383 | 383 | ||
| @@ -454,13 +454,13 @@ namespace WixToolset.Serialize | |||
| 454 | { | 454 | { |
| 455 | if (this.collectionStack != null && this.collectionStack.Count > 0) | 455 | if (this.collectionStack != null && this.collectionStack.Count > 0) |
| 456 | { | 456 | { |
| 457 | CollectionTuple tuple = (CollectionTuple)this.collectionStack.Peek(); | 457 | CollectionSymbol symbol = (CollectionSymbol)this.collectionStack.Peek(); |
| 458 | object container = tuple.Collection.items[tuple.ContainerIndex]; | 458 | object container = symbol.Collection.items[symbol.ContainerIndex]; |
| 459 | 459 | ||
| 460 | CollectionItem collectionItem = container as CollectionItem; | 460 | CollectionItem collectionItem = container as CollectionItem; |
| 461 | if (collectionItem != null) | 461 | if (collectionItem != null) |
| 462 | { | 462 | { |
| 463 | return collectionItem.Elements[tuple.ItemIndex]; | 463 | return collectionItem.Elements[symbol.ItemIndex]; |
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | throw new InvalidOperationException(String.Format( | 466 | throw new InvalidOperationException(String.Format( |
| @@ -499,12 +499,12 @@ namespace WixToolset.Serialize | |||
| 499 | } | 499 | } |
| 500 | 500 | ||
| 501 | this.collectionStack = new Stack(); | 501 | this.collectionStack = new Stack(); |
| 502 | this.collectionStack.Push(new CollectionTuple(this.collection)); | 502 | this.collectionStack.Push(new CollectionSymbol(this.collection)); |
| 503 | } | 503 | } |
| 504 | 504 | ||
| 505 | CollectionTuple tuple = (CollectionTuple)this.collectionStack.Peek(); | 505 | CollectionSymbol symbol = (CollectionSymbol)this.collectionStack.Peek(); |
| 506 | 506 | ||
| 507 | if (this.FindNext(tuple)) | 507 | if (this.FindNext(symbol)) |
| 508 | { | 508 | { |
| 509 | return true; | 509 | return true; |
| 510 | } | 510 | } |
| @@ -532,50 +532,50 @@ namespace WixToolset.Serialize | |||
| 532 | collection.Count)); | 532 | collection.Count)); |
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | CollectionTuple tuple = new CollectionTuple(collection); | 535 | CollectionSymbol symbol = new CollectionSymbol(collection); |
| 536 | this.collectionStack.Push(tuple); | 536 | this.collectionStack.Push(symbol); |
| 537 | this.FindNext(tuple); | 537 | this.FindNext(symbol); |
| 538 | } | 538 | } |
| 539 | 539 | ||
| 540 | /// <summary> | 540 | /// <summary> |
| 541 | /// Finds the next item from a given tuple. | 541 | /// Finds the next item from a given symbol. |
| 542 | /// </summary> | 542 | /// </summary> |
| 543 | /// <param name="tuple">The tuple to start looking from.</param> | 543 | /// <param name="symbol">The symbol to start looking from.</param> |
| 544 | /// <returns>True if a next element is found, false otherwise.</returns> | 544 | /// <returns>True if a next element is found, false otherwise.</returns> |
| 545 | private bool FindNext(CollectionTuple tuple) | 545 | private bool FindNext(CollectionSymbol symbol) |
| 546 | { | 546 | { |
| 547 | object container = tuple.Collection.items[tuple.ContainerIndex]; | 547 | object container = symbol.Collection.items[symbol.ContainerIndex]; |
| 548 | 548 | ||
| 549 | CollectionItem collectionItem = container as CollectionItem; | 549 | CollectionItem collectionItem = container as CollectionItem; |
| 550 | if (collectionItem != null) | 550 | if (collectionItem != null) |
| 551 | { | 551 | { |
| 552 | if (tuple.ItemIndex + 1 < collectionItem.Elements.Count) | 552 | if (symbol.ItemIndex + 1 < collectionItem.Elements.Count) |
| 553 | { | 553 | { |
| 554 | tuple.ItemIndex++; | 554 | symbol.ItemIndex++; |
| 555 | return true; | 555 | return true; |
| 556 | } | 556 | } |
| 557 | } | 557 | } |
| 558 | 558 | ||
| 559 | ElementCollection elementCollection = container as ElementCollection; | 559 | ElementCollection elementCollection = container as ElementCollection; |
| 560 | if (elementCollection != null && elementCollection.Count > 0 && tuple.ItemIndex == -1) | 560 | if (elementCollection != null && elementCollection.Count > 0 && symbol.ItemIndex == -1) |
| 561 | { | 561 | { |
| 562 | tuple.ItemIndex++; | 562 | symbol.ItemIndex++; |
| 563 | this.PushCollection(elementCollection); | 563 | this.PushCollection(elementCollection); |
| 564 | return true; | 564 | return true; |
| 565 | } | 565 | } |
| 566 | 566 | ||
| 567 | tuple.ItemIndex = 0; | 567 | symbol.ItemIndex = 0; |
| 568 | 568 | ||
| 569 | for (int i = tuple.ContainerIndex + 1; i < tuple.Collection.items.Count; ++i) | 569 | for (int i = symbol.ContainerIndex + 1; i < symbol.Collection.items.Count; ++i) |
| 570 | { | 570 | { |
| 571 | object nestedContainer = tuple.Collection.items[i]; | 571 | object nestedContainer = symbol.Collection.items[i]; |
| 572 | 572 | ||
| 573 | CollectionItem nestedCollectionItem = nestedContainer as CollectionItem; | 573 | CollectionItem nestedCollectionItem = nestedContainer as CollectionItem; |
| 574 | if (nestedCollectionItem != null) | 574 | if (nestedCollectionItem != null) |
| 575 | { | 575 | { |
| 576 | if (nestedCollectionItem.Elements.Count > 0) | 576 | if (nestedCollectionItem.Elements.Count > 0) |
| 577 | { | 577 | { |
| 578 | tuple.ContainerIndex = i; | 578 | symbol.ContainerIndex = i; |
| 579 | return true; | 579 | return true; |
| 580 | } | 580 | } |
| 581 | } | 581 | } |
| @@ -583,7 +583,7 @@ namespace WixToolset.Serialize | |||
| 583 | ElementCollection nestedElementCollection = nestedContainer as ElementCollection; | 583 | ElementCollection nestedElementCollection = nestedContainer as ElementCollection; |
| 584 | if (nestedElementCollection != null && nestedElementCollection.Count > 0) | 584 | if (nestedElementCollection != null && nestedElementCollection.Count > 0) |
| 585 | { | 585 | { |
| 586 | tuple.ContainerIndex = i; | 586 | symbol.ContainerIndex = i; |
| 587 | this.PushCollection(nestedElementCollection); | 587 | this.PushCollection(nestedElementCollection); |
| 588 | return true; | 588 | return true; |
| 589 | } | 589 | } |
| @@ -596,23 +596,23 @@ namespace WixToolset.Serialize | |||
| 596 | /// Class representing a single point in the collection. Consists of an ElementCollection, | 596 | /// Class representing a single point in the collection. Consists of an ElementCollection, |
| 597 | /// a container index, and an index into the container. | 597 | /// a container index, and an index into the container. |
| 598 | /// </summary> | 598 | /// </summary> |
| 599 | private class CollectionTuple | 599 | private class CollectionSymbol |
| 600 | { | 600 | { |
| 601 | private ElementCollection collection; | 601 | private ElementCollection collection; |
| 602 | private int containerIndex; | 602 | private int containerIndex; |
| 603 | private int itemIndex = -1; | 603 | private int itemIndex = -1; |
| 604 | 604 | ||
| 605 | /// <summary> | 605 | /// <summary> |
| 606 | /// Creates a new CollectionTuple. | 606 | /// Creates a new CollectionSymbol. |
| 607 | /// </summary> | 607 | /// </summary> |
| 608 | /// <param name="collection">The collection for the tuple.</param> | 608 | /// <param name="collection">The collection for the symbol.</param> |
| 609 | public CollectionTuple(ElementCollection collection) | 609 | public CollectionSymbol(ElementCollection collection) |
| 610 | { | 610 | { |
| 611 | this.collection = collection; | 611 | this.collection = collection; |
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | /// <summary> | 614 | /// <summary> |
| 615 | /// Gets the collection for the tuple. | 615 | /// Gets the collection for the symbol. |
| 616 | /// </summary> | 616 | /// </summary> |
| 617 | public ElementCollection Collection | 617 | public ElementCollection Collection |
| 618 | { | 618 | { |
