FormEntity.cs
上传用户:husern
上传日期:2022-03-24
资源大小:534k
文件大小:4k
源码类别:

编辑器/阅读器

开发平台:

C#

  1. // -- FILE ------------------------------------------------------------------
  2. // name       : FormEntity.cs
  3. // project    : Itenso Web User Forms
  4. // created    : Jani Giannoudis - 2008.10.30
  5. // language   : c#
  6. // environment: .NET 2.0
  7. // copyright  : (c) 2008 by Itenso GmbH, Switzerland
  8. // --------------------------------------------------------------------------
  9. using System;
  10. using Itenso.WebUserForms.Data.Variable;
  11. namespace Itenso.WebUserForms.Data.Form
  12. {
  13. // ------------------------------------------------------------------------
  14. public abstract class FormEntity : IFormEntity
  15. {
  16. // ----------------------------------------------------------------------
  17. /// <summary>
  18. /// for internal use only!
  19. /// </summary>
  20. protected FormEntity( FormEntityType kind )
  21. {
  22. this.kind = kind;
  23. } // FormEntity
  24. // ----------------------------------------------------------------------
  25. protected FormEntity( FormEntityType kind, string name )
  26. {
  27. if ( string.IsNullOrEmpty( name ) )
  28. {
  29. throw new ArgumentNullException( "name" );
  30. }
  31. this.kind = kind;
  32. this.name = name;
  33. } // FormEntity
  34. // ----------------------------------------------------------------------
  35. protected FormEntity( FormEntity copy )
  36. {
  37. if ( copy == null )
  38. {
  39. throw new ArgumentNullException( "copy" );
  40. }
  41. this.kind = copy.kind;
  42. this.name = copy.name;
  43. } // FormEntity
  44. // ----------------------------------------------------------------------
  45. public FormEntityType Kind
  46. {
  47. get { return this.kind; }
  48. } // Kind
  49. // ----------------------------------------------------------------------
  50. public string Name
  51. {
  52. get { return this.name; }
  53. set { this.name = value; }
  54. } // Name
  55. // ----------------------------------------------------------------------
  56. IFormEntity IFormEntity.Duplicate()
  57. {
  58. return DoDuplicate();
  59. } // IFormItem.Duplicate
  60. // ----------------------------------------------------------------------
  61. protected abstract IFormEntity DoDuplicate();
  62. // ----------------------------------------------------------------------
  63. public void ExpandVariables( IVariableSet varSet )
  64. {
  65. if ( varSet != null && varSet.Count > 0 )
  66. {
  67. DoExpandVariables( varSet );
  68. }
  69. } // ExpandVariables
  70. // ----------------------------------------------------------------------
  71. protected abstract void DoExpandVariables( IVariableSet varSet );
  72. // ----------------------------------------------------------------------
  73. public override bool Equals( object obj )
  74. {
  75. bool equal = false;
  76. FormEntity compare = obj as FormEntity;
  77. if ( compare != null )
  78. {
  79. equal =
  80. Object.Equals( this.kind, compare.kind ) &&
  81. Object.Equals( this.name, compare.name );
  82. }
  83. return equal;
  84. } // Equals
  85. // ----------------------------------------------------------------------
  86. public override int GetHashCode()
  87. {
  88. int hash = GetType().GetHashCode();
  89. hash = HashTool.AddHashCode( hash, this.kind );
  90. hash = HashTool.AddHashCode( hash, this.name );
  91. return hash;
  92. } // GetHashCode
  93. // ----------------------------------------------------------------------
  94. public override string ToString()
  95. {
  96. return this.kind.ToString() + "-" + this.name;
  97. } // ToString
  98. // ----------------------------------------------------------------------
  99. // members
  100. private readonly FormEntityType kind;
  101. private string name;
  102. } // class FormEntity
  103. } // namespace Itenso.WebUserForms.Data.Form
  104. // -- EOF -------------------------------------------------------------------