private Metadata         metadata;    // the metadata assoc w/ raster
 
 /// <summary>
 /// No arg constructor
 /// </summary>
 /// <remark>
 /// Used before calling Read()
 /// </remark>
 public ImageHeader()
 {
     this.dimensions = new Dimensions(0,0);
     this.bandType = System.TypeCode.Byte;
     this.bandSize = 0;
     this.bandCount = 0;
     this.metadata = new Metadata();
 }
 /// <summary>
 /// Fully specified constructor - used before calling Write()
 /// </summary>
 /// <remark>
 /// Usually used before calling Write() but could call NoArg constructor,
 /// Read(), and then Write() if copying images
 /// </remark>
 public ImageHeader(Dimensions dimensions, System.TypeCode bandType,
                         int bandCount, IMetadata metadata)
 {
     this.dimensions = dimensions;
     this.bandType   = bandType;
     this.bandCount  = bandCount;
     this.metadata   = metadata as Metadata;
     if (bandType == System.TypeCode.Byte)
         this.bandSize   = 1;
     else if (bandType == System.TypeCode.UInt16)
         this.bandSize   = 2;
     else
         throw new ApplicationException("ImageHeader: bandType must either be Byte or UInt16");
 }
Esempio n. 3
0
 static int GetTypeCode(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Enum     obj = (System.Enum)ToLua.CheckObject(L, 1, typeof(System.Enum));
         System.TypeCode o   = obj.GetTypeCode();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 private void TryCtor(string filename,
                      Dimensions dimensions,
                      int bandCount,
                      System.TypeCode bandType,
                      IMetadata metadata)
 {
     try {
         Image image = new Image(filename, dimensions,
                                 bandCount, bandType,
                                 metadata);
     }
     catch (System.Exception exc) {
         Data.Output.WriteLine(exc.Message);
         throw;
     }
 }
 public static bool IsDecimal(System.TypeCode c)
 {
     if (c == System.TypeCode.Decimal)
     {
         return(true);
     }
     if (c == System.TypeCode.Double)
     {
         return(true);
     }
     if (c == System.TypeCode.Single)
     {
         return(true);
     }
     return(false);
 }
        /// <summary>
        /// <see cref="System.Object"/> を JSON 形式にシリアライズします。
        /// </summary>
        /// <param name="srcObject">JSON 形式にシリアライズする <see cref="System.Object"/></param>
        /// <returns>JSON 形式にシリアライズされた <paramref name="srcObject"/></returns>
        private string SerializeValue(object srcObject)
        {
            if (srcObject == null)
            {
                return("null");
            }

            System.TypeCode typeCode = System.Type.GetTypeCode(srcObject.GetType());

            switch (typeCode)
            {
            case System.TypeCode.Byte:
            case System.TypeCode.SByte:
            case System.TypeCode.Int16:
            case System.TypeCode.Int32:
            case System.TypeCode.Int64:
            case System.TypeCode.UInt16:
            case System.TypeCode.UInt32:
            case System.TypeCode.UInt64:
            case System.TypeCode.Single:
            case System.TypeCode.Double:
                return(SerializeNumber(srcObject));

            case System.TypeCode.Boolean:
                return(srcObject.ToString().ToLower());

            case System.TypeCode.String:
                return(SerializeString(srcObject));

            default:
                if (srcObject is System.Collections.Generic.Dictionary <string, object> )
                {
                    return(SerializeObject(srcObject));
                }
                else if (srcObject is System.Collections.Generic.IList <object> )
                {
                    return(SerializeArray(srcObject));
                }
                else
                {
                    return(SerializeString(srcObject));
                }
            }
        }
 /// <summary>
 /// Fully specified constructor - used before calling Write()
 /// </summary>
 /// <remark>
 /// Usually used before calling Write() but could call NoArg constructor,
 /// Read(), and then Write() if copying images
 /// </remark>
 public ImageHeader(Dimensions dimensions, System.TypeCode bandType,
                    int bandCount, IMetadata metadata)
 {
     this.dimensions = dimensions;
     this.bandType   = bandType;
     this.bandCount  = bandCount;
     this.metadata   = metadata as Metadata;
     if (bandType == System.TypeCode.Byte)
     {
         this.bandSize = 1;
     }
     else if (bandType == System.TypeCode.UInt16)
     {
         this.bandSize = 2;
     }
     else
     {
         throw new ApplicationException("ImageHeader: bandType must either be Byte or UInt16");
     }
 }
Esempio n. 8
0
        public DataType Create(string name, string description, System.TypeCode systemType)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(name));
            Contract.Ensures(Contract.Result <DataType>() != null && Contract.Result <DataType>().Id >= 0);

            DataType u = new DataType()
            {
                Name        = name,
                Description = description,
                SystemType  = systemType.ToString(),
            };

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository <DataType> repo = uow.GetRepository <DataType>();
                repo.Put(u);
                uow.Commit();
            }
            return(u);
        }
 public static bool IsUInteger(System.TypeCode c)
 {
     if (c == System.TypeCode.Byte)
     {
         return(true);
     }
     if (c == System.TypeCode.UInt16)
     {
         return(true);
     }
     if (c == System.TypeCode.UInt32)
     {
         return(true);
     }
     if (c == System.TypeCode.UInt64)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 10
0
        /// <summary>
        /// Create an Erdas image file given specs
        /// </summary>
        public Image(string filename,
                     Dimensions dimensions,
                     int bandCount,
                     System.TypeCode bandType,
                     IMetadata metadata)
        {
            // if filename does not end in .gis or .lan throw exception
            string extension = Path.GetExtension(filename).ToLower();

            if (!(extension.Equals(".gis")) && !(extension.Equals(".lan")))
            {
                throw new ApplicationException("Erdas image must have either GIS or LAN as extension");
            }

            // if dimensions are messed up throw exception
            if ((dimensions.Rows < 1) || (dimensions.Columns < 1))
            {
                throw new ApplicationException("Erdas image given invalid dimensions");
            }

            // if bandCount messed up throw exception
            if ((bandCount < 1) || (bandCount > 0xffff))
            {
                throw new ApplicationException("Erdas image given invalid band count");
            }

            // more bandCount checking
            if (extension.Equals(".gis"))
            {
                if (bandCount > 1)
                {
                    throw new ApplicationException("Erdas GIS files cannot support multiband images");
                }
            }

            this.imageHeader =
                new ImageHeader(dimensions, bandType, bandCount, metadata);

            this.imageHeader.Write(filename);
        }
Esempio n. 11
0
    public static bool IsInteger(System.TypeCode code)
    {
        switch (code)
        {
        case System.TypeCode.SByte:
            //5
            return(true);

        case System.TypeCode.Byte:
            //6
            return(true);

        case System.TypeCode.Int16:
            //7
            return(true);

        case System.TypeCode.UInt16:
            //8
            return(true);

        case System.TypeCode.Int32:
            //9
            return(true);

        case System.TypeCode.UInt32:
            //10
            return(true);

        case System.TypeCode.Int64:
            //11
            return(true);

        case System.TypeCode.UInt64:
            //12
            return(true);

        default:
            return(false);
        }
    }
Esempio n. 12
0
        private bool ConvertType(Object obj, System.Reflection.PropertyInfo prop, Type propertyType, string value)
        {
            System.TypeCode typeCode = System.Type.GetTypeCode(propertyType);
            try
            {
                switch (typeCode)
                {
                case TypeCode.Int32:
                    prop.SetValue(obj, Convert.ToInt32(value), null);
                    break;

                case TypeCode.Int64:
                    prop.SetValue(obj, Convert.ToInt64(value), null);
                    break;

                case TypeCode.Double:
                    prop.SetValue(obj, Convert.ToDouble(value), null);
                    break;

                case TypeCode.Decimal:
                    prop.SetValue(obj, Convert.ToDecimal(value), null);
                    break;

                case TypeCode.String:
                    prop.SetValue(obj, value, null);
                    break;

                default:
                    prop.SetValue(obj, value, null);
                    break;
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to set property value for our Foreign Key");
            }
        }
        /// <summary>
        /// Typeds the value from CTS.
        /// </summary>
        /// <param name="typ">The typ.</param>
        /// <param name="typeCode">The type code.</param>
        /// <param name="obj">The object.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException"></exception>
        private static TypedValue TypedValueFromCTS(Type typ, System.TypeCode typeCode, object obj)
        {
            switch (typeCode)
            {
            case System.TypeCode.String:
                return(new TypedValue(RTSTR, obj));

            case System.TypeCode.Int16:
                return(new TypedValue(RTSHORT, obj));

            case System.TypeCode.Int32:
                return(new TypedValue(RTLONG, obj));

            case System.TypeCode.Double:
                return(new TypedValue(RTREAL, obj));

            case System.TypeCode.Int64:
                return(new TypedValue(RTINT64, obj));

            default:
                throw new ArgumentException();
            }
        }
Esempio n. 14
0
 static public System.Int16 ToInt16(object v)
 {
     System.Int16 d = 0;
     if (v != null)
     {
         System.TypeCode tp = Convert.GetTypeCode(v);
         if (tp == System.TypeCode.Int16)
         {
             return((System.Int16)v);
         }
         else
         {
             try
             {
                 d = Convert.ToInt16(v);
             }
             catch
             {
             }
         }
     }
     return(d);
 }
Esempio n. 15
0
        public static object valVariant(object var)
        {
            if (var == null)
            {
                System.TypeCode typeCode = System.Type.GetTypeCode(var.GetType());
                switch (typeCode)
                {
                case System.TypeCode.Char:
                case System.TypeCode.String:
                    return("");

                case System.TypeCode.Decimal:
                case System.TypeCode.Double:
                case System.TypeCode.Int16:
                case System.TypeCode.Int32:
                case System.TypeCode.Int64:
                case System.TypeCode.Single:
                case System.TypeCode.UInt16:
                case System.TypeCode.UInt32:
                case System.TypeCode.UInt64:
                    return(0);

                case System.TypeCode.DateTime:
                    return(CSDataBase.cConstants.C_NO_DATE);

                case System.TypeCode.Boolean:
                    return(false);

                default:
                    return(null);
                }
            }
            else
            {
                return(var);
            }
        }
Esempio n. 16
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService editorService = null;

            if (context != null && context.Instance != null && provider != null)
            {
                editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    IDataControl control = (IDataControl)context.Instance;
                    //PropertySelectorForm dlg = new PropertySelectorForm(control);
                    if (!string.IsNullOrEmpty(control.LinkObject))
                    {
                        System.TypeCode code = control.SysTypeCode;
                        if (code != TypeCode.Empty)
                        {
                            MessageBox.Show("请先选择SysTypeCode 属性并设置为" + code.ToString());
                        }
                        else
                        {
                            MessageBox.Show("请先选择SysTypeCode 属性并设置合适的值");
                        }

                        control.SysTypeCode = TypeCode.Empty;
                        return(control.LinkObject.Trim());
                    }
                    else
                    {
                        MessageBox.Show("请先选择LinkProperty 属性设置值并设置合适的SysTypeCode");
                        control.SysTypeCode = TypeCode.Empty;
                        return("");
                    }
                }
            }

            return(value);
        }
        public static void MergeData(this L1QuoteStreaming q1, L1QuoteStreaming q2)
        {
            if (q1.Symbol != q2.Symbol)
            {
                throw new InvalidCastException(string.Format("Can't merge data: {0} because of different symbols", q1.Symbol));
            }

            var properties = typeof(L1QuoteStreaming).GetProperties();

            foreach (var pi in properties)
            {
                System.Type     propertyType = pi.PropertyType;
                System.TypeCode typeCode     = Type.GetTypeCode(propertyType);

                var type1 = q1.GetType();
                var pi1   = type1.GetProperty(pi.Name);
                var type2 = q2.GetType();
                var pi2   = type2.GetProperty(pi.Name);
                var v1    = pi2.GetValue(q2, null); // Get value of q2's property

                if (typeCode == TypeCode.Int32 ||
                    typeCode == TypeCode.Int64 ||
                    typeCode == TypeCode.Single ||
                    typeCode == TypeCode.Double)
                {
                    if (Convert.ToDouble(v1) != 0.0)
                    {
                        pi1.SetValue(pi1, Convert.ChangeType(v1, typeCode));  // Set the property value
                    }
                }
                else
                {
                    pi1.SetValue(pi1, Convert.ChangeType(v1, typeCode));  // Set the property value
                }
            }
        }
Esempio n. 18
0
 /// <summary>
 /// Regular Expression match test if text is allowed
 /// </summary>
 /// <param name="text"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static bool IsTextAllowed(string text, System.TypeCode type)
 {
     return(type switch
     {
         TypeCode.Empty => text == "",
         TypeCode.Object => false,
         TypeCode.DBNull => false,
         TypeCode.Boolean => !(new Regex("[^0-9.-]+").IsMatch(text)),
         TypeCode.Char => text.Length == 1,
         TypeCode.SByte => !(new Regex("[^0-9-]+").IsMatch(text)),
         TypeCode.Byte => !(new Regex("[^0-9-]+").IsMatch(text)),
         TypeCode.Int16 => !(new Regex("[^0-9-]+").IsMatch(text)),
         TypeCode.UInt16 => !(new Regex("[^0-9-]+").IsMatch(text)),
         TypeCode.Int32 => !(new Regex("[^0-9-]+").IsMatch(text)),
         TypeCode.UInt32 => !(new Regex("[^0-9-]+").IsMatch(text)),
         TypeCode.Int64 => !(new Regex("[^0-9-]+").IsMatch(text)),
         TypeCode.UInt64 => !(new Regex("[^0-9-]+").IsMatch(text)),
         TypeCode.Single => !(new Regex("[^0-9.-]+").IsMatch(text)),
         TypeCode.Double => !(new Regex("[^0-9.-]+").IsMatch(text)),
         TypeCode.Decimal => !(new Regex("[^0-9.-]+").IsMatch(text)),
         TypeCode.DateTime => false,
         TypeCode.String => (new Regex("[ A-Za-z0-9_-]").IsMatch(text)),
         _ => false,
     });
Esempio n. 19
0
        void TestParse()
        {
            System.TypeCode tc1 = TypeCode.Byte;
            System.TypeCode tc2;
            tc1.ToString().TryParse <System.TypeCode>(out tc2);

            Logger.LogG("Testing TryParse", $"{tc1} and {tc2}\n");

            var a = tc1.HasFlag(TypeCode.Int32);

            Logger.LogG("Testing HasFlag TypeCode.Byte = TypeCode.Int32", $"HasFlag = {a}\n");
            a = tc1.HasFlag(TypeCode.Byte);
            Logger.LogG("Testing HasFlag TypeCode.Byte = TypeCode.Byte", $"HasFlag = {a}\n");
//      var r = tc1.
//      Logger.LogG("Testing TryParse(Enum.Name, out...)",$"");


            Console.Write("Press a Key to continue\n");



            Console.ReadKey();
            return;
        }
Esempio n. 20
0
        public static String format(object expression, String strFormat)
        {
            if (expression == null)
            {
                return("");
            }
            else
            {
                bool isDate = false;

                System.TypeCode typeCode = System.Type.GetTypeCode(expression.GetType());
                if (typeCode == System.TypeCode.DateTime)
                {
                    if ((DateTime)expression == CSDataBase.cConstants.C_NO_DATE)
                    {
                        return("");
                    }
                    isDate = true;
                }
                if (strFormat == "")
                {
                    return(expression.ToString());
                }
                else
                {
                    if (isDate)
                    {
                        return(((DateTime)expression).ToString(strFormat));
                    }
                    else
                    {
                        return(cUtil.val(expression).ToString(strFormat));
                    }
                }
            }
        }
Esempio n. 21
0
 public void SetXmlProperty(string xpath, string value, System.TypeCode DataTyp, bool cdata)
 {
     SetXmlProperty(xpath, value, DataTyp, cdata, false, false);
 }
Esempio n. 22
0
        private static void SetObjAttrValue(object obj, PropertyInfo propertyInfo, string sValue)
        {
            try
            {
                System.TypeCode typeCode = Type.GetTypeCode(propertyInfo.PropertyType);
                switch (typeCode)
                {
                case TypeCode.String:
                    propertyInfo.SetValue(obj, sValue);
                    break;

                case TypeCode.Int32:

                    if (propertyInfo.PropertyType.IsEnum)
                    {
                        object o = Enum.Parse(propertyInfo.PropertyType, sValue);
                        if (o != null)
                        {
                            propertyInfo.SetValue(obj, o);
                        }
                        else
                        {
                            throw new Exception("Cannot convert Enum - " + sValue);
                        }
                    }
                    else
                    {
                        propertyInfo.SetValue(obj, Int32.Parse(sValue));
                    }
                    break;

                case TypeCode.Int64:
                    propertyInfo.SetValue(obj, Int64.Parse(sValue));
                    break;

                case TypeCode.Double:
                    propertyInfo.SetValue(obj, double.Parse(sValue));
                    break;

                case TypeCode.Decimal:
                    propertyInfo.SetValue(obj, decimal.Parse(sValue));
                    break;

                case TypeCode.DateTime:
                    propertyInfo.SetValue(obj, DateTime.Parse(sValue));
                    break;

                case TypeCode.Boolean:
                    if (sValue.ToUpper() == "FALSE")
                    {
                        propertyInfo.SetValue(obj, false);
                        return;
                    }
                    if (sValue.ToUpper() == "TRUE")
                    {
                        propertyInfo.SetValue(obj, true);
                        return;
                    }

                    break;

                case TypeCode.Object:

                    if (propertyInfo.PropertyType == typeof(System.Guid))
                    {
                        if (sValue != "00000000-0000-0000-0000-00000000")
                        {
                            propertyInfo.SetValue(obj, new Guid(sValue));
                        }
                    }
                    else if (propertyInfo.PropertyType == typeof(RepositoryItemKey))
                    {
                        RepositoryItemKey repositoryItemKey = new RepositoryItemKey();
                        repositoryItemKey.Key = sValue;
                        propertyInfo.SetValue(obj, repositoryItemKey);
                    }
                    else
                    {
                        //check if this is nullable enum  like: Activity Status?
                        if (Nullable.GetUnderlyingType(propertyInfo.PropertyType).IsEnum)
                        {
                            object o = Enum.Parse(Nullable.GetUnderlyingType(propertyInfo.PropertyType), sValue);
                            if (o != null)
                            {
                                propertyInfo.SetValue(obj, o);
                            }
                            else
                            {
                                throw new Exception("Cannot convert Enum - " + sValue);
                            }
                        }
                        else
                        // handle long?   = int64 nullable  - used in elapsed
                        if (Type.GetTypeCode(Nullable.GetUnderlyingType(propertyInfo.PropertyType)) == TypeCode.Int64)
                        {
                            if (sValue != null)
                            {
                                propertyInfo.SetValue(obj, Int64.Parse(sValue));
                            }
                            else
                            {
                                throw new Exception("Cannot convert Nullable Int64 - " + sValue);
                            }
                        }
                        else
                        if (Type.GetTypeCode(Nullable.GetUnderlyingType(propertyInfo.PropertyType)) == TypeCode.Int32)
                        {
                            if (sValue != null)
                            {
                                propertyInfo.SetValue(obj, Int32.Parse(sValue));
                            }
                            else
                            {
                                throw new Exception("Cannot convert Nullable Int32 - " + sValue);
                            }
                        }
                        else
                        if (Type.GetTypeCode(Nullable.GetUnderlyingType(propertyInfo.PropertyType)) == TypeCode.Double)
                        {
                            if (sValue != null)
                            {
                                propertyInfo.SetValue(obj, Double.Parse(sValue));
                            }
                            else
                            {
                                throw new Exception("Cannot convert Nullable Double - " + sValue);
                            }
                        }

                        else
                        {
                            throw new Exception("Serializer - Err set value, Unknown type - " + propertyInfo.PropertyType.ToString() + " Value: " + sValue);
                        }
                    }
                    break;

                default:
                    throw new Exception("Serializer - Err set value, Unknow type - " + propertyInfo.PropertyType.ToString() + " Value: " + sValue);
                }

                //TODO: all other types
            }
            catch
            {
                string err;
                if (propertyInfo != null)
                {
                    err = "Obj=" + obj + ", Property=" + propertyInfo.Name + ", Value=" + sValue.ToString();
                }
                else
                {
                    err = "Property Not found: Obj=" + obj + " Value=" + sValue.ToString();
                }
                throw new Exception(err);
            }
        }
Esempio n. 23
0
 protected object CnvChangeType(object value, System.TypeCode typeCode)
 {
     return(COMMAND.Convert.Convert.CnvChangeType(value, typeCode));
 }
Esempio n. 24
0
        /// <summary>
        /// Returns the primitive type reference for the given Clr type.
        /// </summary>
        /// <param name="clrType">The Clr type to resolve.</param>
        /// <returns>The primitive type reference for the given Clr type.</returns>
        public static IEdmPrimitiveTypeReference GetPrimitiveTypeReference(Type clrType)
        {
            Debug.Assert(clrType != null, "clrType != null");

            Type     targetType = TestTypeUtils.GetNonNullableType(clrType);
            TypeCode typeCode   = Type.GetTypeCode(targetType);
            bool     nullable   = TestTypeUtils.TypeAllowsNull(clrType);

            IEdmPrimitiveType primitiveType = null;

            switch (typeCode)
            {
            case TypeCode.Boolean:
                primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Boolean);
                break;

            case TypeCode.Byte:
                primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Byte);
                break;

            case TypeCode.Decimal:
                primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Decimal);
                break;

            case TypeCode.Double:
                primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Double);
                break;

            case TypeCode.Int16:
                primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Int16);
                break;

            case TypeCode.Int32:
                primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Int32);
                break;

            case TypeCode.Int64:
                primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Int64);
                break;

            case TypeCode.SByte:
                primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.SByte);
                break;

            case TypeCode.String:
                primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String);
                break;

            case TypeCode.Single:
                primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Single);
                break;

            default:
                if (targetType == typeof(byte[]))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Binary);
                    break;
                }

                if (targetType == typeof(Stream))
                {
                    // stream is always non-nullable
                    nullable      = false;
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Stream);
                    break;
                }

                if (targetType == typeof(DateTimeOffset))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.DateTimeOffset);
                    break;
                }

                if (targetType == typeof(Guid))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Guid);
                    break;
                }

                if (targetType == typeof(TimeSpan))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Duration);
                    break;
                }

                if (typeof(GeographyPoint).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeographyPoint);
                    break;
                }

                if (typeof(GeographyLineString).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeographyLineString);
                    break;
                }

                if (typeof(GeographyPolygon).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeographyPolygon);
                    break;
                }

                if (typeof(GeographyMultiPoint).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeographyMultiPoint);
                    break;
                }

                if (typeof(GeographyMultiLineString).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeographyMultiLineString);
                    break;
                }

                if (typeof(GeographyMultiPolygon).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeographyMultiPolygon);
                    break;
                }

                if (typeof(GeographyCollection).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeographyCollection);
                    break;
                }

                if (typeof(Geography).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Geography);
                    break;
                }

                if (typeof(GeometryPoint).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeometryPoint);
                    break;
                }

                if (typeof(GeometryLineString).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeometryLineString);
                    break;
                }

                if (typeof(GeometryPolygon).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeometryPolygon);
                    break;
                }

                if (typeof(GeometryMultiPoint).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeometryMultiPoint);
                    break;
                }

                if (typeof(GeometryMultiLineString).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeometryMultiLineString);
                    break;
                }

                if (typeof(GeometryMultiPolygon).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeometryMultiPolygon);
                    break;
                }

                if (typeof(GeometryCollection).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.GeometryCollection);
                    break;
                }

                if (typeof(Geometry).IsAssignableFrom(targetType))
                {
                    primitiveType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Geometry);
                    break;
                }

                break;
            }

            if (primitiveType == null)
            {
                return(null);
            }

            return(ToTypeReference(primitiveType, nullable));
        }
Esempio n. 25
0
 protected object CnvChangeType(object value, System.TypeCode typeCode, System.IFormatProvider provider)
 {
     return(COMMAND.Convert.Convert.CnvChangeType(value, typeCode, provider));
 }
Esempio n. 26
0
 private TerminalActionParameter(System.TypeCode typeCode, object value)
 {
     this.TypeCode = typeCode;
     this.Value    = value;
 }
Esempio n. 27
0
 public ListViewItemComparer(int column, SortOrder order, System.TypeCode in_type)
 {
     _col = column;
     _order = order;
     _type = in_type;
 }
 public object Convert(object value, System.TypeCode typeCode)
 {
     return(default(object));
 }
Esempio n. 29
0
 public ListViewItemComparer(int column, SortOrder order, System.TypeCode in_type)
 {
     _col   = column;
     _order = order;
     _type  = in_type;
 }
Esempio n. 30
0
 public static object CnvChangeType(object value, System.TypeCode typeCode)
 {
     return(System.Convert.ChangeType(value, typeCode));
 }
Esempio n. 31
0
 public static object CnvChangeType(object value, System.TypeCode typeCode, System.IFormatProvider provider)
 {
     return(System.Convert.ChangeType(value, typeCode, provider));
 }
        /// <summary>
        /// Read the Erdas Image Header from a file given filename
        /// </summary>
        /// <remark>
        /// Uses variable definitions straight from Erdas spec - ipack, nbands,
        /// irows, icols, xstart, ystart, maptyp, nclass, iautyp, acre, xmap,
        /// ymap, xcell, ycell
        /// </remark>
        public void Read(string filename)
        {
            // init members as needed
            this.metadata = new Metadata();

            // prepare to read header
            FileStream   file       = null;
            BinaryReader fileReader = null;

            System.UInt16 ipack  = 0;
            System.UInt16 nbands = 0;
            System.UInt32 irows  = 0;
            System.UInt32 icols  = 0;

            try
            {
                // open file
                file       = new FileStream(filename, FileMode.Open);
                fileReader = new BinaryReader(file);

                // Read Header

                // if not start with "HEAD74" throw exception
                byte[] sentinel = fileReader.ReadBytes(6);
                if ((sentinel[0] != (byte)'H') ||
                    (sentinel[1] != (byte)'E') ||
                    (sentinel[2] != (byte)'A') ||
                    (sentinel[3] != (byte)'D') ||
                    (sentinel[4] != (byte)'7') ||
                    (sentinel[5] != (byte)'4'))
                {
                    throw new ApplicationException(filename + " is not an ERDAS 7.4 compatible image file");
                }

                // packing
                ipack = fileReader.ReadUInt16();

                // nbands
                nbands = fileReader.ReadUInt16();

                // unused
                byte[] unused = fileReader.ReadBytes(6);

                // icols
                icols = fileReader.ReadUInt32();

                // irows
                irows = fileReader.ReadUInt32();

                // xstart
                System.Int32 xstart = fileReader.ReadInt32();
                this.metadata[MetadataIds.RASTER_ULX] = xstart;

                // ystart
                System.Int32 ystart = fileReader.ReadInt32();
                this.metadata[MetadataIds.RASTER_ULY] = ystart;

                // unused
                unused = fileReader.ReadBytes(56);

                // maptyp
                System.UInt16 maptyp     = fileReader.ReadUInt16();
                string        projection = Projections.find(maptyp);
                if (projection != null)
                {
                    this.metadata[MetadataIds.PROJECTION] = projection;
                }
                if (maptyp == 0)
                {
                    this.metadata[MetadataIds.SCALE_UNITS] = "degrees";
                }
                else if (maptyp == 2)
                {
                    this.metadata[MetadataIds.SCALE_UNITS] = "feet";
                }
                else
                {
                    this.metadata[MetadataIds.SCALE_UNITS] = "meters";
                }

                // nclass : calc if needed but never has been in past
                System.UInt16 nclass = fileReader.ReadUInt16();

                // unused
                unused = fileReader.ReadBytes(14);

                // iautyp
                System.UInt16 iautyp = fileReader.ReadUInt16();

                // acre
                System.Single acre = fileReader.ReadSingle();

                // xmap
                System.Single xmap = fileReader.ReadSingle();
                this.metadata[MetadataIds.WORLD_ULX] = xmap;

                // ymap
                System.Single ymap = fileReader.ReadSingle();
                this.metadata[MetadataIds.WORLD_ULY] = ymap;

                // xcell
                System.Single xcell = fileReader.ReadSingle();
                this.metadata[MetadataIds.X_SCALE] = xcell;

                // ycell
                System.Single ycell = fileReader.ReadSingle();
                this.metadata[MetadataIds.Y_SCALE] = ycell;
            }
            catch
            {
                throw;
            }
            finally
            {
                if (fileReader != null)
                {
                    fileReader.Close();
                }
                // the prev line automatically closes file also
                else if (file != null)
                {
                    file.Close();
                }
            }

            // now set instance vars
            // metadata already set by above code
            this.dimensions = new Dimensions((int)irows, (int)icols);
            this.bandCount  = nbands;
            if (ipack == 0)
            {
                this.bandType = System.TypeCode.Byte;
                this.bandSize = 1;
            }
            else if (ipack == 2)
            {
                this.bandType = System.TypeCode.UInt16;
                this.bandSize = 2;
            }
            else
            {
                throw new ApplicationException("ImageHeader: Only 8 and 16 bit bands are supported");
            }
        }
        /// <summary>
        /// Read the Erdas Image Header from a file given filename
        /// </summary>
        /// <remark>
        /// Uses variable definitions straight from Erdas spec - ipack, nbands,
        /// irows, icols, xstart, ystart, maptyp, nclass, iautyp, acre, xmap,
        /// ymap, xcell, ycell
        /// </remark>
        public void Read(string filename)
        {
            // init members as needed
            this.metadata = new Metadata();
            
            // prepare to read header
            FileStream file = null;
            BinaryReader fileReader = null;
            System.UInt16 ipack = 0;
            System.UInt16 nbands = 0;
            System.UInt32 irows = 0;
            System.UInt32 icols = 0;

            try
            {
                // open file
                file = new FileStream(filename,FileMode.Open);
                fileReader = new BinaryReader(file);

                // Read Header

                // if not start with "HEAD74" throw exception
                byte[] sentinel = fileReader.ReadBytes(6);
                if ((sentinel[0] != (byte)'H') ||
                    (sentinel[1] != (byte)'E') ||
                    (sentinel[2] != (byte)'A') ||
                    (sentinel[3] != (byte)'D') ||
                    (sentinel[4] != (byte)'7') ||
                    (sentinel[5] != (byte)'4'))
                    throw new ApplicationException(filename+" is not an ERDAS 7.4 compatible image file");

                // packing
                ipack = fileReader.ReadUInt16();

                // nbands
                nbands = fileReader.ReadUInt16();

                // unused
                byte[] unused = fileReader.ReadBytes(6);

                // icols
                icols = fileReader.ReadUInt32();

                // irows
                irows = fileReader.ReadUInt32();

                // xstart
                System.Int32 xstart = fileReader.ReadInt32();
                this.metadata[MetadataIds.RASTER_ULX] = xstart;

                // ystart
                System.Int32 ystart = fileReader.ReadInt32();
                this.metadata[MetadataIds.RASTER_ULY] = ystart;

                // unused
                unused = fileReader.ReadBytes(56);

                // maptyp
                System.UInt16 maptyp = fileReader.ReadUInt16();
                string projection = Projections.find(maptyp);
                if (projection != null)
                    this.metadata[MetadataIds.PROJECTION] = projection;
                if (maptyp == 0)
                    this.metadata[MetadataIds.SCALE_UNITS] = "degrees";
                else if (maptyp == 2)
                    this.metadata[MetadataIds.SCALE_UNITS] = "feet";
                else
                    this.metadata[MetadataIds.SCALE_UNITS] = "meters";

                // nclass : calc if needed but never has been in past
                System.UInt16 nclass = fileReader.ReadUInt16();

                // unused
                unused = fileReader.ReadBytes(14);

                // iautyp
                System.UInt16 iautyp = fileReader.ReadUInt16();

                // acre
                System.Single acre = fileReader.ReadSingle();

                // xmap
                System.Single xmap = fileReader.ReadSingle();
                this.metadata[MetadataIds.WORLD_ULX] = xmap;

                // ymap
                System.Single ymap = fileReader.ReadSingle();
                this.metadata[MetadataIds.WORLD_ULY] = ymap;

                // xcell
                System.Single xcell = fileReader.ReadSingle();
                this.metadata[MetadataIds.X_SCALE] = xcell;

                // ycell
                System.Single ycell = fileReader.ReadSingle();
                this.metadata[MetadataIds.Y_SCALE] = ycell;
            }
            catch
            {
                throw;
            }
            finally
            {
                if (fileReader != null)
                    fileReader.Close();
                    // the prev line automatically closes file also
                else if (file != null)
                    file.Close();
            }
            
            // now set instance vars
            // metadata already set by above code
            this.dimensions = new Dimensions((int)irows,(int)icols);
            this.bandCount = nbands;
            if (ipack == 0)
            {
                this.bandType = System.TypeCode.Byte;
                this.bandSize = 1;
            }
            else if (ipack == 2)
            {
                this.bandType = System.TypeCode.UInt16;
                this.bandSize = 2;
            }
            else
                throw new ApplicationException("ImageHeader: Only 8 and 16 bit bands are supported");
        }
Esempio n. 34
0
 public ISParameter AddParameter(string parameterName, System.TypeCode typeCode = TypeCode.Empty)
 {
     return(new ISParameter(this, parameterName, typeCode));
 }