Esempio n. 1
0
        /// <summary>
        /// Gets a collection of elements in the document which are defined as METAL macros.
        /// </summary>
        /// <returns>Elements representing the METAL macros.</returns>
        public override ITalesPathHandler GetMacros()
        {
            var output = this.Document
            .DocumentNode
            .DescendantsAndSelf()
            .Where(ele => ele.Attributes.Any(attr => attr.Name == String.Format("{0}:{1}",
                                                                            ZptConstants.Metal.Namespace.Prefix,
                                                                            ZptConstants.Metal.DefineMacroAttribute)))
            .Select(x => {
              var element = new ZptHtmlElement(x, this.SourceFile, this, isImported: true);
              var context = new RenderingContext(Model.Empty, Model.Empty, element, GetDefaultOptions());
              return new Metal.MetalMacro(context.GetMetalAttribute(ZptConstants.Metal.DefineMacroAttribute).Value, element);
            })
            .ToArray();

              return new CSF.Zpt.Metal.MetalMacroCollection(output);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets a collection of elements in the document which are defined as METAL macros.
        /// </summary>
        /// <returns>Elements representing the METAL macros.</returns>
        public override ITalesPathHandler GetMacros()
        {
            var xpath = String.Format("//*[@{0}:{1}]",
                                ZptConstants.Metal.Namespace.Prefix,
                                ZptConstants.Metal.DefineMacroAttribute);

              var reader = this.Document.CreateReader();
              var root = this.Document.Root;

              var nsManager = new XmlNamespaceManager(reader.NameTable);
              nsManager.AddNamespace(ZptConstants.Metal.Namespace.Prefix, ZptConstants.Metal.Namespace.Uri);

              var output = root
            .XPathSelectElements(xpath, nsManager)
            .Cast<XNode>()
            .Select(x => {
              var element = new ZptXmlLinqElement(x, this.SourceFile, this, isImported: true);
              var context = new RenderingContext(Model.Empty, Model.Empty, element, GetDefaultOptions());
              return new Metal.MetalMacro(context.GetMetalAttribute(ZptConstants.Metal.DefineMacroAttribute).Value, element);
            })
            .ToArray();

              return new CSF.Zpt.Metal.MetalMacroCollection(output);
        }