Example #1
0
        public static string AsText(this IFieldBase field)
        {
            if (field is StringField)
            {
                return((field as StringField).Data);
            }
            else if (field is BinaryFieldBase)
            {
                BinaryFieldBase bin = field as BinaryFieldBase;

                if (bin != null && bin.Data != null)
                {
                    return(StringHelper.GetString(bin.Data));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                if (field != null)
                {
                    DebugHelper.Out("Unexpected field: expected StringField / BinaryFieldBase, got {0}", field.GetType().Name);
                }

                return(null);
            }
        }
Example #2
0
        public static int?AsNumber(this IFieldBase field)
        {
            if (field is Int16Field)
            {
                return((field as Int16Field).Data);
            }
            else if (field is Int32Field)
            {
                return((field as Int32Field).Data);
            }
            else if (field is ByteField)
            {
                return((field as ByteField).Data);
            }
            else
            {
                if (field != null)
                {
                    DebugHelper.Out("Unexpected field: expected Int16Field / Int32Field / ByteField, got {0}", field.GetType().Name);
                }

                return(null);
            }
        }
Example #3
0
 public static void CheckFieldType(IFieldBase field, Type expectedType)
 {
     if ((field != null) && (expectedType != null))
     {
         if (!expectedType.IsInstanceOfType(field))
         {
             DebugHelper.Out("Unexpected field: expected {0}, got {1}", expectedType.Name, field.GetType().Name);
         }
     }
 }