ArtemisComm.Utility.SetProperty C# (CSharp) Method

SetProperty() static private method

static private SetProperty ( Type toType, object baseObject, object intermediateObject, PropertyInfo prop ) : void
toType System.Type
baseObject object
intermediateObject object
prop System.Reflection.PropertyInfo
return void
        static void SetProperty(Type toType, object baseObject, object intermediateObject, PropertyInfo prop)
        {
            if (toType == typeof(string))
            {
                prop.SetValue(baseObject, intermediateObject as string, null);
            }
            if (toType == typeof(ArtemisString))
            {
                prop.SetValue(baseObject, intermediateObject as ArtemisString, null);
            }
            if (toType == typeof(bool) || toType == typeof(bool?))
            {
                prop.SetValue(baseObject, Convert.ToBoolean(intermediateObject, CultureInfo.InvariantCulture), null);
            }
            if (toType == typeof(byte) || toType == typeof(byte?))
            {
                if (prop.PropertyType.IsEnum)
                {
                    prop.SetValue(baseObject, Enum.ToObject(prop.PropertyType, Convert.ToByte(intermediateObject, CultureInfo.InvariantCulture)), null);
                }
                else
                {
                    prop.SetValue(baseObject, Convert.ToByte(intermediateObject, CultureInfo.InvariantCulture), null);
                }
            }
            if (toType == typeof(short) || toType == typeof(short?))
            {
                if (prop.PropertyType.IsEnum)
                {
                    prop.SetValue(baseObject, Enum.ToObject(prop.PropertyType, Convert.ToInt16(intermediateObject, CultureInfo.InvariantCulture)), null);
                }
                else
                {
                    prop.SetValue(baseObject, Convert.ToInt16(intermediateObject, CultureInfo.InvariantCulture), null);
                }
            }
            if (toType == typeof(int) || toType == typeof(int?))
            {
                if (prop.PropertyType.IsEnum)
                {
                    prop.SetValue(baseObject, Enum.ToObject(prop.PropertyType, Convert.ToInt32(intermediateObject, CultureInfo.InvariantCulture)), null);
                }
                else
                {
                    prop.SetValue(baseObject, Convert.ToInt32(intermediateObject, CultureInfo.InvariantCulture), null);
                }
            }
            if (toType == typeof(float) || toType == typeof(float?))
            {
                prop.SetValue(baseObject, Convert.ToSingle(intermediateObject, CultureInfo.InvariantCulture), null);
            }
            if (toType == typeof(long) || toType == typeof(long?))
            {
                if (prop.PropertyType.IsEnum)
                {
                    prop.SetValue(baseObject, Enum.ToObject(prop.PropertyType, Convert.ToInt64(intermediateObject, CultureInfo.InvariantCulture)), null);
                }
                else
                {
                    prop.SetValue(baseObject, Convert.ToInt64(intermediateObject, CultureInfo.InvariantCulture), null);
                }
            }
        }
        public static int LoadProperties(object baseObject, Stream stream, int index, Collection<Exception> errors)