public TypeConvertAction(ParseInfo parseInfo, Scope scope, TypeCast typeConvert)
        {
            // Get the expression. Syntax error if there is none.
            Expression = parseInfo.GetExpression(scope, typeConvert.Expression);

            // Get the type. Syntax error if there is none.
            ConvertingTo = CodeType.GetCodeTypeFromContext(parseInfo, typeConvert.Type);
        }
示例#2
0
        /// <summary>
        ///     Returns the property value with the specified property name (if it exists), otherwise the fallback value is
        ///     returned.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="source">The propset.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="fallbackValue">The fallback value.</param>
        /// <returns>
        ///     Returns the <see cref="object" /> casted to the specified
        ///     <param ref="TValue" />
        ///     for the property.
        /// </returns>
        public static TValue GetValue <TValue>(this IMMWMSPropertySet source, string propertyName, TValue fallbackValue)
        {
            if (source == null || !source.Exists(propertyName))
            {
                return(fallbackValue);
            }

            return(TypeCast.Cast(source.GetProperty(propertyName), fallbackValue));
        }
示例#3
0
        public User GetByUsername(string username)
        {
            TblUsers user;

            using (var imisContext = new ImisDB())
            {
                user = imisContext.TblUsers.Where(u => u.LoginName == username).FirstOrDefault();
            }
            return(TypeCast.Cast <User>(user));
        }
示例#4
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="IntermediateRow" /> struct.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <param name="relClass">The relationship class.</param>
        public IntermediateRow(IRow row, IRelationshipClass relClass)
        {
            this.Row   = row;
            this.Items = new Dictionary <string, object>();

            ITable table = (ITable)relClass;

            this.OriginForeignKey      = TypeCast.Cast(row.get_Value(table.FindField(relClass.OriginForeignKey)), string.Empty);
            this.DestinationForeignKey = TypeCast.Cast(row.get_Value(table.FindField(relClass.DestinationForeignKey)), string.Empty);
        }
示例#5
0
 /// <summary>
 ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="ICodedValueDomain" />
 /// </summary>
 /// <param name="source">An <see cref="ICodedValueDomain" /> to create an <see cref="IEnumerable{T}" /> from.</param>
 /// <returns>An <see cref="IEnumerable{T}" /> that contains the domain from the input source.</returns>
 public static IEnumerable <KeyValuePair <string, string> > AsEnumerable(this ICodedValueDomain source)
 {
     if (source != null)
     {
         for (int i = 0; i < source.CodeCount; i++)
         {
             yield return(new KeyValuePair <string, string>(source.Name[i], TypeCast.Cast(source.Value[i], string.Empty)));
         }
     }
 }
示例#6
0
        public async Task <User> GetByUsernameAsync(string username)
        {
            TblUsers user;

            using (var imisContext = new ImisDB())
            {
                user = await imisContext.TblUsers.Where(u => u.LoginName == username).FirstOrDefaultAsync();
            }
            return(TypeCast.Cast <User>(user));
        }
示例#7
0
        bool login(Order order, ref CookieContainer cookie)
        {
            try
            {
                OrderChargeAccount orderChargeAccount = SQLOrderChargeAccount.GetChargeAccount(OrderChargeAccountType.XunYou, false);

                cookie = Common.CookieOperation.CookieHelper.ReadCookiesFromDisk(orderChargeAccount.ChargeAccount);

                string result = PostAndGet.HttpGetString_XY("http://my.xunyou.com/index.php/uCenter/getLoginId", "", ref cookie);
                if (!result.Contains("-1"))
                {
                    return(true);
                }

                int loginCount = 0;
                while (loginCount < 5)
                {
                    result = PostAndGet.HttpGetString_XY("https://my.xunyou.com/u/", "", ref cookie);

                    string code   = ""; //验证码
                    int    codeid = 0;
                    WrapperHelp.GetCodeByByte_UU("https://my.xunyou.com/index.php/imageoutput/VertifyCode/ver_code_1/50/24", ref cookie, 1005, ref code, ref codeid);
                    string LoginData = "regfrom=uCenter&agree_rule=1&loginid=" + orderChargeAccount.ChargeAccount + "&password="******"&code=" + code;
                    string LoginUrl  = "https://my.xunyou.com/index.php/login/ajaxLoginGj";
                    result = PostAndGet.HttpPostString_XY(LoginUrl, LoginData, ref cookie, "my.xunyou.com", "https://my.xunyou.com/u/");
                    WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + orderChargeAccount.ChargeAccount + "||" + orderChargeAccount.ChargePassword
                                   + ",帐号登录返回:" + result, LogPathFile.Recharge);

                    string msg         = Regex.Match(result, @"""msg"":""(.*?)""").Groups[1].Value;
                    string encodingMsg = "";
                    TypeCast.GetString(msg, ref encodingMsg);

                    if (encodingMsg.Contains("登录成功"))
                    {
                        Common.CookieOperation.CookieHelper.WriteCookiesToDisk(orderChargeAccount.ChargeAccount, cookie);
                        return(true);
                    }
                    else
                    {
                        if (encodingMsg.Contains("验证码错误") || result.Contains("验证码错误"))
                        {
                            WrapperHelp.reportError(codeid);
                        }

                        loginCount++;
                        Thread.Sleep(1 * 1000);
                    }
                }
                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#8
0
        /// <summary>
        ///     Gets the configuration value that is stored in the MM_PX_CONFIG table and converts the value to the specified type.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="source">The helper application reference.</param>
        /// <param name="configName">Name of the configuration.</param>
        /// <param name="fallbackValue">The fallback value.</param>
        /// <returns>
        ///     Returns an object representing the configuration value.
        /// </returns>
        public static TValue GetConfigValue <TValue>(this IMMPxHelper2 source, string configName, TValue fallbackValue)
        {
            if (source == null)
            {
                return(default(TValue));
            }

            object configValue = source.GetConfigValue(configName);

            return(TypeCast.Cast(configValue, fallbackValue));
        }
示例#9
0
        /// <summary>
        ///     Retrieves a single value (for example, an aggregate value) from a database using the specified
        ///     <paramref name="commandText" /> statement.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="source">The source.</param>
        /// <param name="commandText">The command text.</param>
        /// <returns>
        ///     The value from the statement.
        /// </returns>
        public static TValue ExecuteScalar <TValue>(this DbConnection source, string commandText)
        {
            // Create a new select command for the connection.
            using (DbCommand cmd = source.CreateCommand())
            {
                cmd.CommandText = commandText;
                cmd.CommandType = CommandType.Text;

                return(TypeCast.Cast(cmd.ExecuteScalar(), default(TValue)));
            }
        }
示例#10
0
        public override Expression CreateExpressionTree(ResolveContext ec)
        {
            TypeCast child_cast = child as TypeCast;

            if (child_cast != null)
            {
                child.Type = type;
                return(child_cast.CreateExpressionTree(ec));
            }

            return(base.CreateExpressionTree(ec));
        }
示例#11
0
 public T?TryReadValue <T>(string section, string key) where T : struct
 {
     if (ExistsKey(section, key))
     {
         string val = _cfg[section][key];
         return(TypeCast.ChangeType <T>(val));
     }
     else
     {
         return(default(T));
     }
 }
示例#12
0
 public T ReadValue <T>(string section, string key) where T : struct
 {
     try
     {
         string val = _cfg[section][key];
         return(TypeCast.ChangeType <T>(val));
     }
     catch (Exception ex)
     {
         throw ExceptionHelper.CreateWrapException(ex, section, key);
     }
 }
示例#13
0
        /// <summary>
        ///     Implementation of Auto Updater Execute Ex method for derived classes.
        /// </summary>
        /// <param name="obj">The object that triggered the Auto Udpater.</param>
        /// <param name="eAUMode">The auto updater mode.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <exception cref="NotSupportedException">
        ///     The sequence generator is only supported on an ORACLE workspace (remote
        ///     geodatabase).
        /// </exception>
        /// <exception cref="ArgumentNullException">obj;@The field model name is not assigned on the object.</exception>
        /// <remarks>
        ///     This method will be called from IMMSpecialAUStrategy::ExecuteEx
        ///     and is wrapped within the exception handling for that method.
        /// </remarks>
        protected override void InternalExecute(IObject obj, mmAutoUpdaterMode eAUMode, mmEditEvent editEvent)
        {
            if (obj == null)
            {
                return;
            }

            IDataset   dataset   = (IDataset)obj.Class;
            IWorkspace workspace = dataset.Workspace;

            if (workspace.IsDBMS(DBMS.Oracle))
            {
                throw new NotSupportedException("The sequence generator is only supported on an ORACLE workspace (remote geodatabase).");
            }

            string fieldName = obj.Class.GetFieldName(_FieldModelName);

            if (string.IsNullOrEmpty(fieldName))
            {
                throw new ArgumentNullException("obj", @"The field model name is not assigned on the object.");
            }

            // Create a queryDef from the feature workspace
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
            IQueryDef         queryDef         = featureWorkspace.CreateQueryDef();

            // Set the query def to point to the sequence
            queryDef.SubFields = _SequenceName + ".NEXTVAL";
            queryDef.Tables    = "SYS.DUAL";

            // Define a cursor and row, for destroy in finally
            using (ComReleaser cr = new ComReleaser())
            {
                // Fill the cursor via the query def
                ICursor cursor = queryDef.Evaluate();
                cr.ManageLifetime(cursor);

                // Now get the row from the cursor
                IRow row = cursor.NextRow();
                if (row == null)
                {
                    return;
                }

                // Store the formatted value if it's configured.
                int    val            = TypeCast.Cast(row.get_Value(0), -1);
                string formattedValue = this.Format(val, obj);

                int pos = obj.Class.FindField(fieldName);
                obj.set_Value(pos, formattedValue);
            }
        }
        /// <summary>
        /// Get user by username and password by asychronious call
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public async Task <User> GetByUsernameAndPasswordAsync(string username, string password)
        {
            TblUsers user;

            using (var imisContext = new ImisDB())
            {
                var userParameter     = new SqlParameter("user", username);
                var passwordParameter = new SqlParameter("password", password);

                user = await imisContext.TblUsers.FromSql(GetByUsernameAndPasswordSQL(), userParameter, passwordParameter).SingleOrDefaultAsync();
            }
            return(TypeCast.Cast <User>(user));
        }
示例#15
0
        /// <summary>
        ///     Returns the field value that at the specified <paramref name="index" /> for the <paramref name="source" />.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="source">The row.</param>
        /// <param name="index">The index.</param>
        /// <param name="fallbackValue">The default value.</param>
        /// <returns>
        ///     Returns an <see cref="object" /> representing the converted value to the specified type.
        /// </returns>
        /// <exception cref="IndexOutOfRangeException"></exception>
        public static TValue GetValue <TValue>(this IRowBuffer source, int index, TValue fallbackValue)
        {
            if (source == null)
            {
                return(fallbackValue);
            }
            if (index < 0 || index > source.Fields.FieldCount - 1)
            {
                throw new IndexOutOfRangeException();
            }

            return(TypeCast.Cast(source.Value[index], fallbackValue));
        }
示例#16
0
 public long QueryCount(IQuery query)
 {
     try
     {
         string sql = _emit.QueryCount(query);
         _log.Debug(sql);
         object val = _exe.ExecuteScalar(sql);
         return(TypeCast.ChangeType <long>(val));
     }
     catch (Exception ex)
     {
         throw ex.CreateWrapException <ORMException>();
     }
 }
示例#17
0
 private bool TryConvertOneArgument(object val, Type targetType, out object result)
 {
     //Extend:try improve performance here
     try
     {
         result = TypeCast.ChangeToTypeOrNullableType(val, targetType);
         return(true);
     }
     catch
     {
         result = null;
         return(false);
     }
 }
示例#18
0
        /// <summary>
        ///     Gets the value from the property set that has the given <paramref name="name" />.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="source">The property set.</param>
        /// <param name="name">The name.</param>
        /// <param name="defaultValue">The default value.</param>
        /// <returns>
        ///     Returns the value for the property with the specified name; otherwise the <paramref name="defaultValue" /> will be
        ///     returned.
        /// </returns>
        public static TValue GetProperty <TValue>(this IPropertySet source, string name, TValue defaultValue)
        {
            if (source != null)
            {
                foreach (var entry in source.AsEnumerable())
                {
                    if (string.Equals(name, entry.Key, StringComparison.CurrentCultureIgnoreCase))
                    {
                        return(TypeCast.Cast(entry.Value, defaultValue));
                    }
                }
            }

            return(defaultValue);
        }
示例#19
0
        internal static object ConvertToSimpleType(string jsonText, Type targetType, bool ignoreTypeSafe = false)
        {
            IExtendConverter cvt    = ExtendConverter.Instance();
            object           result = null;

            if (cvt.CanConvert(targetType))
            {
                try
                {
                    result = cvt.FromJson(targetType, jsonText, ignoreTypeSafe);
                }
                catch (Exception ex)
                {
                    throw ex.CreateWrapException <JsonExtendConverterException>();
                }
            }
            else
            {
                if (ignoreTypeSafe)
                {
                    //Note: If we don't care type safe, always remove quoter if exist, then cast
                    if (jsonText.StartsWith(JsonConstant.Quot) && jsonText.EndsWith(JsonConstant.Quot) && jsonText.Length > 1)
                    {
                        jsonText = jsonText.UnBracketing(StringPair.DoubleQuote);
                    }

                    result = TypeCast.ChangeToTypeOrNullableType(jsonText, targetType);
                }
                else
                {
                    //Note: If we care type, strict follow JSON standard
                    if (targetType == typeof(string))
                    {
                        if ((!jsonText.StartsWith(JsonConstant.Quot)) || (!jsonText.EndsWith(JsonConstant.Quot)))
                        {
                            ExceptionHelper.ThrowSyntaxNoQuotError();
                        }
                        result = jsonText.UnBracketing(StringPair.DoubleQuote);
                    }
                    else
                    {
                        result = TypeCast.ChangeToTypeOrNullableType(jsonText, targetType);
                    }
                }
            }
            return(result);
        }
示例#20
0
        /// <summary>
        ///     Executes the given statement which is usually an Insert, Update or Delete statement and returns the number of rows
        ///     affected.
        /// </summary>
        /// <param name="source">The process application reference.</param>
        /// <param name="commandText">The command text.</param>
        /// <returns>
        ///     Returns a <see cref="int" /> representing the number of rows affected.
        /// </returns>
        /// <exception cref="ArgumentNullException">commandText</exception>
        public static int ExecuteNonQuery(this IMMPxApplication source, string commandText)
        {
            if (source == null)
            {
                return(-1);
            }
            if (commandText == null)
            {
                throw new ArgumentNullException("commandText");
            }

            object recordsEffected;

            source.Connection.Execute(commandText, out recordsEffected, (int)CommandTypeEnum.adCmdText | (int)ExecuteOptionEnum.adExecuteNoRecords);

            return(TypeCast.Cast(recordsEffected, -1));
        }
示例#21
0
        /// <summary>
        /// Get user by username and password by asychronious call
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public async Task <User> GetByUsernameAndPasswordAsync(string username, string password)
        {
            TblUsers user;

            using (var imisContext = new ImisDB())
            {
                user = await imisContext.TblUsers.Where(u => u.LoginName == username).FirstOrDefaultAsync();

                if (user != null)
                {
                    if (!ValidateLogin(user.StoredPassword, user.PrivateKey, password))
                    {
                        user = null;
                    }
                }
            }
            return(TypeCast.Cast <User>(user));
        }
示例#22
0
    /// <summary>
    /// Checks a player input delegate.
    /// </summary>
    /// <param name="inputFunction">The input delegate to check.</param>
    /// <returns>float: The output of the input delegate, as a float.</returns>
    float GetPlayerInputFloat(Delegate inputFunction)
    {
        var value = inputFunction.DynamicInvoke();

        // Validation
        if (value.GetType() == typeof(float))
        {
            return((float)value);
        }
        else if (value.GetType() == typeof(bool))
        {
            return(TypeCast.BoolToFloat((bool)value));
        }
        else
        {
            Debug.LogError("GetPlayerInputFloat: Unexpected return type from input delegate" + inputFunction + "; returning 0.");
        }
        return(0);
    }
示例#23
0
        public static LocationModel FromTblLocation(TblLocations tblLocation)
        {
            LocationModel locationModel = new LocationModel()
            {
                LocationId       = tblLocation.LocationId,
                LocationCode     = tblLocation.LocationCode,
                LocationName     = tblLocation.LocationName,
                LocationType     = tblLocation.LocationType,
                ParentLocationId = tblLocation.ParentLocationId,
                ValidFrom        = tblLocation.ValidityFrom,
                ValidTo          = tblLocation.ValidityTo,
                MalePopulation   = TypeCast.GetValue <int>(tblLocation.MalePopulation),
                FemalePopulation = TypeCast.GetValue <int>(tblLocation.FemalePopulation),
                OtherPopulation  = TypeCast.GetValue <int>(tblLocation.OtherPopulation),
                Families         = TypeCast.GetValue <int>(tblLocation.Families)
            };

            return(locationModel);
        }
示例#24
0
        /// <summary>
        ///     Creates record in the intermediate table for the relationship that is linked to the
        ///     <paramref name="originObject" /> and <paramref name="destinationObject" />.
        /// </summary>
        /// <param name="originObject">The origin object.</param>
        /// <param name="destinationObject">The destination object.</param>
        /// <returns>
        ///     Returns the <see cref="IntermediateRow" /> struct for the new row.
        /// </returns>
        public IIntermediateRow Create(IObject originObject, IObject destinationObject)
        {
            int originPrimaryIndex      = originObject.Fields.FindField(this.RelationshipClass.OriginPrimaryKey);
            int destinationPrimaryIndex = destinationObject.Fields.FindField(this.RelationshipClass.DestinationPrimaryKey);

            string originForeignKey      = TypeCast.Cast(originObject.get_Value(originPrimaryIndex), string.Empty);
            string destinationForeignKey = TypeCast.Cast(destinationObject.get_Value(destinationPrimaryIndex), string.Empty);

            ITable table = (ITable)this.RelationshipClass;
            int    originForeignIndex      = table.Fields.FindField(this.RelationshipClass.OriginForeignKey);
            int    destinationForeignIndex = table.Fields.FindField(this.RelationshipClass.DestinationForeignKey);

            IRow row = table.CreateRow();

            row.set_Value(originForeignIndex, originForeignKey);
            row.set_Value(destinationForeignIndex, destinationForeignKey);

            return(GetRow(row));
        }
示例#25
0
        /// <summary>
        ///     Retrieves a single value (for example, an aggregate value) from a database.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="source">The process application reference.</param>
        /// <param name="commandText">The command text.</param>
        /// <param name="fallbackValue">The fallback value.</param>
        /// <returns>
        ///     Returns an <see cref="object" /> representing the results of the single value from the database, or the fallback
        ///     value.
        /// </returns>
        /// <exception cref="ArgumentNullException">commandText</exception>
        public static TValue ExecuteScalar <TValue>(this IMMPxApplication source, string commandText, TValue fallbackValue)
        {
            if (source == null)
            {
                return(fallbackValue);
            }
            if (commandText == null)
            {
                throw new ArgumentNullException("commandText");
            }

            TValue value      = fallbackValue;
            object parameters = Type.Missing;

            Command command = new CommandClass();

            command.ActiveConnection = source.Connection;
            command.CommandType      = CommandTypeEnum.adCmdText;
            command.CommandText      = commandText;

            var table = new DataTable();

            table.Locale = CultureInfo.InvariantCulture;

            using (var cr = new ComReleaser())
            {
                object    recordsAffected;
                Recordset recordset = command.Execute(out recordsAffected, ref parameters, (int)CommandTypeEnum.adCmdText);
                cr.ManageLifetime(recordset);

                var adapter = new OleDbDataAdapter();
                adapter.Fill(table, recordset);
                recordset.Close();

                if (table.Rows.Count == 1 && table.Columns.Count == 1)
                {
                    value = TypeCast.Cast(table.Rows[0][0], fallbackValue);
                }
            }

            return(value);
        }
示例#26
0
        /// <summary>
        ///     Returns the field value that has been assigned the <paramref name="modelName" /> that is within the specified
        ///     <paramref name="source" />.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="source">The row.</param>
        /// <param name="modelName">Name of the model.</param>
        /// <param name="fallbackValue">The default value.</param>
        /// <param name="throwException">
        ///     if set to <c>true</c> if an exception should be thrown when the model name is not
        ///     assigned.
        /// </param>
        /// <returns>
        ///     Returns an <see cref="object" /> representing the converted value to the specified type.
        /// </returns>
        /// <exception cref="ArgumentNullException">modelName</exception>
        /// <exception cref="IndexOutOfRangeException"></exception>
        /// <exception cref="MissingFieldModelNameException"></exception>
        public static TValue GetValue <TValue>(this IRow source, string modelName, TValue fallbackValue, bool throwException)
        {
            if (source == null)
            {
                return(fallbackValue);
            }
            if (modelName == null)
            {
                throw new ArgumentNullException("modelName");
            }

            int index = source.Table.GetFieldIndex(modelName, throwException);

            if (index == -1)
            {
                throw new IndexOutOfRangeException();
            }

            return(TypeCast.Cast(source.Value[index], fallbackValue));
        }
示例#27
0
        internal static T MapToEntity <T>(this DataRow dr, IObjectMapInfo map, string alias = null)
        {
            if (IsNull(dr, alias, map))
            {
                return(default(T));
            }

            T          entity = Activator.CreateInstance <T>();
            IReflector r      = Reflector.Bind(entity);

            foreach (var pmi in map.PropertyMaps)
            {
                object val = dr[alias + pmi.ColumnName];

                Type propertyType = r.GetPropertyType(pmi.PropertyName);
                if (propertyType.IsEnum)
                {
                    if (val is string)
                    {
                        r.SetPropertyValue(pmi.PropertyName, EnumEx.Parse(propertyType, val as string, false));
                    }
                    else
                    {
                        r.SetPropertyValue(pmi.PropertyName, EnumEx.Parse(propertyType, (int)System.Convert.ChangeType(val, typeof(int))));
                    }
                }
                else
                {
                    if (val is System.DBNull)
                    {
                        r.SetPropertyValue(pmi.PropertyName, null);
                    }
                    else
                    {
                        r.SetPropertyValue(pmi.PropertyName, TypeCast.ChangeToTypeOrNullableType(val, propertyType));
                    }
                }
            }

            return(entity);
        }
示例#28
0
        /// <summary>
        ///     Updates the column index on the row with the value when the original value and the specified
        ///     <paramref name="value" /> are different.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="index">The index of the field.</param>
        /// <param name="value">The value for the field.</param>
        /// <param name="equalityCompare">if set to <c>true</c> when the changes need to be compared prior to updating.</param>
        /// <returns>
        ///     Returns a <see cref="bool" /> representing <c>true</c> when the row updated; otherwise <c>false</c>
        /// </returns>
        /// <exception cref="IndexOutOfRangeException"></exception>
        public static bool Update(this IRowBuffer source, int index, object value, bool equalityCompare)
        {
            if (source == null)
            {
                return(false);
            }
            if (index < 0 || index > source.Fields.FieldCount - 1)
            {
                throw new IndexOutOfRangeException();
            }

            if (equalityCompare)
            {
                switch (source.Fields.Field[index].Type)
                {
                case esriFieldType.esriFieldTypeOID:
                case esriFieldType.esriFieldTypeInteger:
                    return(source.Update(index, TypeCast.Cast(value, default(long)), EqualityComparer <long> .Default));

                case esriFieldType.esriFieldTypeSmallInteger:
                    return(source.Update(index, TypeCast.Cast(value, default(int)), EqualityComparer <int> .Default));

                case esriFieldType.esriFieldTypeSingle:
                    return(source.Update(index, TypeCast.Cast(value, default(float)), EqualityComparer <float> .Default));

                case esriFieldType.esriFieldTypeDouble:
                    return(source.Update(index, TypeCast.Cast(value, default(double)), EqualityComparer <double> .Default));

                case esriFieldType.esriFieldTypeString:
                case esriFieldType.esriFieldTypeDate:
                case esriFieldType.esriFieldTypeGUID:
                case esriFieldType.esriFieldTypeGlobalID:
                    return(source.Update(index, TypeCast.Cast(value, default(string)), EqualityComparer <string> .Default));

                default:
                    return(source.Update(index, value, EqualityComparer <object> .Default));
                }
            }

            return(source.Update(index, value, null));
        }
示例#29
0
        private static void CopyByBoth(IDictionary <string, string> src, object dest)
        {
            IReflector r = Reflector.Bind(dest);

            foreach (var key in src.Keys)
            {
                if (r.ExistProperty(key))
                {
                    try
                    {
                        Type   pType = r.GetPropertyType(key);
                        object val   = TypeCast.ChangeToTypeOrNullableType(src[key], pType);
                        r.SetPropertyValue(key, val);
                    }
                    catch (Exception ex)
                    {
                        throw ex.CreateWrapException <CopyException>();
                    }
                }
            }
        }
示例#30
0
        //public FamilyModel(TblFamilies tblFamilies):this()
        //{
        //	this.ConvertFromTblFamilies(tblFamilies);
        //}

        public static FamilyModel FromTblFamilies(TblFamilies tblFamilies)
        {
            FamilyModel familyModel = new FamilyModel()
            {
                FamilyId         = tblFamilies.FamilyId,
                LocationId       = TypeCast.GetValue <int>(tblFamilies.LocationId),
                Poverty          = TypeCast.GetValue <bool>(tblFamilies.Poverty),
                FamilyType       = tblFamilies.FamilyType,
                FamilyAddress    = tblFamilies.FamilyAddress,
                Ethnicity        = tblFamilies.Ethnicity,
                ConfirmationNo   = tblFamilies.ConfirmationNo,
                ConfirmationType = tblFamilies.ConfirmationType,
                IsOffline        = TypeCast.GetValue <bool>(tblFamilies.IsOffline),
                Insurees         = tblFamilies.TblInsuree
                                   .Where(i => i.ValidityTo == null)
                                   .Select(i => InsureeModel.FromTblInsuree(i))
                                   .ToList()
            };

            return(familyModel);
        }
 /**
  * Call back method that must be called as soon as the given <code>TypeCast
  * </code> object has been traversed.
  *
  * @param pTypeCast  The <code>TypeCast</code> object that has just been
  *                   traversed.
  */
 public void actionPerformed(
      TypeCast pTypeCast)
 {
     // Nothing to do.
 }
 /**
  * Call back method that must be called when the given <code>TypeCast</code>
  * will become the next <i>traverse candidate</i>.
  *
  * @param pTypeCast  The <code>TypeCast</code> object that will become the
  *                   next <i>traverse candidate</i>.
  */
 public void performAction( TypeCast pTypeCast)
 {
     // Nothing to do.
 }