Ejemplo n.º 1
0
        //----------------------------------------------------- 
        // 
        //  Constructors
        // 
        //-----------------------------------------------------

        /// <summary> Constructor </summary>
        internal BindingExpressionBase(BindingBase binding, BindingExpressionBase parent) : base(ExpressionMode.SupportsUnboundSources) 
        {
            if (binding == null) 
                throw new ArgumentNullException("binding"); 

            _binding = binding; 
            _parentBindingExpression = parent;

            _flags = (PrivateFlags)binding.Flags;
 
            if (parent != null)
            { 
                ResolveNamesInTemplate = parent.ResolveNamesInTemplate; 

                Type type = parent.GetType(); 
                if (type == typeof(MultiBindingExpression))
                    ChangeFlag(PrivateFlags.iInMultiBindingExpression, true);
                else if (type == typeof(PriorityBindingExpression))
                    ChangeFlag(PrivateFlags.iInPriorityBindingExpression, true); 
            }
 
            // initialize tracing information 
            PresentationTraceLevel traceLevel = PresentationTraceSources.GetTraceLevel(binding);
 
            if (traceLevel > 0)
            {
                // copy TraceLevel from parent BindingBase - it can be changed later
                PresentationTraceSources.SetTraceLevel(this, traceLevel); 
            }
 
            if (TraceData.IsExtendedTraceEnabled(this, TraceDataLevel.CreateExpression)) 
            {
                if (parent == null) 
                {
                    TraceData.Trace(TraceEventType.Warning,
                                        TraceData.CreatedExpression(
                                            TraceData.Identify(this), 
                                            TraceData.Identify(binding)));
                } 
                else 
                {
                    TraceData.Trace(TraceEventType.Warning, 
                                        TraceData.CreatedExpressionInParent(
                                            TraceData.Identify(this),
                                            TraceData.Identify(binding),
                                            TraceData.Identify(parent))); 
                }
            } 
 
            if (LookupValidationRule(typeof(ExceptionValidationRule)) != null)
            { 
                ChangeFlag(PrivateFlags.iValidatesOnExceptions, true);
            }

            if (LookupValidationRule(typeof(DataErrorValidationRule)) != null) 
            {
                ChangeFlag(PrivateFlags.iValidatesOnDataErrors, true); 
            } 
        }