예제 #1
0
        /// <summary>
        /// This class is responsible for getting the current iterate item object within an iteration. i.e. The property name starts with "[]."
        /// We do this by navigating up through the parent nodes to determine which of them are iterate elements.
        /// Once found we get the current iteration context item.
        /// If "[]." is not specified, the original approach is used of reflecting the parameterObject to the reflection path specified in the property
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="baseTag"></param>
        /// <param name="parameterObject"></param>
        /// <returns></returns>
        /// <remarks>
        /// Created By: Richard Beacroft
        /// Created Date: 11\10\2013
        /// </remarks>
        protected object GetMemberPropertyValue(SqlTagContext ctx, BaseTag baseTag, object parameterObject)
        {
            if (String.IsNullOrEmpty(baseTag.Property))
            {
                return(parameterObject);
            }
#if dotnet35
            var bindingReplacement = ctx.BuildPropertyBindingReplacements(baseTag).FirstOrDefault();
#else
            BindingReplacement bindingReplacement = null;
            foreach (var replacement in ctx.BuildPropertyBindingReplacements(baseTag))
            {
                bindingReplacement = replacement;
                break;
            }
#endif
            if (bindingReplacement != null)
            {
                if (String.IsNullOrEmpty(bindingReplacement.FullPropertyName))
                {
                    return(bindingReplacement.Value);
                }
                return(_tagPropertyProbe.GetMemberValue(ctx, baseTag, bindingReplacement.FullPropertyName, parameterObject));
            }

            return(_tagPropertyProbe.GetMemberPropertyValue(ctx, baseTag, parameterObject));
        }
예제 #2
0
        //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);
        }
예제 #3
0
        internal void ReplaceBindingName(BindingReplacement replacement)
        {
            if (replacement == null)
            {
                throw new ArgumentNullException("replacement");
            }

            this._currentPropertyName = this._propertyPlaceholder;

            replacement.Replace(ref _currentPropertyName);
        }