Element_AdaptiveSubgroup.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // ******************************************************************
  2. // Copyright (c) Microsoft. All rights reserved.
  3. // This code is licensed under the MIT License (MIT).
  4. // THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  5. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  7. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  9. // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
  10. // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
  11. // ******************************************************************
  12. using System;
  13. using System.Collections.Generic;
  14. namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
  15. {
  16. [NotificationXmlElement("subgroup")]
  17. internal sealed class Element_AdaptiveSubgroup : IElementWithDescendants
  18. {
  19. internal const AdaptiveSubgroupTextStacking DEFAULT_TEXT_STACKING = AdaptiveSubgroupTextStacking.Default;
  20. [NotificationXmlAttribute("hint-textStacking", DEFAULT_TEXT_STACKING)]
  21. public AdaptiveSubgroupTextStacking TextStacking { get; set; } = DEFAULT_TEXT_STACKING;
  22. private int? _weight;
  23. [NotificationXmlAttribute("hint-weight")]
  24. public int? Weight
  25. {
  26. get
  27. {
  28. return _weight;
  29. }
  30. set
  31. {
  32. CheckWeight(value);
  33. _weight = value;
  34. }
  35. }
  36. internal static void CheckWeight(int? weight)
  37. {
  38. if (weight != null && weight.Value < 1)
  39. {
  40. throw new ArgumentOutOfRangeException("Weight must be between 1 and int.MaxValue, inclusive (or null)");
  41. }
  42. }
  43. public IList<IElement_AdaptiveSubgroupChild> Children { get; private set; } = new List<IElement_AdaptiveSubgroupChild>();
  44. public IEnumerable<object> Descendants()
  45. {
  46. foreach (IElement_AdaptiveSubgroupChild child in Children)
  47. {
  48. // Return each child (we know there's no further descendants)
  49. yield return child;
  50. }
  51. }
  52. }
  53. internal interface IElement_AdaptiveSubgroupChild
  54. {
  55. }
  56. }