Esempio n. 1
0
        public static object DefaultValue(Program program, Schema.ScalarType type)
        {
            // ScalarType level default trigger handlers
            program.Stack.Push(null);
            try
            {
                if (type.HasHandlers())
                {
                    foreach (Schema.EventHandler handler in type.EventHandlers)
                    {
                        if ((handler.EventType & EventType.Default) != 0)
                        {
                            object result = handler.PlanNode.Execute(program);
                            if ((result != null) && (bool)result)
                            {
                                return(program.Stack.Peek(0));
                            }
                        }
                    }
                }
            }
            finally
            {
                program.Stack.Pop();
            }

            if (type.Default != null)
            {
                return(type.Default.Node.Execute(program));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        public static object ValidateValue(Program program, Schema.ScalarType type, object tempValue, Schema.Operator fromOperator)
        {
            program.Stack.Push(tempValue);
            try
            {
                TableNode.ValidateScalarTypeConstraints(program, type, false);
                TableNode.ExecuteScalarTypeValidateHandlers(program, type, fromOperator);
            }
            finally
            {
                tempValue = program.Stack.Pop();
            }

            return(tempValue);
        }
Esempio n. 3
0
        /// <summary>Removes cached resolutions involving conversions referencing the given scalar type, if any.</summary>
        public void Clear(Schema.ScalarType sourceType, Schema.ScalarType targetType)
        {
            List <OperatorBindingContext> resolutions = new List <OperatorBindingContext>();

            foreach (KeyValuePair <OperatorBindingContext, OperatorBindingContext> entry in _resolutions)
            {
                foreach (OperatorMatch match in entry.Value.Matches)
                {
                    foreach (ConversionContext conversionContext in match.ConversionContexts)
                    {
                        ScalarConversionContext scalarConversionContext = conversionContext as ScalarConversionContext;
                        if (scalarConversionContext != null)
                        {
                            if (!scalarConversionContext.CanConvert && conversionContext.SourceType.Equals(sourceType) || conversionContext.TargetType.Equals(sourceType) || conversionContext.SourceType.Equals(targetType) || conversionContext.TargetType.Equals(targetType))
                            {
                                resolutions.Add(entry.Value);
                                goto Continue;
                            }

                            foreach (Schema.ScalarConversionPath path in scalarConversionContext.Paths)
                            {
                                if (path.Contains(sourceType) || path.Contains(targetType))
                                {
                                    resolutions.Add(entry.Value);
                                    goto Continue;
                                }
                            }
                        }
                    }
                }

                Continue : continue;
            }

            foreach (OperatorBindingContext removeContext in resolutions)
            {
                _resolutions.Remove(removeContext);
            }
        }
Esempio n. 4
0
 public static object ValidateValue(Program program, Schema.ScalarType type, object tempValue)
 {
     return(ValidateValue(program, type, tempValue, null));
 }