/// <returns> right string in confidence with the type</returns> protected static String getString(String str, StorageAttribute type, bool useHex, bool useEnvCharset) { String result; if (useHex) { if (type == StorageAttribute.BLOB || type == StorageAttribute.BLOB_VECTOR || type == StorageAttribute.DOTNET) { result = byteStreamToString(str); } else { result = str; } } else //working in base64 { if (type == StorageAttribute.BLOB || type == StorageAttribute.BLOB_VECTOR || type == StorageAttribute.DOTNET) { result = Base64.decode(str, (useEnvCharset ? Manager.Environment.GetEncoding() : null)); } else { result = Base64.decodeToHex(str); } } return(result); }
/// <summary> /// get value of Argument /// </summary> /// <param name = "expType">type of expected type of evaluation</param> /// <param name = "expSize">size of expected string from evaluation</param> /// <returns> value of the Argument</returns> protected internal String getValue(StorageAttribute expType, int expSize) { switch (_type) { case ConstInterface.ARG_TYPE_EXP: _val = _exp.evaluate(expType, expSize); if (_val == null) { _val = getEmptyValue(expType == StorageAttribute.BLOB || expType == StorageAttribute.BLOB_VECTOR); } break; case ConstInterface.ARG_TYPE_FIELD: _val = _fld.getValue(true); break; case ConstInterface.ARG_TYPE_VALUE: break; default: return(null); } return(_val); }
/// <summary> Replace the vector's cell attribute in the blob prefix by the specified one</summary> /// <param name="str">a valid blob string (i.e. prefix;data) </param> /// <param name="vecCellAttr">attribute to insert into the prefix </param> /// <returns> modified blob string </returns> public static String SetVecCellAttr(String str, StorageAttribute vecCellAttr) { String result = ""; try { int prefixLastIndex = str.IndexOf(";"); String prefix = str.Substring(0, prefixLastIndex); String data = str.Substring(prefixLastIndex + 1); String[] tokens = StrUtil.tokenize(prefix, ",;"); for (int i = 0; i < GuiConstants.BLOB_PREFIX_ELEMENTS_COUNT; i++) { if (i == 3) { result = result + (char)vecCellAttr + ","; } else { result = result + tokens[i] + ","; } } return(result.Substring(0, result.Length - 1) + ";" + data); } catch (Exception) { throw new ApplicationException(" in XMLparser.blobPrefixLength invalid format"); } }
/// <summary> /// appends data into dotnet blob prefix /// </summary> /// <param name="blob">dotnet blob</param> /// <param name="data">data to add</param> /// <param name="type">storage type of data</param> /// <returns></returns> public static String addDataToDotNetBlob(String blob, String data, StorageAttribute type) { if (isValidDotNetBlob(blob)) { String blobPrefix = getPrefix(blob); String blobData = ""; char contentType = CONTENT_TYPE_ANSI; if (type == StorageAttribute.UNICODE) { contentType = CONTENT_TYPE_UNICODE; } // add content type into the prefix blobPrefix = setContentType(blobPrefix, contentType); // get the data if (data != null) { String tmpBlob = createFromString(data, contentType); blobData = tmpBlob.Substring(blobPrefixLength(tmpBlob)); } return(blobPrefix + blobData); } return(blob); }
/// <summary> /// Converts Magic 'Vector' Type to 'dotNetType' /// </summary> /// <param name="magicVal"></param> /// <param name="dotNetType"></param> /// <returns></returns> private static object convertVectorToDotNet(string magicVal, Type dotNetType) { Object retObject = null; VectorType vector = new VectorType(magicVal); StorageAttribute vecCellAttr = VectorType.getCellsAttr(magicVal); int vecSize = (int)VectorType.getVecSize(magicVal); Type arrayType = null; String vecCellMagicFormat; Object vecCellDotNetFormat; // get the default conversion Type arrayType = getDefaultDotNetTypeForVector(vector); if (arrayType != null) { // construct the arrayObject Array arrayObj = ReflectionServices.CreateArrayInstance(arrayType, new int[] { vecSize }); for (int idx = 0; idx < vecSize; idx++) { vecCellMagicFormat = vector.getVecCell(idx + 1); vecCellDotNetFormat = convertMagicToDotNet(vecCellMagicFormat, vecCellAttr, arrayType); arrayObj.SetValue(vecCellDotNetFormat, idx); } // perform cast into 'dotNetType' retObject = doCast(arrayObj, dotNetType); } return(retObject); }
/// <summary> /// update the return value returned from the task /// </summary> /// <param name="task">exiting task</param> /// <param name="returnValField">field to be updated with the tasks return value</param> internal override void UpdateReturnValue(Task task, Field returnValField) { if (task.RetrunValueExp == 0 || returnValField == null) { return; } StorageAttribute vecCellAttribute = StorageAttribute.NONE; if (returnValField.getType() == StorageAttribute.BLOB_VECTOR) { vecCellAttribute = returnValField.getCellsType(); } // evaluate the expression bool wasEvaluated; String retVal = task.EvaluateExpression(task.RetrunValueExp, returnValField.getType(), returnValField.getSize(), false, vecCellAttribute, true, out wasEvaluated); if (wasEvaluated) { returnValField.setValueAndStartRecompute(retVal, false, true, true, false); } else { returnValField.invalidate(true, Field.CLEAR_FLAGS); returnValField.compute(false); } returnValField.updateDisplay(); }
/// <summary> /// CTOR that creates a "Value" type argument from a given Expression Value /// </summary> /// <param name = "expVal">the source expression value</param> protected internal Argument(GuiExpressionEvaluator.ExpVal expVal) { _type = ConstInterface.ARG_TYPE_VALUE; _fld = null; _exp = null; _skip = false; if (expVal.IsNull) { _val = null; } else { _val = expVal.ToMgVal(); if (expVal.Attr == StorageAttribute.DOTNET && (String.IsNullOrEmpty(_val) || !BlobType.isValidDotNetBlob(_val))) { _dnObjectCollectionKey = DNManager.getInstance().DNObjectsCollection.CreateEntry(null); _val = BlobType.createDotNetBlobPrefix(_dnObjectCollectionKey); if (expVal.DnMemberInfo != null) { DNManager.getInstance().DNObjectsCollection.Update(_dnObjectCollectionKey, expVal.DnMemberInfo.value); } // add this key into 'tempDNObjectsCollectionKeys', so that it can be freed later. ClientManager.Instance.getTempDNObjectCollectionKeys().Add(_dnObjectCollectionKey); } } _valueIsNull = (_val == null); _valueAttr = expVal.Attr; }
/// <summary> /// evaluate the expression and return the ReturnValue /// </summary> internal ReturnValue evaluate(int length) { ExpressionEvaluator.ExpVal expVal = null; StorageAttribute resType = StorageAttribute.NONE; ReturnValue retVal; String val = null; if (computedByClient()) { expVal = ExpressionEvaluator.eval(_expBytes, resType, _task); ConvertExpValForDotNet(expVal); // even if actual dotnet obj is null, we need to return blobPrefix if (expVal.IsNull && expVal.Attr != StorageAttribute.DOTNET) { val = null; } else { val = expVal.ToMgVal(); } resType = expVal.Attr; } else { val = evaluate(resType, length); resType = _type; } retVal = new ReturnValue(val, resType); return(retVal); }
void FetchValuesFromView() { // Using a dictionary here, because I don't have a 'hash set' available. var usedLinkValues = new com.magicsoftware.util.MgHashSet <FieldValue>(); displayValues = new List <string>(); linkValues = new List <string>(); nullValueFlags = new List <bool>(); linkType = StorageAttribute.NONE; DbPos pos = new DbPos(true); view.OpenCursor(false, pos, BoudariesFlags.Range); while (view.CursorFetch().Success) { linkType = (StorageAttribute)valueField.Attr; FieldValue linkValue = view.GetFieldValue(valueField); // According to Online and RC-non-offline behavior, null link values should not // be added to the data control. The server does not send them at all. if (!linkValue.IsNull && !usedLinkValues.Contains(linkValue)) { nullValueFlags.Add(false); linkValues.Add(linkValue.Value.ToString()); displayValues.Add(ConvertToDisplayValue(view.GetFieldValue(displayField))); usedLinkValues.Add(linkValue.Clone()); } } view.CloseCursor(); }
void TestLinkValues(DcValues target, string[] linkValues, StorageAttribute type) { target.setType(type); target.SetLinkValues(linkValues); Assert.IsNotNull(target.GetLinkVals()); Assert.AreNotSame(linkValues, target.GetLinkVals()); CompareArrays(linkValues, target.GetLinkVals()); }
internal NodeFinder(MgTreeBase enclosingInstance, String mgValue, bool isNull, StorageAttribute type) { _enclosingInstance = enclosingInstance; _mgValue = mgValue; _isNull = isNull; _type = type; NodeId = NODE_NOT_FOUND; _field = (Field)(_enclosingInstance.Task.getForm().getTreeCtrl().getNodeIdField()); }
/// <summary> convert numbers to our secret format /// </summary> /// <param name="fileName"></param> private static String Encode(String numStr, StorageAttribute attr, String picStr) { PIC pic = new PIC(picStr, attr, 0); NUM_TYPE num_type = new NUM_TYPE(numStr, pic, 0); String encoded_num = num_type.toXMLrecord(); encoded_num = Base64.encode(RecordUtils.byteStreamToString(encoded_num), ClientManager.Instance.getEnvironment().GetEncoding()); return(XmlParser.escape(encoded_num)); }
/// <summary> /// find node in tree by value. for goto function. /// </summary> /// <param name = "mgValue"></param> /// <param name = "isNull"></param> /// <param name = "type"></param> /// <returns> found node id or NODE_NOT_FOUND in case nothing is found</returns> internal int findNode(String mgValue, bool isNull, StorageAttribute type) { NodeFinder nodeFinder = new NodeFinder(this, mgValue, isNull, type); if (_root != null) { _root.doForAllNodes(nodeFinder); } return(nodeFinder.NodeId); }
/// <summary> /// get Value of Argument /// </summary> /// <param name = "idx">the index of the requested argument</param> /// <param name = "expType">type of expected type of evaluation, for expression only</param> /// <param name = "expSize">size of expected string from evaluation, for expression only</param> /// <returns> value of evaluated Argument</returns> internal String getArgValue(int idx, StorageAttribute expType, int expSize) { Argument arg = getArg(idx); if (arg == null) { return(null); } return(arg.getValue(expType, expSize)); }
/// <summary> /// /// </summary> /// <param name="resType"></param> /// <returns></returns> internal ExpressionEvaluator.ExpVal evaluate(StorageAttribute resType) { ExpressionEvaluator.ExpVal expVal = null; String retVal; bool isNull = false; if (computedByClient()) { expVal = ExpressionEvaluator.eval(_expBytes, resType, _task); } else { RunTimeEvent rtEvt = ClientManager.Instance.EventsManager.getLastRtEvent(); Task mprgCreator = null; if (rtEvt != null) { mprgCreator = rtEvt.getMainPrgCreator(); } // create a new command object only when necessary if (resType != _prevResType) { _cmdToServer = CommandFactory.CreateEvaluateCommand(_task.getTaskTag(), resType, _id, 0, mprgCreator); } ClientManager.Instance.execRequestWithSubformRecordCycle(_cmdsToServer, _cmdToServer, this, _task); if (resType != StorageAttribute.BLOB && resType != StorageAttribute.BLOB_VECTOR) { retVal = _resultValue; } else if (_resultValue != null && _resultValue.Equals(" ")) { retVal = ""; } else { retVal = RecordUtils.byteStreamToString(_resultValue); } if (retVal == null) { isNull = true; } // If we don't know what result type we got, and want to keep it, as in ExpCalc if (resType == StorageAttribute.NONE) { resType = _type; } expVal = new ExpressionEvaluator.ExpVal(resType, isNull, retVal); } _prevResType = resType; return(expVal); }
/// <summary> /// Converts 'dotNetObj' to 'Vector' Magic type /// </summary> /// <param name="dotNetObj"></param> /// <returns></returns> private static string convertDotNetToVector(object dotNetObj) { String retObject = ""; Type dotNetType = dotNetObj.GetType(); if (dotNetType.IsArray) { Array arrObj = (Array)dotNetObj; Type arrCellType = arrObj.GetType().GetElementType(); StorageAttribute vecCellType = getDefaultVecCellTypeForDotNet(arrCellType); if (vecCellType != StorageAttribute.NONE) { VectorType vector; String[] magicVals = new String[arrObj.Length]; long maxLength = 0; // convert each element of array into magic equivalent and store it in temp string array. for (int idx = 0; idx < arrObj.Length; idx++) { magicVals[idx] = convertDotNetToMagic(arrObj.GetValue(idx), vecCellType); // evaluate max length if (magicVals[idx].Length > maxLength) { maxLength = magicVals[idx].Length; } } if (vecCellType == StorageAttribute.BLOB) { maxLength = 28; // length for a blob is always 28 } // find cellContentType and create a vector char cellContentType = BlobType.CONTENT_TYPE_UNKNOWN; if (vecCellType == StorageAttribute.BLOB && magicVals.Length > 0) { cellContentType = BlobType.getContentType(magicVals[0]); } vector = new VectorType(vecCellType, cellContentType, "", true, true, maxLength); // set the temp string array into vector for (int idx = 0; idx < arrObj.Length; idx++) { vector.setVecCell(idx + 1, magicVals[idx], false); } // get the flattened string retObject = vector.ToString(); } } return(retObject); }
public void SetTypeTest() { DcValues target = new DcValues(false, false); StorageAttribute type = StorageAttribute.ALPHA; target.setType(type); Assert.AreEqual(type, target.GetAttr()); type = StorageAttribute.NUMERIC; target.setType(type); Assert.AreEqual(type, target.GetAttr()); }
/// <summary> /// Ref to coversion table in ConvertMagicToDotNet, gets the default DotNetType for 'magicType' /// </summary> /// <param name="magicType"></param> /// <returns></returns> public static Type getDefaultDotNetTypeForMagicType(String magicVal, StorageAttribute magicType) { Type dotNetType = null; switch (magicType) { case StorageAttribute.NUMERIC: NUM_TYPE numType = new NUM_TYPE(magicVal); if (numType.NUM_IS_LONG()) { dotNetType = typeof(long); } else { dotNetType = typeof(Double); } break; case StorageAttribute.ALPHA: case StorageAttribute.UNICODE: dotNetType = typeof(String); break; case StorageAttribute.DATE: dotNetType = typeof(DateTime); break; case StorageAttribute.TIME: dotNetType = typeof(TimeSpan); break; case StorageAttribute.BOOLEAN: dotNetType = typeof(Boolean); break; case StorageAttribute.BLOB: dotNetType = typeof(String); break; case StorageAttribute.BLOB_VECTOR: dotNetType = typeof(Array); break; case StorageAttribute.DOTNET: dotNetType = typeof(Object); break; default: break; } return(dotNetType); }
/// <summary> /// is the both types belong to the same inner data types /// </summary> /// <param name = "type1">data type</param> /// <param name = "type2">data type</param> public static bool isTheSameType(StorageAttribute type1, StorageAttribute type2) { if (type1 == type2 || (isTypeNumeric(type1) && isTypeNumeric(type2)) || (isTypeLogical(type1) && isTypeLogical(type2)) || (IsTypeAlphaOrUnicode(type1) && IsTypeAlphaOrUnicode(type2)) || (isTypeBlob(type1) && isTypeBlob(type2)) || (isTypeDotNet(type1) && isTypeDotNet(type2))) { return(true); } return(false); }
/// <summary> /// set the cursor offset /// </summary> /// <param name="searchString"></param> private void SetCursorOffset(string searchString) { StorageAttribute storageAttribute = TaskViews.Fields[FldId].StorageAttribute; // if alpha or unicode string, offset the cursor to after the searched string if (storageAttribute == StorageAttribute.ALPHA || storageAttribute == StorageAttribute.UNICODE) { Task.locateQuery.Offset = searchString.Length; } }
/// <summary> /// get the default Vec cell type for DotNet type /// </summary> /// <param name="type"></param> /// <returns></returns> private static StorageAttribute getDefaultVecCellTypeForDotNet(Type type) { StorageAttribute vecCellAttr = StorageAttribute.NONE; if (type == typeof(SByte) || type == typeof(Byte) || type == typeof(Int16) || type == typeof(UInt16) || type == typeof(Int32) || type == typeof(UInt32) || type == typeof(Int64) || type == typeof(UInt64) || type == typeof(float) || type == typeof(Decimal) || type == typeof(Single) || type == typeof(Double) || type == typeof(IntPtr) || type == typeof(UIntPtr)) { vecCellAttr = StorageAttribute.NUMERIC; } else if (type == typeof(Char) || type == typeof(String) || type == typeof(StringBuilder)) { vecCellAttr = StorageAttribute.UNICODE; } else if (type == typeof(DateTime)) { vecCellAttr = StorageAttribute.DATE; } else if (type == typeof(TimeSpan)) { vecCellAttr = StorageAttribute.TIME; } else if (type == typeof(Boolean)) { vecCellAttr = StorageAttribute.BOOLEAN; } /// TODO : need to decide the conversion for char[]. Currently converted into Array of Unicode /// else if (type == typeof(Char[])) else if (type == typeof(Byte[])) { vecCellAttr = StorageAttribute.BLOB; } else if (type == typeof(Array)) { vecCellAttr = StorageAttribute.BLOB_VECTOR; } else if (type == typeof(Object)) { vecCellAttr = StorageAttribute.DOTNET; } return(vecCellAttr); }
/// <summary> /// Initialize the DcValues according to the values set in the tokens vector. /// </summary> /// <param name="tokensVector">A set of attribute value pairs built by the XmlParser.</param> private void InitDCValues(DcValues dcv, List <string> tokensVector) { StorageAttribute type = StorageAttribute.NONE; string[] displayValues = null; string serializedLinkValues = null; for (int j = 0; j < tokensVector.Count; j += 2) { String attribute = (tokensVector[j]); String valueStr = (tokensVector[j + 1]); switch (attribute) { case XMLConstants.MG_ATTR_ID: SetId(dcv, XmlParser.getInt(valueStr)); break; case XMLConstants.MG_ATTR_TYPE: type = (StorageAttribute)valueStr[0]; SetType(dcv, type); break; case ConstInterface.MG_ATTR_DISP: valueStr = XmlParser.unescape(valueStr); displayValues = ParseValues(valueStr, StorageAttribute.UNICODE); break; case ConstInterface.MG_ATTR_LINKED: // optional tag valueStr = XmlParser.unescape(valueStr); serializedLinkValues = valueStr; break; case ConstInterface.MG_ATTR_NULL_FLAGS: SetNullFlags(dcv, valueStr); break; default: Logger.Instance.WriteExceptionToLog("in DcValues.initElements() unknown attribute: " + attribute); break; } } SetDisplayValues(dcv, displayValues); if (serializedLinkValues == null) { SetLinkValues(dcv, displayValues); } else { SetLinkValues(dcv, ParseValues(serializedLinkValues, type)); } }
/// <summary> /// Check if types are compatible or not. /// </summary> /// <param name="sourceAttribute"></param> /// <param name="destinationAttribute"></param> /// <returns></returns> public static bool IsTypeCompatibile(StorageAttribute sourceAttribute, StorageAttribute destinationAttribute) { bool isTypeCompatible = false; switch (sourceAttribute) { case StorageAttribute.ALPHA: case StorageAttribute.UNICODE: if (destinationAttribute == StorageAttribute.ALPHA || destinationAttribute == StorageAttribute.UNICODE || destinationAttribute == StorageAttribute.DATE || destinationAttribute == StorageAttribute.TIME || destinationAttribute == StorageAttribute.NUMERIC) { isTypeCompatible = true; } break; case StorageAttribute.NUMERIC: if (destinationAttribute == StorageAttribute.NUMERIC || destinationAttribute == StorageAttribute.ALPHA || destinationAttribute == StorageAttribute.UNICODE || destinationAttribute == StorageAttribute.BOOLEAN || destinationAttribute == StorageAttribute.DATE || destinationAttribute == StorageAttribute.TIME) { isTypeCompatible = true; } break; case StorageAttribute.BOOLEAN: if (destinationAttribute == StorageAttribute.BOOLEAN || destinationAttribute == StorageAttribute.ALPHA || destinationAttribute == StorageAttribute.UNICODE || destinationAttribute == StorageAttribute.NUMERIC) { isTypeCompatible = true; } break; case StorageAttribute.DATE: case StorageAttribute.TIME: if (destinationAttribute == StorageAttribute.ALPHA || destinationAttribute == StorageAttribute.UNICODE || destinationAttribute == StorageAttribute.NUMERIC || destinationAttribute == StorageAttribute.BOOLEAN || destinationAttribute == StorageAttribute.DATE || destinationAttribute == StorageAttribute.TIME) { isTypeCompatible = true; } break; case StorageAttribute.BLOB: if (destinationAttribute == StorageAttribute.BLOB) { isTypeCompatible = true; } break; } return(isTypeCompatible); }
/// <summary> convert numbers from our secret format /// </summary> /// <param name="fileName"></param> private static String Decode(String numStr, StorageAttribute attr, String picStr) { String decoded_num = XmlParser.unescape(numStr); decoded_num = XmlParser.unescape(decoded_num); decoded_num = Base64.decodeToHex(decoded_num); NUM_TYPE num_type = new NUM_TYPE(decoded_num); PIC pic = new PIC(picStr, attr, 0); return(num_type.toDisplayValue(pic)); }
/// <summary> /// This overload of the ParseValues method simplifies the use of the original method by /// determining the value of the 'useHex' parameter based on the ClientManager's log level and /// the type of the serialized values. /// </summary> /// <param name = "valueStr">The serialized values as received from the XML</param> /// <param name = "dataType">The storage type of the servialized values.</param> private String[] ParseValues(String valueStr, StorageAttribute dataType) { bool useHex = false; if (ClientManager.Instance.getEnvironment().GetDebugLevel() > 1 || dataType == StorageAttribute.ALPHA || dataType == StorageAttribute.UNICODE || dataType == StorageAttribute.BOOLEAN) { useHex = true; } return(ParseValues(valueStr, dataType, useHex)); }
internal void setType(StorageAttribute type) { _type = type; if (_type == StorageAttribute.MEMO) { _type = StorageAttribute.ALPHA; } if (_type == StorageAttribute.NUMERIC || _type == StorageAttribute.DATE || _type == StorageAttribute.TIME) { _isNumericType = true; } }
/// <summary> /// Evaluates the expression corresponding to the passed ID. /// </summary> /// <param name="expId">Exp ID</param> /// <param name="resType">expected return type</param> /// <param name="length">Expected len - is not used, it must be here because of computability with Rich Client</param> /// <param name="contentTypeUnicode">should the result be unicode</param> /// <param name="resCellType"></param> /// <param name="alwaysEvaluate">for form properties and some control properties we always evaluate expressions</param> /// <param name="wasEvaluated">indicates whether the expression was evaluated</param> /// <returns>evaluated value</returns> public String EvaluateExpression(int expId, StorageAttribute resType, int length, bool contentTypeUnicode, StorageAttribute resCellType, bool alwaysEvaluate, out bool wasEvaluated) { String result = null; wasEvaluated = false; if (alwaysEvaluate || DataViewWasRetrieved) { result = CalculateExpression(expId, resType, length, contentTypeUnicode, resCellType); wasEvaluated = true; } return(result); }
/// <summary> /// fill the argument from a string /// </summary> /// <param name="argStr"></param> internal void FillFromString(string argStr) { // type is always a value _type = ConstInterface.ARG_TYPE_VALUE; string argType = null; // If string is shorter than 3, assume it does not have an attribute identifier if (argStr.Length > 2) { argType = argStr.Substring(0, 2); } switch (argType) { case ConstInterface.REQ_ARG_ALPHA: _valueAttr = StorageAttribute.ALPHA; break; case ConstInterface.REQ_ARG_UNICODE: _valueAttr = StorageAttribute.UNICODE; break; case ConstInterface.REQ_ARG_NUMERIC: _valueAttr = StorageAttribute.NUMERIC; break; case ConstInterface.REQ_ARG_DOUBLE: _valueAttr = StorageAttribute.NUMERIC; break; case ConstInterface.REQ_ARG_LOGICAL: _valueAttr = StorageAttribute.BOOLEAN; break; case ConstInterface.REQ_ARG_NULL: _valueAttr = StorageAttribute.NONE; break; default: // if storage type is not defined, assume alpha string and the entire string is the value _valueAttr = StorageAttribute.ALPHA; _val = argStr; return; } // the case the string is too short was dealt with earlier - it will get to the default case in the switch // and return from there _val = argStr.Substring(2); }
/// <summary> /// gets the default dotnet type for vector /// </summary> /// <param name="vector"></param> /// <returns></returns> private static Type getDefaultDotNetTypeForVector(VectorType vector) { StorageAttribute vecCellAttr = vector.getCellsAttr(); Type dotNetType = null; switch (vecCellAttr) { case StorageAttribute.NUMERIC: dotNetType = typeof(Double); break; case StorageAttribute.ALPHA: case StorageAttribute.UNICODE: dotNetType = typeof(String); break; case StorageAttribute.DATE: dotNetType = typeof(DateTime); break; case StorageAttribute.TIME: dotNetType = typeof(TimeSpan); break; case StorageAttribute.BOOLEAN: dotNetType = typeof(Boolean); break; case StorageAttribute.BLOB: if (vector.getVecSize() > 0 && BlobType.getContentType(vector.getVecCell(1)) == BlobType.CONTENT_TYPE_BINARY) { dotNetType = typeof(Byte[]); } else { dotNetType = typeof(String); } break; case StorageAttribute.BLOB_VECTOR: dotNetType = typeof(Array); break; case StorageAttribute.DOTNET: dotNetType = typeof(Object); break; } return(dotNetType); }
/// <summary> /// This function converts the itmVals values to the datatype of ValueMember column /// and add the row to DataTable. /// </summary> /// <param name="ctrl"></param> /// <param name="itmVals"></param> /// <param name="dispVals"></param> internal void AddRows(StorageAttribute dataType, string[] itmVals, string[] dispVals) { Debug.Assert(itmVals.Length == dispVals.Length); Object obj = null; Type dnDataType = (DataTblObj.Columns[GuiConstants.STR_VALUE_MEMBER]).DataType; for (int i = 0; i < dispVals.Length; i++) { // convert the value to type of ValueMember column of the DataTable obj = DNConvert.convertMagicToDotNet(itmVals[i], dataType, dnDataType); DataTblObj.Rows.Add(obj, dispVals[i]); } }