当前位置: 首页>>代码示例>>C#>>正文


C# XmlTextReader.GetAttribute方法代码示例

本文整理汇总了C#中XmlTextReader.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextReader.GetAttribute方法的具体用法?C# XmlTextReader.GetAttribute怎么用?C# XmlTextReader.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlTextReader的用法示例。


在下文中一共展示了XmlTextReader.GetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAlbumArt

    protected void GetAlbumArt(string albumId, string album, string artist)
    {
        string path = Server.MapPath(@"~/images/cover-art/");

        if(!File.Exists(path + albumId + ".png")){
            string url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=b25b959554ed76058ac220b7b2e0a026&artist=" + artist + "&album=" + album;
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                XmlTextReader reader = new XmlTextReader(response.GetResponseStream());
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "image")
                    {
                        if (reader.GetAttribute("size").Equals("large"))
                        {
                            url = reader.ReadInnerXml();

                            WebClient webClient = new WebClient();
                            webClient.DownloadFile(url, path + albumId + ".png");
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
    }
开发者ID:dantomosoiu,项目名称:MusicMachine,代码行数:32,代码来源:UploadSong.aspx.cs

示例2: selectCharGUI

    void selectCharGUI()
    {
        if (reader != null)
        {
            reader.Close();
            reader = null;
        }
        reader = new XmlTextReader(Application.dataPath + "/Resources/Characters/Characters.char");

        GUI.Label(new Rect(Screen.width * 0.125f, Screen.height * 0.05f, Screen.width * 0.75f, Screen.height * 0.05f), "Select Character...");

        Vector2 scrollPos = Vector2.zero;
        scrollPos = GUI.BeginScrollView(new Rect(Screen.width * 0.125f, Screen.height * 0.1f, Screen.width * 0.75f, Screen.height * 0.8f), scrollPos, new Rect(0, 0, Screen.width * 0.75f, 200));

        int i = 0;
        int boxHeight = 20;
        int spacing = 5;
        while(reader.Read())
        {
            XmlNodeType nType = reader.NodeType;
            if(nType == XmlNodeType.Element && reader.Name == "Character")
            {
                GUI.Box(new Rect(0, i * (boxHeight + spacing), Screen.width * 0.75f, boxHeight), "");
                GUILayout.BeginHorizontal();

                    GUI.Label(new Rect(5, i * (boxHeight + spacing), Screen.width * 0.20f, boxHeight), reader.GetAttribute("name"));
                    GUI.Label(new Rect(Screen.width * 0.25f, i * (boxHeight + spacing), Screen.width * 0.20f, boxHeight), reader.GetAttribute("subname"));

                if(GUI.Button(new Rect(Screen.width * 0.50f, i * (boxHeight + spacing), Screen.width * 0.24f, boxHeight), "Build..."))
                {
                    charSubName = reader.GetAttribute("subname");
                    string charname = reader.GetAttribute("name");
                    string file = reader.ReadInnerXml();
                    Debug.Log ("Constructing Character: " + charSubName + " " + charname + " from file " + file);
                    charToBuild = Application.dataPath + "/Resources/Characters/" + file;
                }

                GUILayout.EndHorizontal();
                i++;
            }

        }

        GUI.EndScrollView();
    }
开发者ID:gogolB,项目名称:NuGame,代码行数:45,代码来源:CharTesterGUI.cs

示例3: skipToAttribute

 // This pushes the reader forward to an element with the given name and an attrib with the given name and value.
 public static void skipToAttribute(XmlTextReader reader, string elementName, string AttribName, string attribvalue)
 {
     XmlNodeType nType = reader.NodeType;
     while(!reader.EOF)
     {
         reader.Read();
         nType = reader.NodeType;
         if(nType == XmlNodeType.Element && reader.Name == elementName && reader.GetAttribute(AttribName) == attribvalue)
             return;
     }
     Debug.LogError("Could not find " + elementName + ", with attrib " + AttribName + " with value "+ attribvalue);
     #if UNITY_EDITOR
         Debug.Break();
     #endif
 }
开发者ID:gogolB,项目名称:NuGame,代码行数:16,代码来源:Character_Factory.cs

示例4: onStartClicked

 protected void onStartClicked(object sender, System.EventArgs e)
 {
     XmlTextReader reader = new XmlTextReader ("facts.xml");
         while (!reader.EOF && reader.Name != "year"){
             reader.Read ();
         }
         label2.LabelProp = "<span font-size = 'x-large'>"+ reader.GetAttribute("id") + "</span>";
         reader.Read (); // Move from "item" to "title"
         while (reader.NodeType == XmlNodeType.Whitespace){
             reader.Read ();
         }
         textview1.Buffer.Text = reader.ReadString ();
     reader.Close();
 }
开发者ID:ksavvopoulos,项目名称:byzGame,代码行数:14,代码来源:MainWindow.cs

示例5: fileToStruct

    // This method takes a configData object and creates a config.xml file at
    // the given path out of it.
    public bool fileToStruct(string configXMLPath, ConfigData configData)
    {
        if (!File.Exists(configXMLPath))
            return false;

        using (XmlTextReader configReader = new XmlTextReader(configXMLPath))
        {
            while (configReader.Read())
            {
                if (configReader.NodeType == XmlNodeType.Element)
                {
                    // "Global" Attributes
                    string itNameAttr = "";

                    switch (configReader.Name)
                    {
                        case "ImageTarget":

                            // Parse name from config file
                            itNameAttr = configReader.GetAttribute("name");
                            if (itNameAttr == null)
                            {
                                Debug.LogWarning("Found ImageTarget without " +
                                                 "name attribute in " +
                                                 "config.xml. Image Target " +
                                                 "will be ignored.");
                                continue;
                            }

                            // Parse itSize from config file
                            Vector2 itSize = Vector2.zero;
                            string[] itSizeAttr =
                                configReader.GetAttribute("size").Split(' ');
                            if (itSizeAttr != null)
                            {
                                if (!QCARUtilities.SizeFromStringArray(
                                    out itSize, itSizeAttr))
                                {
                                    Debug.LogWarning("Found illegal itSize " +
                                                     "attribute for Image " +
                                                     "Target " + itNameAttr +
                                                     " in config.xml. " +
                                                     "Image Target will be " +
                                                     "ignored.");
                                    continue;
                                }
                            }
                            else
                            {
                                Debug.LogWarning("Image Target " + itNameAttr +
                                                 " is missing a itSize " +
                                                 "attribut in config.xml. " +
                                                 "Image Target will be " +
                                                 "ignored.");
                                continue;
                            }
                            configReader.MoveToElement();

                            ConfigData.ImageTarget imageTarget =
                                new ConfigData.ImageTarget();

                            imageTarget.size = itSize;
                            imageTarget.virtualButtons =
                                new List<ConfigData.VirtualButton>();

                            configData.SetImageTarget(imageTarget, itNameAttr);

                            break;

                        case "VirtualButton":

                            // Parse name from config file
                            string vbNameAttr =
                                configReader.GetAttribute("name");
                            if (vbNameAttr == null)
                            {
                                Debug.LogWarning("Found VirtualButton " +
                                                 "without name attribute in " +
                                                 "config.xml. Virtual Button " +
                                                 "will be ignored.");
                                continue;
                            }

                            // Parse rectangle from config file
                            Vector4 vbRectangle = Vector4.zero;
                            string[] vbRectangleAttr =
                                configReader.GetAttribute("rectangle").Split(' ');
                            if (vbRectangleAttr != null)
                            {
                                if (!QCARUtilities.RectangleFromStringArray(
                                    out vbRectangle, vbRectangleAttr))
                                {
                                    Debug.LogWarning("Found invalid " +
                                                     "rectangle attribute " +
                                                     "for Virtual Button " +
                                                     vbNameAttr +
                                                     " in config.xml. " +
                                                     "Virtual Button will " +
//.........这里部分代码省略.........
开发者ID:yonutix,项目名称:BattleTroops,代码行数:101,代码来源:ConfigParser.cs

示例6: GetCreatedWorlds

    /// <summary>
    /// Gets the created worlds.
    /// </summary>
    /// <returns>The created worlds.</returns>
    public static List<WorldSpecs> GetCreatedWorlds()
    {
        if(File.Exists(directory + "CreatedWorlds.xml"))
        {
            List<WorldSpecs> existingSpecs = new List<WorldSpecs> ();
            XmlTextReader reader = new XmlTextReader(directory + "CreatedWorlds.xml");

            while(reader.Read())
            {
                if(reader.IsStartElement() && reader.NodeType == XmlNodeType.Element)
                {
                    switch(reader.Name)
                    {
                        case "WorldSpec":
                            if(reader.AttributeCount >= 10)
                            {
                                WorldSpecs tempSpec = new WorldSpecs();
                                tempSpec.spaceName = reader.GetAttribute(0);
                                tempSpec.spaceArea = int.Parse(reader.GetAttribute(1));
                                tempSpec.mapLength = int.Parse(reader.GetAttribute(2));
                                tempSpec.cellLength = float.Parse(reader.GetAttribute(3));
                                tempSpec.start = new Vector2(float.Parse(reader.GetAttribute(4)),float.Parse(reader.GetAttribute(5)));
                                tempSpec.degreeJumpStep = float.Parse(reader.GetAttribute(6));
                                tempSpec.subdivisions = int.Parse(reader.GetAttribute(7));
                                tempSpec.totalNumberOfCells = int.Parse(reader.GetAttribute(8));
                                tempSpec.seed = int.Parse(reader.GetAttribute(9));
                                tempSpec.planetPositions = new Vector2[(reader.AttributeCount - 10) / 2];
                                if(reader.AttributeCount > 11)
                                {
                                    float maxPosition = (reader.AttributeCount - 10)/2.0f;
                                    int maxP = Mathf.CeilToInt(maxPosition);
                                    for(int i = 0, j = 0; j < maxP; j++)
                                    {
                                        tempSpec.planetPositions[j].Set(float.Parse(reader.GetAttribute(i+10)), float.Parse(reader.GetAttribute(i+11)));
                                     	i+= 2;
                                    }
                                }
                                existingSpecs.Add(tempSpec);
                            }
                            else
                            {
                                Debug.Log("Data is missing from 1 of the worlds. Not Saving it anymore");
                            }
                            break;
                        case "Root":
                            break;
                        default:
                            Debug.Log(reader.Name + " : possible invalid data in save file ignoring, please review file");
                            break;
                    }
                }
            }

            reader.Close();
            return existingSpecs;
        }
        else
        {
            return new List<WorldSpecs>(1);
        }
    }
开发者ID:Jetblacktsunami,项目名称:CSE455-Salvage,代码行数:65,代码来源:WorldGenerator.cs

示例7: readConfig

        void readConfig(string path)
        {
            int i = 0;
            int j = 0;
            int k = 0;
            uint lastZoneTemp = 10;
            uint firstZoneTemp;
            XmlTextReader reader = new XmlTextReader(path);
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.NodeType)
                        {
                            case XmlNodeType.Element:
                                reader.ReadToFollowing("expander");//Configure Expanders
                                do
                                {
                                    swampExpanderTypes[i] = reader.GetAttribute("Type");
                                    expanderIDs[i] = Convert.ToUInt16(reader.GetAttribute("ID"));

                                    if (swampExpanderTypes[i] == "swampE4")
                                    {
                                        lastZoneTemp += 4;
                                        firstZoneTemp = lastZoneTemp - 3;
                                    }
                                    else
                                    {
                                        lastZoneTemp += 8;
                                        firstZoneTemp = lastZoneTemp - 7;
                                    }
                                    expanderLastZone[i] = lastZoneTemp;
                                    expanderFirstZone[i] = firstZoneTemp;
                                    i++;
                                } while (reader.ReadToNextSibling("expander"));
                                numberOfExpanders = (ushort)i;
                                i = 0;

                                reader.ReadToFollowing("audioZone"); //Audio Zone Names & Numbers
                                do
                                {
                                    zoneNameArray[i] = reader.GetAttribute("Name");
                                    zoneNumberArray[i] = Convert.ToUInt16(reader.GetAttribute("zoneNumber"));
                                    i++;
                                    if (zoneNameArray[i] != " ")
                                    {
                                        k++;
                                    }
                                } while (reader.ReadToNextSibling("audioZone"));
                                numberOfZones = (ushort)k;

                                i = 1;
                                reader.ReadToFollowing("audioSource"); //Audio Source Names & Numbers
                                sourceNameArray[0] = "Off";
                                do
                                {
                                    sourceNameArray[i] = reader.GetAttribute("Name");
                                    i++;
                                } while (reader.ReadToNextSibling("audioSource"));

                                i = 0;
                                reader.ReadToFollowing("group");//group numbers
                                do
                                {
                                    groupNames[i] = reader.GetAttribute("Name");
                                    reader.ReadToFollowing("zone");
                                    do
                                    {
                                        UItoZone.zoneNumbersInGroups[i, j] = Convert.ToUInt16(reader.GetAttribute("zoneNumber"));//add zone numbers per floor/group
                                        j++;
                                    } while (reader.ReadToNextSibling("zone"));
                                    UItoZone.groupSizes[i] = (ushort)j;//Number of zones in groups
                                    j = 0;
                                    i++;
                                } while (reader.ReadToNextSibling("group"));
                                UItoZone.numberOfGroups = i;
                                break;
                        } break;

                    }

                }
            }
        }
开发者ID:rvanderluit,项目名称:AV,代码行数:85,代码来源:ControlSystem.cs

示例8: Button2_Click

	//
	private void Button2_Click(System.Object sender, System.EventArgs e)
	{
		verify.Visible = false;
		Button1.Visible = false;
		OpenFileDialog1.ShowDialog();
		if (string.IsNullOrEmpty(OpenFileDialog1.FileName)) {
			return;
		} else {
			spinny.Visible = true;
			Button2.Visible = false;
			Delay(1.5);
			try {
				//Parsing time baby!!!
				//Load up xml...
				XmlTextReader m_xmlr = null;
				m_xmlr = new XmlTextReader(OpenFileDialog1.FileName);
				m_xmlr.WhitespaceHandling = WhitespaceHandling.None;
				m_xmlr.Read();
				m_xmlr.Read();
				while (!m_xmlr.EOF) {
					m_xmlr.Read();
					if (!m_xmlr.IsStartElement()) {
						break; // TODO: might not be correct. Was : Exit While
					}
					dynamic iFaithAttribute = m_xmlr.GetAttribute("iFaith");
					m_xmlr.Read();
					xml_revision = m_xmlr.ReadElementString("revision");
					xml_ios = m_xmlr.ReadElementString("ios");
					xml_model = m_xmlr.ReadElementString("model");
					xml_board = m_xmlr.ReadElementString("board");
					xml_ecid = m_xmlr.ReadElementString("ecid");
					blob_logo = m_xmlr.ReadElementString("logo");
					blob_chg0 = m_xmlr.ReadElementString("chg0");
					blob_chg1 = m_xmlr.ReadElementString("chg1");
					blob_batf = m_xmlr.ReadElementString("batf");
					blob_bat0 = m_xmlr.ReadElementString("bat0");
					blob_bat1 = m_xmlr.ReadElementString("bat1");
					blob_dtre = m_xmlr.ReadElementString("dtre");
					blob_glyc = m_xmlr.ReadElementString("glyc");
					blob_glyp = m_xmlr.ReadElementString("glyp");
					blob_ibot = m_xmlr.ReadElementString("ibot");
					blob_illb = m_xmlr.ReadElementString("illb");
					if (xml_ios.Substring(0, 1) == "3") {
						blob_nsrv = m_xmlr.ReadElementString("nsrv");
					}
					blob_recm = m_xmlr.ReadElementString("recm");
					blob_krnl = m_xmlr.ReadElementString("krnl");
					xml_md5 = m_xmlr.ReadElementString("md5");
					xml_ipsw_md5 = m_xmlr.ReadElementString("ipsw_md5");
				}
				m_xmlr.Close();
			} catch (Exception Ex) {
				Interaction.MsgBox("Error while processing specified file!", MsgBoxStyle.Critical);
				spinny.Visible = false;
				Button2.Visible = true;
				return;
			}
		}

		//Were going to Check to see if this was made with a newer iFaith revision...
		if (xml_revision > MDIMain.VersionNumber) {
			Interaction.MsgBox("This iFaith SHSH Cache file was made with iFaith v" + xml_revision + Strings.Chr(13) + Strings.Chr(13) + "Please download the latest iFaith revision at http://ih8sn0w.com", MsgBoxStyle.Critical);
			spinny.Visible = false;
			Button2.Visible = true;
			return;
		}

		//Hashing time! :)
		if (MD5CalcString(blob_logo + xml_ecid + xml_revision) == xml_md5) {
			if (xml_board == "n72ap") {
				Interaction.MsgBox("iPod Touch 2G IPSW Creation is still being worked on.", MsgBoxStyle.Exclamation);
				spinny.Visible = false;
				Button2.Visible = true;
				return;
			}
			//Load IPSW Pwner...
			verify.Visible = false;
			//Hide Logo + Welcome txt...
			PictureBox1.Visible = false;
			spinny.Visible = false;
			Label1.Visible = false;
			//
			ORlabel.Visible = true;
			dl4mebtn.Visible = true;
			browse4ios.Visible = true;
			browse4ios.Text = "Browse for the " + xml_ios;
			browse4ios.ForeColor = Color.Cyan;
			browse4ios.Left = (Width / 2) - (browse4ios.Width / 2);
			if (xml_board == "n92ap") {
				Label2.Text = "IPSW for the iPhone 4 (CDMA)";
			} else {
				Label2.Text = "IPSW for the " + xml_model;
			}
			Label2.ForeColor = Color.Cyan;
			Label2.Left = (Width / 2) - (Label2.Width / 2);
			Button3.Text = "Browse for the iOS " + xml_ios + " IPSW";
			Button3.Left = (Width / 2) - (Button3.Width / 2);
			Button2.Visible = false;
			Button3.Visible = true;
//.........这里部分代码省略.........
开发者ID:bobbytdotcom,项目名称:iFaith,代码行数:101,代码来源:Welcome-ipsw.cs

示例9: LoadActor

 public void LoadActor(UIMenuItem item, int slot)
 {
     var path = GetActorFilename(slot);
     UI.Notify(String.Format("Loading actor from {0}", path));
     var reader = new XmlTextReader(path);
     while (reader.Read())
     {
         if (reader.Name == "SetPlayerModel")
         {
             ped_data.ChangePlayerModel(_pedhash[reader.GetAttribute("name")]);
         }
         else if (reader.Name == "SetSlotValue")
         {
             var key = new SlotKey(reader);
             var val = new SlotValue(reader);
             ped_data.SetSlotValue(Game.Player.Character, key, val);
         }
     }
 }
开发者ID:mcmtroffaes,项目名称:ChangingRoom,代码行数:19,代码来源:ChangingRoom.cs

示例10: start_load

    public void start_load()
    {
        click_col_blocker.SetActive (true);
        foreach (node item in nodes) {
            Destroy (item.gameObject);
        }
        nodes.Clear ();

        WWWForm wwwform = new WWWForm ();
        System.Text.Encoding encoding = new System.Text.UTF8Encoding ();
        Hashtable postHeader = new Hashtable ();
        postHeader.Add ("Content-Type", "text/json");
        int s = 10;
        postHeader.Add ("Content-Length", s);
        wwwform.AddField ("schid", (SLOT_FIELD.GetComponent<Dropdown> ().value + 1).ToString ());
        WWW www = new WWW ("http://h2385854.stratoserver.net/smartsps/get_schematic.php", wwwform);
        StartCoroutine (WaitForRequest (www));

        float t = 0.0f;
        while (!www.isDone) {
        //	Debug.Log ("Downloading XML DataSet: " + t.ToString ());
            t += Time.deltaTime;
            if (t > 60) {
                break;
            }
        }

        //		StringReader textreader = new StringReader (www.text);
        int highes_node_id = 0;
        XmlReader xml_reader = new XmlTextReader ("http://h2385854.stratoserver.net/smartsps/get_schematic.php?schid=" + (SLOT_FIELD.GetComponent<Dropdown> ().value + 1).ToString ());
        List<node_database_information> ndi = new List<node_database_information> ();
        while (xml_reader.Read()) {
            if (xml_reader.IsStartElement ("node")) {
                // get attributes from npc tag
                node_database_information tmp = new node_database_information ();
                tmp.node_id = int.Parse (xml_reader.GetAttribute ("nid"));
                if(tmp.node_id > highes_node_id){highes_node_id = tmp.node_id;}
                tmp.NSI = xml_reader.GetAttribute ("nsi");
                string pos = xml_reader.GetAttribute ("npos");
                tmp.pos_x = float.Parse (pos.Split (',') [0]);
                tmp.pos_y = float.Parse (pos.Split (',') [1]);
                tmp.node_connections = xml_reader.GetAttribute ("ncon");
                tmp.node_parameters = xml_reader.GetAttribute ("nparam");
                ndi.Add (tmp);
                //Debug.Log ("load node : " + tmp.node_id);
            }
        }

        //Debug.Log (ndi.Count + " Nodes loaded");
        id_creator.node_id_count = highes_node_id+1;
        //instanziate them
        for (int j = 0; j < ndi.Count; j++) {
            for (int i = 0; i < input_manager.GetComponent<input_connector>().nodes.Length; i++) {
                //Debug.Log(ndi[j].NSI);
                if (input_manager.GetComponent<input_connector> ().nodes [i].gameObject.GetComponent<node> ().NSI == ndi [j].NSI) {
                    GameObject tmp_to_add = input_manager.GetComponent<input_connector> ().nodes [i].gameObject;
                    tmp_to_add.GetComponent<node>().node_id = ndi [j].node_id;
                    GameObject tmp = (GameObject)Instantiate (tmp_to_add, new Vector3 (ndi [j].pos_x, ndi [j].pos_y, 0.0f), Quaternion.identity);
                    tmp.transform.SetParent (node_parent.transform);
                }
            }
        }

        float t1 = 0.0f;
        while (true) {
            //	Debug.Log ("Downloading XML DataSet: " + t.ToString ());
            t1 += Time.deltaTime;
            if (t1 > 5.0f) {
                break;
            }
        }

        //make konnections
        for (int k = 0; k < ndi.Count; k++) {
            string con_raw = ndi[k].node_connections;
            if(con_raw != ""){
            string[] con_split = con_raw.Split(trenner.ToCharArray());
            //	Debug.Log(	"123123    " + con_split.Length);
            for (int i = 0; i < con_split.Length; i++) {
                    if(con_split[i] == ""){break;}
                string[] con_att = con_split[i].Split(node_con_trenner.ToCharArray());
                int source_node_id = int.Parse (con_att[0]);
                int source_connection_position = int.Parse (con_att[1]);
                int dest_node_id = int.Parse(con_att[2]);
                int dest_connection_position = int.Parse(con_att[3]);
                Debug.Log(source_node_id + "-" + source_connection_position + " nach " + dest_node_id + "-" + dest_connection_position);
                    //source connecion suchen
                    foreach (GameObject con in GameObject.FindGameObjectsWithTag("connection")) {
                        if(con.GetComponent<node_conection>().associated_node == source_node_id && con.GetComponent<node_conection>().connection_position == source_connection_position){
                            Debug.Log("1");
                            //DEST CONNECTION SUCHEN
                            foreach (GameObject dcon in GameObject.FindGameObjectsWithTag("connection")) {
                                if(dcon.GetComponent<node_conection>().associated_node == dest_node_id && dcon.GetComponent<node_conection>().connection_position == dest_connection_position){
                                    Debug.Log("2");
                                    dcon.GetComponent<node_conection>().connection_destination_input_id = con.GetComponent<node_conection>().connection_id;
                                    dcon.GetComponent<node_conection>().redraw_curve();
                                }
                            }
                        }
                    }
//.........这里部分代码省略.........
开发者ID:RBEGamer,项目名称:SmartSPS,代码行数:101,代码来源:remote_uploader.cs

示例11: Load

	//loads all the objects in the cell
	public void Load()
	{
		if(File.Exists(fileName) && status != CellStatus.active)
		{
			if(positions.Count <= 0 && perlin.Count <= 0)
			{
				positions = new List<Vector2>();
				perlin = new List<float>();

				XmlTextReader reader = new XmlTextReader(fileName);

				while(reader.Read())
				{
					if(reader.IsStartElement() && reader.NodeType == XmlNodeType.Element)
					{
						switch(reader.Name)
						{
							case "AsteroidPosition" :
								positions.Add(new Vector2(float.Parse(reader.GetAttribute(0)), float.Parse(reader.GetAttribute(1))));
								break;

							case "PerlinValue":
								perlin.Add( float.Parse(reader.ReadElementString()));
								break;
						}
					}
				}
				reader.Close ();
			}
			children.Clear ();
			Vector2 indexes = ObjectPool.Pool.Redirect(positions, perlin, this);

			if(indexes.x >= 0 && indexes.x < positions.Count)
			{
				for(int i = (int)indexes.x, j = (int)indexes.y; i < positions.Count && j < perlin.Count; i++,j++)
				{
					GameObject asteroidOBJ = GameObject.Instantiate(Resources.Load("Asteroid/Asteroid")) as GameObject;
					asteroidOBJ.transform.parent = parent.transform;
					Asteroid temp =	asteroidOBJ.AddComponent<Asteroid>();
					temp.assignedPosition = positions[i];
					temp.perlinValue = perlin[j];
					temp.parentCell = this;
					temp.Change();
					children.Add(asteroidOBJ);
					if(ObjectPool.Pool.CanPoolMore())
					{
						ObjectPool.Pool.Register(asteroidOBJ);
					}
				}
			}
		}
	}
开发者ID:Jetblacktsunami,项目名称:CSE455-Salvage,代码行数:53,代码来源:WorldCell.cs

示例12: Read

    void Read()
    {
        XmlTextReader reader = new XmlTextReader(AssetDatabase.GetAssetPath(text));
        Rect rect;
        List<SpriteMetaData> listSprite = new List<SpriteMetaData>();
        SpriteMetaData spritedata;
        int imageHeight = texture2d.height;

        int SpriteX;
        int SpriteY;
        int SpriteWidth;
        int SpriteHeight;

        Debug.Log("do I work?");
        while (reader.Read())
        {
            if (reader.NodeType == XmlNodeType.Element)
            {
                //if (reader.Name == "SubTexture")
                Debug.Log(reader.Name);
                if (reader.Name == "ImageBrush")
                {
                    //got some info before
                    Debug.Log("0: " + reader.GetAttribute(0));
                    Debug.Log("1: " + reader.GetAttribute(1));
                    Debug.Log("2: " + reader.GetAttribute(2));
                    Debug.Log("3: " + reader.GetAttribute(3));
                    Debug.Log("4: " + reader.GetAttribute(4));

                    string[] dimensions = reader.GetAttribute(2).Split(',');

                    SpriteX = int.Parse(dimensions[0]);
                    SpriteY = int.Parse(dimensions[1]);
                    SpriteWidth = int.Parse(dimensions[2]);
                    SpriteHeight = int.Parse(dimensions[3]);

                    //SpriteY = int.Parse(reader.GetAttribute(2));
                    //spriteHeight = int.Parse(reader.GetAttribute(4));

                    //create rect of sprite
                    rect = new Rect(
                        SpriteX, //x
                        imageHeight - SpriteY - SpriteHeight, //y imageHeight - SpriteY - spriteHeight
                        SpriteWidth, //width
                        SpriteHeight //hegith
                        );

                    //init spritedata
                    spritedata = new SpriteMetaData();
                    spritedata.rect = rect;
                    spritedata.name = reader.GetAttribute(0);
                    spritedata.alignment = (int)pivot;
                    if (pivot == SpriteAlignment.Custom)
                    {
                        spritedata.pivot = customPivot;
                    }
                    //add to list
                    listSprite.Add(spritedata);
                }
            }
        }

        //was sucessfull?
        if (listSprite.Count > 0)
        {
            //import texture
            TextureImporter textImp = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture2d)) as TextureImporter;
            //add spritesheets
            textImp.spritesheet = listSprite.ToArray();
            //configure texture
            textImp.textureType = TextureImporterType.Sprite;
            textImp.spriteImportMode = SpriteImportMode.Multiple;
            //import, for forceupdate and save it
            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(texture2d), ImportAssetOptions.ForceUpdate);
            //Debug.Log("Done");
        }
        else
        {
            Debug.LogWarning("This is not a file of ShoeBox or is not a XML file");
        }
    }
开发者ID:Noesis,项目名称:noesisgui-contrib,代码行数:81,代码来源:ShoeBoxXamlReading.cs

示例13: Lista_de_utiles_Click

    protected void Lista_de_utiles_Click(object sender, EventArgs e)
    {
        FileStream fs = new FileStream(@"F:\SuperProProductList.xml",
                           FileMode.Open);
        XmlTextReader r = new XmlTextReader(fs);
        List<Lista_Utiles> listUtiles = new List<Lista_Utiles>();

        while(r.Read())
        {
            if(r.NodeType == XmlNodeType.Element && r.Name =="Lista_Utiles")
            {
                Lista_Utiles newUtiles=new Lista_Utiles();
                newUtiles.ID=Int32.Parse(r.GetAttribute(0));
                newUtiles.curso=r.GetAttribute(1);

                while (r.NodeType != XmlNodeType.EndElement)
                {
                    r.Read();
                    if (r.Name == "Creditos")
                    {
                        while (r.NodeType != XmlNodeType.EndElement)
                        {
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                newUtiles.creditos = Int32.Parse(r.Value);
                            }
                        }
                    }
                }
                listUtiles.Add(newUtiles);
            }
        }
        r.Close();
        Utiles.DataSource = listUtiles;
        Utiles.DataBind();
    }
开发者ID:iguilleng,项目名称:proyectofinal,代码行数:37,代码来源:matricula.aspx.cs

示例14: LoadSettings

    public static CamConfigData[] LoadSettings(string vsSettingsFile)
    {

        List<CamConfigData> data = new List<CamConfigData>();
        // check file existance
        if (File.Exists(vsSettingsFile))
        {
            //  VsSplasher.Status = "Load setting...";

            FileStream fs = null;
            XmlTextReader xmlIn = null;


            // open file
            fs = new FileStream(vsSettingsFile, FileMode.Open, FileAccess.Read);
            // create XML reader
            xmlIn = new XmlTextReader(fs);

            xmlIn.WhitespaceHandling = WhitespaceHandling.None;
            xmlIn.MoveToContent();

            // check for main node
            if (xmlIn.Name != "Cameras")
                throw new ApplicationException("");

            xmlIn.Read();
            if (xmlIn.NodeType == XmlNodeType.EndElement)
                xmlIn.Read();

            CamConfigData obj;

            while (xmlIn.Name == "Camera")
            {
                obj = new CamConfigData();

                obj.id = Convert.ToInt32(xmlIn.GetAttribute("id"));
                obj.name = xmlIn.GetAttribute("name");
                obj.desc = xmlIn.GetAttribute("desc");

                obj.run = Convert.ToBoolean(xmlIn.GetAttribute("run"));
                obj.analyse = Convert.ToBoolean(xmlIn.GetAttribute("analyse"));
                obj.record = Convert.ToBoolean(xmlIn.GetAttribute("record"));
                obj.events = Convert.ToBoolean(xmlIn.GetAttribute("event"));
                obj.data = Convert.ToBoolean(xmlIn.GetAttribute("data"));

                obj.provider = xmlIn.GetAttribute("provider");
                obj.source = xmlIn.GetAttribute("source");
                obj.analyzer = xmlIn.GetAttribute("analyzer");

                obj.ThresholdAlpha = Convert.ToInt32(xmlIn.GetAttribute("ThresholdAlpha"));
                obj.ThresholdSigma = Convert.ToInt32(xmlIn.GetAttribute("ThresholdSigma"));
                obj.endcoder = xmlIn.GetAttribute("encoder");

                obj.ImageWidth = Convert.ToInt32(xmlIn.GetAttribute("ImageWidth"));
                obj.ImageHeight = Convert.ToInt32(xmlIn.GetAttribute("ImageHeight"));

                obj.CodecsName = xmlIn.GetAttribute("CodecsName");
                obj.Quality = Convert.ToInt32(xmlIn.GetAttribute("Quality"));

                data.Add(obj);

                xmlIn.Read();
                if (xmlIn.NodeType == XmlNodeType.EndElement)
                    xmlIn.Read();
            }

            // close file
            xmlIn.Close();
            fs.Close();

            return data.ToArray();
        }
        else
        {
            return data.ToArray();
        }
    }
开发者ID:tdhieu,项目名称:openvss,代码行数:77,代码来源:CamConfigData.cs

示例15: Read

    /// <summary>
    /// Read cylinder parameters for all specified targets.
    /// </summary>
    /// <param name="datFile">Path to dataset-file with extension .dat</param>
    /// <param name="targetData">Cylinder targets for which the corresponding parameters should be retreived from the file.</param>
    public static void Read(string datFile, ConfigData.CylinderTargetData[] targetData)
    {
        var ci = CultureInfo.InvariantCulture;

        using (var configReader = new XmlTextReader(UnzipFile(datFile, CONFIG_XML)))
        {
            var latestDataIdx = -1;
            var indices = new Dictionary<string, int>();
            for (var i = 0; i < targetData.Length; i++)
                indices[targetData[i].name] = i;

            var latestBottomImageFile = "";
            var latestTopImageFile = "";

            while (configReader.Read())
            {
                if (configReader.NodeType == XmlNodeType.Element)
                {
                    switch (configReader.Name)
                    {
                        case CYLINDER_TARGET_ELEMENT:

                            var objname = configReader.GetAttribute(NAME_ATTRIBUTE);
                            if (objname == null || !indices.ContainsKey(objname))
                            {
                                latestDataIdx = -1;
                                continue;
                            }
                            var idx = indices[objname];
                            var data = targetData[idx];

                            var sidelengthAttr = configReader.GetAttribute(SIDELENGTH_ATTRIBUTE);
                            var topDiameterAttr = configReader.GetAttribute(TOP_DIAMETER_ATTRIBUTE);
                            var bottomDiameterAttr = configReader.GetAttribute(BOTTOM_DIAMETER_ATTRIBUTE);
                            if (sidelengthAttr == null || topDiameterAttr == null || bottomDiameterAttr == null)
                                continue;

                            var sideLength = float.Parse(sidelengthAttr, ci);
                            var scale = 1.0f;
                            if (data.sideLength > 0)
                                scale = data.sideLength/sideLength;
                            else
                                data.sideLength = sideLength;
                            data.topDiameter = scale*float.Parse(topDiameterAttr, ci);
                            data.bottomDiameter = scale*float.Parse(bottomDiameterAttr, ci);

                            latestDataIdx = idx;
                            targetData[idx] = data;

                            latestBottomImageFile = GetBottomImageFile(objname);
                            latestTopImageFile = GetTopImageFile(objname);

                            break;
                        case KEYFRAME_ELEMENT:
                            if (latestDataIdx >= 0)
                            {
                                var ldata = targetData[latestDataIdx];
                                var imgName = configReader.GetAttribute(NAME_ATTRIBUTE);

                                if (imgName == latestTopImageFile)
                                {
                                    ldata.hasTopGeometry = true;
                                }
                                else if (imgName == latestBottomImageFile)
                                {
                                    ldata.hasBottomGeometry = true;
                                }
                                targetData[latestDataIdx] = ldata;
                            }
                            break;
                    }
                }
            }
        }
    }
开发者ID:carrizofm2010,项目名称:app012-acuariotribuno,代码行数:80,代码来源:CylinderDatasetReader.cs


注:本文中的XmlTextReader.GetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。