XmlMembersMapping.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // System.Xml.Serialization.XmlMembersMapping
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. // Lluis Sanchez Gual ([email protected])
  7. //
  8. // Copyright (C) Tim Coleman, 2002
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using System.Reflection;
  31. namespace System.Xml.Serialization {
  32. public class XmlMembersMapping : XmlMapping {
  33. bool _hasWrapperElement;
  34. XmlMemberMapping[] _mapping;
  35. internal XmlMembersMapping ()
  36. {
  37. }
  38. internal XmlMembersMapping (XmlMemberMapping[] mapping): this ("", null, false, false, mapping)
  39. {
  40. }
  41. internal XmlMembersMapping (string elementName, string ns, XmlMemberMapping[] mapping): this (elementName, ns, true, false, mapping)
  42. {
  43. }
  44. internal XmlMembersMapping (string elementName, string ns, bool hasWrapperElement, bool writeAccessors, XmlMemberMapping[] mapping)
  45. : base (elementName, ns)
  46. {
  47. _hasWrapperElement = hasWrapperElement;
  48. _mapping = mapping;
  49. ClassMap map = new ClassMap ();
  50. map.IgnoreMemberNamespace = writeAccessors;
  51. foreach (XmlMemberMapping mm in mapping)
  52. map.AddMember (mm.TypeMapMember);
  53. ObjectMap = map;
  54. }
  55. #region Properties
  56. public int Count {
  57. get { return _mapping.Length; }
  58. }
  59. #if !NET_2_0
  60. public string ElementName {
  61. get { return _elementName; }
  62. }
  63. public string Namespace {
  64. get { return _namespace; }
  65. }
  66. #endif
  67. public XmlMemberMapping this [int index] {
  68. get { return _mapping[index]; }
  69. }
  70. public string TypeName {
  71. [MonoTODO]
  72. get { throw new NotImplementedException (); }
  73. }
  74. public string TypeNamespace {
  75. [MonoTODO]
  76. get { throw new NotImplementedException (); }
  77. }
  78. internal bool HasWrapperElement {
  79. get { return _hasWrapperElement; }
  80. }
  81. #endregion // Properties
  82. }
  83. }