protected string getFunctionDocAndExample(XmlReader reader)
        {
            //assumes doc is before example. Otherwise, could miss an example.
            string strRes = "";
            bool bFound = reader.ReadToDescendant("doc");
            if (bFound) strRes += (unencodeXml(reader.ReadString()));
            bFound = reader.ReadToNextSibling("example");
            if (bFound) strRes += ("\r\n\r\nExample:\r\n" + unencodeXml(reader.ReadString()));

            reader.Close();
            return strRes;
        }
Esempio n. 2
0
        public void ReadXml(XmlReader reader)
        {
            if (reader.LocalName != "icon" && !reader.ReadToDescendant("icon"))
                throw new InvalidDataException();

            XmlHelper.ParseXml(reader, new XmlParseSet
            {
                {"url", () => this.RelativeUrl = reader.ReadString()},
                {"mimetype", () => this.MimeType = reader.ReadString()},
                {"width", () => this.Width = reader.ReadElementContentAsInt()},
                {"height", () => this.Height = reader.ReadElementContentAsInt()},
                {"depth", () => this.Depth = reader.ReadElementContentAsInt()}
            });
        }
		Dictionary<string, List<CallerInfo>> ReadValidCertificates(XmlReader parser) {
			var validCertificates = new Dictionary<string, List<CallerInfo>>();
			try {
				while (parser.Read()) {
					if (parser.IsStartElement() && parser.Name == "signing_certificate") {
						var name = parser[0];
						var packageName = parser[2];
						var isRelease = Convert.ToBoolean(parser[1]);
						var certificate = parser.ReadString();
						if (certificate != null)
							certificate = certificate.Replace("\\s|\\n", "");

						var info = new CallerInfo(name, packageName, isRelease, certificate);

						List<CallerInfo> infos; 
						validCertificates.TryGetValue(certificate, out infos);
						if (infos == null) {
							infos = new List<CallerInfo>();
							validCertificates.Add(certificate, infos);
						}
						LogHelper.Verbose(Tag, "Adding allowed caller: ", info.Name,
							" package=", info.PackageName, " release=", info.Release,
							" certificate=", certificate);
						infos.Add(info);
					}
				}
			} catch (XmlException e) {
				LogHelper.Error(Tag, e, "Could not read allowed callers from XML.");
			} catch (IOException e) {
				LogHelper.Error(Tag, e, "Could not read allowed callers from XML.");
			}
			return validCertificates;
		}
        /// <summary>
        /// Obtains the type and value of a parameter from an XML Error file.
        /// </summary>
        /// <param name="reader">XML Error file.</param>
        /// <param name="parameter">Parameter to obtain.</param>
        /// <returns>Parameter.</returns>
        public static Parameter Deserialize(XmlReader reader, Parameter parameter)
        {
            if (reader.IsStartElement(DTD.Error.ErrorParams.TagErrorParam))
            {
                if (parameter == null)
                {
                    parameter = new Parameter();
                }

                // Read Attributes of Node.
                parameter.Key = reader.GetAttribute(DTD.Error.ErrorParams.TagKey);
                switch (reader.GetAttribute(DTD.Error.ErrorParams.TagType))
                {
                    case ResponseException.ErrorKey:
                        parameter.Type = ErrorParamType.Key;
                        break;
                    case ResponseException.ErrorLiteral:
                        parameter.Type = ErrorParamType.Literal;
                        break;
                }

                if (!reader.IsEmptyElement)
                {
                    parameter.Text = reader.ReadString();
                }
                else
                {
                    reader.Skip();
                }
            }
            return parameter;
        }
Esempio n. 5
0
		protected override void LoadLanguageSpecificSettings(XmlReader xr)
		{
			while(xr.Read())
				switch (xr.LocalName)
				{
					case "type":
						try
						{
							OutputType = (OutputTypes)Convert.ToInt32(xr.ReadString());
						}
						catch { }
						break;
					case "isrelease":
						IsRelease = xr.ReadString()=="true";
						break;
					case "dversion":
						DMDVersion = (DVersion)Convert.ToInt32(xr.ReadString());
						break;
					case "libs":
						var xr2 = xr.ReadSubtree();
						while (xr2.Read())
						{
							if (xr2.LocalName == "lib")
								LinkedLibraries.Add(xr2.ReadString());
						}
						break;
					default: break;
				}
		}
Esempio n. 6
0
        public override void ReadXml(XmlReader reader)
        {
            var isEmptyElement = reader.IsEmptyElement;

            var packagePathHash = new FoxHash("packagePathHash");
            packagePathHash.ReadXml(reader);
            var archivePathHash = new FoxHash("archivePathHash");
            archivePathHash.ReadXml(reader);
            var nameInArchiveHash = new FoxHash("nameInArchiveHash");
            nameInArchiveHash.ReadXml(reader);

            var packagePath = reader.GetAttribute("packagePath");
            var archivePath = reader.GetAttribute("archivePath");
            var nameInArchive = reader.GetAttribute("nameInArchive");

            PackagePathLiteral = new FoxStringLiteral(packagePath, packagePathHash);
            ArchivePathLiteral = new FoxStringLiteral(archivePath, archivePathHash);
            NameInArchiveLiteral = new FoxStringLiteral(nameInArchive, nameInArchiveHash);

            reader.ReadStartElement("value");
            if (isEmptyElement == false)
            {
                string value = reader.ReadString();
                EntityHandle = value.StartsWith("0x")
                    ? ulong.Parse(value.Substring(2, value.Length - 2), NumberStyles.AllowHexSpecifier)
                    : ulong.Parse(value);
                reader.ReadEndElement();
            }
        }
        //public static Oids.Oid Deserialize(XmlReader reader, Oids.Oid oid)
        /// <summary>
        /// Deserializes Oid from an XML stream.
        /// </summary>
        /// <param name="reader">XML stream.</param>
        /// <returns>Oid.</returns>
        public static Oids.Oid Deserialize(XmlReader reader)
        {
            Oids.Oid lResult = null;
            if (reader.IsStartElement(DTD.TagOID))
            {
                string lClassName = reader.GetAttribute(DTD.OID.TagClass);
                List<KeyValuePair<ModelType,object>> lFields = new List<KeyValuePair<ModelType,object>>();

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    do
                    {
                    #region Process tag <OID.Field>.
                    if (reader.IsStartElement(DTD.OID.TagOIDField))
                    {
                        if (!reader.IsEmptyElement)
                        {
                            ModelType lType = Convert.StringTypeToMODELType(reader.GetAttribute(DTD.OID.TagType));
                            lFields.Add(new KeyValuePair<ModelType, object>(lType, Convert.XmlToType(lType, reader.ReadString())));
                        }
                        else
                        {
                            throw new ArgumentException("Xml Reader have one OID.Field with empty Element.", "XmlReader reader");
                        }
                    }
                    #endregion Process tag <OID.Field>.
                    else
                    {
                        #region Process tag <?>
                        reader.Skip();
                        if (reader.NodeType == XmlNodeType.None)
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                        #endregion Process tag <?>
                    }
                    } while (reader.Read());
                }
                else
                {
                    reader.Skip();
                }

                if(lClassName.Length > 0)
                {
                    lResult = ServerConnection.CreateOid(lClassName,lFields);
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the OID in Start Element.", "XmlReader reader");
            }
            return lResult;
        }
Esempio n. 8
0
 public void ReadXml(XmlReader reader)
 {
     var isEmptyElement = reader.IsEmptyElement;
     reader.ReadStartElement("value");
     if (isEmptyElement == false)
     {
         Value = double.Parse(reader.ReadString(), CultureInfo.InvariantCulture);
         reader.ReadEndElement();
     }
 }
Esempio n. 9
0
 public void ReadXml(XmlReader reader)
 {
     if (reader.IsEmptyElement) {
         reader.Read();
         return;
     }
     reader.ReadStartElement("File");
     FilePath = reader.ReadString();
     reader.ReadEndElement();
 }
Esempio n. 10
0
 public void ReadXml(XmlReader reader)
 {
     var isEmptyElement = reader.IsEmptyElement;
     reader.ReadStartElement("value");
     if (isEmptyElement == false)
     {
         Value = ExtensionMethods.ParseFloatRoundtrip(reader.ReadString());
         reader.ReadEndElement();
     }
 }
Esempio n. 11
0
 public void ReadXml(XmlReader reader)
 {
     var isEmptyElement = reader.IsEmptyElement;
     reader.ReadStartElement("value");
     if (isEmptyElement == false)
     {
         Value = bool.Parse(reader.ReadString());
         reader.ReadEndElement();
     }
 }
Esempio n. 12
0
		public static string ReadContent(XmlReader xr)
		{
			string rlt;
			if (xr.NodeType != XmlNodeType.Element)
			{
				xr.MoveToElement();
			}
			rlt = xr.ReadString();
			xr.MoveToElement();
			return rlt;
		}
Esempio n. 13
0
File: test.cs Progetto: mono/gert
	void IXmlSerializable.ReadXml (XmlReader reader)
	{
		XmlDocument doc = new XmlDocument ();
		string str = reader.ReadString ();
		try {
			doc.LoadXml (str);
		} catch {
			doc.LoadXml (reader.ReadOuterXml ());
		}
		mFuncXmlNode = (XmlNode) (doc.DocumentElement);
	}
 private static bool ProcessChildNode(XmlReader xmlTextReader, LogEntry entry)
 {
     switch (xmlTextReader.Name)
     {
         case "log4j:event":
             return true;
         case ("log4j:message"):
             entry.Message = xmlTextReader.ReadString();
             break;
         case ("log4j:data"):
             ProcessDataTag(xmlTextReader, entry);
             break;
         case ("log4j:throwable"):
             entry.Throwable = xmlTextReader.ReadString();
             break;
         case ("log4j:locationInfo"):
             SetLocationInfo(entry, xmlTextReader);
             break;
     }
     return false;
 }
Esempio n. 15
0
 public void Load(XmlReader reader)
 {
     while (reader.Read()) {
         if (reader.IsStartElement()) {
             switch (reader.Name) {
                 case "ActionType": {
                         ActionType = reader.ReadString().ToEnum<Logic.Display.CharSprite.ActionType>();
                         break;
                     }
             }
         }
     }
 }
Esempio n. 16
0
 public void ReadXml(XmlReader reader)
 {
     var isEmptyElement = reader.IsEmptyElement;
     reader.ReadStartElement("value");
     if (isEmptyElement == false)
     {
         string value = reader.ReadString();
         Value = value.StartsWith("0x")
             ? sbyte.Parse(value.Substring(2, value.Length - 2), NumberStyles.AllowHexSpecifier)
             : sbyte.Parse(value);
         reader.ReadEndElement();
     }
 }
Esempio n. 17
0
 public void ReadXml(XmlReader reader)
 {
     var isEmptyElement = reader.IsEmptyElement;
     reader.ReadStartElement("value");
     if (isEmptyElement == false)
     {
         string entityPtr = reader.ReadString();
         EntityPtr = entityPtr.StartsWith("0x")
             ? ulong.Parse(entityPtr.Substring(2, entityPtr.Length - 2), NumberStyles.AllowHexSpecifier)
             : ulong.Parse(entityPtr);
         reader.ReadEndElement();
     }
 }
Esempio n. 18
0
 Profile(XmlReader r)
 {
     while (r.Read())
     {
         if (r.NodeType == XmlNodeType.Element)
         {
             if (r.Name == "guid")
             {
                 string content = r.ReadString();
                 profileId = new Guid(content);
             }
             else if (r.Name == "name")
             {
                 string content = r.ReadString();
                 profileName = content;
             }
             else if (r.Name == "description")
             {
                 string content = r.ReadString();
                 profileDesc = content;
             }
         }
     }
 }
Esempio n. 19
0
		public void ReadXml(XmlReader reader) {
			reader.ReadToFollowing("TypeName");
			reader.ReadStartElement("TypeName");
			TypeName=reader.ReadString();
			reader.ReadEndElement();//TypeName
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();//gets rid of whitespace if in debug mode.
			}
			reader.ReadStartElement("Obj");
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();
			}
			string strObj=reader.ReadOuterXml();
			//now get the reader to the correct location
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//Obj
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//DtoObject
			Type type=null;
			if(TypeName.StartsWith("List<")) {
				Type typeGen=Type.GetType(TypeName.Substring(5,TypeName.Length-6));
				Type typeList=typeof(List<>);
				type=typeList.MakeGenericType(typeGen);
			}
			else if(TypeName=="System.Drawing.Color") {
				type=typeof(int);
			}
			else {
				//This works fine for non-system types as well without specifying the assembly,
				//because we are already in the OpenDentBusiness assembly.
				type=Type.GetType(TypeName);
			}
			XmlSerializer serializer = new XmlSerializer(type);
			//XmlReader reader2=XmlReader.Create(new StringReader(strObj));
			XmlTextReader reader2=new XmlTextReader(new StringReader(strObj));
			if(TypeName=="System.Drawing.Color") {
				Obj=Color.FromArgb((int)serializer.Deserialize(reader2));
			}
			else {
				Obj=serializer.Deserialize(reader2);
			}
				//Convert.ChangeType(serializer.Deserialize(reader2),type);
		}
Esempio n. 20
0
		public void ReadXml(XmlReader reader) {
			reader.ReadToFollowing("TypeName");
			reader.ReadStartElement("TypeName");
			TypeName=reader.ReadString();
			reader.ReadEndElement();//TypeName
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();//gets rid of whitespace if in debug mode.
			}
			reader.ReadStartElement("Obj");
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();
			}
			string strObj=reader.ReadOuterXml();
			//now get the reader to the correct location
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//Obj
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//DtoObject
			//Now, process what we read.
			Type type=null;
			if(TypeName=="System.Drawing.Color") {
				type=typeof(int);
			}
			else{
				type=ConvertNameToType(TypeName);
			}
			XmlSerializer serializer = new XmlSerializer(type);
			//XmlReader reader2=XmlReader.Create(new StringReader(strObj));
			XmlTextReader reader2=new XmlTextReader(new StringReader(strObj));
			if(TypeName=="System.Drawing.Color") {
				Obj=Color.FromArgb((int)serializer.Deserialize(reader2));
			}
			else {
				Obj=serializer.Deserialize(reader2);
			}
				//Convert.ChangeType(serializer.Deserialize(reader2),type);
		}
Esempio n. 21
0
 public static string ReadXmlElement(XmlReader r, string name)
 {
     if (r.IsStartElement(name))
     {
         //r.Read();
         if (!r.IsEmptyElement)
         {
             r.ReadStartElement(name);
             string s = r.ReadString();
             r.ReadEndElement();
             return s;
         }
         else
         {
             r.Read();
         }
     }
     else
     {
         r.Read();
     }
     return string.Empty;
 }
Esempio n. 22
0
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>parses xml to fill a precreated AtomSource object (might be a feed)</summary>
        /// <param name="reader">correctly positioned reader</param>
        /// <param name="source">created source object to be filled</param>
        /// <returns> </returns>
        //////////////////////////////////////////////////////////////////////
        protected void ParseSource(XmlReader reader, AtomSource source)
        {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            Tracing.Assert(source != null, "source should not be null");
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            Tracing.TraceCall();
            //
            // atomSource =
            //    element atom:source {
            //       atomCommonAttributes,
            //       (atomAuthor?
            //        & atomCategory*
            //        & atomContributor*
            //        & atomGenerator?
            //        & atomIcon?
            //        & atomId?
            //        & atomLink*
            //        & atomLogo?
            //        & atomRights?
            //        & atomSubtitle?
            //        & atomTitle?
            //        & atomUpdated?
            //        & extensionElement*)
            //  this will also parse the gData extension elements.
            //    }

            int depth = -1;

            ParseBasicAttributes(reader, source);

            while (NextChildElement(reader, ref depth))
            {
                object   localname = reader.LocalName;
                AtomFeed feed      = source as AtomFeed;
                if (IsCurrentNameSpace(reader, BaseNameTable.NSAtom))
                {
                    if (localname.Equals(this.nameTable.Title))
                    {
                        source.Title = ParseTextConstruct(reader, source);
                    }
                    else if (localname.Equals(this.nameTable.Updated))
                    {
                        source.Updated = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.Link))
                    {
                        source.Links.Add(ParseLink(reader, source));
                    }
                    else if (localname.Equals(this.nameTable.Id))
                    {
                        source.Id = source.CreateAtomSubElement(reader, this) as AtomId;
                        ParseBaseLink(reader, source.Id);
                    }
                    else if (localname.Equals(this.nameTable.Icon))
                    {
                        source.Icon = source.CreateAtomSubElement(reader, this) as AtomIcon;
                        ParseBaseLink(reader, source.Icon);
                    }
                    else if (localname.Equals(this.nameTable.Logo))
                    {
                        source.Logo = source.CreateAtomSubElement(reader, this) as AtomLogo;
                        ParseBaseLink(reader, source.Logo);
                    }
                    else if (localname.Equals(this.nameTable.Author))
                    {
                        source.Authors.Add(ParsePerson(reader, source));
                    }
                    else if (localname.Equals(this.nameTable.Contributor))
                    {
                        source.Contributors.Add(ParsePerson(reader, source));
                    }
                    else if (localname.Equals(this.nameTable.Subtitle))
                    {
                        source.Subtitle = ParseTextConstruct(reader, source);
                    }
                    else if (localname.Equals(this.nameTable.Rights))
                    {
                        source.Rights = ParseTextConstruct(reader, source);
                    }
                    else if (localname.Equals(this.nameTable.Generator))
                    {
                        source.Generator = ParseGenerator(reader, source);
                    }
                    else if (localname.Equals(this.nameTable.Category))
                    {
                        // need to make this another colleciton
                        source.Categories.Add(ParseCategory(reader, source));
                    }
                    else if (feed != null && localname.Equals(this.nameTable.Entry))
                    {
                        ParseEntry(reader);
                    }
                    // this will either move the reader to the end of an element
                    // if at the end, to the start of a new one.
                    reader.Read();
                }
                else if (feed != null && IsCurrentNameSpace(reader, BaseNameTable.gBatchNamespace))
                {
                    // parse the google batch extensions if they are there
                    ParseBatch(reader, feed);
                }
                else if (feed != null && IsCurrentNameSpace(reader, BaseNameTable.OpenSearchNamespace(this.versionInfo)))
                {
                    if (localname.Equals(this.nameTable.TotalResults))
                    {
                        feed.TotalResults = int.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.StartIndex))
                    {
                        feed.StartIndex = int.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.ItemsPerPage))
                    {
                        feed.ItemsPerPage = int.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                }
                else
                {
                    // default extension parsing.
                    ParseExtensionElements(reader, source);
                }
            }
            return;
        }
Esempio n. 23
0
        //**************************************************************************************************************
        //      Options Form Load
        //**************************************************************************************************************
        private void Options_Form_Load(object sender, EventArgs e)
        {
            String jdkpath                 = getJDKPath();
            String webbrowser              = getWebBrowser();
            String appearance              = "";
            String tabsalign               = "";
            String showstatusstrip         = "";
            String showtoolstrip           = "";
            String showprojectexplorerview = "";
            String showclassesview         = "";
            String showmethodsview         = "";
            String showerrorlist           = "";
            String showerrordialog         = "";
            String showstartpageonstartup  = "";
            String font                 = "";
            String fontsize             = "";
            String showlinenumbers      = "";
            String showlinehighlighter  = "";
            String bracesmatching       = "";
            String autocompletebraces   = "";
            String showinvalidlines     = "";
            String showendoflinemarkers = "";
            String showvisiblespaces    = "";
            String autocompilejava      = "";
            String autocompletion       = "";

            using (XmlReader reader = XmlReader.Create(configfile))
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.Name.ToString())
                        {
                        case "Appearance":
                            appearance = reader.ReadString();
                            break;

                        case "TabsAlignment":
                            tabsalign = reader.ReadString();
                            break;

                        case "ShowStatusStrip":
                            showstatusstrip = reader.ReadString();
                            break;

                        case "ShowToolStrip":
                            showtoolstrip = reader.ReadString();
                            break;

                        case "ShowProjectExplorer":
                            showprojectexplorerview = reader.ReadString();
                            break;

                        case "ShowClassesView":
                            showclassesview = reader.ReadString();
                            break;

                        case "ShowMethodsView":
                            showmethodsview = reader.ReadString();
                            break;

                        case "ShowErrorList":
                            showerrorlist = reader.ReadString();
                            break;

                        case "ShowErrorDialog":
                            showerrordialog = reader.ReadString();
                            break;

                        case "ShowStartPageOnStartUp":
                            showstartpageonstartup = reader.ReadString();
                            break;

                        case "Font":
                            font = reader.ReadString();
                            break;

                        case "FontSize":
                            fontsize = reader.ReadString();
                            break;

                        case "ShowLineNumbers":
                            showlinenumbers = reader.ReadString();
                            break;

                        case "ShowLineHighlighter":
                            showlinehighlighter = reader.ReadString();
                            break;

                        case "BracesMatching":
                            bracesmatching = reader.ReadString();
                            break;

                        case "AutoCompleteBraces":
                            autocompletebraces = reader.ReadString();
                            break;

                        case "ShowInvalidLines":
                            showinvalidlines = reader.ReadString();
                            break;

                        case "ShowEndOfLineMarker":
                            showendoflinemarkers = reader.ReadString();
                            break;

                        case "ShowVisibleSpaces":
                            showvisiblespaces = reader.ReadString();
                            break;

                        case "AutoCompileJava":
                            autocompilejava = reader.ReadString();
                            break;

                        case "AutoCompletion":
                            autocompletion = reader.ReadString();
                            break;
                        }
                    }
                }
            }


            //add jdk path to JDKPathTextBox
            if (jdkpath == "" || jdkpath == "null")
            {
            }
            else
            {
                JDKPathTextBox.Text = jdkpath;
            }

            //add web browser path to WebBrowserTextBox
            if (webbrowser == "" || webbrowser == "null")
            {
            }
            else
            {
                WebBrowserTextBox.Text = webbrowser;
            }

            //set appearances to Combo Box
            if (appearance != "")
            {
                comboBox1.SelectedText = appearance;
                getappearance          = comboBox1.SelectedText;
            }

            //select Tabs Alignment Radio Buttons
            if (tabsalign == "")
            {
            }
            else if (tabsalign == "Top")
            {
                TopRadioButton.Checked = true;
            }
            else
            {
                BottomRadioButton.Checked = true;
            }

            //select or not Status Strip check box
            if (showstatusstrip == "true")
            {
                StatusStripCheckBox.Checked = true;
            }
            else
            {
                StatusStripCheckBox.Checked = false;
            }

            //select or not Tool Strip check box
            if (showtoolstrip == "true")
            {
                ToolStripCheckBox.Checked = true;
            }
            else
            {
                ToolStripCheckBox.Checked = false;
            }

            //select or not Project Explorer check box
            if (showprojectexplorerview == "true")
            {
                ProjectExplorerCheckBox.Checked = true;
            }
            else
            {
                ProjectExplorerCheckBox.Checked = false;
            }

            //select or not Classes View check box
            if (showclassesview == "true")
            {
                ClassesViewCheckBox.Checked = true;
            }
            else
            {
                ClassesViewCheckBox.Checked = false;
            }

            //select or not Methods View check box
            if (showmethodsview == "true")
            {
                MethodsViewCheckBox.Checked = true;
            }
            else
            {
                MethodsViewCheckBox.Checked = false;
            }

            //select or not Errors List check box
            if (showerrorlist == "true")
            {
                ErrorListCheckBox.Checked = true;
            }
            else
            {
                ErrorListCheckBox.Checked = false;
            }

            //select or not Shwo Error Dialog check box
            if (showerrordialog == "true")
            {
                ShowErrorDialogCheckBox.Checked = true;
                showErrorDialog = true;
            }
            else
            {
                ShowErrorDialogCheckBox.Checked = false;
                showErrorDialog = false;
            }

            //select or not Show StartPage check box
            if (showstartpageonstartup == "true")
            {
                ShowStartPageCheckBox.Checked = true;
            }
            else
            {
                ShowStartPageCheckBox.Checked = false;
            }

            //select font to FontListBox
            if (font != "")
            {
                FontListBox.SelectedItem = font;
            }

            //select font size to FontSizeListBox
            if (fontsize != "")
            {
                FontSizeListBox.SelectedItem = fontsize;
            }

            //select or not Line Numbers Check box
            if (showlinenumbers == "true")
            {
                LineNumbersCheckBox.Checked = true;
            }
            else
            {
                LineNumbersCheckBox.Checked = false;
            }

            //select or not Line Highlighter check box
            if (showlinehighlighter == "true")
            {
                LineHighlighterCheckBox.Checked = true;
            }
            else
            {
                LineHighlighterCheckBox.Checked = false;
            }

            //select or not Braces Matching check box
            if (bracesmatching == "true")
            {
                BracesMatchingCheckBox.Checked = true;
            }
            else
            {
                BracesMatchingCheckBox.Checked = false;
            }

            //select or not Auto Complete Braces check box
            if (autocompletebraces == "true")
            {
                AutoCompleteBracesCheckBox.Checked = true;
            }
            else
            {
                AutoCompleteBracesCheckBox.Checked = false;
            }

            //select or not Invalid Lines check box
            if (showinvalidlines == "true")
            {
                InvalidLinesCheckBox.Checked = true;
            }
            else
            {
                InvalidLinesCheckBox.Checked = false;
            }

            //select or not End Of Line Marker check box
            if (showendoflinemarkers == "true")
            {
                EndOfLineMarkerCheckBox.Checked = true;
            }
            else
            {
                EndOfLineMarkerCheckBox.Checked = false;
            }

            //select or not Visible Spaces check box
            if (showvisiblespaces == "true")
            {
                VisibleSpacesCheckBox.Checked = true;
            }
            else
            {
                VisibleSpacesCheckBox.Checked = false;
            }

            //select or not Auto Compile Program check box
            if (autocompilejava == "true")
            {
                AutoCompileJavaCheckBox.Checked = true;
            }
            else
            {
                AutoCompileJavaCheckBox.Checked = false;
            }


            //select or not Auto Completion check box
            if (autocompletion == "true")
            {
                AutoCompleteCheckBox.Checked = true;
            }
            else
            {
                AutoCompleteCheckBox.Checked = false;
            }
        }
        //verify repairResolutionList field
        public void VerifyrepairResolutionList(string fileName)
        {
            XmlReader   reader = XmlReader.Create(fileName);
            XmlDocument doc    = new XmlDocument();

            doc.Load(fileName);

            reader.Close();
            //reader.Dispose();

            //verify the tag
            foreach (XmlElement e in doc.SelectNodes("//*[local-name() = 'repairOrderResolution']"))
            {
                try
                {
                    string ascWarrantyCd = e.SelectSingleNode("*[local-name() = 'repairResolutionList']").InnerText;
                }
                catch (Exception)
                {
                    Console.WriteLine("Missing the repairResolutionList tag. Failed!!!");
                    msgSubject = "Errors in resolution XML file: repairResolutionList tag";
                    msgBody    = "\n Missing the repairResolutionList tag. Failed!!!\n File Name: " + fileName;
                    try
                    {
                        //es.SendEmailMethod(msgSubject, msgBody);

                        //this region part is for moving the error files method
                        #region
                        ResolutionFileLocation rf = new ResolutionFileLocation();
                        MoveFailedFile         mv = new MoveFailedFile(fileName, fileName.Remove(0, rf.outboundPath.Length));
                        mv.Move();
                        #endregion
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }

            //verify the content
            while (reader.Read())
            {
                string clientDamageCdCon;
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "ervmt:repairResolutionCode")
                {
                    clientDamageCdCon = reader.ReadString();
                    if (clientDamageCdCon == "")
                    {
                        Console.WriteLine("The content of repairResolutionCode tag is empty. Failed!!!\n");
                        msgSubject = "Errors in resolution XML file: repairResolutionCode content";
                        msgBody    = "\n The content of repairResolutionCode tag is empty. Failed!!!\n File Name: " + fileName;
                        try
                        {
                            //es.SendEmailMethod(msgSubject, msgBody);

                            //this region part is for moving the error files method
                            #region
                            ResolutionFileLocation rf = new ResolutionFileLocation();
                            MoveFailedFile         mv = new MoveFailedFile(fileName, fileName.Remove(0, rf.outboundPath.Length));
                            mv.Move();
                            #endregion
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                }
            }

            reader.Close();
            //reader.Dispose();
        }
Esempio n. 25
0
 public void ReadXml(XmlReader reader)
 {
     reader.ReadStartElement();
     NodeDocument.File = reader.ReadString();
     reader.ReadEndElement();
 }
        /// <summary>
        /// Generates an BorderWidth from its RDL representation.
        /// </summary>
        /// <param name="reader">The <typeparamref name="XmlReader"/> stream from which the BorderWidth is deserialized</param>
        public void ReadXml(XmlReader reader)
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == Rdl.BORDERWIDTH)
                {
                    break;
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    //--- Default
                    if (reader.Name == Rdl.DEFAULT && !reader.IsEmptyElement)
                    {
                        if (_default == null)
                        {
                            _default = new Expression();
                        }

                        _default.Value = reader.ReadString();
                    }

                    //--- Left
                    if (reader.Name == Rdl.LEFT && !reader.IsEmptyElement)
                    {
                        if (_left == null)
                        {
                            _left = new Expression();
                        }

                        _left.Value = reader.ReadString();
                    }

                    //--- Right
                    if (reader.Name == Rdl.RIGHT && !reader.IsEmptyElement)
                    {
                        if (_right == null)
                        {
                            _right = new Expression();
                        }

                        _right.Value = reader.ReadString();
                    }

                    //--- Top
                    if (reader.Name == Rdl.TOP && !reader.IsEmptyElement)
                    {
                        if (_top == null)
                        {
                            _top = new Expression();
                        }

                        _top.Value = reader.ReadString();
                    }

                    //--- Bottom
                    if (reader.Name == Rdl.BOTTOM && !reader.IsEmptyElement)
                    {
                        if (_bottom == null)
                        {
                            _bottom = new Expression();
                        }

                        _bottom.Value = reader.ReadString();
                    }
                }
            }
        }
        //method
        public void VerifyNumberOfRecordsMethod()
        {
            //verify the number of records
            reader.MoveToContent();
            while (reader.Read())
            {
                //find the specific tag (ervmt:numberOfRecords) of the resolution XML file
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "ervmt:numberOfRecords")
                {
                    //assign the specific element value and convert it to an integer
                    string messageType = reader.ReadString();
                    numberOfRecords = Convert.ToInt32(messageType);

                    //display the number of records
                    Console.WriteLine("The number of records: " + numberOfRecords);
                }

                //find the specific tag (ervmt:repairID) of the resolution XML file
                string repairID = null;
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "ervmt:repairID")
                {
                    //assign the specific element value
                    repairID = reader.ReadString();

                    //display the number of records
                    Console.WriteLine("The repairID: " + repairID);

                    //count the total of repair IDs
                    repairIDCount++;
                }
            }

            reader.Close();
            //reader.Dispose();

            Console.WriteLine("The total of the repairIDs: " + repairIDCount);

            //compare between the numberOfRecords and  total of repairIDs
            if (numberOfRecords == repairIDCount) //if match
            {
                Console.WriteLine("This number of records Passed!");

                VerifyResolutionList vfRlist = new VerifyResolutionList();
                vfRlist.VerifyrepairResolutionList(fileName);
            }
            else //if not match
            {
                //throw new Exception("The number of records did not match the total of repairID\n");
                Console.WriteLine("The number of records did not match the total of repairID. Failed!!!\n");

                msgSubject = "Errors in resolution XML file: repairID not match";
                msgBody    = "\n The number of records: " + numberOfRecords + ", The total of repairIDs: " + repairIDCount +
                             ".\n The number of records did not match the total of repairID. Failed!!!\n File Name: " + fileName;
                try
                {
                    //send the error message to email
                    //es.SendEmailMethod(msgSubject, msgBody);

                    //this region part is for moving the error files method
                    #region
                    ResolutionFileLocation rf = new ResolutionFileLocation();
                    MoveFailedFile         mv = new MoveFailedFile(fileName, fileName.Remove(0, rf.outboundPath.Length));
                    mv.Move();
                    #endregion
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Esempio n. 28
0
        void ParseBoneScale(XmlReader xml, Dictionary<int, XmlBoneKeyFrame> frames)
        {
            int depth = xml.Depth;
            while (xml.Read() && xml.Depth > depth)
            {
                if (xml.IsStartElement() && !xml.IsEmptyElement)
                {
                    if (xml.Name == "Value")
                    {
                        int fr = int.Parse(xml.GetAttribute("Frame"));

                        XmlBoneKeyFrame frame;
                        if (!frames.TryGetValue(fr, out frame))
                        {
                            frame.Position = new Vector3();
                            frame.FrameId = fr;
                            frame.Scale = new Vector3(1, 1, 1);
                            frame.Rotation = Quaternion.Identity;
                            frames.Add(fr, frame);
                        }

                        frame.Scale = ParseVector3(xml.ReadString());
                        frames[fr] = frame;
                    }
                }
            }
        }
Esempio n. 29
0
        public void ReadFrom(XmlReader x)
        {
            while (x.Read())
            {
                switch (x.LocalName)
                {
                case "obj":
                    ObjectFileLinkPattern = x.ReadString();
                    break;

                case "include":
                    IncludePathPattern = x.ReadString();
                    break;

                case "version":
                    VersionDefinition = x.ReadString();
                    break;

                case "debug":
                    DebugDefinition = x.ReadString();
                    break;

                case "unittest":
                    UnittestFlag = x.ReadString();
                    break;

                case "profile":
                    ProfileFlag = x.ReadString();
                    break;

                case "ddFlag":
                    EnableDDocFlag = x.ReadString();
                    break;

                case "ddMacroDefinition":
                    DDocDefinitionFile = x.ReadString();
                    break;

                case "ddDir":
                    DDocExportDirectory = x.ReadString();
                    break;

                case "linkerRedirectFlag":
                    LinkerRedirectPrefix = x.ReadString();
                    break;

                case "commandFile":
                    var attr = x.GetAttribute("alsoForLinking");
                    CommandFileCanBeUsedForLinking = attr != "false";
                    CommandFile = x.ReadString();
                    break;

                case "platform":
                    var id = x.GetAttribute("id");
                    if (!string.IsNullOrWhiteSpace(id))
                    {
                        PlatformDependentOptions[id] = x.ReadString();
                    }
                    break;
                }
            }
        }
Esempio n. 30
0
        public void ReadFrom(XmlReader x)
        {
            XmlReader s = null;

            while (x.Read())
            {
                switch (x.LocalName)
                {
                case "BinaryPath":
                    BinPath = x.ReadString();
                    break;

                case "TargetConfiguration":
                    s = x.ReadSubtree();

                    var t = new LinkTargetConfiguration();
                    if (t.LoadFrom(this, s))
                    {
                        LinkTargetConfigurations [t.TargetType] = t;
                    }

                    s.Close();
                    break;

                case "DefaultLibs":
                    s = x.ReadSubtree();

                    while (s.Read())
                    {
                        if (s.LocalName == "lib")
                        {
                            DefaultLibraries.Add(s.ReadString());
                        }
                    }

                    s.Close();
                    break;

                case "Includes":
                    s = x.ReadSubtree();

                    while (s.Read())
                    {
                        if (s.LocalName == "Path")
                        {
                            IncludePaths.Add(s.ReadString());
                        }
                    }

                    s.Close();
                    break;

                case "VersionId":
                    PredefinedVersionConstant = x.ReadString();
                    break;

                case "CompilerCommand":
                    SourceCompilerCommand = x.ReadString();
                    break;

                case "Patterns":
                    s = x.ReadSubtree();
                    ArgumentPatterns.ReadFrom(s);
                    s.Close();
                    break;

                case "gdcLibPrefixing":
                    EnableGDCLibPrefixing = x.ReadString() == "true";
                    break;
                }
            }
        }
Esempio n. 31
0
        public void Read(XmlReader reader)
        {
            reader.Read();

            reader.ReadStartElement("MetasequoiaDocument");

            reader.ReadStartElement("IncludedBy");
            string mqo_file = reader.ReadString();

            Console.WriteLine(mqo_file);
            reader.ReadEndElement();//IncludedBy

            reader.ReadStartElement("Plugin.56A31D20.71F282AB");
            reader.ReadStartElement("BoneSet");
            int len = 255;

            bones = new MqoBone[len];
            int i = 0;

            while (reader.IsStartElement("Bone"))
            {
                MqoBone bone = new MqoBone(i);
                bone.Read(reader);
                this.bones[i++] = bone;
            }
            reader.ReadEndElement();//BoneSet

            len = i;
            Array.Resize(ref bones, len);

            CreateBoneMap();
            CreateBoneTurnedMap();
            UpdateBones();

            while (reader.IsStartElement("Obj"))
            {
                //Console.WriteLine("Obj");
                //Console.WriteLine("  id:{0}", reader.GetAttribute("id"));
                reader.Read();//Obj
            }

            while (reader.IsStartElement("Poses"))
            {
                //Console.WriteLine("Poses");
                //Console.WriteLine("  isExist:{0}", reader.GetAttribute("isExist"));
                bool empty = reader.IsEmptyElement;
                reader.Read();//Poses
                if (empty)
                {
                    continue;
                }
                while (reader.IsStartElement("Pose"))
                {
                    //Console.WriteLine("Pose");
                    //Console.WriteLine("  id:{0}", reader.GetAttribute("id"));
                    reader.Read();       //Pose
                }
                reader.ReadEndElement(); //Poses
            }
            reader.ReadEndElement();     //Plugin.56A31D20.71F282AB
            reader.ReadEndElement();     //MetasequoiaDocument
        }
Esempio n. 32
0
        /// <summary>
        /// Get meta and file pathes from iTunes (and Winamp-Export) XML files and store that data as songs and audiofiles in the database. Overwrites existing songs.
        /// </summary>
        /// <param name="path">Path to your XML file.</param>
        public static void ReadITunesXML(string path)
        {
            XmlReaderSettings xrs = new XmlReaderSettings();

            xrs.DtdProcessing = DtdProcessing.Parse;
            List <Song>   songs      = new List <Song>();
            List <string> audiofiles = new List <string>();

            using (XmlReader xr = XmlReader.Create(path, xrs))
            {
                bool   inmeta   = false;
                ushort level    = 0; // for skipping all the shit at the beginning
                Song   tempsong = new Song();


                while (xr.Read())
                {
                    if (xr.NodeType == XmlNodeType.Element)
                    {
                        switch (xr.Name)
                        {
                        case "key":
                            if (inmeta)
                            {
                                // This is actually a line we can use. Format is <key>keyname</key><[datatype]>data</[datatype]>. Yes it's crap.
                                string keyname = xr.ReadString();
                                xr.Read();               // throw away the </key>
                                try { xr.Read(); }
                                catch (XmlException) { } // throw away the datatype element
                                string value = xr.ReadString();
                                xr.Read();               // throw away the datatype endelement
                                // Process the read stuff.
                                switch (keyname)
                                {
                                case "Name":
                                    tempsong.Title = value;
                                    break;

                                case "Artist":
                                    tempsong.Artists = value;
                                    break;

                                case "Album Artist":
                                    if (tempsong.Album == null)
                                    {
                                        tempsong.Album = new CAlbum();
                                    }
                                    tempsong.Album.AlbumArtists = value;
                                    break;

                                case "Album":
                                    if (tempsong.Album == null)
                                    {
                                        tempsong.Album = new CAlbum();
                                    }
                                    tempsong.Album.Name = value;
                                    break;

                                case "BPM":
                                    tempsong.BPM = ushort.Parse(value);
                                    break;

                                case "Genre":
                                    tempsong.Genres = value;
                                    break;

                                case "Comments":
                                    tempsong.Comment = value;
                                    break;

                                case "Composer":
                                    tempsong.Composers = value;
                                    break;

                                case "Total Time":
                                    tempsong.Length = uint.Parse(value);
                                    break;

                                case "Track Number":
                                    tempsong.TrackNr = ushort.Parse(value);
                                    break;

                                case "Track Count":
                                    if (tempsong.Album == null)
                                    {
                                        tempsong.Album = new CAlbum();
                                    }
                                    tempsong.Album.TrackCount = uint.Parse(value);
                                    break;

                                case "Year":
                                    if (tempsong.Album == null)
                                    {
                                        tempsong.Album = new CAlbum();
                                    }
                                    tempsong.Album.Year = uint.Parse(value);
                                    break;

                                case "Location":
                                    //TODO: Import locations for audiofiles or discard them? If using them, how to link to meta?
                                    break;

                                case "Rating":
                                    tempsong.Rating = (short)((short.Parse(value)) / (short)20);
                                    break;

                                case "Play Count":
                                    tempsong.PlayCount = uint.Parse(value);
                                    break;

                                case "Track ID":
                                case "Disc Number":
                                case "Disc Count":
                                case "Kind":
                                case "Size":
                                case "Date Modified":
                                case "Date Added":
                                case "Bitrate":
                                case "File Folder Count":
                                case "Library Folder Count":
                                case "Publisher":
                                case "Play Date UTC":
                                case "Has Video":
                                case "Video Width":
                                case "Video Height":
                                    break;

                                default:
                                    throw new KeyNotFoundException(keyname);
                                }
                            }
                            break;

                        case "dict":
                            if (level < 2)
                            {
                                level++;
                            }
                            else
                            {
                                inmeta   = true;
                                tempsong = new Song();
                            }
                            break;

                        case "plist":
                            break;

                        default:
                            // This is data.
                            break;
                        }
                    }
                    else if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "dict")
                    {
                        inmeta = false;
                        songs.Add(tempsong);
                    }
                }
            }
            // Insert new songs
            Startup.ActiveDB.InsertSongs(songs);
            // Split songs that have an id from those not having one (of course they have one, but it is not set in the song object yet)
            var insertedsongs = from song in songs
                                where song.id != 0
                                select song;
            var existingsongs = from song in songs
                                where song.id == 0
                                select song;

            // Those not having an id set were existing. Update them and afterwards get the ids.
            Startup.ActiveDB.UpdateSongs(existingsongs);
            existingsongs = Startup.ActiveDB.LoadSongIDs(existingsongs);
            // Merge them again
            List <Song> result = new List <Song>(insertedsongs);

            result.AddRange(existingsongs);
            // Create a pool and finish
            string strImportpool = "iTunes Import " + DateTime.Now.ToString();

            Startup.ActiveDB.CreateSongpool(strImportpool);
            Startup.ActiveDB.PutSongsInPool(result, strImportpool);
        }
Esempio n. 33
0
    // Use this for initialization
    void LoadSpellData()
    {
        loadedSpells = new Dictionary <int, Spell>();
        string fileName = Application.dataPath + "/Data/Spells.dat";

        if (File.Exists(fileName))
        {
            Debug.Log("Loading spell data from .dat file");
            BinaryFormatter format = new BinaryFormatter();
            FileStream      load   = File.Open(fileName, FileMode.Open);
            loadedSpells = (Dictionary <int, Spell>)format.Deserialize(load);
            load.Close();
            LoadLocalizedText("enUS");
        }
        else
        {
            fileName = Application.dataPath + "/Development/Spells.xml";
            XmlReader fileReader = XmlReader.Create(fileName);
            while (fileReader.Read())
            {
                if (fileReader.IsStartElement() && fileReader.Name == "spell")
                {
                    Spell newSpell = new Spell();
                    newSpell.id = int.Parse(fileReader.GetAttribute("id"));
                    fileReader.ReadToDescendant("manaCost");
                    newSpell.manaCost = int.Parse(fileReader.ReadString());
                    fileReader.ReadToNextSibling("potency");
                    newSpell.damageValue = int.Parse(fileReader.ReadString());
                    fileReader.ReadToNextSibling("range");
                    newSpell.range = int.Parse(fileReader.ReadString());
                    fileReader.ReadToNextSibling("texture");
                    newSpell.texture = fileReader.ReadString();
                    fileReader.ReadToNextSibling("cooldown");
                    newSpell.cooldown = int.Parse(fileReader.ReadString());
                    fileReader.ReadToNextSibling("ignoreGCD");
                    newSpell.ignoreGCD = bool.Parse(fileReader.ReadString());
                    fileReader.ReadToNextSibling("school");
                    newSpell.school = int.Parse(fileReader.ReadString());
                    fileReader.ReadToNextSibling("gameObject");
                    newSpell.objectPath = fileReader.ReadString();
                    if (fileReader.ReadToNextSibling("extraFlags"))
                    {
                        fileReader.ReadToDescendant("type");
                        newSpell.type = fileReader.ReadString();
                        switch (newSpell.type)
                        {
                        case "DoT":     // duration, ticks
                            fileReader.ReadToNextSibling("duration");
                            newSpell.duration = int.Parse(fileReader.ReadString());
                            fileReader.ReadToNextSibling("ticks");
                            newSpell.ticks = int.Parse(fileReader.ReadString());
                            break;

                        case "AoE":     // radius
                            fileReader.ReadToNextSibling("radius");
                            newSpell.radius = int.Parse(fileReader.ReadString());
                            break;

                        case "AoEDoT":     // duration, ticks, radius
                            fileReader.ReadToNextSibling("duration");
                            newSpell.duration = int.Parse(fileReader.ReadString());
                            fileReader.ReadToNextSibling("ticks");
                            newSpell.ticks = int.Parse(fileReader.ReadString());
                            fileReader.ReadToNextSibling("radius");
                            newSpell.radius = int.Parse(fileReader.ReadString());
                            break;
                        }
                    }
                    loadedSpells.Add(newSpell.id, newSpell);
                }
            }
            fileReader.Close();
            LoadLocalizedText("enUS"); // TODO: Store locale to be loaded via UserPref settings
            SaveSpellData();
        }
        //foreach (KeyValuePair<int, Spell> entry in loadedSpells)
        //    entry.Value.DebugPrint();
    }
        private void CreateUserTrackingLocation(XmlReader reader, UserTrackingLocation location)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == location)
                throw new ArgumentNullException("location");

            if (0 != string.Compare(reader.Name, "UserTrackingLocation", StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "UserTrackingLocation.");

            if (reader.IsEmptyElement)
                return;

            string name = null, type = null;
            bool derived = false, seenAct = false, seenArg = false;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Activity", StringComparison.Ordinal))
                            seenAct = true;
                        else if (0 == string.Compare(reader.Name, "KeyName", StringComparison.Ordinal))
                            location.KeyName = reader.ReadString();
                        else if (0 == string.Compare(reader.Name, "Argument", StringComparison.Ordinal))
                            seenArg = true;
                        else if (0 == string.Compare(reader.Name, "TypeName", StringComparison.Ordinal))
                            name = reader.ReadString();
                        else if (0 == string.Compare(reader.Name, "Type", StringComparison.Ordinal))
                            type = reader.ReadString();
                        else if (0 == string.Compare(reader.Name, "MatchDerivedTypes", StringComparison.Ordinal))
                            derived = reader.ReadElementContentAsBoolean();
                        else if (0 == string.Compare(reader.Name, "Conditions", StringComparison.Ordinal))
                            CreateConditions(reader, location.Conditions);
                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "UserTrackingLocation", StringComparison.Ordinal))
                        {
                            if (!seenAct)
                            {
                                location.ActivityType = typeof(Activity);
                                location.MatchDerivedActivityTypes = true;
                            }

                            if (!seenArg)
                            {
                                location.ArgumentType = typeof(object);
                                location.MatchDerivedArgumentTypes = true;
                            }

                            if ((null == location.ActivityType) && ((null == location.ActivityTypeName) || (0 == location.ActivityTypeName.Trim().Length)) && (null == location.ArgumentType) && ((null == location.ArgumentTypeName) || (0 == location.ArgumentTypeName.Trim().Length)))
                                throw new TrackingProfileDeserializationException(ExecutionStringManager.MissingActivityType);

                            return;
                        }
                        else if (0 == string.Compare(reader.Name, "Activity", StringComparison.Ordinal))
                        {
                            if (!seenAct)
                            {
                                location.ActivityType = typeof(Activity);
                                location.MatchDerivedActivityTypes = true;
                            }
                            else
                            {
                                if ((null != type) && (type.Trim().Length > 0))
                                    location.ActivityType = Type.GetType(type, true);
                                else
                                    location.ActivityTypeName = name;

                                location.MatchDerivedActivityTypes = derived;
                            }

                            name = null;
                            type = null;
                            derived = false;
                        }
                        else if (0 == string.Compare(reader.Name, "Argument", StringComparison.Ordinal))
                        {
                            if (!seenArg)
                            {
                                location.ArgumentType = typeof(object);
                                location.MatchDerivedArgumentTypes = true;
                            }
                            else
                            {
                                if ((null != type) && (type.Trim().Length > 0))
                                    location.ArgumentType = Type.GetType(type, true);
                                else
                                    location.ArgumentTypeName = name;

                                location.MatchDerivedArgumentTypes = derived;
                            }

                            name = null;
                            type = null;
                            derived = false;
                        }

                        break;
                }
            }
            //
            // Something bad happened
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "UserTrackingLocation.");
        }
Esempio n. 35
0
        private void Parse(XmlReader reader)
        {
            NetSparkleAppCastItem currentItem = null;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case itemNode:
                        currentItem = new NetSparkleAppCastItem()
                        {
                            AppVersionInstalled = _config.InstalledVersion,
                            AppName             = _config.ApplicationName
                        };
                        break;

                    case releaseNotesLinkNode:
                        if (currentItem != null)
                        {
                            currentItem.ReleaseNotesDSASignature = reader.GetAttribute(dsaSignature);
                            currentItem.ReleaseNotesLink         = reader.ReadString().Trim();
                        }
                        break;

                    case descriptionNode:
                        if (currentItem != null)
                        {
                            currentItem.Description = reader.ReadString().Trim();
                        }
                        break;

                    case enclosureNode:
                        if (currentItem != null)
                        {
                            currentItem.Version              = reader.GetAttribute(versionAttribute);
                            currentItem.DownloadLink         = reader.GetAttribute(urlAttribute);
                            currentItem.DownloadDSASignature = reader.GetAttribute(dsaSignature);
                        }
                        break;

                    case pubDateNode:
                        if (currentItem != null)
                        {
                            string dt = reader.ReadString().Trim();
                            try
                            {
                                currentItem.PublicationDate = DateTime.ParseExact(dt, "ddd, dd MMM yyyy HH:mm:ss zzz", System.Globalization.CultureInfo.InvariantCulture);
                            }
                            catch (FormatException ex)
                            {
                                Debug.WriteLine("netsparkle: Cannot parse item datetime " + dt + " with message " + ex.Message);
                            }
                        }
                        break;
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    switch (reader.Name)
                    {
                    case itemNode:
                        _items.Add(currentItem);
                        break;
                    }
                }
            }

            // sort versions reserve order
            _items.Sort((item1, item2) => - 1 * item1.CompareTo(item2));
        }
        private void CreateStatusEvents(XmlReader reader, IList<ActivityExecutionStatus> events)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == events)
                throw new ArgumentNullException("events");

            if (0 != string.Compare("ExecutionStatusEvents", reader.Name, StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "ExecutionStatusEvents.");

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "ExecutionStatus", StringComparison.Ordinal))
                        {
                            string status = reader.ReadString();
                            if ((null != status) && (status.Trim().Length > 0))
                            {
                                string[] names = Enum.GetNames(typeof(ActivityExecutionStatus));
                                foreach (string s in names)
                                {
                                    if (0 == string.Compare(s, status, StringComparison.Ordinal))
                                        events.Add((ActivityExecutionStatus)Enum.Parse(typeof(ActivityExecutionStatus), status));
                                }
                            }
                        }
                        //
                        // Xsd validation will catch unknown elements

                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "ExecutionStatusEvents", StringComparison.Ordinal))
                            return;
                        break;
                }
            }
            //
            // Something is funky
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "ExecutionStatusEvents.");
        }
Esempio n. 37
0
        /// <summary>
        /// Write a date.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        /// <param name="input">
        /// The input.
        /// </param>
        private static void WriteDate(AmfStreamWriter writer, XmlReader input)
        {
            double value = Convert.ToDouble(input.ReadString());

            WriteDate(writer, value);
        }
        private void CreateExtract(XmlReader reader, TrackingExtract extract)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == extract)
                throw new ArgumentNullException("extract");

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Member", StringComparison.Ordinal))
                            extract.Member = reader.ReadString();
                        else if (0 == string.Compare(reader.Name, "Annotations", StringComparison.Ordinal))
                            CreateAnnotations(reader, extract.Annotations);
                        //
                        // Xsd validation will catch unknown elements

                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, extract.GetType().Name, StringComparison.Ordinal))
                            return;
                        break;
                }
            }
            //
            // Only valid exit is on an EndElement that matches the element that is passed in.
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + extract.GetType().Name);
        }
Esempio n. 39
0
        public Red LeerXml(string Path)
        {
            var Red     = new Red();
            var Default = @"data.xml";

            try
            {
                using (XmlReader Reader = XmlReader.Create(Path ?? Default))
                {
                    while (Reader.Read())
                    {
                        if (Reader.IsStartElement())
                        {
                            switch (Reader.Name.ToString())
                            {
                            case "Config":
                                var Config = Reader.ReadString().Trim();
                                Console.WriteLine(Config);
                                var Unidades = Config.Split(';');
                                foreach (var Unidad in Unidades)
                                {
                                    if (!Double.TryParse(Unidad, out _))
                                    {
                                        return(null);
                                    }
                                }
                                if (ValidarRata(Double.Parse(Unidades[2])))
                                {
                                    return(null);
                                }
                                Red.SetConfig(Config);
                                break;

                            case "Patrones":
                                var Patrones = Reader.ReadString().Trim();
                                Console.WriteLine(Patrones);
                                var Split = Patrones.Split(' ');
                                foreach (var item in Split)
                                {
                                    var Entradas = item.Split(';');
                                    foreach (var Entrada in Entradas)
                                    {
                                        if (!Double.TryParse(Entrada, out _))
                                        {
                                            return(null);
                                        }
                                    }
                                    Red.Patrones.Add(new Patron(item.Trim()));
                                }
                                break;

                            case "Salidas":
                                var Salidas = Reader.ReadString().Trim();
                                Console.WriteLine(Salidas);
                                Split = Salidas.Split(' ');
                                foreach (var item in Split)
                                {
                                    var salidas = item.Split(';');
                                    foreach (var Salida in salidas)
                                    {
                                        if (!Double.TryParse(Salida, out _))
                                        {
                                            return(null);
                                        }
                                    }
                                    Red.Salidas.Add(new Salida(item.Trim()));
                                }
                                break;

                            case "Capas":
                                //var Capas = Reader.ReadString().Trim();
                                //Console.WriteLine(Capas);
                                //Split = Capas.Split(' ');
                                break;

                            case "Umbrales":
                                var umbral = Reader.ReadString().Trim();

                                break;

                            case "Pesos":
                                //var Pesos = Reader.ReadString().Trim();
                                //Console.WriteLine(Pesos);
                                //Split = Pesos.Split(';');
                                //foreach (var item in Split)
                                //{
                                //    if (!Double.TryParse(item, out _))
                                //    {
                                //        return null;
                                //    }
                                //    else if (ValidarPeso(Double.Parse(item)))
                                //    {
                                //        return null;
                                //    }
                                //    Red.Pesos.Valores.Add(new Peso(Double.Parse(item.Trim())));
                                //}
                                //if (EntradasVsPesos(Red.Patrones, Red.Pesos) || PatronesVsSalidas(Red.Salidas, Red.Patrones))
                                //{
                                //    return null;
                                //}
                                break;

                            case "Red":
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            return(Red);
        }
Esempio n. 40
0
        private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                // number the coloums
                int a = -1;
                foreach (DataGridViewColumn col in dataGridView1.Columns)
                {
                    col.HeaderText = a.ToString();
                    a++;
                }
            }
            catch { }
            try
            {
                // process the line type
                string option = dataGridView1[1, e.RowIndex].EditedFormattedValue.ToString();

                // new self describing log
                if (DFLog.logformat.ContainsKey(option))
                {
                    int a = 2;
                    foreach (string name in DFLog.logformat[option].FieldNames)
                    {
                        dataGridView1.Columns[a].HeaderText = name;
                        a++;
                    }
                    for (; a < dataGridView1.Columns.Count; a++)
                    {
                        dataGridView1.Columns[a].HeaderText = "";
                    }
                    return;
                }

                if (option.StartsWith("PID-"))
                {
                    option = "PID-1";
                }

                using (XmlReader reader = XmlReader.Create(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "dataflashlog.xml"))
                {
                    reader.Read();
                    reader.ReadStartElement("LOGFORMAT");
                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduPlane)
                    {
                        reader.ReadToFollowing("APM");
                    }
                    else if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduRover)
                    {
                        reader.ReadToFollowing("APRover");
                    }
                    else
                    {
                        reader.ReadToFollowing("AC2");
                    }
                    reader.ReadToFollowing(option);

                    dataGridView1.Columns[1].HeaderText = "";

                    if (reader.NodeType == XmlNodeType.None)
                    {
                        return;
                    }

                    XmlReader inner = reader.ReadSubtree();

                    inner.MoveToElement();

                    int a = 2;

                    while (inner.Read())
                    {
                        inner.MoveToElement();
                        if (inner.IsStartElement())
                        {
                            if (inner.Name.StartsWith("F"))
                            {
                                dataGridView1.Columns[a].HeaderText = inner.ReadString();
                                log.Info(a + " " + dataGridView1.Columns[a].HeaderText);
                                a++;
                            }
                        }
                    }

                    for (; a < dataGridView1.Columns.Count; a++)
                    {
                        dataGridView1.Columns[a].HeaderText = "";
                    }
                }
            }
            catch { log.Info("DGV logbrowse error"); }
        }
 public void ReadXml(XmlReader reader)
 {
     Mp3DestinationDirectory = reader.ReadString();
 }
Esempio n. 42
0
        // ProbeMatch response stub
        public WsMessage Probe(WsMessage msg)
        {
            // If Adhoc disco is turned off return null. Adhoc disco is optional with a Discovery Proxy
            if (Device.SupressAdhoc == true)
            {
                return(null);
            }

            XmlReader   reader = msg.Reader;
            WsWsaHeader header = msg.Header;

            DpwsHostedService matchedService = null;

            string wsdNamespace = m_discovery.Version.DiscoveryNamespace;

            reader.ReadStartElement("Probe", wsdNamespace);

            bool match     = true;
            bool fMatchAny = false;

            if (reader.IsStartElement("Types", wsdNamespace))
            {
                // use MoveToContent, ReadString, Read instead of ReadElementString because local namespaces are popped
                // from the stack on return.
                reader.MoveToContent();

                // Look for specified type, send probe match if any instance of any of the listed types are found
                string[] typesList = reader.ReadString().Trim().Split(' ');

                int count = typesList.Length;
                match = false;

                if (count == 0 || ((count == 1) && (typesList[0] == "")))
                {
                    fMatchAny = true;
                }

                if (count > 0 && !fMatchAny)
                {
                    for (int i = 0; i < count; i++)
                    {
                        string type = typesList[i];
                        // Parse type
                        string namespaceUri, prefix, typeName;
                        int    namespaceIndex = type.IndexOf(':');
                        if (namespaceIndex == -1)
                        {
                            namespaceUri = "";
                            typeName     = type;
                        }
                        else
                        {
                            if (namespaceIndex == type.Length - 1)
                            {
                                throw new XmlException();
                            }

                            prefix       = type.Substring(0, namespaceIndex);
                            namespaceUri = reader.LookupNamespace(prefix);

                            if (namespaceUri == null)
                            {
                                namespaceUri = prefix;
                            }

                            typeName = type.Substring(namespaceIndex + 1);
                        }

                        // Check for the dpws standard type
                        if (namespaceUri == m_version.WsdpNamespaceUri && typeName == "Device")
                        {
                            match = true;
                        }

                        // If there is a host check it
                        if (Device.Host != null)
                        {
                            if (Device.Host.ServiceNamespace.NamespaceURI == namespaceUri && Device.Host.ServiceTypeName == typeName)
                            {
                                match = true;
                            }
                        }

                        // Check for matching service
                        int servicesCount = Device.HostedServices.Count;
                        DpwsHostedService hostedService;
                        for (i = 0; i < servicesCount; i++)
                        {
                            hostedService = (DpwsHostedService)Device.HostedServices[i];
                            // Skip internal services
                            if (hostedService.ServiceTypeName == "Internal")
                            {
                                continue;
                            }

                            if (hostedService.ServiceNamespace.NamespaceURI == namespaceUri &&
                                hostedService.ServiceTypeName == typeName)
                            {
                                match          = true;
                                matchedService = hostedService;
                                break;
                            }
                        }

                        if (match)
                        {
                            break;
                        }
                    }
                }
                reader.Read(); // read the EndElement or the empty StartElement
            }

            if (reader.IsStartElement("Scopes", wsdNamespace))
            {
                reader.MoveToContent();

                // Look for specified scope.  We do not support scopes at this point, so
                // any scope will result in no matches
                // TODO: Add support for scopes?
                string[] scopeList = reader.ReadString().Trim().Split(' ');

                int count = scopeList.Length;

                if (count == 1 && scopeList[0] == "")
                {
                    count = 0;
                }

                if (count > 0)
                {
                    match     = false;
                    fMatchAny = false;
                }

                reader.Read(); // read the EndElement or the empty StartElement
            }

            // For completeness sake
            // We don't care about the rest...
            XmlReaderHelper.SkipAllSiblings(reader);
            reader.ReadEndElement(); // Probe

            if (match || fMatchAny)
            {
                return(m_discovery.ProbeMatch(msg, matchedService));
            }

            return(null);
        }
        private int ReadOldRowData(DataSet ds, ref DataTable table, ref int pos, XmlReader row)
        {
            // read table information
            if (ds != null)
            {
                table = ds.Tables.GetTable(XmlConvert.DecodeName(row.LocalName), row.NamespaceURI);
            }
            else
            {
                table = GetTable(XmlConvert.DecodeName(row.LocalName), row.NamespaceURI);
            }

            if (table == null)
            {
                row.Skip(); // need to skip this element if we dont know about it, before returning -1
                return(-1);
            }

            int    iRowDepth = row.Depth;
            string value     = null;

            value = row.GetAttribute(Keywords.ROWORDER, Keywords.MSDNS);
            if (!string.IsNullOrEmpty(value))
            {
                pos = (int)Convert.ChangeType(value, typeof(int), null);
            }

            int record = table.NewRecord();

            foreach (DataColumn col in table.Columns)
            {
                col[record] = DBNull.Value;
            }

            foreach (DataColumn col in table.Columns)
            {
                if ((col.ColumnMapping == MappingType.Element) ||
                    (col.ColumnMapping == MappingType.SimpleContent))
                {
                    continue;
                }

                if (col.ColumnMapping == MappingType.Hidden)
                {
                    value = row.GetAttribute("hidden" + col.EncodedColumnName, Keywords.MSDNS);
                }
                else
                {
                    value = row.GetAttribute(col.EncodedColumnName, col.Namespace);
                }

                if (value == null)
                {
                    continue;
                }

                col[record] = col.ConvertXmlToObject(value);
            }

            row.Read();
            SkipWhitespaces(row);

            int currentDepth = row.Depth;

            if (currentDepth <= iRowDepth)
            {
                // the node is empty
                if (currentDepth == iRowDepth && row.NodeType == XmlNodeType.EndElement)
                {
                    // read past the EndElement of the current row
                    // note: (currentDepth == iRowDepth) check is needed so we do not skip elements on parent rows.
                    row.Read();
                    SkipWhitespaces(row);
                }
                return(record);
            }

            if (table.XmlText != null)
            {
                DataColumn col = table.XmlText;
                col[record] = col.ConvertXmlToObject(row.ReadString());
            }
            else
            {
                while (row.Depth > iRowDepth)
                {
                    string     ln     = XmlConvert.DecodeName(row.LocalName);
                    string     ns     = row.NamespaceURI;
                    DataColumn column = table.Columns[ln, ns];

                    if (column == null)
                    {
                        while ((row.NodeType != XmlNodeType.EndElement) && (row.LocalName != ln) && (row.NamespaceURI != ns))
                        {
                            row.Read(); // consume the current node
                        }
                        row.Read();     // now points to the next column
                        //SkipWhitespaces(row); seems no need, just in case if we see other issue , this will be here as hint
                        continue;       // add a read here!
                    }

                    if (column.IsCustomType)
                    {
                        // if column's type is object or column type does not implement IXmlSerializable
                        bool isPolymorphism = (column.DataType == typeof(object) || (row.GetAttribute(Keywords.MSD_INSTANCETYPE, Keywords.MSDNS) != null) ||
                                               (row.GetAttribute(Keywords.TYPE, Keywords.XSINS) != null));

                        bool skipped = false;
                        if (column.Table.DataSet != null && column.Table.DataSet._udtIsWrapped)
                        {
                            row.Read(); // if UDT is wrapped, skip the wrapper
                            skipped = true;
                        }

                        XmlRootAttribute xmlAttrib = null;

                        if (!isPolymorphism && !column.ImplementsIXMLSerializable)
                        { // THIS CHECK MAY BE IS WRONG think more
                            // if does not implement IXLSerializable, need to go with XmlSerializer: pass XmlRootAttribute
                            if (skipped)
                            {
                                xmlAttrib           = new XmlRootAttribute(row.LocalName);
                                xmlAttrib.Namespace = row.NamespaceURI;
                            }
                            else
                            {
                                xmlAttrib           = new XmlRootAttribute(column.EncodedColumnName);
                                xmlAttrib.Namespace = column.Namespace;
                            }
                        }
                        // for else case xmlAttrib MUST be null
                        column[record] = column.ConvertXmlToObject(row, xmlAttrib); // you need to pass null XmlAttib here


                        if (skipped)
                        {
                            row.Read(); // if Wrapper is skipped, skip its end tag
                        }
                    }
                    else
                    {
                        int iColumnDepth = row.Depth;
                        row.Read();

                        // SkipWhitespaces(row);seems no need, just in case if we see other issue , this will be here as hint
                        if (row.Depth > iColumnDepth)
                        { //we are inside the column
                            if (row.NodeType == XmlNodeType.Text || row.NodeType == XmlNodeType.Whitespace || row.NodeType == XmlNodeType.SignificantWhitespace)
                            {
                                string text = row.ReadString();
                                column[record] = column.ConvertXmlToObject(text);

                                row.Read(); // now points to the next column
                            }
                        }
                        else
                        {
                            // <element></element> case
                            if (column.DataType == typeof(string))
                            {
                                column[record] = string.Empty;
                            }
                        }
                    }
                }
            }
            row.Read(); //now it should point to next row
            SkipWhitespaces(row);
            return(record);
        }
Esempio n. 44
0
        /// <summary>
        /// Write a string.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        /// <param name="input">
        /// The input.
        /// </param>
        private static void WriteString(AmfStreamWriter writer, XmlReader input)
        {
            string value = input.IsEmptyElement ? string.Empty : input.ReadString();

            WriteString(writer, value);
        }
Esempio n. 45
0
// </snippet1>

// <snippet2>
    public void ReadXml(XmlReader reader)
    {
        personName = reader.ReadString();
    }
        private void SetMap()
        {
            //一、设置读取器
            Stream            stream   = new FileStream(LevelPath, FileMode.Open);
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.Async            = true;
            settings.IgnoreWhitespace = true;
            XmlReader reader = XmlReader.Create(stream, settings);

            //二、生成点
            reader.ReadToFollowing("allnodes");
            while (reader.NodeType != XmlNodeType.EndElement || reader.Name != "allnodes")
            {//读取循环到结束节点为止
                reader.ReadToFollowing("id");
                int id = Convert.ToInt32(reader.ReadString());
                reader.ReadToFollowing("x");
                float x = Convert.ToSingle(reader.ReadString());
                reader.ReadToFollowing("y");
                float y = Convert.ToSingle(reader.ReadString());
                Factory.CreatNode(id, new Vector2(x, y));
                reader.ReadEndElement();
                reader.ReadEndElement();
            }
            //设置起点终点
            reader.ReadToFollowing("startnode");
            reader.Read();
            NodeDic[reader.ReadContentAsInt()].BecomeBegin();
            reader.ReadToFollowing("endnode");
            reader.Read();
            NodeDic[reader.ReadContentAsInt()].BecomeEnd();

            //三、生成链接
            while (reader.NodeType != XmlNodeType.EndElement || reader.Name != "links")
            {
                reader.ReadToFollowing("start");
                reader.Read();
                int start = reader.ReadContentAsInt();
                reader.ReadToFollowing("end");
                reader.Read();
                int end = reader.ReadContentAsInt();
                Factory.CreatLink(NodeDic[start], NodeDic[end]);
                reader.ReadEndElement();
                reader.ReadEndElement();
            }

            //四、设置敌人列表
            reader.ReadToFollowing("enemies");
            if (!reader.IsEmptyElement)
            {
                while (reader.NodeType != XmlNodeType.EndElement || reader.Name != "enemies")
                {
                    reader.ReadToFollowing("type");
                    reader.Read();
                    EnemyWaiting.Enqueue((Enemy.EnemyTypeEnum)reader.ReadContentAsInt());
                    reader.ReadEndElement();
                    reader.ReadEndElement();
                }
            }

            //五、生成既有火箭
            reader.ReadToFollowing("allarrows");
            if (!reader.IsEmptyElement)
            {
                while (reader.NodeType != XmlNodeType.EndElement || reader.Name != "allarrows")
                {
                    reader.ReadToFollowing("type");
                    reader.Read();
                    int type = reader.ReadContentAsInt();
                    reader.ReadToFollowing("x");
                    reader.Read();
                    float x = reader.ReadContentAsFloat();
                    reader.ReadToFollowing("y");
                    reader.Read();
                    float y = reader.ReadContentAsFloat();
                    reader.ReadToFollowing("direction");
                    reader.Read();
                    float   direction = reader.ReadContentAsFloat();
                    Vector2 position  = new Vector2(x, y);
                    Vector2 dVector   = new Vector2(Mathf.Cos(direction * Mathf.Deg2Rad + Mathf.PI / 2), Mathf.Sin(direction * Mathf.Deg2Rad + Mathf.PI / 2));
                    switch (type)
                    {
                    case 0:
                        Factory.CreatDrillRocket(position, dVector);
                        break;

                    case 1:
                        Factory.CreatReturnRocket(position, dVector);
                        break;
                    }

                    reader.ReadEndElement();
                    reader.ReadEndElement();
                }
            }
            //六、设置玩家可用火箭
            reader.ReadToFollowing("attackarrow");
            reader.Read();
            DrillRocketUnused = reader.ReadContentAsInt();
            reader.ReadToFollowing("returnarrow");
            reader.Read();
            ReturnRocketUnused = reader.ReadContentAsInt();
            reader.Close();
        }
Esempio n. 47
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>reads one of the feed entries at a time</summary>
        /// <param name="reader"> XmlReader positioned at the entry element</param>
        /// <returns> notifies user using event mechanism</returns>
        //////////////////////////////////////////////////////////////////////
        public void ParseEntry(XmlReader reader)
        {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }


            object localname = reader.LocalName;

            Tracing.TraceCall("Parsing atom entry");
            if (localname.Equals(this.nameTable.Entry) == false)
            {
                throw new ClientFeedException("trying to parse an atom entry, but reader is not at the right spot");
            }

            AtomEntry entry = OnCreateNewEntry();

            ParseBasicAttributes(reader, entry);


            // remember the depth of entry
            int depth = -1;

            while (NextChildElement(reader, ref depth))
            {
                localname = reader.LocalName;

                if (IsCurrentNameSpace(reader, BaseNameTable.NSAtom))
                {
                    if (localname.Equals(this.nameTable.Id))
                    {
                        entry.Id = entry.CreateAtomSubElement(reader, this) as AtomId;
                        ParseBaseLink(reader, entry.Id);
                    }
                    else if (localname.Equals(this.nameTable.Link))
                    {
                        entry.Links.Add(ParseLink(reader, entry));
                    }
                    else if (localname.Equals(this.nameTable.Updated))
                    {
                        entry.Updated = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.Published))
                    {
                        entry.Published = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.Author))
                    {
                        entry.Authors.Add(ParsePerson(reader, entry));
                    }
                    else if (localname.Equals(this.nameTable.Contributor))
                    {
                        entry.Contributors.Add(ParsePerson(reader, entry));
                    }
                    else if (localname.Equals(this.nameTable.Rights))
                    {
                        entry.Rights = ParseTextConstruct(reader, entry);
                    }
                    else if (localname.Equals(this.nameTable.Category))
                    {
                        AtomCategory category = ParseCategory(reader, entry);
                        entry.Categories.Add(category);
                    }
                    else if (localname.Equals(this.nameTable.Summary))
                    {
                        entry.Summary = ParseTextConstruct(reader, entry);
                    }
                    else if (localname.Equals(this.nameTable.Content))
                    {
                        entry.Content = ParseContent(reader, entry);
                    }
                    else if (localname.Equals(this.nameTable.Source))
                    {
                        entry.Source = entry.CreateAtomSubElement(reader, this) as AtomSource;
                        ParseSource(reader, entry.Source);
                    }
                    else if (localname.Equals(this.nameTable.Title))
                    {
                        entry.Title = ParseTextConstruct(reader, entry);
                    }
                    // all parse methods should leave the reader at the end of their element
                    reader.Read();
                }
                else if (IsCurrentNameSpace(reader, BaseNameTable.gBatchNamespace))
                {
                    // parse the google batch extensions if they are there
                    ParseBatch(reader, entry);
                }
                else
                {
                    // default extension parsing
                    ParseExtensionElements(reader, entry);
                }
            }
            OnNewAtomEntry(entry);

            return;
        }
Esempio n. 48
0
            private List <Transaction> TransactionXmlReader(Stream stream)
            {
                List <Transaction> transactionList = new List <Transaction>();

                try
                {
                    XmlReader reader = XmlReader.Create(stream);
                    var       model  = new Transaction();
                    while (reader.Read())
                    {
                        // Only detect start elements.
                        if (reader.IsStartElement())
                        {
                            // Get element name and switch on it.
                            switch (reader.Name)
                            {
                            case "Transactions":
                                break;

                            case "Transaction":
                                Transaction lastElement = transactionList.LastOrDefault();
                                if (lastElement != null)
                                {
                                    string tranId = reader["id"];
                                    if (!tranId.Equals(lastElement.TransactionId, StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        model = new Transaction
                                        {
                                            TransactionId = reader["id"],
                                            FileType      = XML,
                                            Created       = DateTime.UtcNow
                                        };
                                        transactionList.Add(model);
                                    }
                                }
                                else
                                {
                                    model = new Transaction
                                    {
                                        TransactionId = reader["id"],
                                        FileType      = XML,
                                        Created       = DateTime.UtcNow
                                    };
                                    transactionList.Add(model);
                                }
                                break;

                            case "TransactionDate":
                                model.TransactionDate = Convert.ToDateTime(reader.ReadString());
                                break;

                            case "PaymentDetails":
                                break;

                            case "Amount":
                                model.Amount = decimal.Parse(Regex.Replace(reader.ReadString(), @"[^\d.]", ""));
                                break;

                            case "CurrencyCode":
                                var  currencyCode = reader.ReadString();
                                bool isCorrect    = CurrencyCodes.Where(e => e == currencyCode).Count() == 1;
                                if (isCorrect)
                                {
                                    model.CurrencyCode = currencyCode;
                                }
                                else
                                {
                                    throw new Exception("The data is not correct");
                                }
                                break;

                            case "Status":
                                model.Status = CheckStatus(XML, reader.ReadString());
                                break;
                            }
                        }
                    }

                    return(transactionList);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
Esempio n. 49
0
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>creates an AtomContent object by parsing an xml stream</summary>
        /// <param name="reader">a XMLReader positioned correctly </param>
        /// <param name="owner">the container element</param>
        /// <returns> null or an AtomContent object</returns>
        //////////////////////////////////////////////////////////////////////
        protected AtomContent ParseContent(XmlReader reader, AtomBase owner)
        {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }


            AtomContent content = owner.CreateAtomSubElement(reader, this) as AtomContent;

            Tracing.TraceCall();
            if (content != null)
            {
                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        object localname = reader.LocalName;
                        if (localname.Equals(this.nameTable.Type))
                        {
                            content.Type = Utilities.DecodedValue(reader.Value);
                        }
                        else if (localname.Equals(this.nameTable.Src))
                        {
                            content.Src = new AtomUri(reader.Value);
                        }
                        else
                        {
                            ParseBaseAttributes(reader, content);
                        }
                    }
                }

                if (MoveToStartElement(reader))
                {
                    if (content.Type.Equals("text") ||
                        content.Type.Equals("html") ||
                        content.Type.StartsWith("text/"))
                    {
                        // if it's text it get's just the string treatment. No
                        // subelements are allowed here
                        content.Content = Utilities.DecodedValue(reader.ReadString());
                    }
                    else if (content.Type.Equals("xhtml") ||
                             content.Type.Contains("/xml") ||
                             content.Type.Contains("+xml"))
                    {
                        // do not get childlists if the element is empty. That would skip to the next element
                        if (!reader.IsEmptyElement)
                        {
                            // everything else will be nodes in the extension element list
                            // different media type. Create extension elements
                            int lvl = -1;
                            while (NextChildElement(reader, ref lvl))
                            {
                                ParseExtensionElements(reader, content);
                            }
                        }
                    }
                    else
                    {
                        // everything else SHOULD be base 64 encoded, so one big string
                        // i know the if statement could be combined with the text handling
                        // but i consider it clearer to make a 3 cases statement than combine them
                        content.Content = Utilities.DecodedValue(reader.ReadString());
                    }
                }
            }
            return(content);
        }
        public void WriteCsv()
        {
            FileStream CsvStream = File.Open(_csvFileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);

            _csvTextWriter = new StreamWriter(CsvStream);

            FileStream        XmlStream = File.Open(_xmlFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
            XmlReaderSettings Settings  = new XmlReaderSettings();

            Settings.ValidationType = ValidationType.None;
            _xmlReader = XmlReader.Create(XmlStream, Settings);
            if (_isHeaderRow)
            {
                WriteCsvHeaderRecord();
            }
            _currentParticipantRecord = new Participant();

            while (_xmlReader.Read())
            {
                if (_xmlReader.IsStartElement())
                {
                    switch (_xmlReader.LocalName)
                    {
                    case "ProvidingOrganisation":
                        _currentParticipantRecord.ProvidingOrganisation = _xmlReader.ReadString();
                        break;

                    case "FileRunDate":
                        _currentParticipantRecord.FileRunDate = _xmlReader.ReadString();
                        break;

                    case "RegionCode":
                        _currentParticipantRecord.RegionCode = _xmlReader.ReadString();
                        break;

                    case "RegionName":
                        _currentParticipantRecord.RegionName = _xmlReader.ReadString();
                        break;

                    case "AgreementID":
                        _currentParticipantRecord.AgreementID = _xmlReader.ReadString();
                        break;

                    case "ProviderProjectID":
                        _currentParticipantRecord.ProviderProjectID = _xmlReader.ReadString();
                        break;

                    case "FundingType":
                        _currentParticipantRecord.FundingType = _xmlReader.ReadString();
                        break;

                    case "ParticipantReferenceID":
                        _currentParticipantRecord.ParticipantReferenceID = _xmlReader.ReadString();
                        break;

                    case "StartDate":
                        _currentParticipantRecord.StartDate = _xmlReader.ReadString();
                        break;

                    case "Gender":
                        _currentParticipantRecord.Gender = _xmlReader.ReadString();
                        break;

                    case "DOB":
                        _currentParticipantRecord.DOB = _xmlReader.ReadString();
                        break;

                    case "Postcode":
                        _currentParticipantRecord.Postcode = _xmlReader.ReadString();
                        break;

                    case "EmploymentStatus":
                        _currentParticipantRecord.EmploymentStatus = _xmlReader.ReadString();
                        break;

                    case "UnemployedMonths":
                        _currentParticipantRecord.UnemployedMonths = _xmlReader.ReadString();
                        break;

                    case "Ethnicity":
                        _currentParticipantRecord.Ethnicity = _xmlReader.ReadString();
                        break;

                    case "Disability":
                        _currentParticipantRecord.Disability = _xmlReader.ReadString();
                        break;

                    case "QualificationHeld":
                        _currentParticipantRecord.QualificationHeld = _xmlReader.ReadString();
                        break;

                    case "InPostGradResearch":
                        _currentParticipantRecord.InPostGradResearch = _xmlReader.ReadString();
                        break;

                    case "GraduatePlacedWithSME":
                        _currentParticipantRecord.GraduatePlacedWithSME = _xmlReader.ReadString();
                        break;

                    case "LeavingDate":
                        _currentParticipantRecord.LeavingDate = _xmlReader.ReadString();
                        break;

                    case "P1P4LeavingStatus":
                        _currentParticipantRecord.P1P4LeavingStatus = _xmlReader.ReadString();
                        break;

                    case "P1P4NoQualificationGained":
                        _currentParticipantRecord.P1P4NoQualificationGained = _xmlReader.ReadString();
                        break;

                    case "P1P4QualificationGained":
                        _currentParticipantRecord.P1P4QualificationGained = _xmlReader.ReadString();
                        break;

                    case "P2P5IntoEducationOrTraining":
                        _currentParticipantRecord.P2P5IntoEducationOrTraining = _xmlReader.ReadString();
                        break;

                    case "P5GraduatePlacedWithinSMEWhoGainedEmployment":
                        _currentParticipantRecord.P5GraduatePlacedWithinSMEWhoGainedEmployment = _xmlReader.ReadString();
                        break;

                    case "P2P5NoQualificationGained":
                        _currentParticipantRecord.P2P5NoQualificationGained = _xmlReader.ReadString();
                        break;

                    case "P2P5QualificationGained":
                        _currentParticipantRecord.P2P5QualificationGained = _xmlReader.ReadString();
                        break;
                    }
                }
                else
                {
                    switch (_xmlReader.LocalName)
                    {
                    case "ProvidingOrganisation":
                    case "FileRunDate":
                        break;

                    case "Region":
                        _currentParticipantRecord.RegionCode             = "";
                        _currentParticipantRecord.RegionName             = "";
                        _currentParticipantRecord.AgreementID            = "";
                        _currentParticipantRecord.ProviderProjectID      = "";
                        _currentParticipantRecord.FundingType            = "";
                        _currentParticipantRecord.ParticipantReferenceID = "";
                        _currentParticipantRecord.StartDate                   = "";
                        _currentParticipantRecord.Gender                      = "";
                        _currentParticipantRecord.DOB                         = "";
                        _currentParticipantRecord.Postcode                    = "";
                        _currentParticipantRecord.EmploymentStatus            = "";
                        _currentParticipantRecord.UnemployedMonths            = "";
                        _currentParticipantRecord.Ethnicity                   = "";
                        _currentParticipantRecord.Disability                  = "";
                        _currentParticipantRecord.QualificationHeld           = "";
                        _currentParticipantRecord.InPostGradResearch          = "";
                        _currentParticipantRecord.GraduatePlacedWithSME       = "";
                        _currentParticipantRecord.LeavingDate                 = "";
                        _currentParticipantRecord.P1P4LeavingStatus           = "";
                        _currentParticipantRecord.P1P4NoQualificationGained   = "";
                        _currentParticipantRecord.P1P4QualificationGained     = "";
                        _currentParticipantRecord.P2P5IntoEducationOrTraining = "";
                        _currentParticipantRecord.P5GraduatePlacedWithinSMEWhoGainedEmployment = "";
                        _currentParticipantRecord.P2P5NoQualificationGained = "";
                        _currentParticipantRecord.P2P5QualificationGained   = "";
                        break;

                    case "Agreement":
                        _currentParticipantRecord.AgreementID            = "";
                        _currentParticipantRecord.ProviderProjectID      = "";
                        _currentParticipantRecord.FundingType            = "";
                        _currentParticipantRecord.ParticipantReferenceID = "";
                        _currentParticipantRecord.StartDate                   = "";
                        _currentParticipantRecord.Gender                      = "";
                        _currentParticipantRecord.DOB                         = "";
                        _currentParticipantRecord.Postcode                    = "";
                        _currentParticipantRecord.EmploymentStatus            = "";
                        _currentParticipantRecord.UnemployedMonths            = "";
                        _currentParticipantRecord.Ethnicity                   = "";
                        _currentParticipantRecord.Disability                  = "";
                        _currentParticipantRecord.QualificationHeld           = "";
                        _currentParticipantRecord.InPostGradResearch          = "";
                        _currentParticipantRecord.GraduatePlacedWithSME       = "";
                        _currentParticipantRecord.LeavingDate                 = "";
                        _currentParticipantRecord.P1P4LeavingStatus           = "";
                        _currentParticipantRecord.P1P4NoQualificationGained   = "";
                        _currentParticipantRecord.P1P4QualificationGained     = "";
                        _currentParticipantRecord.P2P5IntoEducationOrTraining = "";
                        _currentParticipantRecord.P5GraduatePlacedWithinSMEWhoGainedEmployment = "";
                        _currentParticipantRecord.P2P5NoQualificationGained = "";
                        _currentParticipantRecord.P2P5QualificationGained   = "";
                        break;

                    case "ProviderProjectReference":
                        _currentParticipantRecord.ProviderProjectID      = "";
                        _currentParticipantRecord.FundingType            = "";
                        _currentParticipantRecord.ParticipantReferenceID = "";
                        _currentParticipantRecord.StartDate                   = "";
                        _currentParticipantRecord.Gender                      = "";
                        _currentParticipantRecord.DOB                         = "";
                        _currentParticipantRecord.Postcode                    = "";
                        _currentParticipantRecord.EmploymentStatus            = "";
                        _currentParticipantRecord.UnemployedMonths            = "";
                        _currentParticipantRecord.Ethnicity                   = "";
                        _currentParticipantRecord.Disability                  = "";
                        _currentParticipantRecord.QualificationHeld           = "";
                        _currentParticipantRecord.InPostGradResearch          = "";
                        _currentParticipantRecord.GraduatePlacedWithSME       = "";
                        _currentParticipantRecord.LeavingDate                 = "";
                        _currentParticipantRecord.P1P4LeavingStatus           = "";
                        _currentParticipantRecord.P1P4NoQualificationGained   = "";
                        _currentParticipantRecord.P1P4QualificationGained     = "";
                        _currentParticipantRecord.P2P5IntoEducationOrTraining = "";
                        _currentParticipantRecord.P5GraduatePlacedWithinSMEWhoGainedEmployment = "";
                        _currentParticipantRecord.P2P5NoQualificationGained = "";
                        _currentParticipantRecord.P2P5QualificationGained   = "";
                        break;

                    case "Participant":
                        WriteCsvRecord("1");
                        //reset flag for next participant
                        _is1Written = false;
                        _currentParticipantRecord.ParticipantReferenceID = "";
                        _currentParticipantRecord.StartDate                   = "";
                        _currentParticipantRecord.Gender                      = "";
                        _currentParticipantRecord.DOB                         = "";
                        _currentParticipantRecord.Postcode                    = "";
                        _currentParticipantRecord.EmploymentStatus            = "";
                        _currentParticipantRecord.UnemployedMonths            = "";
                        _currentParticipantRecord.Ethnicity                   = "";
                        _currentParticipantRecord.Disability                  = "";
                        _currentParticipantRecord.QualificationHeld           = "";
                        _currentParticipantRecord.InPostGradResearch          = "";
                        _currentParticipantRecord.GraduatePlacedWithSME       = "";
                        _currentParticipantRecord.LeavingDate                 = "";
                        _currentParticipantRecord.P1P4LeavingStatus           = "";
                        _currentParticipantRecord.P1P4NoQualificationGained   = "";
                        _currentParticipantRecord.P1P4QualificationGained     = "";
                        _currentParticipantRecord.P2P5IntoEducationOrTraining = "";
                        _currentParticipantRecord.P5GraduatePlacedWithinSMEWhoGainedEmployment = "";
                        _currentParticipantRecord.P2P5NoQualificationGained = "";
                        _currentParticipantRecord.P2P5QualificationGained   = "";
                        break;

                    /* case "Leaver":
                     *   _currentParticipantRecord.LeavingDate = "";
                     *   _currentParticipantRecord.P1P4LeavingStatus = "";
                     *   _currentParticipantRecord.P1P4NoQualificationGained = "";
                     *   _currentParticipantRecord.P1P4QualificationGained = "";
                     *   _currentParticipantRecord.P2P5IntoEducationOrTraining = "";
                     *   _currentParticipantRecord.P5GraduatePlacedWithinSMEWhoGainedEmployment = "";
                     *   _currentParticipantRecord.P2P5NoQualificationGained = "";
                     *   _currentParticipantRecord.P2P5QualificationGained = "";
                     *   break;
                     * case "P1P4Leaver":
                     *   _currentParticipantRecord.P1P4LeavingStatus = "";
                     *   _currentParticipantRecord.P1P4NoQualificationGained = "";
                     *   _currentParticipantRecord.P1P4QualificationGained = "";
                     *   break;
                     * case "P2P5Leaver":
                     *   _currentParticipantRecord.P2P5IntoEducationOrTraining = "";
                     *   _currentParticipantRecord.P5GraduatePlacedWithinSMEWhoGainedEmployment = "";
                     *   _currentParticipantRecord.P2P5NoQualificationGained = "";
                     *   _currentParticipantRecord.P2P5QualificationGained = "";
                     *   break;*/
                    case "ESFP1P4Qualification":
                        WriteCsvRecord("2");
                        _currentParticipantRecord.P1P4QualificationGained = "";
                        break;

                    case "ESFP2P5Qualification":
                        WriteCsvRecord("3");
                        _currentParticipantRecord.P2P5QualificationGained = "";
                        break;
                    }
                }
            }
            _xmlReader.Close();
            _csvTextWriter.Close();
            XmlStream.Close();
            CsvStream.Close();
        }
Esempio n. 51
0
        VertexWeight ParseVertexWeight(XmlReader xml)
        {
            VertexWeight w = new VertexWeight();

            List<int> bones = new List<int>();
            List<float> weights = new List<float>();

            int subDepth = xml.Depth;
            while (xml.Read() && xml.Depth > subDepth)
            {
                if (xml.IsStartElement() && !xml.IsEmptyElement)
                {
                    if (xml.Name == "Value")
                    {
                        int id = int.Parse(xml.GetAttribute("BoneID"));
                        float weight = float.Parse(xml.ReadString());

                        bones.Add(id);
                        weights.Add(weight);
                    }
                }
            }

            w.BoneID = bones.ToArray();
            w.Weight = weights.ToArray();
            return w;
        }
Esempio n. 52
0
        public override object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute xmlAttrib)
        {
            object retValue      = null;
            bool   isBaseCLRType = false;
            bool   legacyUDT     = false; // in 1.0 and 1.1 we used to call ToString on CDT obj. so if we have the same case

            // we need to handle the case when we have column type as object.
            if (null == xmlAttrib)
            { // this means type implements IXmlSerializable
                Type   type     = null;
                string typeName = xmlReader.GetAttribute(Keywords.MSD_INSTANCETYPE, Keywords.MSDNS);
                if (typeName == null || typeName.Length == 0)
                {                                                                               // No CDT polumorphism
                    string xsdTypeName = xmlReader.GetAttribute(Keywords.TYPE, Keywords.XSINS); // this xsd type: Base type polymorphism
                    if (null != xsdTypeName && xsdTypeName.Length > 0)
                    {
                        string[] _typename = xsdTypeName.Split(':');
                        if (_typename.Length == 2)
                        { // split will return aray of size 1 if ":" is not there
                            if (xmlReader.LookupNamespace(_typename[0]) == Keywords.XSDNS)
                            {
                                xsdTypeName = _typename[1]; // trim the prefix and just continue with
                            }
                        } // for other case, let say we have two ':' in type, the we throws (as old behavior)
                        type          = XSDSchema.XsdtoClr(xsdTypeName);
                        isBaseCLRType = true;
                    }
                    else if (_dataType == typeof(object))
                    {                     // there is no Keywords.MSD_INSTANCETYPE and no Keywords.TYPE
                        legacyUDT = true; // see if our type is object
                    }
                }

                if (legacyUDT)
                { // if Everett UDT, just read it and return string
                    retValue = xmlReader.ReadString();
                }
                else
                {
                    if (typeName == Keywords.TYPEINSTANCE)
                    {
                        retValue = Type.GetType(xmlReader.ReadString());
                        xmlReader.Read(); // need to move to next node
                    }
                    else
                    {
                        if (null == type)
                        {
                            type = (typeName == null) ? _dataType : DataStorage.GetType(typeName);
                        }

                        if (type == typeof(char) || type == typeof(Guid))
                        { //msdata:char and msdata:guid imply base types.
                            isBaseCLRType = true;
                        }

                        if (type == typeof(object))
                        {
                            throw ExceptionBuilder.CanNotDeserializeObjectType();
                        }
                        if (!isBaseCLRType)
                        {
                            retValue = System.Activator.CreateInstance(type, true);
                            Debug.Assert(xmlReader is DataTextReader, "Invalid DataTextReader is being passed to customer");
                            ((IXmlSerializable)retValue).ReadXml(xmlReader);
                        }
                        else
                        {  // Process Base CLR type
                           // for Element Node, if it is Empty, ReadString does not move to End Element; we need to move it
                            if (type == typeof(string) && xmlReader.NodeType == XmlNodeType.Element && xmlReader.IsEmptyElement)
                            {
                                retValue = string.Empty;
                            }
                            else
                            {
                                retValue = xmlReader.ReadString();
                                if (type != typeof(byte[]))
                                {
                                    retValue = SqlConvert.ChangeTypeForXML(retValue, type);
                                }
                                else
                                {
                                    retValue = Convert.FromBase64String(retValue.ToString());
                                }
                            }
                            xmlReader.Read();
                        }
                    }
                }
            }
            else
            {
                XmlSerializer deserializerWithRootAttribute = ObjectStorage.GetXmlSerializer(_dataType, xmlAttrib);
                retValue = deserializerWithRootAttribute.Deserialize(xmlReader);
            }
            return(retValue);
        }
        private void CreateActivityTrackingLocation(XmlReader reader, ActivityTrackingLocation location)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == location)
                throw new ArgumentNullException("location");

            if (0 != string.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "ActivityTrackingLocation.");

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "TypeName", StringComparison.Ordinal))
                        {
                            if (null != location.ActivityType)
                                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidType);

                            location.ActivityTypeName = reader.ReadString();
                        }
                        else if (0 == string.Compare(reader.Name, "Type", StringComparison.Ordinal))
                        {
                            if (null != location.ActivityTypeName)
                                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidType);

                            if (!reader.IsEmptyElement)
                            {
                                //
                                // Schema validation will catch empty elements, just make sure
                                // we don't pass GetType a null or empty string and continue.
                                string type = reader.ReadString();
                                if ((null != type) && (type.Trim().Length > 0))
                                    location.ActivityType = Type.GetType(type, true);
                            }
                        }
                        else if (0 == string.Compare(reader.Name, "MatchDerivedTypes", StringComparison.Ordinal))
                            location.MatchDerivedTypes = reader.ReadElementContentAsBoolean();
                        else if (0 == string.Compare(reader.Name, "ExecutionStatusEvents", StringComparison.Ordinal))
                            CreateStatusEvents(reader, location.ExecutionStatusEvents);
                        else if (0 == string.Compare(reader.Name, "Conditions", StringComparison.Ordinal))
                            CreateConditions(reader, location.Conditions);
                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal))
                        {
                            //
                            // If we don't have a type or name create the Activity type to track all activities
                            if ((null == location.ActivityType) && (null == location.ActivityTypeName))
                            {
                                location.ActivityType = typeof(Activity);
                                location.MatchDerivedTypes = true;
                            }

                            return;
                        }
                        break;
                }
            }
            //
            // Something bad happened
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "ActivityTrackingLocation.");
        }
        public void ReadXml(XmlReader reader)
        {
            Utility.Code.Require(reader, "reader");

            string extension = reader.GetAttribute(Xml.Type);

            if (!string.IsNullOrEmpty(extension))
            {
                this.ExtensionType = new Regex(extension);
            }

            reader.ReadStartElement();

            reader.ConsumeUntilFirst(XmlReaderHelper.ElementFilter);

            string name = reader.Name;

            if ((name == Xml.DiscoveryCommandLine) || (name == Xml.DiscoveryFileMap))
            {
                this.DiscoveryMethodType = (DiscoveryMethodType)Enum.Parse(typeof(DiscoveryMethodType), name);

                bool empty = reader.IsEmptyElement;

                reader.ReadStartElement();
                if (name == Xml.DiscoveryCommandLine)
                {
                    empty = false;
                    this.DiscoveryCommandLine = CommandLine.FromString(reader.ReadString());
                }
                else if (name == Xml.DiscoveryFileMap)
                {
                    reader.ConsumeUntilFirst(XmlReaderHelper.ElementFilter);
                    while (reader.NodeType == XmlNodeType.Element)
                    {
                        string key = reader.GetAttribute(Xml.DiscoveryFileMapSource);

                        reader.MoveToElement();
                        empty = reader.IsEmptyElement;
                        reader.ReadStartElement();

                        this.DiscoveryFileMap[key] = (empty) ? string.Empty : reader.ReadString();

                        if (!empty)
                        {
                            reader.ReadEndElement();
                        }

                        reader.ConsumeUntilFirst(XmlReaderHelper.ElementFilter);
                    }
                }

                if (!empty)
                {
                    reader.ReadEndElement();
                }

                reader.ConsumeUntilFirst(XmlReaderHelper.ElementFilter);
            }

            this.ExecutionCommandLine = CommandLine.FromString(reader.ReadElementString(Xml.ExecutionCommandLine));

            reader.ReadEndElement();
        }
        private void CreateWorkflowTrackPoint(XmlReader reader, TrackingProfile profile)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == profile)
                throw new ArgumentNullException("profile");

            if (0 != string.Compare(reader.Name, "WorkflowTrackPoint", StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "WorkflowTrackPoint.");

            if (reader.IsEmptyElement)
                return;

            WorkflowTrackPoint point = new WorkflowTrackPoint();
            point.MatchingLocation = new WorkflowTrackingLocation();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Annotations", StringComparison.Ordinal))
                            CreateAnnotations(reader, point.Annotations);
                        else if (0 == string.Compare(reader.Name, "TrackingWorkflowEvent", StringComparison.Ordinal))
                            point.MatchingLocation.Events.Add((TrackingWorkflowEvent)Enum.Parse(typeof(TrackingWorkflowEvent), reader.ReadString()));
                        //
                        // Xsd validation will catch unknown elements
                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "WorkflowTrackPoint", StringComparison.Ordinal))
                        {
                            profile.WorkflowTrackPoints.Add(point);
                            return;
                        }
                        break;
                }
            }
            //
            // Only valid exit is on an EndElement that matches the element that is passed in.
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "WorkflowTrackPoint.");
        }
Esempio n. 56
0
        public Stream CreateZugFerdXML()
        {
            //Create ZugFerd Invoice
            ZugFerdInvoice invoice = new ZugFerdInvoice("2058557939", new DateTime(2013, 6, 5), CurrencyCodes.USD);

            //Set ZugFerdProfile to ZugFerdInvoice
            invoice.Profile = ZugFerdProfile.Basic;

            //Add buyer details
            invoice.Buyer = new UserDetails
            {
                ID          = "Abraham_12",
                Name        = "Abraham Swearegin",
                ContactName = "Swearegin",
                City        = "United States, California",
                Postcode    = "9920",
                Country     = CountryCodes.US,
                Street      = "9920 BridgePointe Parkway"
            };

            //Add seller details
            invoice.Seller = new UserDetails
            {
                ID          = "Adventure_123",
                Name        = "AdventureWorks",
                ContactName = "Adventure support",
                City        = "Austin,TX",
                Postcode    = "",
                Country     = CountryCodes.US,
                Street      = "800 Interchange Blvd"
            };
            Stream xmlStream = typeof(ZugFerd).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.InvoiceProductList.xml");
            float  total     = 0;

            using (XmlReader reader = XmlReader.Create(xmlStream))
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        reader.Name.ToString();

                        Product product = new Product();


                        switch (reader.Name.ToString())
                        {
                        case "Productid":
                            product.ProductID = reader.ReadString();
                            break;

                        case "Product":
                            product.productName = reader.ReadString();
                            break;

                        case "Price":
                            product.Price = float.Parse(reader.ReadString(), System.Globalization.CultureInfo.InvariantCulture);
                            break;

                        case "Quantity":
                            product.Quantity = float.Parse(reader.ReadString(), System.Globalization.CultureInfo.InvariantCulture);
                            break;

                        case "Total":
                            product.Total = float.Parse(reader.ReadString(), System.Globalization.CultureInfo.InvariantCulture);
                            total        += product.Total;
                            invoice.AddProduct(product.ProductID, product.productName, product.Price, product.Quantity, product.Total);
                            break;
                        }
                    }
                }
            }

            invoice.TotalAmount = total;

            MemoryStream ms = new MemoryStream();

            //Save ZugFerd Xml
            return(invoice.Save(ms));
        }
        private void CreateCondition(XmlReader reader, TrackingCondition condition)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == condition)
                throw new ArgumentNullException("condition");

            if (0 != string.Compare(condition.GetType().Name, reader.Name, StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + condition.GetType().Name);

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Member", StringComparison.Ordinal))
                        {
                            condition.Member = reader.ReadString();
                        }
                        else if (0 == string.Compare(reader.Name, "Operator", StringComparison.Ordinal))
                        {
                            string op = reader.ReadString();
                            if ((null != op) && (op.Trim().Length > 0))
                            {
                                string[] names = Enum.GetNames(typeof(ComparisonOperator));
                                foreach (string s in names)
                                {
                                    if (0 == string.Compare(s, op, StringComparison.Ordinal))
                                        condition.Operator = (ComparisonOperator)Enum.Parse(typeof(ComparisonOperator), op);
                                }
                            }
                        }
                        else if (0 == string.Compare(reader.Name, "Value", StringComparison.Ordinal))
                        {
                            if (!reader.IsEmptyElement)
                                condition.Value = reader.ReadString();
                        }
                        //
                        // Xsd validation will catch unknown elements

                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, condition.GetType().Name, StringComparison.Ordinal))
                            return;
                        break;
                }
            }
            //
            // Only valid exit is on an EndElement that matches the element that is passed in.
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + condition.GetType().Name);
        }
Esempio n. 58
0
        public ICustomXmlSerializer ReadFrom(XmlReader x)
        {
            if (!x.Read())
            {
                return(this);
            }

            while (x.Read())
            {
                switch (x.LocalName)
                {
                case "DefaultCompiler":
                    if (x.MoveToAttribute("Name"))
                    {
                        DefaultCompiler = x.ReadContentAsString();
                    }
                    else
                    {
                        DefaultCompiler = x.ReadString();
                    }
                    break;

                case "Compiler":
                    var vendor = "";

                    if (x.MoveToAttribute("Name"))
                    {
                        vendor = x.ReadContentAsString();

                        x.MoveToElement();
                    }

                    var cmp = GetCompiler(vendor) ?? new DCompilerConfiguration(vendor);

                    cmp.ReadFrom(x.ReadSubtree());

                    Compilers.Add(cmp);
                    break;

                case "ResCmp":
                    Win32ResourceCompiler.Instance.Load(x.ReadSubtree());
                    break;

                case "DDocBaseUrl":
                    MonoDevelop.D.Refactoring.DDocumentationLauncher.DigitalMarsUrl = x.ReadString();
                    break;

                case "DocumentOutline":
                    x.MoveToAttribute("ShowParameters");
                    Outline.ShowFuncParams = Boolean.Parse(x.ReadContentAsString());
                    x.MoveToAttribute("ShowVariables");
                    Outline.ShowFuncVariables = Boolean.Parse(x.ReadContentAsString());
                    x.MoveToAttribute("ShowTypes");
                    Outline.ShowTypes = Boolean.Parse(x.ReadContentAsString());
                    x.MoveToAttribute("GrayOutNonPublic");
                    Outline.GrayOutNonPublic = Boolean.Parse(x.ReadContentAsString());
                    x.MoveToAttribute("ExpandTree");
                    Outline.ExpandAll = Boolean.Parse(x.ReadContentAsString());
                    break;

                case "CompletionOptions":
                    CompletionOptions.Load(x.ReadSubtree());
                    break;
                }
            }

            return(this);
        }
        private void CreateAnnotations(XmlReader reader, TrackingAnnotationCollection annotations)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == annotations)
                throw new ArgumentNullException("annotations");

            if (0 != string.Compare(reader.Name, "Annotations", StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "Annotations.");

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Annotation", StringComparison.Ordinal))
                        {
                            //
                            // Preserve null and empty as distinct values
                            // null == <Annotation /> empty string = <Annotation></Annotation>
                            if (!reader.IsEmptyElement)
                                annotations.Add(reader.ReadString());
                            else
                                annotations.Add(null);
                        }
                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "Annotations", StringComparison.Ordinal))
                            return;
                        break;
                }
            }
            //
            // Only valid exit is on an EndElement that matches the element that is passed in.
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "Annotations.");
        }
Esempio n. 60
0
    public override void ReadXml(XmlReader reader)
    {
        int num = reader.ReadVersionAttribute();

        this.GUID          = reader.GetAttribute <ulong>("GUID");
        this.ArmyPillaging = reader.GetAttribute <ulong>("ArmyPillaging");
        base.ReadXml(reader);
        string text = reader.GetAttribute("PointOfInterestTemplateName");

        reader.ReadStartElement("PointOfInterestDefinition");
        this.PointOfInterestDefinition = new PointOfInterestDefinition();
        if (text == "QuestLocation_SunkenRuin")
        {
            text = "NavalQuestLocation_SunkenRuin";
        }
        IDatabase <PointOfInterestTemplate> database = Databases.GetDatabase <PointOfInterestTemplate>(true);

        this.PointOfInterestDefinition.PointOfInterestTemplateName = text;
        this.PointOfInterestDefinition.PointOfInterestTemplate     = database.GetValue(text);
        this.PointOfInterestDefinition.WorldPosition = reader.ReadElementSerializable <WorldPosition>();
        int attribute = reader.GetAttribute <int>("Count");

        reader.ReadStartElement("Overrides");
        for (int i = 0; i < attribute; i++)
        {
            string attribute2 = reader.GetAttribute("Key");
            string attribute3 = reader.GetAttribute("Value");
            this.PointOfInterestDefinition.Overrides.Add(attribute2, attribute3);
        }
        reader.ReadEndElement("Overrides");
        reader.ReadEndElement("PointOfInterestDefinition");
        this.Interaction.Bits = reader.GetAttribute <int>("Bits");
        int attribute4 = reader.GetAttribute <int>("InteractionLockCount");

        reader.ReadStartElement("Interaction");
        for (int j = 0; j < attribute4; j++)
        {
            int attribute5 = reader.GetAttribute <int>("Key");
            int attribute6 = reader.GetAttribute <int>("ValueCount");
            reader.ReadStartElement("InteractionLock");
            for (int k = 0; k < attribute6; k++)
            {
                string attribute7 = reader.GetAttribute <string>("Key");
                int    attribute8 = reader.GetAttribute <int>("Value");
                reader.ReadStartElement("Value");
                if (!this.Interaction.InteractionLockCount.ContainsKey(attribute5))
                {
                    this.Interaction.InteractionLockCount.Add(attribute5, new Dictionary <string, int>());
                }
                this.Interaction.InteractionLockCount[attribute5].Add(attribute7, attribute8);
                reader.ReadEndElement("Value");
            }
            reader.ReadEndElement("InteractionLock");
        }
        reader.ReadEndElement("Interaction");
        string text2 = reader.ReadElementString("PointOfInterestImprovement");

        if (!string.IsNullOrEmpty(text2))
        {
            IDatabase <DepartmentOfIndustry.ConstructibleElement> database2 = Databases.GetDatabase <DepartmentOfIndustry.ConstructibleElement>(true);
            DepartmentOfIndustry.ConstructibleElement             pointOfInterestImprovement = null;
            if (database2.TryGetValue(text2, out pointOfInterestImprovement))
            {
                this.PointOfInterestImprovement = pointOfInterestImprovement;
                if (this.PointOfInterestImprovement != null)
                {
                    for (int l = 0; l < this.PointOfInterestImprovement.Descriptors.Length; l++)
                    {
                        if (!base.SimulationObject.Tags.Contains(this.PointOfInterestImprovement.Descriptors[l].Name))
                        {
                            base.AddDescriptor(this.PointOfInterestImprovement.Descriptors[l], false);
                        }
                    }
                }
            }
            reader.ReadEndElement("PointOfInterestImprovement");
        }
        if (reader.IsStartElement("AffinityMapping"))
        {
            this.AffinityMapping = reader.ReadElementString("AffinityMapping");
        }
        this.QuestStepsUsedBy.Clear();
        if (reader.IsStartElement("QuestStepsUsedBy"))
        {
            int attribute9 = reader.GetAttribute <int>("QuestStepsCount");
            reader.ReadStartElement("QuestStepsUsedBy");
            for (int m = 0; m < attribute9; m++)
            {
                this.QuestStepsUsedBy.Add(reader.ReadString());
            }
            reader.ReadEndElement("QuestStepsUsedBy");
        }
        if (num < 2 && this.Type == Fortress.Citadel)
        {
            base.RemoveDescriptorByType("CitadelType");
            IDatabase <DepartmentOfIndustry.ConstructibleElement> database3 = Databases.GetDatabase <DepartmentOfIndustry.ConstructibleElement>(true);
            DepartmentOfIndustry.ConstructibleElement             pointOfInterestImprovement2 = null;
            if (database3.TryGetValue(this.PointOfInterestDefinition.PointOfInterestTemplate.Properties["Improvement"], out pointOfInterestImprovement2))
            {
                this.PointOfInterestImprovement = pointOfInterestImprovement2;
                if (this.PointOfInterestImprovement != null)
                {
                    for (int n = 0; n < this.PointOfInterestImprovement.Descriptors.Length; n++)
                    {
                        if (!base.SimulationObject.Tags.Contains(this.PointOfInterestImprovement.Descriptors[n].Name))
                        {
                            base.AddDescriptor(this.PointOfInterestImprovement.Descriptors[n], false);
                        }
                    }
                }
            }
        }
        if (num >= 3)
        {
            this.UntappedDustDeposits = reader.ReadElementString <bool>("UntappedDustDeposits");
        }
        if (num >= 4)
        {
            string text3 = reader.ReadElementString("CreepingNodeImprovement");
            if (!string.IsNullOrEmpty(text3))
            {
                IDatabase <CreepingNodeImprovementDefinition> database4 = Databases.GetDatabase <CreepingNodeImprovementDefinition>(true);
                CreepingNodeImprovementDefinition             creepingNodeImprovement = null;
                if (database4.TryGetValue(text3, out creepingNodeImprovement))
                {
                    this.CreepingNodeImprovement = creepingNodeImprovement;
                    if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools && this.CreepingNodeImprovement != null)
                    {
                        for (int num2 = 0; num2 < this.CreepingNodeImprovement.Descriptors.Length; num2++)
                        {
                            if (base.SimulationObject.Tags.Contains(this.CreepingNodeImprovement.Descriptors[num2].Name))
                            {
                                base.RemoveDescriptor(this.CreepingNodeImprovement.Descriptors[num2]);
                            }
                        }
                    }
                }
            }
            this.CreepingNodeGUID = reader.ReadElementString <ulong>("CreepingNodeGUID");
        }
    }