コード例 #1
0
ファイル: IterateSerializer.cs プロジェクト: reckcn/CSharp
        /// <summary>
        /// Deserializes the specified configuration in an <see cref="Iterate"/> object
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <returns></returns>
        public override SqlTag Deserialize(IConfiguration configuration)
		{
            Iterate iterate = new Iterate(accessorFactory);

            iterate.Prepend = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "prepend");
            iterate.Property = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "property");
            iterate.Close = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "close");
            iterate.Conjunction = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "conjunction");
            iterate.Open = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "open");

			return iterate;
		}
コード例 #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;
        }