Exemple #1
0
        /// <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;
        }
Exemple #2
0
        /// <summary>
        ///   update the result into expression DNObjectsCollection Entry and modifies Expval to contain the blob prefix
        /// </summary>
        /// <param name = "expVal"></param>
        private void ConvertExpValForDotNet(ExpressionEvaluator.ExpVal expVal)
        {
            if (expVal.Attr == StorageAttribute.DOTNET)
            {
                // update the value at DNObjectsCollection Key. This is updated into Expression DNObjectsCollection key, so no need to Cast.
                DNManager.getInstance().DNObjectsCollection.Update(_dnObjectCollectionKey, expVal.DnMemberInfo.value);

                bool isNull = (expVal.DnMemberInfo.value == null);

                expVal.Nullify();
                expVal.Init(StorageAttribute.DOTNET, isNull, BlobType.createDotNetBlobPrefix(_dnObjectCollectionKey));
            }
        }
Exemple #3
0
        /// <summary>
        ///   set dot net parameters as arguments for the event
        /// </summary>
        /// <param name = "parameters"></param>
        internal void setDotNetArgs(object[] parameters)
        {
            ExpressionEvaluator.ExpVal[] argsList = new ExpressionEvaluator.ExpVal[parameters.Length];
            for (int i = 0; i < parameters.Length; i++)
            {
                int    key        = DNManager.getInstance().DNObjectsCollection.CreateEntry(null);
                String blobString = BlobType.createDotNetBlobPrefix(key);
                DNManager.getInstance().DNObjectsCollection.Update(key, parameters[i]);
                argsList[i] = new ExpressionEvaluator.ExpVal(StorageAttribute.DOTNET,
                                                             parameters[i] == null, blobString);
            }
            //create the string for the blob
            ArgumentsList args = new ArgumentsList(argsList);

            setArgList(args);
        }
Exemple #4
0
        /// <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);
        }