/// <summary> /// remove DNObjectsCollection entries made by dot net parameters for the event /// </summary> internal void removeDotNetArgs() { // free the object table entry for (int i = 0; i < _argList.getSize(); i++) { string val = _argList.getArg(i).getValue(StorageAttribute.DOTNET, 0); DNManager.getInstance().DNObjectsCollection.Remove(BlobType.getKey(val)); } }
/// <summary> /// Converts Magic 'DotNet' Type to 'dotNetType' /// </summary> /// <param name="magicVal"></param> /// <param name="dotNetType"></param> /// <returns></returns> private static object convertDotNetMagicToDotNet(string magicVal, Type dotNetType) { if (dotNetType == typeof(Object)) { // From blobstr, get the key. Then get object from DNObjectsCollection, clone it and return it. int key = BlobType.getKey(magicVal); Object obj = DNManager.getInstance().DNObjectsCollection.GetDNObj(key); return(obj); } else { return(null); } }
/// <summary> /// converts Alpha/Unicode values to Blob and vice versa. /// </summary> /// <param name="value"></param> /// <param name="srcAttr"></param> /// <param name="expectedType"></param> /// <returns></returns> internal static String convertArgs(String value, StorageAttribute srcAttr, StorageAttribute expectedType) { int key; object dotNetObj = null; bool invalidArg = false; if (srcAttr != StorageAttribute.DOTNET && expectedType == StorageAttribute.DOTNET) { //Convert Magic To DotNet key = _tempTableKey; dotNetObj = DNConvert.convertMagicToDotNet(value, srcAttr, DNConvert.getDefaultDotNetTypeForMagicType(value, srcAttr)); DNManager.getInstance().DNObjectsCollection.Update(key, dotNetObj); value = BlobType.createDotNetBlobPrefix(key); } else if (srcAttr == StorageAttribute.DOTNET && expectedType != StorageAttribute.DOTNET && expectedType != StorageAttribute.NONE) { //Convert DotNet to Magic key = BlobType.getKey(value); if (key != 0) { dotNetObj = DNManager.getInstance().DNObjectsCollection.GetDNObj(key); value = DNConvert.convertDotNetToMagic(dotNetObj, expectedType); } } else { switch (expectedType) { case StorageAttribute.ALPHA: case StorageAttribute.UNICODE: if (srcAttr == StorageAttribute.BLOB) { if (BlobType.isValidBlob(value)) { value = BlobType.getString(value); } } else if (!StorageAttributeCheck.IsTypeAlphaOrUnicode(srcAttr)) { invalidArg = true; } break; case StorageAttribute.NUMERIC: case StorageAttribute.DATE: case StorageAttribute.TIME: if (!StorageAttributeCheck.isTypeNumeric(srcAttr)) { invalidArg = true; } break; case StorageAttribute.BLOB: if (StorageAttributeCheck.IsTypeAlphaOrUnicode(srcAttr)) { char contentType = srcAttr == StorageAttribute.ALPHA ? BlobType.CONTENT_TYPE_ANSI : BlobType.CONTENT_TYPE_UNICODE; value = BlobType.createFromString(value, contentType); } else if (!StorageAttributeCheck.isTypeBlob(srcAttr)) { invalidArg = true; } break; } //If there is mismatch in attribute, take default value of expectd argument. if (invalidArg) { value = FieldDef.getMagicDefaultValue(expectedType); } } return(value); }