public static uint GetParamEnum(List <string> vParams, int iIndex, uint uDefault, EcasEnum enumItems) { if (enumItems == null) { Debug.Assert(false); return(uDefault); } string str = GetParamString(vParams, iIndex, null); if (string.IsNullOrEmpty(str)) { Debug.Assert(false); return(uDefault); } uint uID; if (!uint.TryParse(str, out uID)) { Debug.Assert(false); return(uDefault); } // Make sure the enumeration contains the value if (enumItems.GetItemString(uID, null) == null) { Debug.Assert(false); return(uDefault); } return(uID); }
public EcasParameter(string strName, EcasValueType t, EcasEnum eEnumValues) { if(strName == null) throw new ArgumentNullException("strName"); m_strName = strName; m_type = t; m_vEnumValues = eEnumValues; }
public EcasParameter(string strName, EcasValueType t, EcasEnum eEnumValues) { if (strName == null) { throw new ArgumentNullException("strName"); } m_strName = strName; m_type = t; m_vEnumValues = eEnumValues; }
public static uint GetParamEnum(List<string> vParams, int iIndex, uint uDefault, EcasEnum enumItems) { if(enumItems == null) { Debug.Assert(false); return uDefault; } string str = GetParamString(vParams, iIndex, null); if(string.IsNullOrEmpty(str)) { Debug.Assert(false); return uDefault; } uint uID; if(!uint.TryParse(str, out uID)) { Debug.Assert(false); return uDefault; } // Make sure the enumeration contains the value if(enumItems.GetItemString(uID, null) == null) { Debug.Assert(false); return uDefault; } return uID; }
public static string ParametersToString(IEcasObject ecasObj, EcasParameter[] vParamInfo) { if (ecasObj == null) { throw new ArgumentNullException("ecasObj"); } if (ecasObj.Parameters == null) { throw new ArgumentException(); } bool bParamInfoValid = true; if ((vParamInfo == null) || (ecasObj.Parameters.Count > vParamInfo.Length)) { Debug.Assert(false); bParamInfoValid = false; } StringBuilder sb = new StringBuilder(); EcasCondition eCond = (ecasObj as EcasCondition); if (eCond != null) { if (eCond.Negate) { sb.Append(KPRes.Not); } } for (int i = 0; i < ecasObj.Parameters.Count; ++i) { string strParam = ecasObj.Parameters[i]; string strAppend; if (bParamInfoValid) { EcasValueType t = vParamInfo[i].Type; if (t == EcasValueType.String) { strAppend = strParam; } else if (t == EcasValueType.Bool) { strAppend = (StrUtil.StringToBool(strParam) ? KPRes.Yes : KPRes.No); } else if (t == EcasValueType.EnumStrings) { uint uEnumID; if (uint.TryParse(strParam, out uEnumID) == false) { Debug.Assert(false); } EcasEnum ee = vParamInfo[i].EnumValues; if (ee != null) { strAppend = ee.GetItemString(uEnumID, string.Empty); } else { Debug.Assert(false); strAppend = strParam; } } else if (t == EcasValueType.Int64) { strAppend = FilterTypeI64(strParam); } else if (t == EcasValueType.UInt64) { strAppend = FilterTypeU64(strParam); } else { Debug.Assert(false); strAppend = strParam; } } else { strAppend = strParam; } if (string.IsNullOrEmpty(strAppend)) { continue; } string strAppTrimmed = strAppend.Trim(); if (strAppTrimmed.Length == 0) { continue; } if (sb.Length > 0) { sb.Append(", "); } sb.Append(strAppTrimmed); } return(sb.ToString()); }