Ejemplo n.º 1
0
        public static string GetReflectedFullName(SqlTagContext ctx, BaseTag tag, string propertyName)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException("ctx");
            }
            if (tag == null)
            {
                throw new ArgumentNullException("tag");
            }
            if (propertyName == null)
            {
                throw new ArgumentNullException("propertyName");
            }

            var currentIteratorContext = ctx.GetAttribute(tag) as IterateContext;

            // is current tag an iterate?
            if (currentIteratorContext != null)
            {
                propertyName = String.Format("{0}[{1}]", propertyName, currentIteratorContext.Index);
            }

            var parentIteratorTag = FindParentIteratorTag(ctx, tag);

            // is current node a child of another iterate node?
            if (parentIteratorTag != null)
            {
                return(BuildReflectedFullName(ctx, parentIteratorTag, propertyName));
            }

            return(propertyName);
        }
Ejemplo n.º 2
0
        private static string BuildReflectedFullName(SqlTagContext ctx, Iterate parentIteratorTag, string propertyName)
        {
            if (parentIteratorTag != null)
            {
                var parentIteratorContext = ctx.GetAttribute(parentIteratorTag) as IterateContext;
                var indexOfIndexer        = propertyName.IndexOf(THIS_ENUMERATOR_PLACEHOLDER);

                if (parentIteratorContext == null)
                {
                    return(propertyName);
                }

                if (indexOfIndexer == 0)
                {
                    // the property name is a reflection name relative to the iterate.
                    propertyName = propertyName.Substring(indexOfIndexer + THIS_ENUMERATOR_PLACEHOLDER.Length);
                    propertyName = String.Format("{0}[{1}].{2}", parentIteratorTag.Property, parentIteratorContext.Index, propertyName);

                    var parentOrParentIteratorTag = FindParentIteratorTag(ctx, parentIteratorTag);

                    if (parentOrParentIteratorTag != null)
                    {
                        return(BuildReflectedFullName(ctx, parentOrParentIteratorTag, propertyName));
                    }
                }
                else if (propertyName.IndexOf(ENUMERATOR_PLACEHOLDER) > -1)
                {
                    return(propertyName + "[" + parentIteratorContext.Index + "]"); //Parameter-Index-Dynamic
                }
            }

            return(propertyName);
        }
Ejemplo n.º 3
0
        private IterateContext FindParentIteratorContext(SqlTagContext ctx, BaseTag tag)
        {
            if (tag.Parent is Iterate)
            {
                return(ctx.GetAttribute(tag.Parent) as IterateContext);
            }

            var parentBaseTag = tag.Parent as BaseTag;

            if (tag.Parent == null || parentBaseTag == null)
            {
                return(null);
            }

            return(FindParentIteratorContext(ctx, parentBaseTag));
        }