Exemplo n.º 1
0
        public virtual List <TDestination> MapList(XPathProcessor source, string collectionNode, string nodeName, string collectionNodeNamespacePrefix = "", string collectionItemNodeNamespacePrefix = "", bool outputDefault = false)
        {
            // Default namespace
            this.RegisterNamespace(source, this.NamespacePrefix, this.Namespace);

            string collNamespace;
            var    list = new List <TDestination>();

            if (string.IsNullOrWhiteSpace(collectionNodeNamespacePrefix))
            {
                // It's the same as normal
                collectionNodeNamespacePrefix = this.NamespacePrefix;
                collNamespace = this.Namespace;
            }
            else
            {
                // Look it up.
                collNamespace = source.LookupNamespace(collectionNodeNamespacePrefix);
                if (string.IsNullOrWhiteSpace(collNamespace))
                {
                    throw new MappingException(string.Format("No namespace registered for {0}", collectionNodeNamespacePrefix));
                }
            }

            if (!string.IsNullOrEmpty(collectionNode))
            {
                source.Push(collectionNode, collNamespace, collectionNodeNamespacePrefix);
            }

            if (string.IsNullOrEmpty(nodeName))
            {
                nodeName = this.NodeName;
            }

            var          index = 1;
            TDestination item;

            do
            {
                item = this.Map(source, nodeName, string.Empty, collectionItemNodeNamespacePrefix, index++);
                if (item != null)
                {
                    list.Add(item);
                }
            }while (item != null);

            if (!string.IsNullOrEmpty(collectionNode))
            {
                source.Pop();
            }

            return(list);
        }
Exemplo n.º 2
0
        private Tuple <string, string> XmlTypeInfo(XPathProcessor source, string xmlType)
        {
            var parts = xmlType.Split(':');

            if (parts.GetUpperBound(0) == 0)
            {
                return(new Tuple <string, string>(source.CurrentNamespace, parts[0]));
            }

            // Need the namespace not the registered prefix
            var ns = source.LookupNamespace(parts[0]);

            return(new Tuple <string, string>(ns, parts[1]));
        }