MoveToChild() public method

public MoveToChild ( XPathNodeType type ) : bool
type XPathNodeType
return bool
Exemplo n.º 1
0
        public CreateCone(System.Xml.XPath.XPathNavigator navigator, GEMSSingle parent)
            : base(navigator, parent)
        {
            alineAxis = (Axis)Enum.Parse(typeof(Axis), navigator.GetAttribute("axis", string.Empty));

            //Bottom radius of cylinder
            navigator.MoveToChild("BottomRadius", string.Empty);
            bottomRadius = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent( );

            //Top radius of cylinder
            navigator.MoveToChild("TopRadius", string.Empty);
            topRadius = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent( );

            //Height of cylinder
            navigator.MoveToChild("Height", string.Empty);
            height = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent( );

            //Center of cylinder
            navigator.MoveToChild("Center", string.Empty);
            center   = new Vector3WithUnit( );
            center.X = new Length(navigator.GetAttribute("x", string.Empty), navigator.GetAttribute("ux", string.Empty));
            center.Y = new Length(navigator.GetAttribute("y", string.Empty), navigator.GetAttribute("uy", string.Empty));
            center.Z = new Length(navigator.GetAttribute("z", string.Empty), navigator.GetAttribute("uz", string.Empty));
            navigator.MoveToParent( );
        }
Exemplo n.º 2
0
        public CreateCuboid(System.Xml.XPath.XPathNavigator navigator, GEMSSingle parent)
            : base(navigator, parent)
        {
            //Width of box
            navigator.MoveToChild("Width", string.Empty);
            width = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent();

            //Depth of box
            navigator.MoveToChild("Depth", string.Empty);
            depth = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent();

            //Height of box
            navigator.MoveToChild("Height", string.Empty);
            height = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent();

            //Reference point of box
            navigator.MoveToChild("RefPoint", string.Empty);
            refPoint   = new Vector3WithUnit();
            refPoint.X = new Length(navigator.GetAttribute("x", string.Empty), navigator.GetAttribute("ux", string.Empty));
            refPoint.Y = new Length(navigator.GetAttribute("y", string.Empty), navigator.GetAttribute("uy", string.Empty));
            refPoint.Z = new Length(navigator.GetAttribute("z", string.Empty), navigator.GetAttribute("uz", string.Empty));
            navigator.MoveToParent();
        }
Exemplo n.º 3
0
        public CreateSphere(System.Xml.XPath.XPathNavigator navigator, GEMSSingle parent)
            : base(navigator, parent)
        {
            //Radius of sphere
            navigator.MoveToChild("Radius", string.Empty);
            radius = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent();

            //Center of sphere
            navigator.MoveToChild("Center", string.Empty);
            center   = new Vector3WithUnit();
            center.X = new Length(navigator.GetAttribute("x", string.Empty), navigator.GetAttribute("ux", string.Empty));
            center.Y = new Length(navigator.GetAttribute("y", string.Empty), navigator.GetAttribute("uy", string.Empty));
            center.Z = new Length(navigator.GetAttribute("z", string.Empty), navigator.GetAttribute("uz", string.Empty));
            navigator.MoveToParent();
        }
        private static bool ProcessItemGroupNode(XPathNavigator nav)
        {
            try
            {
                if (nav.MoveToChild("StyleCopTreatErrorsAsWarnings", "http://schemas.microsoft.com/developer/msbuild/2003"))
                {
                    if (nav.Value == "false")
                    {
                        nav.ReplaceSelf("<StyleCopTreatErrorsAsWarnings>true</StyleCopTreatErrorsAsWarnings>");
                    }
                    else
                    {
                        nav.ReplaceSelf("<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>");
                    }
                }
                else
                {
                    nav.AppendChild("<StyleCopTreatErrorsAsWarnings>true</StyleCopTreatErrorsAsWarnings>");
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
Exemplo n.º 5
0
 XPathNavigator GetAssemblyIdentityNav(XPathNavigator nav)
 {
     do
     {
         if (Utilities.Compare(nav.LocalName, "assemblyIdentity"))
             return nav;
     } while (nav.MoveToChild(XPathNodeType.Element));
     return null;
 }
Exemplo n.º 6
0
        public CreateRound(System.Xml.XPath.XPathNavigator navigator, GEMSSingle parent)
            : base(navigator, parent)
        {
            alineAxis = (Axis)Enum.Parse(typeof(Axis), navigator.GetAttribute("axis", string.Empty));

            //Radius of circle
            navigator.MoveToChild("Radius", string.Empty);
            radius = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent();

            //Center of circle
            navigator.MoveToChild("Center", string.Empty);
            center   = new Vector3WithUnit();
            center.X = new Length(navigator.GetAttribute("x", string.Empty), navigator.GetAttribute("ux", string.Empty));
            center.Y = new Length(navigator.GetAttribute("y", string.Empty), navigator.GetAttribute("uy", string.Empty));
            center.Z = new Length(navigator.GetAttribute("z", string.Empty), navigator.GetAttribute("uz", string.Empty));
            navigator.MoveToParent();
        }
Exemplo n.º 7
0
 private string GetChildNodesValue(XPathNavigator nav, string nodeName)
 {
     string value = string.Empty;
     if (nav.MoveToChild(nodeName, ""))
     {
         value = nav.Value;
         nav.MoveToParent();
     }
     return value;
 }
Exemplo n.º 8
0
      public void ReadXml(XPathNavigator node, XmlResolver resolver) {

         if (node.NodeType == XPathNodeType.Element) {

            if (node.MoveToFirstAttribute()) {
               do {
                  switch (node.LocalName) {
                     case "media-type":
                        this.MediaType = node.Value;
                        break;

                     case "boundary":
                        this.Boundary = node.Value;
                        break;
                  }
               } while (node.MoveToNextAttribute());

               node.MoveToParent();
            }

            if (node.MoveToChild(XPathNodeType.Element)) {

               XPathHttpMultipartItem currentItem = null;

               do {
                  if (node.NamespaceURI == XPathHttpClient.Namespace) {

                     switch (node.LocalName) {
                        case "header":
                           if (currentItem == null)
                              currentItem = new XPathHttpMultipartItem();

                           currentItem.Headers.Add(node.GetAttribute("name", ""), node.GetAttribute("value", ""));
                           break;

                        case "body":
                           if (currentItem == null)
                              currentItem = new XPathHttpMultipartItem();

                           currentItem.Body = new XPathHttpBody();
                           currentItem.Body.ReadXml(node, resolver);

                           this.Items.Add(currentItem);
                           currentItem = null;
                           break;
                     }
                  }

               } while (node.MoveToNext(XPathNodeType.Element));
               
               node.MoveToParent();
            }
         }
      }
Exemplo n.º 9
0
 public CreatePoint(System.Xml.XPath.XPathNavigator navigator, GEMSSingle parent)
     : base(navigator, parent)
 {
     //Position of Point
     navigator.MoveToChild("Position", string.Empty);
     position   = new Vector3WithUnit();
     position.X = new Length(navigator.GetAttribute("x", string.Empty), navigator.GetAttribute("ux", string.Empty));
     position.Y = new Length(navigator.GetAttribute("y", string.Empty), navigator.GetAttribute("uy", string.Empty));
     position.Z = new Length(navigator.GetAttribute("z", string.Empty), navigator.GetAttribute("uz", string.Empty));
     navigator.MoveToParent();
 }
        private bool CopyToUnsetValues(XPathNavigator sourceNavigator, RunSettings targetRunSettings)
        {
            if (sourceNavigator.MoveToChild(GoogleTestConstants.SettingsName, ""))
            {
                RunSettings sourceRunSettings = RunSettings.LoadFromXml(sourceNavigator.ReadSubtree());
                targetRunSettings.GetUnsetValuesFrom(sourceRunSettings);

                return true;
            }

            return false;
        }
Exemplo n.º 11
0
        public CreateRectangle(System.Xml.XPath.XPathNavigator navigator, GEMSSingle parent)
            : base(navigator, parent)
        {
            alineAxis = (Axis)Enum.Parse(typeof(Axis), navigator.GetAttribute("axis", string.Empty));

            //Width of rectangle
            navigator.MoveToChild("Width", string.Empty);
            width = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent();

            //Height of rectangle
            navigator.MoveToChild("Height", string.Empty);
            height = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent();

            //Reference point of rectangle
            navigator.MoveToChild("RefPoint", string.Empty);
            refPoint   = new Vector3WithUnit();
            refPoint.X = new Length(navigator.GetAttribute("x", string.Empty), navigator.GetAttribute("ux", string.Empty));
            refPoint.Y = new Length(navigator.GetAttribute("y", string.Empty), navigator.GetAttribute("uy", string.Empty));
            refPoint.Z = new Length(navigator.GetAttribute("z", string.Empty), navigator.GetAttribute("uz", string.Empty));
            navigator.MoveToParent();
        }
Exemplo n.º 12
0
        public CreateLine(System.Xml.XPath.XPathNavigator navigator, GEMSSingle parent)
            : base(navigator, parent)
        {
            navigator.MoveToChild("Positions", string.Empty);
            navigator.MoveToFirstChild();

            //Start Point of line
            startPoint   = new Vector3WithUnit();
            startPoint.X = new Length(navigator.GetAttribute("x", string.Empty), navigator.GetAttribute("ux", string.Empty));
            startPoint.Y = new Length(navigator.GetAttribute("y", string.Empty), navigator.GetAttribute("uy", string.Empty));
            startPoint.Z = new Length(navigator.GetAttribute("z", string.Empty), navigator.GetAttribute("uz", string.Empty));


            //End Point of line
            navigator.MoveToNext();
            endPoint   = new Vector3WithUnit();
            endPoint.X = new Length(navigator.GetAttribute("x", string.Empty), navigator.GetAttribute("ux", string.Empty));
            endPoint.Y = new Length(navigator.GetAttribute("y", string.Empty), navigator.GetAttribute("uy", string.Empty));
            endPoint.Z = new Length(navigator.GetAttribute("z", string.Empty), navigator.GetAttribute("uz", string.Empty));

            navigator.MoveToParent();
            navigator.MoveToParent();
        }
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the
        /// build process.
        /// </summary>
        /// <param name="buildProcess">A reference to the current build
        /// process.</param>
        /// <param name="configuration">The configuration data that the plug-in
        /// should use to initialize itself.</param>
        public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
        {
            builder = buildProcess;

            builder.ReportProgress("{0} Version {1}\r\n{2}\r\n    This build will only include " +
                "additional content items.", this.Name, this.Version, this.Copyright);

            if(!builder.CurrentProject.HasItems(BuildAction.ContentLayout) &&
              !builder.CurrentProject.HasItems(BuildAction.SiteMap) &&
              !builder.CurrentProject.HasItems(BuildAction.Content))
                throw new BuilderException("ACP0001", "The Additional Content " +
                    "Only plug-in requires a conceptual content layout file, " +
                    "a site map file, or content items in the project.");

            // If doing a preview for conceptual content, suppress all the
            // steps that actually build the help file too.
            configuration.MoveToChild(XPathNodeType.All);

            if(configuration.GetAttribute("previewBuild", String.Empty) == "true")
            {
                isPreviewBuild = true;

                this.ExecutionPoints.AddRange(new [] {
                    new ExecutionPoint(BuildStep.GenerateIntermediateTableOfContents, ExecutionBehaviors.InsteadOf),
                    new ExecutionPoint(BuildStep.CombiningIntermediateTocFiles, ExecutionBehaviors.InsteadOf),
                    new ExecutionPoint(BuildStep.ExtractingHtmlInfo, ExecutionBehaviors.InsteadOf),
                    new ExecutionPoint(BuildStep.GenerateHelpFormatTableOfContents, ExecutionBehaviors.InsteadOf),
                    new ExecutionPoint(BuildStep.GenerateHelpFileIndex,  ExecutionBehaviors.InsteadOf),
                    new ExecutionPoint(BuildStep.GenerateHelpProject, ExecutionBehaviors.InsteadOf),
                    new ExecutionPoint(BuildStep.CompilingHelpFile, ExecutionBehaviors.InsteadOf),
                    new ExecutionPoint(BuildStep.GenerateFullTextIndex, ExecutionBehaviors.InsteadOf),
                    new ExecutionPoint(BuildStep.CopyingWebsiteFiles, ExecutionBehaviors.InsteadOf) });
            }
        }
Exemplo n.º 14
0
		public string CreateNamespace(string prefix, string namespaceUri, XPathNavigator source)
		{
			if (string.IsNullOrEmpty(namespaceUri) == false)
			{
				source = source.Clone();
				source.MoveToRoot();
				source.MoveToChild(XPathNodeType.Element);

				if (string.IsNullOrEmpty(prefix))
					prefix = AddNamespace(namespaceUri);

				var existing = source.GetNamespace(prefix);
				if (existing == namespaceUri) return prefix;
				if (string.IsNullOrEmpty(existing) == false) return null;

				source.CreateAttribute("xmlns", prefix, "", namespaceUri);
			}
			return prefix;
		}
Exemplo n.º 15
0
		private static bool MoveOffRoot(XPathNavigator source, XPathNodeType to)
		{
			if (source.NodeType == XPathNodeType.Root)
			{
				return source.MoveToChild(to);
			}
			return true;
		}
Exemplo n.º 16
0
        private IEnumerable<XPathNavigator> FindNodes(
            XPathNavigator doc,
            string name)
        {
            List<XPathNavigator> nodes = new List<XPathNavigator>();

            if (doc.Name == name) {
                nodes.Add(doc.Clone());
            }

            if (doc.HasChildren) {
                doc.MoveToChild(XPathNodeType.All);
                do {
                    XPathNavigator child = doc.Clone();
                    nodes.AddRange(this.FindNodes(child, name));
                } while (doc.MoveToNext());
            }

            return nodes;
        }
 public void Execute(XmlDocument doc)
 {
     _navigator = doc.CreateNavigator();
     _navigator.MoveToChild(XPathNodeType.Element);
     ExecuteElement(CurrentElement);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Reposition the navigator on the first element child with a matching name.
 /// </summary>
 public override bool MoveToContent(XPathNavigator navigator) {
     return navigator.MoveToChild(this.localName, this.namespaceUri);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Reposition the navigator on the first child with a matching type.
 /// </summary>
 public override bool MoveToContent(XPathNavigator navigator) {
     return navigator.MoveToChild(this.nodeType);
 }
Exemplo n.º 20
0
        public void ReadXml(XPathNavigator node)
        {
            bool movedToDocEl = false;

             if (node.NodeType == XPathNodeType.Root) {
            movedToDocEl = node.MoveToChild(XPathNodeType.Element);
             }

             if (node.NamespaceURI == XPathHttpClient.Namespace
            && node.LocalName == "request") {

            if (node.NodeType == XPathNodeType.Element) {

               if (node.MoveToFirstAttribute()) {

                  do {
                     switch (node.LocalName) {
                        case "method":
                           this.Method = node.Value;
                           break;

                        case "href":
                           this.Href = new Uri(node.Value, UriKind.Absolute);
                           break;

                        case "status-only":
                           this.StatusOnly = node.ValueAsBoolean;
                           break;

                        case "username":
                           this.Username = node.Value;
                           break;

                        case "password":
                           this.Password = node.Value;
                           break;

                        case "auth-method":
                           this.AuthMethod = node.Value;
                           break;

                        case "send-authorization":
                           this.SendAuthorization = node.ValueAsBoolean;
                           break;

                        case "override-media-type":
                           this.OverrideMediaType = node.Value;
                           break;

                        case "follow-redirect":
                           this.FollowRedirect = node.ValueAsBoolean;
                           break;

                        case "timeout":
                           this.Timeout = node.ValueAsInt;
                           break;

                        default:
                           break;
                     }

                  } while (node.MoveToNextAttribute());

                  node.MoveToParent();
               }

               if (node.MoveToChild(XPathNodeType.Element)) {
                  do {
                     if (node.NamespaceURI == XPathHttpClient.Namespace) {
                        switch (node.LocalName) {
                           case "header":
                              this.Headers.Add(node.GetAttribute("name", ""), node.GetAttribute("value", ""));
                              break;

                           case "body":
                              this.Body = new XPathHttpBody();
                              this.Body.ReadXml(node, this.Resolver);
                              break;

                           case "multipart":
                              this.Multipart = new XPathHttpMultipart();
                              this.Multipart.ReadXml(node, this.Resolver);
                              break;

                           default:
                              break;
                        }
                     }
                  } while (node.MoveToNext(XPathNodeType.Element));

                  node.MoveToParent();
               }
            }
             }

             if (movedToDocEl) {
            node.MoveToParent();
             }
        }
Exemplo n.º 21
0
      public void ReadXml(XPathNavigator node) {

         bool movedToDocEl = false;

         if (node.NodeType == XPathNodeType.Root)
            movedToDocEl = node.MoveToChild(XPathNodeType.Element);

         if (node.NamespaceURI == XPathSmtpClient.Namespace
            && node.LocalName == "message") {

            if (node.MoveToFirstAttribute()) {

               do {
                  if (String.IsNullOrEmpty(node.NamespaceURI)) {

                  }
               } while (node.MoveToNextAttribute());

               node.MoveToParent();
            }

            if (node.MoveToChild(XPathNodeType.Element)) {

               do {
                  if (node.NamespaceURI == XPathSmtpClient.Namespace) {

                     switch (node.LocalName) {
                        case "from":
                           this.From = new XPathMailAddress();
                           this.From.ReadXml(node);
                           break;

                        case "reply-to": {
                              XPathMailAddress address = new XPathMailAddress();
                              address.ReadXml(node);

                              this.ReplyTo.Add(address);
                           }
                           break;

                        case "sender":
                           this.Sender = new XPathMailAddress();
                           this.Sender.ReadXml(node);
                           break;

                        case "to": {
                              XPathMailAddress address = new XPathMailAddress();
                              address.ReadXml(node);

                              this.To.Add(address);
                           }
                           break;

                        case "cc": {
                              XPathMailAddress address = new XPathMailAddress();
                              address.ReadXml(node);

                              this.CC.Add(address);
                           }
                           break;

                        case "bcc": {
                              XPathMailAddress address = new XPathMailAddress();
                              address.ReadXml(node);

                              this.Bcc.Add(address);
                           }
                           break;

                        case "subject":
                           this.Subject = node.Value;
                           break;

                        case "body":
                           this.Body = new XPathMailBody();
                           this.Body.ReadXml(node);
                           break;

                        default:
                           break;
                     }
                  }

               } while (node.MoveToNext(XPathNodeType.Element));

               node.MoveToParent();
            }
         }

         if (movedToDocEl)
            node.MoveToParent();
      }
Exemplo n.º 22
0
        private void loadDataFromNavigatorToTitle(ref XPathNavigator navigator, ref OMLSDKTitle newTitle)
        {
            SDKUtilities.DebugLine("[MyMoviesImporter] Loading data for a new title");
            newTitle.MetadataSourceID = GetChildNodesValue(navigator, "WebServiceID");

            #region covers
            SDKUtilities.DebugLine("[MyMoviesImporter] Scanning for {0} node", "Covers");
            if (navigator.MoveToChild("Covers", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Covers found, processing");
                SDKUtilities.DebugLine("[MyMoviesImporter] Scanning for {0} node", "Front");
                if (navigator.MoveToChild("Front", ""))
                {
                    string imagePath = navigator.Value;
                    string finalImagePath = FindFinalImagePath(imagePath);
                    SDKUtilities.DebugLine("[MyMoviesImporter] Final image path is: {0}", finalImagePath);
                    if (File.Exists(finalImagePath))
                    {
                        SDKUtilities.DebugLine("[MyMoviesImporter] This file appears to be valid, we'll set it on the title");
                        newTitle.FrontCoverPath = finalImagePath;
                    }
                    navigator.MoveToParent();
                }
                SDKUtilities.DebugLine("[MyMoviesImporter] Scanning for {0} node", "Back");
                if (navigator.MoveToChild("Back", ""))
                {
                    string imagePath = navigator.Value;
                    if (File.Exists(imagePath))
                    {
                        SDKUtilities.DebugLine("[MyMoviesImporter] Found Back cover image");
                        newTitle.BackCoverPath = imagePath;
                    }
                    navigator.MoveToParent();
                }

                navigator.MoveToParent();
            }
            #endregion

            newTitle.Synopsis = GetChildNodesValue(navigator, "Description");

            #region production year
            if (navigator.MoveToChild("ProductionYear", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Found production year, I hope the format is something we can read");
                try
                {
                    string year = navigator.Value;
                    if (!string.IsNullOrEmpty(year))
                    {
                        DateTime rls_date = new DateTime(int.Parse(year), 1, 1);
                        if (rls_date != null)
                        {
                            SDKUtilities.DebugLine("[MyMoviesImporter] Got it, loading the production year");
                            newTitle.ReleaseDate = rls_date;
                        }
                    }
                    navigator.MoveToParent();
                }
                catch (Exception e)
                {
                    navigator.MoveToParent();
                    SDKUtilities.DebugLine("[MyMoviesImporter] error reading ProductionYear: " + e.Message);
                }
            }
            #endregion

            #region parental rating (mpaa rating)
            if (navigator.MoveToChild("ParentalRating", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Scanning for the ParentalRating");
                if (navigator.HasChildren)
                {
                    string ratingId = GetChildNodesValue(navigator, "Value");
                    if (!string.IsNullOrEmpty(ratingId))
                    {
                        int mmRatingId;
                        if (int.TryParse(ratingId, out mmRatingId))
                            switch (mmRatingId)
                            {
                                case 0:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] This appears to be unrated");
                                    newTitle.ParentalRating = "Unrated";
                                    break;
                                case 1:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] This appears to be rated G");
                                    newTitle.ParentalRating = "G";
                                    break;
                                case 2:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] I have no idea what rating this is");
                                    break;
                                case 3:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] This appears to be rated PG");
                                    newTitle.ParentalRating = "PG";
                                    break;
                                case 4:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] This appears to be rated PG13");
                                    newTitle.ParentalRating = "PG13";
                                    break;
                                case 5:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] I have NO idea what rating this is");
                                    break;
                                case 6:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] This appears to be rated R");
                                    newTitle.ParentalRating = "R";
                                    break;
                            }
                        else
                            SDKUtilities.DebugLine("[MyMoviesImporter] Error parsing rating: {0} not a number", ratingId);
                    }
                    string ratingReason = GetChildNodesValue(navigator, "Description");
                    if (!string.IsNullOrEmpty(ratingReason))
                        newTitle.ParentalRatingReason = ratingReason;
                }
                navigator.MoveToParent();
            }
            #endregion

            newTitle.Runtime = Int32.Parse(GetChildNodesValue(navigator, "RunningTime"));

            #region persons
            if (navigator.MoveToChild("Persons", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Beginning the long, painful process of scanning people");
                if (navigator.HasChildren)
                {
                    XPathNodeIterator nIter = navigator.SelectChildren("Person", "");
                    if (navigator.MoveToFirstChild())
                    {
                        XPathNavigator localNav = navigator.CreateNavigator();
                        navigator.MoveToParent();
                        for (int i = 0; i < nIter.Count; i++)
                        {
                            string name = GetChildNodesValue(localNav, "Name");
                            string role = GetChildNodesValue(localNav, "Role");
                            string type = GetChildNodesValue(localNav, "Type");

                            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(type))
                            {
                                switch (type)
                                {
                                    case "Actor":
                                        SDKUtilities.DebugLine("[MyMoviesImporter] actor {0}, {1}", name, role);

                                        newTitle.AddActingRole(name, role);
                                        break;
                                    case "Director":
                                        SDKUtilities.DebugLine("[MyMoviesImporter] director {0}", name);

                                        newTitle.AddDirector(new OMLSDKPerson(name));
                                        break;

                                    default:
                                        break;
                                }
                            }
                            localNav.MoveToNext("Person", "");
                        }
                    }
                }
                navigator.MoveToParent();
            }
            #endregion

            #region studio (s)
            if (navigator.MoveToChild("Studios", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Ahh... Studios (pssst.. we only copy the last entry from here... dont tell anyone)");
                if (navigator.HasChildren)
                {
                    XPathNodeIterator nIter = navigator.SelectChildren("Studio", "");
                    if (navigator.MoveToFirstChild())
                    {
                        XPathNavigator localNav = navigator.CreateNavigator();
                        navigator.MoveToParent();
                        for (int i = 0; i < nIter.Count; i++)
                        {
                            newTitle.Studio = localNav.Value;
                        }
                    }
                }
                navigator.MoveToParent();
            }
            #endregion

            newTitle.CountryOfOrigin = GetChildNodesValue(navigator, "Country");
            newTitle.AspectRatio = GetChildNodesValue(navigator, "AspectRatio");
            newTitle.VideoStandard = GetChildNodesValue(navigator, "VideoStandard");
            newTitle.OriginalName = GetChildNodesValue(navigator, "OriginalTitle");
            newTitle.SortName = GetChildNodesValue(navigator, "SortTitle");

            #region genres
            if (navigator.MoveToChild("Genres", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Genres... good old genres");
                XPathNodeIterator nIter = navigator.SelectChildren("Genre", "");
                if (navigator.MoveToFirstChild())
                {
                    XPathNavigator localNav = navigator.CreateNavigator();
                    navigator.MoveToParent();
                    for (int i = 0; i < nIter.Count; i++)
                    {
                        newTitle.AddGenre(localNav.Value);
                        localNav.MoveToNext("Genre", "");
                    }
                }
                navigator.MoveToParent();
            }
            #endregion

            #region audio tracks
            if (navigator.MoveToChild("AudioTracks", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] AudioTracks.. yeah, like you can even change them anyway");
                XPathNodeIterator nIter = navigator.SelectChildren("AudioTrack", "");
                if (navigator.MoveToFirstChild())
                {
                    XPathNavigator localNav = navigator.CreateNavigator();
                    navigator.MoveToParent();
                    for (int i = 0; i < nIter.Count; i++)
                    {
                        string audioLanguage = localNav.GetAttribute("Language", "");
                        string audioType = localNav.GetAttribute("Type", "");
                        string audioChannels = localNav.GetAttribute("Channels", "");

                        if (!string.IsNullOrEmpty(audioLanguage))
                        {
                            string audioTrackString = audioLanguage;
                            if (!string.IsNullOrEmpty(audioType))
                                audioTrackString += string.Format(", {0}", audioType);

                            if (!string.IsNullOrEmpty(audioChannels))
                                audioTrackString += string.Format(", {0}", audioChannels);

                            SDKUtilities.DebugLine("[MyMoviesImporter] Got one: {0}, {1}, {2}", audioLanguage, audioType, audioChannels);
                            newTitle.AddAudioTrack(audioTrackString);
                        }
                        localNav.MoveToNext("AudioTrack", "");
                    }
                }
                navigator.MoveToParent();
            }
            #endregion

            #region watched status (Submitted by yodine from our forums)
            if (navigator.MoveToChild("Watched", ""))
            {
                navigator.MoveToParent(); // move back, we just wanted to know this field existed.
                SDKUtilities.DebugLine("[MyMoviesImporter] Found Watched status. Trying to decode");
                string watched = GetChildNodesValue(navigator, "Watched");
                if (!string.IsNullOrEmpty(watched))
                {
                    if (Boolean.Parse(watched))
                        newTitle.WatchedCount++;
                }
            }
            #endregion

            #region subtitles
            if (navigator.MoveToChild("Subtitles", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Subtitles here we come!");
                if (navigator.GetAttribute("NotPresent", "").CompareTo("False") == 0)
                {
                    XPathNodeIterator nIter = navigator.SelectChildren("Subtitle", "");
                    if (navigator.MoveToFirstChild())
                    {
                        XPathNavigator localNav = navigator.CreateNavigator();
                        navigator.MoveToParent();
                        for (int i = 0; i < nIter.Count; i++)
                        {
                            string subtitleLanguage = localNav.GetAttribute("Language", "");
                            if (!string.IsNullOrEmpty(subtitleLanguage))
                            {
                                SDKUtilities.DebugLine("[MyMoviesImporter] Subtitle {0}", subtitleLanguage);
                                newTitle.AddSubtitle(subtitleLanguage);
                            }

                            localNav.MoveToNext("Subtitle", "");
                        }
                    }
                }
                navigator.MoveToParent();
            }
            #endregion

            #region discs
            if (navigator.MoveToChild("Discs", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Discs... ok here is the good one, we'll passing this off to some other method to handle.");
                XPathNodeIterator nIter = navigator.SelectChildren("Disc", "");
                if (navigator.MoveToFirstChild())
                {
                    XPathNavigator localNav = navigator.CreateNavigator();
                    extractDisksFromXML(nIter, localNav, newTitle);
                    navigator.MoveToParent();
                }
                navigator.MoveToParent();
            }
            #endregion
        }
Exemplo n.º 23
0
 public XReader(string s) {
     navigator = new XPathDocument(new StringReader(s)).CreateNavigator();
     navigator.MoveToChild(XPathNodeType.Element);
     stack.Push(GetNodeName());
 }
        public EventMultiTracerControl()
        {
            try
            {
                InitializeComponent();

                _tracingOptions = new TracingOptions();
                tracingOptionsPropertyGrid.SelectedObject = _tracingOptions;

                _filterViewControl = new FilterViewControl();
                _filterViewControl.Dock = DockStyle.Fill;
                FilterTabPage.Controls.Add(_filterViewControl);
                //
                xPathStatementControl = new DescriptiveListEditorControl();
                xPathStatementControl.Dock = DockStyle.Fill;
                xPathStatementControl.LoadFromFile(TracingOptions.XPathFilePath);
                xPathTabPage.Controls.Add(xPathStatementControl);

                //_filterViewControl.Filter =
                // TODO: This will be a dynamic section (SD)
                logTransform1TabPage = new TextTransformerTabPage();
                logTransform2TabPage = new TextTransformerTabPage
                    (
                    new XsltTextTransformer
                        (
                        AppDomain.CurrentDomain.SetupInformation.ApplicationBase +
                        @"XsltEventTransform.xslt"
                        ));
                //
                // logTransform1TabPage
                //
                logTransform1TabPage.Location = new Point(4, 22);
                logTransform1TabPage.Name = "logTransform1TabPage";
                logTransform1TabPage.Size =
                    new Size
                        (
                        logEntryViewsTabControl.Width,
                        logEntryViewsTabControl.Height - 22
                        );
                logTransform1TabPage.TabIndex = 0;
                logTransform1TabPage.Text = "Xml";
                //
                // logTransform2TabPage
                //
                logTransform2TabPage.Location = new Point(4, 22);
                logTransform2TabPage.Name = "logTransform2TabPage";
                logTransform2TabPage.Size =
                    new Size
                        (
                        logEntryViewsTabControl.Width,
                        logEntryViewsTabControl.Height - 22
                        );
                logTransform2TabPage.TabIndex = 1;
                logTransform2TabPage.Text = "Message";
                //
                logEntryViewsTabControl.Controls.Add(logTransform1TabPage);
                logEntryViewsTabControl.Controls.Add(logTransform2TabPage);
                //
                //
                Resize += LogControl_Resize;

                #region  xpath quering proof of concept

                XmlElement xRoot = xEventsCache.CreateElement(null, "ArrayOfApplicationEvent", null);
                xEventsCache.AppendChild(xRoot);

                if (xPathStatementControl.ContextMenuStrip == null)
                {
                    xPathStatementControl.ContextMenuStrip =
                        new ContextMenuStrip();
                }
                xPathStatementControl.ContextMenuStrip.Items.AddRange
                    (
                    new ToolStripMenuItem[2]
                        {
                            applyFilterToolStripMenuItem,
                            cancelFilterToolStripMenuItem
                        });
                applyFilterToolStripMenuItem.Click += applyMenuItem_Click;
                cancelFilterToolStripMenuItem.Click += cancelFilterMenuItem_Click;

                XmlElement xFilterRoot = xEventsFilteredCache.CreateElement
                    (
                    null,
                    "ArrayOfApplicationEvent",
                    null
                    );
                xEventsFilteredCache.AppendChild(xFilterRoot);

                //xPathStatementControl.applyMenuItem.Click +=new EventHandler(applyMenuItem_Click);
                //xPathStatementControl.cancelFilterMenuItem.Click +=new EventHandler(cancelFilterMenuItem_Click);

                #endregion  xpath quering proof of concept

                #region Subscribing to the list view scroll event

                monitorPanel.Scroll += listView1_Scrolled;

                #endregion Subscribing to the list view scroll event

                keysControl = new ContextHolderPointersControl();
                keysControl.Dock = DockStyle.Fill;

                xQueryTabPage.Controls.Add(keysControl);

                monitorPanel.ContextMenu = monitorContolContextMenu;
                monitorPanel.ItemsListView.SelectedIndexChanged += listView1_SelectedIndexChanged;
                monitorPanel.ItemsListView.SetScrollBarMaxValue(1);
                countToShow = 20; //listView1.DisplayRectangle.Height / Convert.ToUInt16(listView1.Font.GetHeight());
                filterBySameFieldToolStripComboBox.ComboBox.DataSource = TraceRecord.CorrelationFieldNames;

                searchBackgroundWorker.DoWork += searchBackgroundWorker_DoFilterBySameFieldWork;
                searchBackgroundWorker.RunWorkerCompleted += searchBackgroundWorker_RunWorkerCompleted;

                navigator = xEventsCache.CreateNavigator();
                navigator.MoveToChild(XPathNodeType.Element);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }