Persistate

The LendStatus struct

Hide Navigation Pane

The LendStatus struct

Previous topic Next topic No directory for this topic  

The LendStatus struct

Previous topic Next topic Topic directory requires JavaScript JavaScript is required for the print function Mail us feedback on this topic!  

using System;
using System.ComponentModel;
using Persistate;
 
namespace Library.Model
{
   // This LendStatus partial class has been generated by Persistate.  Do
   // not modify as the entire file is recreated on each generation.
 
   [System.Diagnostics.DebuggerDisplay("{ToString()} ({ordinal})")]   
   [TypeConverter(typeof(MultiValueConverter))]
   public partial struct LendStatus : IMultiValue
   {
      /// <summary> Contains the value of the LendStatus. </summary>
      public int ordinal;
 
      // IMultiValue property implementations
      
      /// <summary> Gets the integer ordinal value of this LendStatus. </summary>
      public int Ordinal { get { return ordinal; } set { ordinal = value; } }
 
      /// <summary> Indicates whether LendStatus values can be combined. </summary>
      public bool IsCombinable { get { return false; } }
 
      /// <summary> Gets the array of ISourcePairs holding ordinal and text values. </summary>
      public ISourcePair[] SourcePairs { get { return sourcePairs; } }
 
      /// <summary> This is the default LendStatus value. </summary>
      public const int _undefined_ = 0;
      /// <summary> This is the value for available. </summary>
      public const int Available = 1;
      /// <summary> This is the value for on loan. </summary>
      public const int OnLoan = 2;
      /// <summary> This is the value for unavailable. </summary>
      public const int Unavailable = 3;
      /// <summary> This is the value for the top value. </summary>
      public const int TopValue = 3;
 
      /// <summary> This class represents a text and ordinal pair for LendStatus values. </summary>
      public class SourcePair : ISourcePair {
         private LendStatus ordinal_;
         private string text_;
 
         /// <summary> Gets the ordinal value of the source pair. </summary>
         public LendStatus ordinal { get { return ordinal_; } }
 
         // ISourcePair property implementations
         
         /// <summary> Gets the ordinal value of the source pair as an int. </summary>
         public int intOrdinal { get { return ordinal_; } }
         
         /// <summary> Gets the ordinal value of the source pair as an IMultiValue . </summary>
         public IMultiValue multiValueOrdinal { get { return ordinal; } }
         
         /// <summary> Gets the text value of the source pair. </summary>
         public string text { get { return text_; } }
 
         internal SourcePair(int ordinal, string text) {
            text_ = text;
            ordinal_ = (LendStatus)ordinal;
         }
      }
 
      /// <summary> This array contains one source pair for each LendStatus value. </summary>
      public static readonly SourcePair[] sourcePairs = { 
         new SourcePair(_undefined_, ""),
         new SourcePair(Available, "available"),
         new SourcePair(OnLoan, "on loan"),
         new SourcePair(Unavailable, "unavailable") 
      };
 
      /// <summary> Creates a new LendStatus from an integer value. </summary>
      /// <param name="ordinal"> The ordinal value for the new LendStatus. </param>
      /// <exception cref="ArgumentOutOfRangeException"> Thrown if the ordinal is negative or greater than the TopValue.</exception>
      public LendStatus(int ordinal) {
         if (ordinal < 0 || ordinal > TopValue)
            throw new ArgumentOutOfRangeException("ordinal", ordinal, "Invalid value for multi value struct");
         this.ordinal = ordinal;
      }
 
      /// <summary> Implicit conversion from LendStatus to int. </summary>
      /// <param name="val"> The LendStatus to convert. </param>
      /// <returns> An int containing the converted valaue. </returns>
      public static implicit operator int(LendStatus val) {
         return val.ordinal;
      }
 
      /// <summary> Implicit conversion from int to LendStatus. </summary>
      /// <param name="ordinal"> The int to convert. </param>
      /// <returns> An LendStatus containing the converted value. </returns>
      public static implicit operator LendStatus(int ordinal) {
         return new LendStatus(ordinal);
      }
 
      /// <summary> Explicit conversion from LendStatus to string. </summary>
      /// <param name="val"> The LendStatus to convert. </param>
      /// <returns> A string containing the converted valaue. </returns>
      public static explicit operator string(LendStatus val) {
         return val.ToString();
      }
 
      /// <summary> Implicit conversion from string to LendStatus. </summary>
      /// <param name="input"> The string to convert. </param>
      /// <returns> An LendStatus containing the converted value. </returns>
      public static implicit operator LendStatus(string input) {
         return Parse(input);
      }
 
      /// <summary> Performs an equality comparison with another object. </summary>
      /// <param name="val"> The object to compare this one against. </param>
      /// <returns> True if the two objects are equal, otherwise false. </returns>
      public override bool Equals(object val) {
         return (val is LendStatus && ((LendStatus)val).ordinal == this.ordinal);
      }
 
      /// <summary> Creates a hash code for the LendStatus. </summary>
      /// <returns> An int containing the hash code. </returns>
      public override int GetHashCode() {
         return this.ordinal;
      }
 
      /// <summary> Creates a textual representation of the LendStatus. </summary>
      /// <returns> A string containing the textual respresentation. </returns>
      public override string ToString() {
         return Utl.MultiValueText(this);
      }
 
      /// <summary> Parses a string containing a textual representation of an LendStatus. </summary>
      /// <param name="input"> The string containing the textual representation. </param>
      /// <returns> An LendStatus which is the result of the parse, or _undefined_ if the parse fails. </returns>
      public static LendStatus Parse(string input) {
         return Utl.ParseMultiValue(input, sourcePairs, false);
      }
   }
}