Ejemplo n.º 1
0
        private void WriteExtensionMethodSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            string            name       = (string)reflection.Evaluate(apiNameExpression);
            XPathNavigator    returnType = reflection.SelectSingleNode(apiReturnTypeExpression);
            XPathNodeIterator parameters = reflection.Select(apiParametersExpression);

            // extract the first parameter as the extension type
            parameters.MoveNext();
            XPathNavigator extendedType     = parameters.Current.SelectSingleNode(parameterTypeExpression);
            string         extendedTypeName = (string)parameters.Current.Evaluate(parameterNameExpression);

            // write the declarations
            ParameterDeclaration(extendedTypeName, extendedType, writer);
            WriteParameterDeclarations(parameters.Clone(), writer);
            if (returnType != null)
            {
                ParameterDeclaration("returnValue", returnType, writer);
            }
            writer.WriteLine();

            // write the method invocation
            if (returnType != null)
            {
                writer.WriteParameter("returnValue");
                writer.WriteString(" = ");
            }
            writer.WriteParameter(extendedTypeName);
            writer.WriteString(".");
            writer.WriteIdentifier(name);
            writer.WriteString("(");
            WriteParameters(parameters.Clone(), writer);
            writer.WriteString(")");
        }
Ejemplo n.º 2
0
        public static string DisplayTitle(XPathNodeIterator bill)
        {
            bill = bill.Clone();
            if (!bill.MoveNext())
            {
                throw new ArgumentException();
            }

            string ret;

            ret = DisplayTitle2(bill.Current, "short");
            if (ret != "")
            {
                return(ret);
            }

            ret = DisplayTitle2(bill.Current, "popular");
            if (ret != "")
            {
                return(ret);
            }

            ret = DisplayTitle2(bill.Current, "official");
            if (ret.EndsWith("."))
            {
                ret = ret.Substring(0, ret.Length - 1);
            }
            if (ret != "")
            {
                return(ret);
            }

            ret = (string)bill.Current.Evaluate("string(titles/title[position()=last()])");
            return(ret);
        }
Ejemplo n.º 3
0
        private static VariableBlock ParseVariableBlock(ref XPathNodeIterator xPathIter)
        {
            VariableBlock variableBlock =
                new VariableBlock();

            System.Globalization.CultureInfo CultureInfo =
                new System.Globalization.CultureInfo(xPathIter.Current.GetAttribute("cultureinfo", xPathIter.Current.NamespaceURI));

            if (xPathIter.Current.MoveToFirstChild())
            {
                XPathNodeIterator xPathIter_V = xPathIter.Clone();

                if (xPathIter_V.Current.MoveToFirstChild())
                {
                    do
                    {
                        variableBlock.Add(
                            xPathIter_V.Current.GetAttribute("key", xPathIter_V.Current.NamespaceURI),
                            Convert.ChangeType(
                                xPathIter_V.Current.Value.ToString(CultureInfo),
                                Service.LoadTypeFromDomain(
                                    AppDomain.CurrentDomain,
                                    xPathIter_V.Current.GetAttribute("type", xPathIter_V.Current.NamespaceURI)
                                    )
                                )
                            );
                    } while (xPathIter_V.Current.MoveToNext());
                }
            }

            return(variableBlock);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// A helper method to retrieve the right Item. If the current item is a variant and
        /// a specific field doesn't exist on the variant, then the parent item is returned.
        /// </summary>
        /// <param name="fieldName">
        /// </param>
        /// <param name="ni">
        /// </param>
        public XPathNodeIterator selectProduct(string fieldName, XPathNodeIterator ni)
        {
            XPathNodeIterator clone = ni.Clone();

            var helper = new Xml.Xsl.XslHelper();

            string fldValue = helper.fld(fieldName, clone);

            if (fldValue.Length > 0)
            {
                return(ni);
            }

            string currentId = clone.Current.GetAttribute("id", string.Empty);

            Item currentItem = Sitecore.Context.Database.GetItem(currentId);

            if (currentItem != null)
            {
                Item parentItem = currentItem.Parent;
                if (parentItem != null &&
                    parentItem.Fields[fieldName] != null)
                {
                    return(helper.item(parentItem.Paths.FullPath, ni));
                }
            }

            return(ni);
        }
Ejemplo n.º 5
0
        void ColumnsAttributes()
        {
            //go to the first row to get info
            XPathNodeIterator temp_xpni = _xpni.Clone();                // temporary iterator for determining columns

            temp_xpni.MoveNext();

            XPathNodeIterator ni = temp_xpni.Current.Select("@*");              // select for attributes

            while (ni.MoveNext())
            {
                _Types.Add(ni.Current.Value.GetType());
                AddName(ni.Current.Name);
                _xcmd.ColumnsXPath.Add("@" + ni.Current.Name);
            }
        }
Ejemplo n.º 6
0
        XPathNodeIterator PositionToTracks()
        {
            //go to the first row to get info
            XPathNodeIterator temp_xpni = _xpni.Clone();        // temporary iterator for determining columns

            temp_xpni.MoveNext();

            XPathNodeIterator ni = temp_xpni.Current.Select("*");

            while (ni.MoveNext())
            {
                if (ni.Current.Name != "key")
                {
                    continue;
                }
                if (ni.Current.Value == "Tracks")
                {
                    ni.MoveNext();
                    if (ni.Current.Name != "dict")  // next item should be "dict"
                    {
                        break;
                    }
                    string            sel = "dict/*";
                    XPathNodeIterator ti  = ni.Current.Select(sel);
                    return(ti);
                }
            }
            return(null);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MergeConfiguration"/> class.
        /// </summary>
        /// <param name="sitecoreConfigurationSwitcher">The Sitecore configuration switcher.</param>
        /// <param name="fileName">The file name.</param>
        /// <param name="xpath">The XPath of the element to merge configuration to.</param>
        public MergeConfiguration(SitecoreConfigurationSwitcher sitecoreConfigurationSwitcher, string fileName, string xpath) : this(sitecoreConfigurationSwitcher)
        {
            const string FileNameDoesNotRepresentAFileMessage = "File name does not represent a file.";

            Assert.ArgumentNotNullOrEmpty(fileName, "fileName");
            Assert.ArgumentNotNullOrEmpty(xpath, "xpath");

            string fileDirectory = Path.GetDirectoryName(fileName);
            string filePattern   = Path.GetFileName(fileName);

            Assert.ArgumentCondition(fileDirectory != null, "fileName", FileNameDoesNotRepresentAFileMessage);
            Assert.ArgumentCondition(!string.IsNullOrEmpty(filePattern), "fileName", FileNameDoesNotRepresentAFileMessage);

            XPathNodeIterator iterator = this.SitecoreConfigurationSwitcher.GetNodeIterator(xpath);
            LinkedList <XPathNodeIterator> elements = new LinkedList <XPathNodeIterator>();

            while (iterator.MoveNext())
            {
                elements.AddLast(iterator.Clone());
            }

            fileDirectory = string.IsNullOrEmpty(fileDirectory) ? "." : fileDirectory;

            foreach (string file in Directory.GetFiles(fileDirectory, filePattern))
            {
                foreach (XPathNodeIterator element in elements)
                {
                    element.MergeContent(file);
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes the reader.
 /// </summary>
 /// <param name="iterator">The iterator to expose as a single reader.</param>
 /// <param name="rootName">The name to use for the enclosing root element.</param>
 /// <param name="ns">The namespace URI of the root element.</param>
 public XPathIteratorReader(XPathNodeIterator iterator, string rootName, string ns)
     : base(new StringReader(String.Empty))
 {
     _iterator = iterator.Clone();
     _current  = new FakedRootReader(rootName, ns, XmlNodeType.Element);
     _rootname = new XmlQualifiedName(rootName, ns);
 }
Ejemplo n.º 9
0
 protected static XPathNodeIterator Clone(XPathNodeIterator input)
 {
     if (input != null)
     {
         return(input.Clone());
     }
     return(null);
 }
Ejemplo n.º 10
0
            public object Invoke(XsltContext ctx, object [] args, XPathNavigator docContext)
            {
                if (args.Length != 0)
                {
                    throw new ArgumentException("Not allowed arguments for function here().", "args");
                }

                return(xpathNode.Clone());
            }
Ejemplo n.º 11
0
            public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
            {
                XsltCompileContext xsltCompileContext = (XsltCompileContext)xsltContext;

                string local, prefix;

                PrefixQName.ParseQualifiedName(ToString(args[0]), out prefix, out local);
                string           ns      = xsltContext.LookupNamespace(prefix);
                XmlQualifiedName keyName = new XmlQualifiedName(local, ns);

                XPathNavigator root = docContext.Clone();

                root.MoveToRoot();

                ArrayList resultCollection = null;

                foreach (Key key in xsltCompileContext.processor.KeyList)
                {
                    if (key.Name == keyName)
                    {
                        Hashtable keyTable = key.GetKeys(root);
                        if (keyTable == null)
                        {
                            keyTable = xsltCompileContext.BuildKeyTable(key, root);
                            key.AddKey(root, keyTable);
                        }

                        XPathNodeIterator it = args[1] as XPathNodeIterator;
                        if (it != null)
                        {
                            it = it.Clone();
                            while (it.MoveNext())
                            {
                                resultCollection = AddToList(resultCollection, (ArrayList)keyTable[it.Current.Value]);
                            }
                        }
                        else
                        {
                            resultCollection = AddToList(resultCollection, (ArrayList)keyTable[ToString(args[1])]);
                        }
                    }
                }
                if (resultCollection == null)
                {
                    return(XPathEmptyIterator.Instance);
                }
                else if (resultCollection[0] is XPathNavigator)
                {
                    return(new XPathArrayIterator(resultCollection));
                }
                else
                {
                    return(new XPathMultyIterator(resultCollection));
                }
            }
        public ICollection <BuildArtifact> getArtifacts(string buildKey)
        {
            string buildUrl = string.Format(getCorrectEnpointOrXPath(ALL_ARTIFACTS, ALL_ARTIFACTS_3_0), buildKey);
            string endpoint = server.Url + buildUrl;

            using (Stream stream = getQueryResultStream(endpoint + getBasicAuthParameter(endpoint), true)) {
                XPathDocument doc = XPathUtils.getXmlDocument(stream);

                string code = getRestErrorStatusCode(doc);
                if (code != null)
                {
                    throw new Exception(code);
                }

                XPathNavigator nav = doc.CreateNavigator();

                List <BuildArtifact> artifacts = new List <BuildArtifact>();

                XPathExpression   expr = nav.Compile("/build/artifacts/artifact");
                XPathNodeIterator it   = nav.Select(expr);

                if (it.MoveNext())
                {
                    artifacts.Add(getArtifact(null, it.Current));
                }

                expr = nav.Compile("/result/artifacts/artifact");
                it   = nav.Select(expr);

                if (it.MoveNext())
                {
                    artifacts.Add(getArtifact(null, it.Current));
                }

                expr = nav.Compile("/result/stages/stage/results/result");
                it   = nav.Select(expr);

                while (it.MoveNext())
                {
                    string            resultKey = XPathUtils.getAttributeSafely(it.Current, "key", null);
                    XPathNodeIterator it2       = it.Clone();
                    XPathExpression   expr3     = it2.Current.Compile("artifacts/artifact");

                    XPathNodeIterator it3 = it2.Current.Select(expr3);

                    while (it3.MoveNext())
                    {
                        artifacts.Add(getArtifact(resultKey, it3.Current));
                    }
                }

                return(artifacts);
            }
        }
Ejemplo n.º 13
0
 public XmlIteratorNodeList(XmlDocument doc, XPathNodeIterator iter)
 {
     if (doc == null)
     {
         throw new Exception("huh?");
     }
     this.doc = doc;
     //doc.NodeRemoving += SaveNodeList;
     source   = iter;
     iterator = iter.Clone();
     list     = new ArrayList();
 }
Ejemplo n.º 14
0
        /// <summary>
        /// InsureFontNameAttributes
        /// </summary>
        /// <param name="xpIterator"></param>
        /// <param name="xpe"></param>
        /// <param name="strNewFontName"></param>
        /// <param name="bCreateIfNotPresent">indicates whether to create the attribute/element if it doesn't already exist</param>
        /// <returns>true if the attribute was already present; false if not (whether it was created or not)</returns>
        protected bool InsureFontNameAttributes(XPathNodeIterator xpIterator, XPathExpression xpe,
                                                string strNewFontName, bool bCreateIfNotPresent)
        {
            XPathNodeIterator xpIteratorAttrib = xpIterator.Current.Select(xpe);

            if (xpIteratorAttrib.MoveNext())
            {
                xpIteratorAttrib.Current.SetValue(strNewFontName);
                return(true);
            }
            else if (bCreateIfNotPresent)
            {
                xpIteratorAttrib = xpIterator.Clone();
                string strExpr = xpe.Expression;

                // this code only handles expressions of the form "w:x/y:z" so there should be 4 "parts")
                string[] astrSplit = strExpr.Split(new char[] { '/', ':', '@' }, StringSplitOptions.RemoveEmptyEntries);
                System.Diagnostics.Debug.Assert(astrSplit.Length == 6);

                string strChildElementPrefix = astrSplit[0];
                string strNameSpace          = m_mapPrefix2NamespaceURI[strChildElementPrefix];
                string strChildElementName   = astrSplit[1];
                int    nOffset = 0;
                if (astrSplit.Length == 6)
                {
                    if (!xpIteratorAttrib.Current.MoveToChild(strChildElementName, strNameSpace))
                    {
                        xpIteratorAttrib.Current.PrependChildElement(strChildElementPrefix, strChildElementName, strNameSpace, null);
                        bool bMoveRes = xpIteratorAttrib.Current.MoveToChild(strChildElementName, strNameSpace);
                        System.Diagnostics.Debug.Assert(bMoveRes);
                    }
                    nOffset = 2;
                }

                strChildElementPrefix = astrSplit[0 + nOffset];
                strNameSpace          = m_mapPrefix2NamespaceURI[strChildElementPrefix];
                strChildElementName   = astrSplit[1 + nOffset];
                string strAttribPrefix = astrSplit[2 + nOffset];
                string strAttribName   = astrSplit[3 + nOffset];

                if (!xpIteratorAttrib.Current.MoveToChild(strChildElementName, strNameSpace))
                {
                    xpIteratorAttrib.Current.PrependChildElement(strChildElementPrefix, strChildElementName, strNameSpace, null);
                    bool bMoveRes = xpIteratorAttrib.Current.MoveToChild(strChildElementName, strNameSpace);
                    System.Diagnostics.Debug.Assert(bMoveRes);
                }

                xpIteratorAttrib.Current.CreateAttribute(strAttribPrefix, strAttribName, strNameSpace, strNewFontName);
            }

            return(false);
        }
        public virtual XPathNodeIterator SortListField(
            string listField,
            string sortField,
            XPathNodeIterator ni,
            bool reverse)
        {
            Sitecore.Xml.Packet packet   = new Sitecore.Xml.Packet("values");
            XPathNodeIterator   iterator = ni.Clone();

            if (iterator.MoveNext())
            {
                Sitecore.Data.Items.Item item = GetItem(iterator);

                if (item != null)
                {
                    Sitecore.Data.Fields.MultilistField fieldList = item.Fields[listField];

                    if (fieldList != null)
                    {
                        List <Item> itemList = new List <Item>();

                        foreach (Sitecore.Data.Items.Item pointer in fieldList.GetItems())
                        {
                            if (pointer != null)
                            {
                                itemList.Add(pointer);
                            }
                        }

                        Item[] items = itemList.ToArray();
                        Array.Sort(items, new FieldValueComparer(sortField));

                        if (reverse)
                        {
                            Array.Reverse(items);
                        }

                        foreach (Sitecore.Data.Items.Item reference in items)
                        {
                            packet.AddElement("value", reference.ID.ToString());
                        }
                    }
                }
            }

            XPathNavigator navigator = packet.XmlDocument.CreateNavigator()
                                       ?? new XmlDocument().CreateNavigator();

            navigator.MoveToRoot();
            navigator.MoveToFirstChild();
            return(navigator.SelectChildren(XPathNodeType.Element));
        }
        /// <summary>
        /// Returns BranchID attribute value at LearningResource/PackageDescription/General/LearningResourceData/ID
        /// </summary>
        /// <param name="indexXmlNavigator">XPathNavigator for index xml document</param>
        /// <returns>BranchID as Guid</returns>
        public static Guid ParseIndexXml(XPathNavigator indexXmlNavigator)
        {
            Guid identifier                = System.Guid.Empty;
            XPathNodeIterator allNodes     = indexXmlNavigator.Select("//*");
            XPathNodeIterator allNodesCopy = allNodes.Clone();

            while (allNodes.MoveNext())
            {
                if (allNodes.Current.Name == "LearningResource")
                {
                    indexXmlNavigator.MoveTo(allNodes.Current);
                    break;
                }
            }
            string nameSpace = indexXmlNavigator.NamespaceURI;
            XmlNamespaceManager nsManager = new XmlNamespaceManager(indexXmlNavigator.NameTable);

            //assigning a dummy prefix aa to force XPath query to use learning resources namespace
            nsManager.AddNamespace("aa", nameSpace);
            XPathNavigator idNode           = indexXmlNavigator.SelectSingleNode("//aa:LearningResource/aa:PackageDescription/aa:General/aa:LearningResourceData/aa:ID", nsManager);
            string         identifierString = String.Empty;

            if (idNode != null)
            {
                identifierString = idNode.GetAttribute("BranchID", "");
            }
            else
            {
                //loop through all nodes, looking for any ID node having LearningResourceData parent
                while (allNodesCopy.MoveNext())
                {
                    if (allNodesCopy.Current.LocalName == "ID")
                    {
                        indexXmlNavigator.MoveTo(allNodesCopy.Current);
                        indexXmlNavigator.MoveToParent();
                        if (indexXmlNavigator.LocalName == "LearningResourceData")
                        {
                            //thats the right identity node
                            identifierString = allNodesCopy.Current.GetAttribute("BranchID", "");
                        }
                        break;
                    }
                }
            }
            if (identifierString != String.Empty)
            {
                identifier = FormatGuid(identifierString);
            }
            return(identifier);
        }
Ejemplo n.º 17
0
 // Create a new node list.
 public SelectNodeList(XPathNodeIterator iterator)
 {
     if (iterator != null)
     {
         this.iterator = iterator.Clone();
         this.current  = iterator.Clone();
         finished      = false;
     }
     else
     {
         finished = true;
     }
     cached = new ArrayList();
 }
Ejemplo n.º 18
0
        private static IEnumerable <IPublishedContent> GetByXPath(XPathNodeIterator iterator)
        {
            iterator = iterator.Clone();
            while (iterator.MoveNext())
            {
                var xnav     = iterator.Current as NavigableNavigator;
                var xcontent = xnav?.UnderlyingObject as NavigableContent;
                if (xcontent == null)
                {
                    continue;
                }

                yield return(xcontent.InnerContent);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Get component position and other values.
        /// </summary>
        /// <param name="name"></param>
        public static void GetSetting(List <Setting> list, XPathHandler handler,
                                      IComponentSetting setting, string name, string type)
        {
            Setting settingName = new Setting(1, "Name", name);

            list.Add(settingName);

            string relPath = "";

            switch (type)
            {
            case "form":
                relPath = "GUI/Forms/";
                break;

            case "toolbar":
                relPath = "GUI/Toolbars/";
                break;

            case "statusbar":
                relPath = "GUI/Statusbars/";
                break;

            case "column":
                relPath = "GUI/MainWindow/Columns/";
                break;
            }

            string path = "/configuration/" + relPath + type +
                          @"[@name=""$name""]/*".Replace("$name", name);
            XPathNodeIterator iterator = handler.GetComponentSettings(path);

            switch (type)
            {
            case "form":
                SetFormValues((FormSetting)setting, iterator.Clone());
                SetPositionValues((FormSetting)setting, iterator.Clone());
                break;

            case "toolbar":
                SetPositionValues((ToolbarSetting)setting, iterator.Clone());
                SetVisibleValue((ToolbarSetting)setting, iterator.Clone());
                break;

            case "statusbar":
                SetVisibleValue((StatusbarSetting)setting, iterator.Clone());
                break;

            case "column":
                SetColumnValues((ColumnSetting)setting, iterator.Clone());
                break;

            default:
                break;
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Initializes the ExsltNodeList with the specified XPathNodeIterator. All nodes
        /// in the iterator are placed in the list.
        /// </summary>
        /// <param name="iterator">The iterator to load the nodelist from</param>
        /// <param name="removeDuplicates">A flag that indicates whether duplicate nodes
        /// should be loaded into the nodelist or only node with unique identity should
        /// be added</param>
        public ExsltNodeList(XPathNodeIterator iterator, bool removeDuplicates)
        {
            XPathNodeIterator it = iterator.Clone();

            while (it.MoveNext())
            {
                if (removeDuplicates)
                {
                    if (this.Contains(it.Current))
                    {
                        continue;
                    }
                }

                this.Add(it.Current.Clone());
            }
        }
Ejemplo n.º 21
0
        public void TraverseSiblings(XPathNodeIterator nodeItor)
        {
            XPathNodeIterator igor = nodeItor.Clone();

            igor.Current.MoveToNext();
            bool more = false;

            do
            {
                Champ champ = new Champ();
                champ.NomChamp = igor.Current.Name;

                TraverseChildren(igor, champ);
                more = igor.Current.MoveToNext();

                listChamp.Add(champ);
            } while (more);
        }
Ejemplo n.º 22
0
        public static string DisplayNumber(XPathNodeIterator bill)
        {
            bill = bill.Clone();
            if (!bill.MoveNext())
            {
                throw new ArgumentException();
            }
            int    session = int.Parse((string)bill.Current.Evaluate("string(@session)"));
            string type    = (string)bill.Current.Evaluate("string(@type)");
            string number  = (string)bill.Current.Evaluate("string(@number)");
            string ret     = BillTypeToDisplayString(type) + " " + number;

            if (session != Util.CurrentSession)
            {
                ret += " [" + Util.Ordinate(session) + "]";
            }
            return(ret);
        }
        public XPathNavigatorIterator(XPathNodeIterator iterator, bool removeDuplicates)
            : this()
        {
            var it = iterator.Clone();

            while (it.MoveNext())
            {
                if (removeDuplicates)
                {
                    if (Contains(it.Current))
                    {
                        continue;
                    }
                }

                Add(it.Current.Clone());
            }
        }
Ejemplo n.º 24
0
        public void TraverseChildren(XPathNodeIterator nodeItor, Champ champ)
        {
            XPathNodeIterator igor = nodeItor.Clone();

            igor.Current.MoveToFirstChild();
            bool more = false;

            do
            {
                if (igor.Current.Name.Equals("DEBUT"))
                {
                    champ.Position_deb = int.Parse(igor.Current.Value);
                }
                else
                {
                    champ.Position_fin = int.Parse(igor.Current.Value);
                }
                more = igor.Current.MoveToNext();
            } while (more);
        }
Ejemplo n.º 25
0
        public static string XMLReportQuery(string className, string ApplicationPath)
        {
            string PathFile   = string.Empty;
            string NameOfFile = string.Empty;
            string strXML     = string.Empty;
            string lClassName = "ClassName";

            System.Configuration.AppSettingsReader appconfig = new System.Configuration.AppSettingsReader();
            NameOfFile = appconfig.GetValue("ConfigurationOfReports", typeof(string)) as string;

            PathFile = Path.GetFullPath(NameOfFile);
            if (!File.Exists(PathFile))
            {
                if (!File.Exists(PathFile))
                {
                    throw (new ArgumentException("File not found: " + PathFile));
                }
            }

            XmlDocument lxmlDoc = new XmlDocument();

            lxmlDoc.Load(PathFile);

            //Open the document and associate a navigator.
            XPathNavigator navXPath = lxmlDoc.CreateNavigator();

            string xpathQuery;             //@"XMLReportQuery/@Name[text() = '" +XMLReportQueryName + "']";

            //Select nodes with the same class name.
            xpathQuery = @"/XMLReportsQuery/XMLReportQuery[@" + lClassName + " = '" + className.Trim() + "']";

            XPathExpression expXPath = navXPath.Compile(xpathQuery);

            //Order the reports by the type of report.
            expXPath.AddSort("@Type", XmlSortOrder.Ascending, XmlCaseOrder.None, string.Empty, XmlDataType.Text);
            XPathNodeIterator itNodes = navXPath.Select(expXPath);

            return(XMLReportsQueryHandler.GetOutXML(itNodes.Clone()));
        }
        /// <summary>
        /// Returns "identifier" attribute value of the /manifest node
        /// or if its not found, looks for value in metadata/lom/general/identifier
        /// </summary>
        /// <param name="manifestNavigator">XPathNavigator for imsmanifest document</param>
        /// <returns>identifier value as Guid</returns>
        public static Guid ParseImsManifestXml(XPathNavigator manifestNavigator)
        {
            Guid identifier                = System.Guid.Empty;
            XPathNodeIterator allNodes     = manifestNavigator.Select("//*");
            XPathNodeIterator allNodesCopy = allNodes.Clone();

            while (allNodes.MoveNext())
            {
                if (allNodes.Current.Name == "manifest")
                {
                    string identifierString = allNodes.Current.GetAttribute("identifier", "");
                    if (identifierString != String.Empty)
                    {
                        identifier = FormatGuid(identifierString);
                    }
                    break;
                }
            }
            if (identifier == System.Guid.Empty)
            {
                while (allNodesCopy.MoveNext())
                {
                    if (allNodesCopy.Current.LocalName == "identifier")
                    {
                        manifestNavigator.MoveTo(allNodesCopy.Current);
                        manifestNavigator.MoveToParent();
                        if (manifestNavigator.LocalName == "general")
                        {
                            //thats the right identity node
                            identifier = FormatGuid(allNodesCopy.Current.Value);
                        }
                        break;
                    }
                }
            }
            return(identifier);
        }
Ejemplo n.º 27
0
 public List(XPathNodeIterator iterator, XmlNamespaceManager namespaceManager)
 {
     _currentIterator  = iterator;
     _iterator         = iterator.Clone();
     _namespaceManager = namespaceManager;
 }
Ejemplo n.º 28
0
        public override void WritePropertySyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            string            name         = (string)reflection.Evaluate(apiNameExpression);
            string            typeSubgroup = (string)reflection.Evaluate(apiContainingTypeSubgroupExpression);
            bool              isDefault    = (bool)reflection.Evaluate(apiIsDefaultMemberExpression);
            bool              hasGetter    = (bool)reflection.Evaluate(apiIsReadPropertyExpression);
            bool              hasSetter    = (bool)reflection.Evaluate(apiIsWritePropertyExpression);
            bool              isExplicit   = (bool)reflection.Evaluate(apiIsExplicitImplementationExpression);
            XPathNodeIterator parameters   = reflection.Select(apiParametersExpression);

            WriteAttributes(reflection, writer);
            WriteProcedureVisibility(reflection, writer);
            WritePrefixProcedureModifiers(reflection, writer);
            writer.WriteKeyword("property");
            writer.WriteString(" ");
            WriteReturnValue(reflection, writer);
            writer.WriteString(" ");

            // if is default member, write default, otherwise write name
            if (isDefault)
            {
                writer.WriteKeyword("default");
            }
            else
            {
                writer.WriteIdentifier(name);
            }

            if (parameters.Count > 0)
            {
                writer.WriteString("[");
                WriteParameters(parameters.Clone(), false, writer);
                writer.WriteString("]");
            }

            writer.WriteString(" {");
            writer.WriteLine();

            if (hasGetter)
            {
                writer.WriteString("\t");

                //write the get visibility
                string getVisibility = (string)reflection.Evaluate(apiGetVisibilityExpression);
                if (!String.IsNullOrEmpty(getVisibility))
                {
                    WriteVisibility(getVisibility, writer);
                    writer.WriteString(":");
                    writer.WriteString(" ");
                }

                WriteReturnValue(reflection, writer);
                writer.WriteString(" ");
                writer.WriteKeyword("get");
                writer.WriteString(" ");

                writer.WriteString("(");
                WriteParameters(parameters.Clone(), false, writer);
                writer.WriteString(")");

                WritePostfixProcedureModifiers(reflection, writer);
                if (isExplicit)
                {
                    XPathNavigator implement = reflection.SelectSingleNode(apiImplementedMembersExpression);
                    XPathNavigator contract  = implement.SelectSingleNode(memberDeclaringTypeExpression);
                    //string id = (string) implement.GetAttribute("api", String.Empty);

                    writer.WriteString(" = ");
                    WriteTypeReference(contract, false, writer);
                    writer.WriteString("::");
                    WriteMemberReference(implement, writer);
                    //writer.WriteReferenceLink(id);
                    writer.WriteString("::");
                    writer.WriteKeyword("get");
                }
                writer.WriteString(";");
                writer.WriteLine();
            }

            if (hasSetter)
            {
                writer.WriteString("\t");

                // write the set visibility
                string setVisibility = (string)reflection.Evaluate(apiSetVisibilityExpression);
                if (!String.IsNullOrEmpty(setVisibility))
                {
                    WriteVisibility(setVisibility, writer);
                    writer.WriteString(":");
                    writer.WriteString(" ");
                }

                writer.WriteKeyword("void");
                writer.WriteString(" ");
                writer.WriteKeyword("set");
                writer.WriteString(" ");

                writer.WriteString("(");
                if (parameters.Count > 0)
                {
                    WriteParameters(parameters.Clone(), false, writer);
                    writer.WriteString(", ");
                }
                WriteReturnValue(reflection, writer);
                writer.WriteString(" ");
                writer.WriteParameter("value");
                writer.WriteString(")");

                WritePostfixProcedureModifiers(reflection, writer);
                if (isExplicit)
                {
                    XPathNavigator implement = reflection.SelectSingleNode(apiImplementedMembersExpression);
                    XPathNavigator contract  = implement.SelectSingleNode(memberDeclaringTypeExpression);
                    //string id = (string) implement.GetAttribute("api", String.Empty);

                    writer.WriteString(" = ");
                    WriteTypeReference(contract, false, writer);
                    writer.WriteString("::");
                    WriteMemberReference(implement, writer);
                    //writer.WriteReferenceLink(id);
                    writer.WriteString("::");
                    writer.WriteKeyword("set");
                }
                writer.WriteString(";");
                writer.WriteLine();
            }


            writer.WriteString("}");
        }
Ejemplo n.º 29
0
        public bool Read()
        {
            if (_xpni == null)
            {
                return(false);
            }

            XPathNodeIterator ti = _xpni;

            Hashtable ht = new Hashtable(_Names.Length);

            // clear out previous values;  previous row might have values this row doesn't
            for (int i = 0; i < _Data.Length; i++)
            {
                _Data[i] = null;
            }

            XPathNodeIterator save_ti = ti.Clone();
            bool rc = false;

            while (ti.MoveNext())
            {
                if (ti.Current.Name != "key")
                {
                    continue;
                }
                string name = ti.Current.Value.Replace(' ', '_');
                // we only know we're on the next row when a column repeats
                if (ht.Contains(name))
                {
                    break;
                }
                ht.Add(name, name);

                int ix;
                try
                {
                    ix = this.GetOrdinal(name);
                    rc = true; // we know we got at least one column value
                }
                catch          // this isn't a know column; skip it
                {
                    ti.MoveNext();
                    save_ti = ti.Clone();
                    continue;                   // but keep trying
                }


                ti.MoveNext();
                save_ti = ti.Clone();
                try
                {
                    switch (ti.Current.Name)
                    {
                    case "integer":
                        if (_Names[ix] == "Play_Date")      // will overflow a long
                        {
                            _Data[ix] = ti.Current.ValueAsLong;
                        }
                        else
                        {
                            _Data[ix] = ti.Current.ValueAsInt;
                        }
                        break;

                    case "string":
                        _Data[ix] = ti.Current.Value;
                        break;

                    case "real":
                        _Data[ix] = ti.Current.ValueAsDouble;
                        break;

                    case "true":
                        _Data[ix] = true;
                        break;

                    case "false":
                        _Data[ix] = false;
                        break;

                    case "date":
                        _Data[ix] = ti.Current.ValueAsDateTime;
                        break;

                    default:
                        _Data[ix] = ti.Current.Value;
                        break;
                    }
                }
                catch { _Data[ix] = null; }
            }

            _xpni = save_ti;
            return(rc);
        }
Ejemplo n.º 30
0
 public XmlNodeListIterator(XPathNodeIterator iterator)
 {
     _iterator = iterator.Clone();
 }