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


C# StringReader.Close方法代码示例

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


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

示例1: Page_Load

    /// <summary>
    /// Default method, that gets called upon loading the page.
    /// </summary>
    /// <param name="sender">object that invoked this method</param>
    /// <param name="e">Event arguments</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        this.notificationDetailsFile = ConfigurationManager.AppSettings["notificationDetailsFile"];
        if (string.IsNullOrEmpty(this.notificationDetailsFile))
        {
            this.notificationDetailsFile = @"~\\notificationDetailsFile.txt";
        }
        Stream inputstream = Request.InputStream;
        int streamLength = Convert.ToInt32(inputstream.Length);
        byte[] stringArray = new byte[streamLength];
        inputstream.Read(stringArray, 0, streamLength);

        //string xmlString = System.Text.Encoding.UTF8.GetString(stringArray);
        string xmlString ="<?xml version=\"1.0\" encoding=\"UTF-8\"?><ownershipEvent type=\"grant\" timestamp=\"2014-07-17T23:01:30+00:00\"><networkOperatorId>cingularmi</networkOperatorId><ownerIdentifier>T_NWS_PNW_1351286778000105651482</ownerIdentifier><purchaseDate>2014-07-17T23:01:19+00:00</purchaseDate><productIdentifier>Onetime_Cat3</productIdentifier><purchaseActivityIdentifier>SYusvaaFefcszswDAqAzY2LEVSMZ698NXjI5</purchaseActivityIdentifier><instanceIdentifier>dcce5466-2548-4fb7-b907-f16ab49ffb81-CSHARPUAT</instanceIdentifier><minIdentifier>2067472099</minIdentifier><sequenceNumber>6798</sequenceNumber><reasonCode>0</reasonCode><reasonMessage>Processed Normally</reasonMessage><vendorPurchaseIdentifier>CThuJul172014230053</vendorPurchaseIdentifier></ownershipEvent>";
        ownershipEvent notificationObj;
        if (!String.IsNullOrEmpty(xmlString))
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(ownershipEvent));
            TextReader textReader = new StringReader(xmlString);

            notificationObj = (ownershipEvent)deserializer.Deserialize(textReader);
            textReader.Close();

            string notificationDetails = string.Empty;
            foreach (var prop in notificationObj.GetType().GetProperties())
            {
                Console.WriteLine("{0} = {1}", prop.Name, prop.GetValue(notificationObj, null));
                notificationDetails += prop.Name + "%" + prop.GetValue(notificationObj, null) + "$";
            }
            this.WriteRecord(notificationDetails);
        }
    }
开发者ID:GurjitDrish,项目名称:ATT_APIPlatform_SampleApps,代码行数:37,代码来源:Default.aspx.cs

示例2: Load

    public static ScoreHistory Load()
    {
        try
        {
            string buffer = PlayerPrefs.GetString(key);
            TextReader stReader = null;
            XmlSerializer xmlSerializer;
            try
            {
                xmlSerializer = new XmlSerializer(typeof(ScoreHistory));
                stReader = new StringReader(buffer);
                return xmlSerializer.Deserialize(stReader) as ScoreHistory;
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            finally
            {
                if (stReader != null)
                    stReader.Close();
            }

        }
        catch (Exception)
        {

        }

        return null;
    }
开发者ID:duchsoft,项目名称:igameleague_sample,代码行数:31,代码来源:UIStateManager.cs

示例3: OnHandleResponse

    public override void OnHandleResponse(OperationResponse response)
    {
        NetworkManager view = _controller.ControlledView as NetworkManager;
        view.LogDebug("GOT A RESPONSE for KNOWN Planets");
        if (response.ReturnCode == 0)
        {
            // TODO FIX THIS FOR ONLY 1 PLANET??
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.Planets].ToString());

            // Deserialize
            var xmlData = response.Parameters[(byte)ClientParameterCode.Planets].ToString();
            XmlSerializer deserializer = new XmlSerializer(typeof(XmlPlanetList));
            TextReader reader = new StringReader(xmlData);
            object obj = deserializer.Deserialize(reader);
            XmlPlanetList planetCollection = (XmlPlanetList)obj;
            reader.Close();

            // Update local data
            foreach (SanPlanet p in planetCollection.Planets) {
                var planet = PlayerData.instance.ownedPlanets.Find(x => x.starID == p.StarId && x.planetID == p.PlanetNum);
                if (planet != null)
                {
                    planet.planetpopulation = p.Population;
                }
            }              
                


        }
        else
        {
            view.LogDebug("RESPONSE: " + response.DebugMessage);
            DisplayManager.Instance.DisplayMessage(response.DebugMessage);
        }
    }
开发者ID:seanbraley,项目名称:PocketCosmos,代码行数:35,代码来源:UpdatePopulationResponseHandler.cs

示例4: getConfigMuret

    public Dictionary<string, float> getConfigMuret(string index)
    {
        Dictionary<string, float> conf = new Dictionary<string, float>();
        string fullpath = "shaders/configs/muret/" + index/* + ".txt"*/; // the file is actually ".txt" in the end

        TextAsset textAsset = (TextAsset) Resources.Load(fullpath, typeof(TextAsset));

        if(textAsset != null){
            StringReader reader = new StringReader(textAsset.text);

            if(reader != null)
            {
                string floatString = "";

                do
                {
                    floatString = reader.ReadLine();

                    if(floatString != null)
                    {
                        string szkey = floatString.Substring(0, floatString.IndexOf("="));
                        float fvalue = float.Parse(floatString.Substring(floatString.IndexOf("=") + 1));
                        conf.Add(szkey,fvalue);

                    }

                }while(floatString != null);

                reader.Close();
            }
            return conf;
        }else{
            return null;
        }
    }
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:35,代码来源:LoadShaderPresets.cs

示例5: OnHandleResponse

    public override void OnHandleResponse(OperationResponse response)
    {

        NetworkManager view = _controller.ControlledView as NetworkManager;
        view.LogDebug("GOT A RESPONSE for KNOWN STARS");
        if (response.ReturnCode == 0)
        {
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.KnownStars].ToString());

            // Deserialize
            var xmlData = response.Parameters[(byte)ClientParameterCode.KnownStars].ToString();
            XmlSerializer deserializer = new XmlSerializer(typeof(XmlStarPlayerList));
            TextReader reader = new StringReader(xmlData);
            object obj = deserializer.Deserialize(reader);
            XmlStarPlayerList starCollection = (XmlStarPlayerList)obj;
            reader.Close();

            List<KnownStar> stars = new List<KnownStar>();
            foreach (SanStarPlayer s in starCollection.StarPlayers)
                stars.Add(new KnownStar(s));

            // Update local data
            PlayerData.instance.UpdateKnownStars(stars);
        }
        else
        {
            view.LogDebug("RESPONSE: " + response.DebugMessage);
            DisplayManager.Instance.DisplayMessage(response.DebugMessage);
        }
    }
开发者ID:seanbraley,项目名称:PocketCosmos,代码行数:30,代码来源:KnownStarsResponseHandler.cs

示例6: OnHandleResponse

    public override void OnHandleResponse(OperationResponse response)
    {
        NetworkManager view = _controller.ControlledView as NetworkManager;
        if (response.ReturnCode == 0)
        {
            // TODO FIX THIS FOR ONLY 1 PLANET??
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.Planets].ToString());
            DisplayManager.Instance.DisplayMessage("Planet Colonized!");

            // Deserialize
            var xmlData = response.Parameters[(byte)ClientParameterCode.Planets].ToString();
            XmlSerializer deserializer = new XmlSerializer(typeof(XmlPlanetList));
            TextReader reader = new StringReader(xmlData);
            object obj = deserializer.Deserialize(reader);
            XmlPlanetList planetCollection = (XmlPlanetList)obj;
            reader.Close();

            // Update local data
            foreach (SanPlanet p in planetCollection.Planets)
                PlayerData.instance.AddOwnedPlanet(new OwnedPlanet(p));
        }
        else
        {
            view.LogDebug("RESPONSE: " + response.DebugMessage);
            DisplayManager.Instance.DisplayMessage(response.DebugMessage);
        }
    }
开发者ID:seanbraley,项目名称:PocketCosmos,代码行数:27,代码来源:ColonizePlanetResponseHandler.cs

示例7: NameEntered

    void NameEntered()
    {
        congratulationsUILabel.text = "";
        PlayerPrefs.SetString("name", playerName);

        StringReader reader = new StringReader(PlayerPrefs.GetString(Application.loadedLevel+"","600 IACONIC\n1200 IACONIC\n1800 IACONIC\n2400 IACONIC\n3000 IACONIC\n3600 IACONIC\n4200 IACONIC\n4800 IACONIC\n5400 IACONIC\n6000 IACONIC"));
        string output = "";
        bool counted = false;
        timeUILabel.text = "";
        nameUILabel.text = "";
        for(int i = 0; i < 10; i ++)
        {
            string input = reader.ReadLine();
            int timer = int.Parse(input.Split(' ')[0]);
            if(playTime<timer&&!counted)
            {
                timeUILabel.text += TimeToString(playTime) + "\n";
                nameUILabel.text += playerName + "\n";
                output += playTime + " " + playerName + "\n";
                i ++;
                counted = true;
            }
            timeUILabel.text += TimeToString(timer);
            nameUILabel.text += input.Split(' ')[1];
            if(i!=9)
            {
                timeUILabel.text +=  "\n";
                nameUILabel.text +=  "\n";
            }
            output += input + "\n";
        }
        reader.Close();
        PlayerPrefs.SetString(Application.loadedLevel+"",output);
    }
开发者ID:iaconic,项目名称:Crossword,代码行数:34,代码来源:Scoreboard.cs

示例8: deserialization

 public static object deserialization(object o,string xml_text)
 {
     TextReader reader;
     XmlSerializer serialRead = new XmlSerializer (o.GetType());
     reader = new StringReader(xml_text);
     o = serialRead.Deserialize (reader);
     reader.Close ();
     return o;
 }
开发者ID:umb16,项目名称:AoH_emulation,代码行数:9,代码来源:Serialize.cs

示例9: Load

	public static ItemContainer Load(string path) {
		TextAsset _xml = Resources.Load<TextAsset>(path);
		StringReader reader = new StringReader(_xml.text);
		XmlSerializer serializer = new XmlSerializer(typeof(ItemContainer));
		ItemContainer items = serializer.Deserialize(reader) as ItemContainer;
		reader.Close();

		return items;
	}
开发者ID:greengrass17,项目名称:RPG-skeleton,代码行数:9,代码来源:ItemContainer.cs

示例10: runTest

	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		String strValue = String.Empty;
		try
		{
			StringReader sr;
			strLoc = "Loc_98yg7";
			iCountTestcases++;
			try {		
                sr = new StringReader(null);
                String strTemp = sr.ReadToEnd();
				iCountErrors++;
				printerr( "Error_18syx! StringReader should only hold null");
				sr.ReadLine();
				sr.Peek();
				sr.Read();
				sr.Close();
			} catch (ArgumentNullException exc) {
				printinfo("Expected exception thrown, exc=="+exc.Message);
			}catch (Exception exc) {
				iCountErrors++;
				printerr("Error_109xu! Unexpected exception thrown, exc=="+exc.ToString());
			}
			strLoc = "Loc_4790s";
			sr = new StringReader(String.Empty);
			iCountTestcases++;
			if(!sr.ReadToEnd().Equals(String.Empty)) {
				iCountErrors++;
				printerr( "Error_099xa! Incorrect construction");
			}		   		 
			strLoc = "Loc_8388x";
			sr = new StringReader("Hello\0World");
			iCountTestcases++;
			if(!sr.ReadToEnd().Equals("Hello\0World")) {
				iCountErrors++;
				printerr( "Error_1099f! Incorrect construction");
			}
		} catch (Exception exc_general ) {			
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:56,代码来源:co5566ctor_str.cs

示例11: Parse

	protected static void Parse(string filePath, string fileName, Dictionary<string, ParseHandler> handlers) 
	{
		string 		path = string.Format("{0}/{1}", filePath, fileName);
		Debug.Log(path);
		TextAsset 	asset = (TextAsset)Resources.Load(path, typeof(TextAsset));
		TextReader 	input = new StringReader(asset.text);
		string     	aLine;
		int 		lineCurrent = 0;
		
		if (!handlers.ContainsKey(kHandlerStart) || !handlers.ContainsKey(kHandlerDone)) {
			Debug.LogError(string.Format("Handlers must include keys `{0}' and `{1}'",
			                             kHandlerStart, kHandlerDone));
			input.Close();
			return;
		}
		handlers[kHandlerStart](lineCurrent, null);
		while ((aLine = input.ReadLine()) != null) {
			string trimmedLine = aLine.Trim();
			
			// Ignore blank lines
			if (trimmedLine.Length < 1 || trimmedLine.StartsWith(kTokenComment)) {
				++lineCurrent;
				continue;
			}
			
			// Get the tokens and update the current object.
			string[] tokens = aLine.Split(kTokenDelimiters, 
			                              System.StringSplitOptions.RemoveEmptyEntries);
			string tokenType = tokens[0].Trim(kTrimCharacters);
			if (handlers.ContainsKey(tokenType)) {
				if (!handlers[tokenType](lineCurrent+1, tokens)) break;
			}
			else {
				Debug.LogError(string.Format("Unknown token type `{0}' on line {1}.",
				                             tokenType, lineCurrent+1));
				break;
			}
			
			++lineCurrent;
		}
		handlers[kHandlerDone](lineCurrent, null);
		input.Close();
	}
开发者ID:wids-eria,项目名称:tf_client,代码行数:43,代码来源:Parser.cs

示例12: Load

    public void Load()
    {
        TextAsset _xml = Resources.Load<TextAsset>(_path);
        XmlSerializer serializer = new XmlSerializer(typeof(gvmPropertiesManager));
        StringReader reader = new StringReader(_xml.text);

        _instance = serializer.Deserialize(reader) as gvmPropertiesManager;

        reader.Close();
    }
开发者ID:CalvoR,项目名称:2016_3A_Unity_Calvo_GodVSMan,代码行数:10,代码来源:gvmPropertiesManager.cs

示例13: LoadFromFile

    public static LevelData LoadFromFile(int zone, int level)
    {
        string levelFilePath = LevelUtils.GetPathForLevelLoad (zone, level);

        TextAsset textAsset = (TextAsset)Resources.Load(levelFilePath, typeof(TextAsset));
        XmlSerializer serializer = new XmlSerializer (typeof(LevelData));
        StringReader stream = new StringReader (textAsset.text);
        LevelData data = serializer.Deserialize (stream) as LevelData;
        stream.Close ();
        return data;
    }
开发者ID:brwagner,项目名称:rocket-gilbs-v2,代码行数:11,代码来源:LevelData.cs

示例14: DeserializeFromXML

    public static EmbedHandDataV1 DeserializeFromXML(string xmlData)
    {
        EmbedHandDataV1 data = null;

        StringReader stringReader = null;

        XmlSerializer deserializer = new XmlSerializer(typeof(EmbedHandDataV1));
        stringReader = new StringReader(xmlData);
        data = (EmbedHandDataV1)deserializer.Deserialize(stringReader);
        stringReader.Close();

        return data;
    }
开发者ID:yeasinmahi,项目名称:Lucid-Work,代码行数:13,代码来源:Rotate.cs

示例15: Load

    public static gvmSpellContainer Load(string path)
    {
        TextAsset _xml = Resources.Load<TextAsset>(path);

        XmlSerializer serializer = new XmlSerializer(typeof(gvmSpellContainer));
        StringReader reader = new StringReader(_xml.text);

        var data = serializer.Deserialize(reader) as gvmSpellContainer;

        reader.Close();

        return data;
    }
开发者ID:CalvoR,项目名称:2016_3A_Unity_Calvo_GodVSMan,代码行数:13,代码来源:gvmSpellContainer.cs


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