/* i-net software provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This programming example assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. i-net software support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. © i-net software 1998-2013 */ using System; namespace Inet.Viewer.Data { using Inet.Viewer.Resources; /// /// Abstract super class of a prompt value /// [System.SerializableAttribute()] public abstract class PromptValue { /// /// decription for the prompt value private string description = ""; /// /// value type of this prompt private int type; /// /// if true show only the decription for the prompt value private bool onlyDescription; /// /// Creates a prompt values of the given type initialized with the default value of its type /// type of this default value. public PromptValue(int type) { this.type = type; InitValue(); } /// /// Creates a prompt values of the given type initialized with the default value of its type /// type of this default value. /// decription of this promt public PromptValue(string description, int type) { this.description = description; this.type = type; } /// /// Returns the value of this prompt as string. /// the value of this prompt as string. internal abstract string ValueString { get; } /// /// Returns the value of this prompt as string. /// the given promptValue. /// the value of this prompt as string. public static string GetValueString(PromptValue promptValue) { if (promptValue == null) { return strings.Prompt_None; } else { return promptValue.ValueString; } } /// /// Returns a string representation of the value of this prompt. /// a string representation of the value of this prompt. public abstract string StringRepresentation { get; } /// /// Returns the value of this prompt - its type will depend on which value type this PromptValue has: /// String for STRING
/// Double for NUMBER and CURRENCY
/// Boolean for BOOLEAN
/// Date for DATE and DATETIME
/// Time for TIME
/// byte[] for BINARY
/// the value of this prompt - its type will depend on which value type this PromptValue has. public abstract object Value { get; } /// /// initializes the prompt value. /// internal abstract void InitValue(); /// /// Creates a formated string representation of this prompt value with its decription and value. /// String representation public override string ToString() { string value = ValueString; string result = ""; if (this.Description != null && this.Description.Length > 0) { if (!this.OnlyDescription) { result = value + " - "; } result += this.Description; } else { return value; } return result; } /// /// Get description of the prompt value /// decription of the prompt value public virtual string Description { get { return description; } set { this.description = value; } } /// /// Get value type of the prompt, see the value type constants in /// value type of the prompt, see the value type constants in public virtual int Type { get { return type; } } /// /// If true only the decription will be displayed in the report dialog. /// (only necessary if this prompt value represents a default value) /// whether only description is displayed public virtual bool OnlyDescription { get { return onlyDescription; } set { this.onlyDescription = value; } } /// /// Used for showing the values in combo boxes /// public string DisplayString { get { return this.ToString(); } } /// public override bool Equals(object obj) { return obj is PromptValue && StringRepresentation == ((PromptValue)obj).StringRepresentation; } /// public override int GetHashCode() { if (StringRepresentation == null) { return 0; } return StringRepresentation.GetHashCode(); } } }