//public static void ReplacePropertyBindingUsage(IList<BindingExpression> bindings, BaseTag baseTag)
        //{
        //    var conditional = baseTag as Conditional;

        //    foreach (var binding in bindings)
        //    {
        //        if (baseTag != null)
        //        {
        //            if (HasBindingExpression(baseTag.Property))
        //            {
        //                baseTag.Property = ReplaceBindingExpressions(binding, baseTag.Property);
        //            }
        //            if (conditional != null)
        //            {
        //                if (HasBindingExpression(conditional.CompareProperty))
        //                {
        //                    conditional.CompareProperty = ReplaceBindingExpressions(binding, conditional.CompareProperty);
        //                }
        //                if (HasBindingExpression(conditional.CompareValue))
        //                {
        //                    conditional.CompareValue = ReplaceBindingExpressions(binding, conditional.CompareValue);
        //                }
        //            }
        //        }
        //    }
        //}

        private static IList<BindingReplacement> BuildBindingReplacements(BindingExpression binding, string content, char? surroundChar = null)
        {
            var replacements = new List<BindingReplacement>();

            if (String.IsNullOrEmpty(content))
                return replacements;

            var bindingExpressions = FindBindingExpressions(content, surroundChar);

            foreach (var bindingExpression in bindingExpressions)
            {
                if (String.Compare(bindingExpression.Name, binding.Name, true) == 0)
                {
                    var replacement = new BindingReplacement
                    {
                        Name = binding.Name,
                        Placeholder = bindingExpression.Placeholder,
                        Value = binding.Value,
                        FullPropertyName = binding.FullPropertyName
                    };

                    if (!String.IsNullOrEmpty(binding.Value) || !String.IsNullOrEmpty(binding.FullPropertyName))
                    {
                        replacements.Add(replacement);
                    }
                }
            }

            return replacements;
        }
Ejemplo n.º 2
0
        internal void ReplaceBindingName(BindingReplacement replacement)
        {
            if (replacement == null)
                throw new ArgumentNullException("replacement");

            this._currentPropertyName = this._propertyPlaceholder;

            replacement.Replace(ref _currentPropertyName);
        }