예제 #1
0
        private void GetTypeAndValue(out DAE.Schema.IDataType LType, out object LValue)
        {
            LType  = null;
            LValue = null;
            var interfaceValue = FindParent(typeof(IInterface)) as IInterface;

            if (interfaceValue == null || String.IsNullOrEmpty(_keyName) || !interfaceValue.UserState.ContainsKey(_keyName))
            {
                // Get from the default value by parsing
                var expression = new Alphora.Dataphor.DAE.Language.D4.Parser().ParseExpression(_defaultValue);
                if (!(expression is ValueExpression))
                {
                    throw new ClientException(ClientException.Codes.ValueExpressionExpected);
                }
                var process = HostNode.Session.DataSession.UtilityProcess;
                var source  = (ValueExpression)expression;
                switch (source.Token)
                {
                case TokenType.Boolean:
                    LType  = process.DataTypes.SystemBoolean;
                    LValue = (bool)source.Value;
                    break;

                case TokenType.Decimal:
                    LType  = process.DataTypes.SystemDecimal;
                    LValue = (decimal)source.Value;
                    break;

                case TokenType.Integer:
                    LType  = process.DataTypes.SystemInteger;
                    LValue = (int)source.Value;
                    break;

                case TokenType.Money:
                    LType  = process.DataTypes.SystemMoney;
                    LValue = (decimal)source.Value;
                    break;

                case TokenType.Nil:
                    LType  = process.DataTypes.SystemNilGeneric;
                    LValue = null;
                    break;

                case TokenType.String:
                    LType  = process.DataTypes.SystemString;
                    LValue = (string)source.Value;
                    break;
                }
            }
            else
            {
                // Get from user state
                LValue = interfaceValue.UserState[_keyName];
                LType  = LValue == null ? null : DataSession.ScalarTypeFromNativeType(HostNode.Session.DataSession.UtilityProcess, LValue.GetType());
            }
        }