Пример #1
0
    private string Type2String(eTypes t)
    {
        switch (t)
        {
        case eTypes.Typedouble:
            return("double");

        case eTypes.Typefloat:
            return("float");

        case eTypes.TypeInt:
            return("int");

        case eTypes.TypeBool:
            return("bool");

        case eTypes.TypeString:
            return("string");

        case eTypes.TypeUint:
            return("uint");

        case eTypes.TypeEnum:
            return("enum");

        default: return("");
        }
    }
Пример #2
0
 /// <summary>
 /// create a new healthInfo
 /// </summary>
 /// <param name="sP">full path</param>
 /// <param name="sT">type descriptor</param>
 public healthInfo(string sP, string sT)
 {
     sPath = sP;
     sType = sT;
     if (sT == "Integer")
     {
         eType = eTypes.Integer;
     }
     else if (sT == "String")
     {
         eType = eTypes.String;
     }
     else if (sT == "Float")
     {
         eType = eTypes.Float;
     }
     else if (sT == "Boolean")
     {
         eType = eTypes.Boolean;
     }
     else
     {
         eType = eTypes.unknown;
     }
     string[] sTemp = sP.Split('\\');
     sShortName = sTemp[sTemp.Length - 1];
 }
Пример #3
0
        public object getValue(eTypes type)
        {
            switch (type)
            {
            case eTypes.eBoolean:
                switch (m_value.ToLower())
                {
                case "true":
                case "verdadero":
                case "-1":
                case "1":
                    return(-1);

                //"False":
                //"Falso":
                // or any other value is FALSE
                default:
                    return(0);
                }

            case eTypes.eDate:
            case eTypes.eDateOrNull:
                if (cDateUtils.isDate(m_value))
                {
                    return(m_value);
                }
                else
                {
                    return(0);
                }

            case eTypes.eLong:
            case eTypes.eInteger:
            case eTypes.eId:
            case eTypes.eSingle:
            case eTypes.eCurrency:
                double dummy;
                if (double.TryParse(m_value, out dummy))
                {
                    return(m_value);
                }
                else
                {
                    return(0);
                }

            case eTypes.eText:
            case eTypes.eVariant:
            case eTypes.eCuit:
                return(m_value);

            default:
                return(m_value);
            }
        }
Пример #4
0
 public object getValue(eTypes type)
 {
     switch (type)
     {
         case eTypes.eBoolean:
             switch (m_value.ToLower())
             {
                 case "true":
                 case "verdadero":
                 case "-1":
                 case "1":
                     return -1;
                 //"False":
                 //"Falso":
                 // or any other value is FALSE
                 default:
                     return 0;
             }
         case eTypes.eDate:
         case eTypes.eDateOrNull:
             if (cDateUtils.isDate(m_value))
             {
                 return m_value;
             }
             else
             {
                 return 0;
             }
         case eTypes.eLong:
         case eTypes.eInteger:
         case eTypes.eId:
         case eTypes.eSingle:
         case eTypes.eCurrency:
             double dummy;
             if (double.TryParse(m_value, out dummy))
             {
                 return m_value;
             }
             else
             {
                 return 0;
             }
         case eTypes.eText:
         case eTypes.eVariant:
         case eTypes.eCuit:
             return m_value;
         default:
             return m_value;
     }
 }
Пример #5
0
 public void setValue(eTypes type, object value)
 {
     if (type == eTypes.eBoolean)
     {
         m_value = (bool)value ? "-1" : "0";
     }
     else if (type == eTypes.eInteger)
     {
         m_value = Convert.ToInt64(value).ToString();
     }
     else
     {
         m_value = value.ToString();
     }
 }
Пример #6
0
        public bool Filter(Object obj, bool isMain)
        {
            if (obj == null || obj.Equals(null))
            {
                return(isMain);
            }
            string path = AssetDatabase.GetAssetPath(obj);

            if (string.IsNullOrEmpty(path))
            {
                path = obj.name;
            }
            if (isMain)
            {
                if (mFilterTypes.Count > 0)
                {
                    System.Type type = obj.GetType();
                    bool        flag = false;
                    for (int i = mFilterTypes.Count - 1; i >= 0; i--)
                    {
                        if (type.Equals(mFilterTypes[i]) || type.IsSubclassOf(mFilterTypes[i]))
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        return(false);
                    }
                }
                return(FilterContent(path, mKeyWords[(int)eTypes.Default], true));
            }
            eTypes et = GetObjectType(obj);

            if (et == eTypes.Default)
            {
                return(true);
            }
            List <string> filters = mKeyWords[(int)et];

            return(FilterContent(path, filters, false));
        }
Пример #7
0
        public static void ValidateFormatCellInGrid(string columnName, object formattedValue, eTypes type, Boolean validateNegative = false, string text = null)
        {
            try
            {
                string value = null;
                object valueReal;

                if (formattedValue != null)
                {
                    value = formattedValue.ToString();

                    if (!String.IsNullOrEmpty(value))
                    {
                        switch (type)
                        {
                        case eTypes.DECIMAL:
                            try { valueReal = Convert.ToDecimal(value); }
                            catch
                            {
                                string message = "El valor [" + value + "] de la columna [" + text + "] no cumple con el formato numerico decimal.";
                                throw new Exception(message);
                            }

                            if (validateNegative && ((decimal)valueReal) < 0)
                            {
                                throw new Exception("El valor de la columna [" + text + "] no puede ser un numero negativo");
                            }

                            break;

                        case eTypes.ENTERO:
                            try { valueReal = Convert.ToInt64(value); }
                            catch
                            {
                                string message = "El valor [" + value + "] de la columna [" + text + "] no cumple con el formato numerico entero.";
                                throw new Exception(message);
                            }

                            if (validateNegative && ((long)valueReal) < 0)
                            {
                                throw new Exception("El valor de la columna [" + text + "] no puede ser un numero negativo");
                            }

                            break;

                        case eTypes.FECHAHORA:
                            try { Convert.ToDateTime(value); }
                            catch
                            {
                                string message = "El valor [" + value + "] de la columna [" + text + "] no cumple con el formato de fecha y hora.";
                                throw new Exception(message);
                            }
                            break;
                        }
                    }
                }
            }
            catch { throw; }
        }
Пример #8
0
 public static void ValidateCompleteCellInGrid(string columnName, object formattedValue, eTypes type, Boolean validateNegative = false, string text = null)
 {
     try
     {
         Grid.ValidateIsEmptyCellInGrid(columnName, formattedValue, text);
         Grid.ValidateFormatCellInGrid(columnName, formattedValue, type, validateNegative, text);
     }
     catch { throw; }
 }
Пример #9
0
 public bool getValueBool(eTypes type)
 {
     return ((int)getValue(type) != 0);
 }
Пример #10
0
 public string getValueString(eTypes type)
 {
     return (string)getValue(type);
 }
Пример #11
0
 public int getValueInt(eTypes type)
 {
     return Convert.ToInt32(getValue(type));
 }
Пример #12
0
 public void setValue(eTypes type, object value)
 {
     if (type == eTypes.eBoolean)
     {
         m_value = (bool)value ? "-1" : "0";
     }
     else if (type == eTypes.eInteger)
     {
         m_value = Convert.ToInt64(value).ToString();
     }
     else
     {
         m_value = value.ToString();
     }
 }
Пример #13
0
 public bool getValueBool(eTypes type)
 {
     return((int)getValue(type) != 0);
 }
Пример #14
0
 public string getValueString(eTypes type)
 {
     return((string)getValue(type));
 }
Пример #15
0
 public int getValueInt(eTypes type)
 {
     return(Convert.ToInt32(getValue(type)));
 }
Пример #16
0
 public bool GetTypeRestrict(eTypes type)
 {
     return(mKeyWords[(int)type].Count > 0);
 }