CompareValidator.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // Permission is hereby granted, free of charge, to any person obtaining
  3. // a copy of this software and associated documentation files (the
  4. // "Software"), to deal in the Software without restriction, including
  5. // without limitation the rights to use, copy, modify, merge, publish,
  6. // distribute, sublicense, and/or sell copies of the Software, and to
  7. // permit persons to whom the Software is furnished to do so, subject to
  8. // the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be
  11. // included in all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  17. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  18. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  19. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. //
  21. /**
  22. * Project : Mono
  23. * Namespace : System.Web.UI.MobileControls
  24. * Class : CompareValidator
  25. * Author : Gaurav Vaish
  26. *
  27. * Copyright : 2003 with Gaurav Vaish, and with
  28. * Ximian Inc
  29. */
  30. using System.ComponentModel;
  31. using System.Web.UI;
  32. using System.Web.Mobile;
  33. using System.Web.UI.WebControls;
  34. namespace System.Web.UI.MobileControls
  35. {
  36. public class CompareValidator : BaseValidator
  37. {
  38. private System.Web.UI.WebControls.CompareValidator webCmpVal;
  39. public CompareValidator()
  40. {
  41. }
  42. protected override System.Web.UI.WebControls.BaseValidator CreateWebValidator()
  43. {
  44. webCmpVal = new System.Web.UI.WebControls.CompareValidator();
  45. return webCmpVal;
  46. }
  47. protected override bool EvaluateIsValid()
  48. {
  49. return base.EvaluateIsValidInternal();
  50. }
  51. protected override bool ControlPropertiesValid()
  52. {
  53. if(ControlToCompare.Length > 0)
  54. {
  55. base.CheckControlValidationProperty(ControlToCompare, "ControlToCompare");
  56. if(String.Compare(ControlToCompare, ControlToValidate, true) == 0)
  57. {
  58. // FIXME
  59. throw new ArgumentException("CompareValidator_BadCompareControl");
  60. }
  61. } else
  62. {
  63. if(Operator != ValidationCompareOperator.DataTypeCheck)
  64. {
  65. if(!BaseCompareValidator.CanConvert(ValueToCompare, Type))
  66. {
  67. // FIXME
  68. throw new ArgumentException("Validator_ValueBadType");
  69. }
  70. }
  71. }
  72. return base.ControlPropertiesValid();
  73. }
  74. public string ControlToCompare
  75. {
  76. get
  77. {
  78. return webCmpVal.ControlToCompare;
  79. }
  80. set
  81. {
  82. webCmpVal.ControlToCompare = value;
  83. }
  84. }
  85. public ValidationCompareOperator Operator
  86. {
  87. get
  88. {
  89. return webCmpVal.Operator;
  90. }
  91. set
  92. {
  93. webCmpVal.Operator = value;
  94. }
  95. }
  96. public ValidationDataType Type
  97. {
  98. get
  99. {
  100. return webCmpVal.Type;
  101. }
  102. set
  103. {
  104. webCmpVal.Type = value;
  105. }
  106. }
  107. public string ValueToCompare
  108. {
  109. get
  110. {
  111. return webCmpVal.ValueToCompare;
  112. }
  113. set
  114. {
  115. webCmpVal.ValueToCompare = value;
  116. }
  117. }
  118. }
  119. }