Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void
コード例 #1
0
ファイル: Token.cs プロジェクト: rynqs/DotNetOpenAuth
		private Token(string tokenXml, Uri audience, TokenDecryptor decryptor) {
			Requires.NotNullOrEmpty(tokenXml, "tokenXml");
			Requires.True(decryptor != null || !IsEncrypted(tokenXml), null);
			Contract.Ensures(this.AuthorizationContext != null);

			byte[] decryptedBytes;
			string decryptedString;

			using (StringReader xmlReader = new StringReader(tokenXml)) {
				var readerSettings = MessagingUtilities.CreateUntrustedXmlReaderSettings();
				using (XmlReader tokenReader = XmlReader.Create(xmlReader, readerSettings)) {
					Contract.Assume(tokenReader != null); // BCL contract should say XmlReader.Create result != null
					if (IsEncrypted(tokenReader)) {
						Logger.InfoCard.DebugFormat("Incoming SAML token, before decryption: {0}", tokenXml);
						decryptedBytes = decryptor.DecryptToken(tokenReader);
						decryptedString = Encoding.UTF8.GetString(decryptedBytes);
						Contract.Assume(decryptedString != null); // BCL contracts should be enhanced here
					} else {
						decryptedBytes = Encoding.UTF8.GetBytes(tokenXml);
						decryptedString = tokenXml;
					}
				}
			}

			var stringReader = new StringReader(decryptedString);
			try {
				this.Xml = new XPathDocument(stringReader).CreateNavigator();
			} catch {
				stringReader.Dispose();
				throw;
			}

			Logger.InfoCard.DebugFormat("Incoming SAML token, after any decryption: {0}", this.Xml.InnerXml);
			this.AuthorizationContext = TokenUtility.AuthenticateToken(this.Xml.ReadSubtree(), audience);
		}
コード例 #2
0
ファイル: GetWeatherData.cs プロジェクト: Shuvayu/DevBox
        public List<string> GetAllCities(string country)
        {
            List<string> cityNames = new List<string>();

            // Creating object of WeatherService proxy class and calling GlobalWeatherSoap12 endpoint
            WeatherService.GlobalWeatherSoapClient client = new WeatherService.GlobalWeatherSoapClient("GlobalWeatherSoap12");
            // Invoke service method through service proxy
            var allCountryCities = client.GetCitiesByCountry(country);

            if (allCountryCities.ToString() == "Data Not Found")
            {
                return null;
            }

            DataSet ds = new DataSet();

            //Creating a stringReader object with Xml Data
            StringReader stringReader = new StringReader(allCountryCities);

            // Xml Data is read and stored in the DataSet object
            ds.ReadXml(stringReader);

            //Adding all city names to the List objects
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                cityNames.Add(item["City"].ToString());
            }

            stringReader.Dispose();

            return cityNames;
        }
コード例 #3
0
        public static UserInterfaceData GetData(string data)
        {
            UserInterfaceData userInterfaceData = new UserInterfaceData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/USERINTERFACES]")
                {
                    break;
                }
                else if (line == "[USERINTERFACE]")
                {
                    userInterfaceData.UserInterfaces.Add(ReadUserInterface(ref reader, ref lineNumber));
                }
            }

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

            return userInterfaceData;
        }
コード例 #4
0
        public static TriggerableData GetData(string data)
        {
            TriggerableData triggerableData = new TriggerableData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/TRIGGERABLES]")
                {
                    break;
                }
                else if (line == "[TRIGGERABLE]")
                {
                    triggerableData.Triggerables.Add(ReadTriggerable(ref reader, ref lineNumber));
                }
            }

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

            return triggerableData;
        }
コード例 #5
0
ファイル: XmlConverterTests.cs プロジェクト: gh0std4ncer/reko
 void RunTest(string c_code, string expectedXml)
 {
     StringReader reader = null;
     StringWriter writer = null;
     try
     {
         reader = new StringReader(c_code);
         writer = new StringWriter();
         var xWriter = new XmlnsHidingWriter(writer)
         {
             Formatting = Formatting.Indented
         };
         var xc = new XmlConverter(reader, xWriter);
         xc.Convert();
         writer.Flush();
         Assert.AreEqual(expectedXml, writer.ToString());
     }
     catch
     {
         Debug.WriteLine(writer.ToString());
         throw;
     }
     finally
     {
         if (writer != null)
             writer.Dispose();
         if (reader != null)
             reader.Dispose();
     }
 }
コード例 #6
0
		public override ParsedDocument Parse (ProjectDom dom, string fileName, string fileContent)
		{
			XmlParsedDocument doc = new XmlParsedDocument (fileName);
			doc.Flags = ParsedDocumentFlags.NonSerializable;
			
			TextReader tr = new StringReader (fileContent);
			try {
				Parser xmlParser = new Parser (
					new XmlFreeState (new HtmlTagState (true), new HtmlClosingTagState (true)),
					true);
				
				xmlParser.Parse (tr);
				doc.XDocument = xmlParser.Nodes.GetRoot ();
				doc.Add (xmlParser.Errors);
				if (doc.XDocument != null)
					doc.Add (Validate (doc.XDocument));
			}
			catch (Exception ex) {
				MonoDevelop.Core.LoggingService.LogError ("Unhandled error parsing HTML document", ex);
			}
			finally {
				if (tr != null)
					tr.Dispose ();
			}
			
			return doc;
		}
コード例 #7
0
        public static SkillData GetData(string data)
        {
            SkillData skillData = new SkillData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/SKILLS]")
                {
                    break;
                }
                else if (line == "[SKILL]")
                {
                    skillData.Skills.Add(ReadSkill(ref reader, ref lineNumber));
                }
            }

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

            return skillData;
        }
コード例 #8
0
        public static MissileData GetData(string data)
        {
            MissileData missileData = new MissileData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/MISSILES]")
                {
                    break;
                }
                else if (line == "[MISSILE]")
                {
                    missileData.Missiles.Add(ReadMissile(ref reader, ref lineNumber));
                }
            }

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

            return missileData;
        }
コード例 #9
0
        public static RoomPieceData GetData(string data)
        {
            RoomPieceData roomPieceData = new RoomPieceData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/ROOMPIECES]")
                {
                    break;
                }
                else if (line == "[LEVELSET]")
                {
                    roomPieceData.LevelSets.Add(ReadLevelSet(ref reader, ref lineNumber));
                }
            }

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

            return roomPieceData;
        }
コード例 #10
0
		public override ParsedDocument Parse (ProjectDom dom, string fileName, string fileContent)
		{
			XmlParsedDocument doc = new XmlParsedDocument (fileName);
			doc.Flags |= ParsedDocumentFlags.NonSerializable;
			TextReader tr = new StringReader (fileContent);
			try {
				Parser xmlParser = new Parser (new XmlFreeState (), true);
				xmlParser.Parse (tr);
				doc.XDocument = xmlParser.Nodes.GetRoot ();
				doc.Add (xmlParser.Errors);
				
				if (doc.XDocument != null && doc.XDocument.RootElement != null) {
					if (!doc.XDocument.RootElement.IsEnded)
						doc.XDocument.RootElement.End (xmlParser.Location);
				}
			}
			catch (Exception ex) {
				MonoDevelop.Core.LoggingService.LogError ("Unhandled error parsing xml document", ex);
			}
			finally {
				if (tr != null)
					tr.Dispose ();
			}
			return doc;
		}
コード例 #11
0
        public static AffixData GetData(string data)
        {
            AffixData affixData = new AffixData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;


            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/AFFIXES]")
                {
                    break;
                }
                else if (line == "[AFFIX]")
                {
                    affixData.Affixes.Add(ReadAffix(ref reader, ref lineNumber));
                }
            }

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

            return affixData;
        }
コード例 #12
0
 public void FromXml(string xml)
 {
     System.IO.StringReader sw = new System.IO.StringReader(xml);
     XmlReader xr = XmlReader.Create(sw);
     FromXml(ref xr);
     sw.Dispose();
     xr.Close();
 }
コード例 #13
0
 public virtual bool FromXmlString(string x)
 {
     System.IO.StringReader sw = new System.IO.StringReader(x);
     XmlReader xr = XmlReader.Create(sw);
     bool result = FromXml(ref xr);
     sw.Dispose();
     xr.Close();
     return result;
 }
コード例 #14
0
ファイル: Command.cs プロジェクト: Kreyl/nute
 public static byte[] HexStringToByteArray(String hexString)
 {
     int NumberChars = hexString.Length / 2;
     byte[] bytes = new byte[NumberChars];
     StringReader sr = new StringReader(hexString);
     for (int i = 0; i < NumberChars; i++)
         bytes[i] = Convert.ToByte(new string(new char[2] { (char)sr.Read(), (char)sr.Read() }), 16);
     sr.Dispose();
     return bytes;
 }
コード例 #15
0
 public void CheckFourCellsMatrix()
 {
     StringReader reader = new StringReader("2");
     StringWriter writer = new StringWriter();
     Console.SetIn(reader);
     Console.SetOut(writer);
     FillMatrix.Main();
     string expectedOutput = "Enter a positive number \r\n     1     4\r\n     3     2\r\n";
     Assert.AreEqual(expectedOutput, writer.ToString());
     reader.Dispose();
     writer.Dispose();
 }
コード例 #16
0
        public DeploymentInfoContext(Microsoft.Samples.WindowsAzure.ServiceManagement.Deployment innerDeployment)
        {
            this.innerDeployment = innerDeployment;

            if (this.innerDeployment.RoleInstanceList != null)
            {
                this.RoleInstanceList = new List<RoleInstance>();
                foreach (var roleInstance in this.innerDeployment.RoleInstanceList)
                {
                    this.RoleInstanceList.Add(new RoleInstance(roleInstance));
                }
            }

            if (!string.IsNullOrEmpty(this.innerDeployment.Configuration))
            {
                string xmlString = ServiceManagementHelper.DecodeFromBase64String(this.innerDeployment.Configuration);
                
                // Ensure that the readers are properly disposed
                StringReader stringReader = null;
                try
                {
                    stringReader = new StringReader(xmlString);
                
                    using (var reader = XmlReader.Create(stringReader))
                    {
                        stringReader = null;

                        XDocument doc = XDocument.Load(reader);

                        this.OSVersion = doc.Root.Attribute("osVersion") != null ?
                                         doc.Root.Attribute("osVersion").Value :
                                         string.Empty;

                        this.RolesConfiguration = new Dictionary<string, RoleConfiguration>();

                        var roles = doc.Root.Descendants(this.ns + "Role");

                        foreach (var role in roles)
                        {
                            this.RolesConfiguration.Add(role.Attribute("name").Value, new RoleConfiguration(role));
                        }
                    }
                }
                finally
                {
                    if (stringReader != null)
                    {
                        stringReader.Dispose();
                    }
                }
            }
        }
コード例 #17
0
 public static AnalyzerComponentType Deserialize(string xml)
 {
     System.IO.StringReader stringReader = null;
     try {
         stringReader = new System.IO.StringReader(xml);
         return ((AnalyzerComponentType)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader))));
     }
     finally {
         if ((stringReader != null)) {
             stringReader.Dispose();
         }
     }
 }
コード例 #18
0
ファイル: WebUtil.cs プロジェクト: prasannapattam/epos
        public static Dictionary<string, string> GetDictionary(string xml, bool removeDupsSuffix)
        {
            Dictionary<string, string> dict = new Dictionary<string, string>();

            StringReader stringReader = new StringReader(xml);
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.CheckCharacters = false;
            XmlReader reader = XmlReader.Create(stringReader, settings);
            //XmlTextReader reader = new XmlTextReader(stringReader);
            //reader.WhitespaceHandling = WhitespaceHandling.None;

            string fieldName = "";
            string fieldValue = "";
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        fieldName = reader.Name;
                        break;
                    case XmlNodeType.Text:
                        fieldValue = reader.Value;
                        break;
                    case XmlNodeType.CDATA:
                        fieldValue = reader.Value;
                        break;
                    case XmlNodeType.EndElement:
                        if (fieldName != "")
                        {
                            if (removeDupsSuffix & fieldValue.Contains("~"))
                            {
                                string dupNumber = fieldValue.Substring(fieldValue.LastIndexOf('~') + 1);
                                int dupNumberOut;
                                if (Int32.TryParse(dupNumber, out dupNumberOut))
                                {
                                    fieldValue = fieldValue.Remove(fieldValue.LastIndexOf('~'));
                                }
                            }
                            dict.Add(fieldName, fieldValue);
                        }
                        fieldName = "";
                        break;
                }
            }

            reader.Close();
            stringReader.Close();
            stringReader.Dispose();

            return dict;
        }
コード例 #19
0
ファイル: Strings.cs プロジェクト: oguretsss/par
        public static void SetLanguage(string loadedLanguageAsset)
        {
            stringReader = new StringReader(loadedLanguageAsset);
            reader = new XmlTextReader(stringReader);

            reader.ReadToFollowing("YES");
            YES = reader.ReadElementContentAsString();
            Debug.Log(YES);

            reader.ReadToFollowing("NO");
            NO = reader.ReadElementContentAsString();
            Debug.Log(NO);

            reader.ReadToFollowing("CONTRACTS");
            CONTRACTS = reader.ReadElementContentAsString();
            Debug.Log(CONTRACTS);

            reader.ReadToFollowing("SHOP");
            SHOP = reader.ReadElementContentAsString();
            Debug.Log(SHOP);

            reader.ReadToFollowing("EXIT");
            EXIT = reader.ReadElementContentAsString();
            Debug.Log(EXIT);

            reader.ReadToFollowing("REST");
            REST = reader.ReadElementContentAsString();
            Debug.Log(REST);

            reader.ReadToFollowing("ENTER_LOCATION_DIALOG");
            ENTER_LOCATION_DIALOG = reader.ReadElementContentAsString();
            Debug.Log(ENTER_LOCATION_DIALOG);

            reader.ReadToFollowing("CITY");
            CITY = reader.ReadElementContentAsString();
            Debug.Log(CITY);

            reader.ReadToFollowing("LAB");
            LAB = reader.ReadElementContentAsString();
            Debug.Log(LAB);

            reader.ReadToFollowing("CITY_1_NAME");
            CITY_1_NAME = reader.ReadElementContentAsString();
            Debug.Log(CITY_1_NAME);

            reader.ReadToFollowing("CITY_1_DESCRIPTION");
            CITY_1_DESCRIPTION = reader.ReadElementContentAsString();
            Debug.Log(CITY_1_DESCRIPTION);

            stringReader.Dispose();
        }
コード例 #20
0
        public static UnitData GetData(string data)
        {
            UnitData unitData = new UnitData();

            StringReader reader = new StringReader(data);

            string line = "";
            List<Unit> unitList = null;
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/UNITDATA]")
                {
                    break;
                }
                else if (line == "[ITEMS]")
                {
                    unitList = unitData.Items;
                }
                else if (line == "[MONSTERS]")
                {
                    unitList = unitData.Monsters;
                }
                else if (line == "[PLAYERS]")
                {
                    unitList = unitData.Players;
                }
                else if (line == "[PROPS]")
                {
                    unitList = unitData.Props;
                }
                else if (line == "[UNIT]")
                {
                    if (unitList == null)
                    {
                        throw new TxtConverterException(String.Format("Units need to be in a group! (Line: {0})", lineNumber));
                    }

                    unitList.Add(ReadUnit(ref reader, ref lineNumber));
                }
            }

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

            return unitData;
        }
コード例 #21
0
ファイル: CSVReader.cs プロジェクト: 15831944/OnlineGame
    protected virtual void Dispose(bool disposing)
    {
        if (!this.m_disposed)
        {
#if UNITY_EDITOR || !UNITY_FLASH
            if (disposing && m_file != null)
            {
                m_file.Dispose();
            }
#endif

            m_disposed = true;
        }
    }
コード例 #22
0
        public XmlReaderFacade(string data)
        {
            _reader = new StringReader(data);

            try
            {
                this.XmlReader = XmlReader.Create(_reader);
            }
            catch
            {
                _reader.Dispose();
                throw;
            }
        }
コード例 #23
0
 public new static NominaOtroPagoCompensacionSaldosAFavor Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((NominaOtroPagoCompensacionSaldosAFavor)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #24
0
 public static ListInsertAtIndexListTypeDateTimes Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((ListInsertAtIndexListTypeDateTimes)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #25
0
 public new static InputList_ReturnNumType Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((InputList_ReturnNumType)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #26
0
ファイル: Xml.cs プロジェクト: stefanbelkot/beste.aws.core
 /// <summary>
 /// Deserializes a xmlString in an object of this class
 /// </summary>
 /// <typeparam name="T">type to deserialize into</typeparam>
 /// <param name="xml">string to deserialize</param>
 /// <returns>an object of type T</returns>
 public static T Deserialize <T>(string xml)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(xml);
         return((T)(Serializer <T>().Deserialize(System.Xml.XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #27
0
ファイル: Util.cs プロジェクト: Alexssandrolima/NFeDownload
 public static TNfeProc Deserialize(string xml)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(xml);
         return ((TNfeProc)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #28
0
 public new static ActSetValueBoolType Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((ActSetValueBoolType)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #29
0
 public new static DataTypesDateTime_DEType Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((DataTypesDateTime_DEType)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #30
0
 public new static dayTimeDuration_DEtype Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((dayTimeDuration_DEtype)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #31
0
 public new static StringReplaceAtIndexStrType Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((StringReplaceAtIndexStrType)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #32
0
 public new static ConditionalGroupActionType Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((ConditionalGroupActionType)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #33
0
 public new static ListMonadicFunctionsNumType111 Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((ListMonadicFunctionsNumType111)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #34
0
 public new static NominaReceptorSubContratacion Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((NominaReceptorSubContratacion)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #35
0
 public new static PredicateType Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((PredicateType)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #36
0
 public new static FuncDateTimeListType000 Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((FuncDateTimeListType000)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #37
0
 public new static WatchedPropertyType Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((WatchedPropertyType)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #38
0
 public static artikelEigenschapArtikelEigenschapGegevens Deserialize(string xml)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(xml);
         return((artikelEigenschapArtikelEigenschapGegevens)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #39
0
 public static NumericConstantsType111 Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((NumericConstantsType111)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #40
0
ファイル: project.Designer.cs プロジェクト: andyward/DSSTools
 public static Project Deserialize(string input)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(input);
         return((Project)(Serializer.Deserialize(XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #41
0
 public static retourBevestigingBevestiging Deserialize(string xml)
 {
     System.IO.StringReader stringReader = null;
     try
     {
         stringReader = new System.IO.StringReader(xml);
         return((retourBevestigingBevestiging)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #42
0
 public void AskUntilValidMatrixSizeEntered(string input)
 {
     StringReader reader = new StringReader(input + "\n3");
     StringWriter writer = new StringWriter();
     Console.SetIn(reader);
     Console.SetOut(writer);
     FillMatrix.Main();
     string expectedOutput = "Enter a positive number \r\n" +
                             "You haven't entered a correct positive number\r\n" +
                             "     1     7     8\r\n" +
                             "     6     2     9\r\n" +
                             "     5     4     3\r\n";
     Assert.AreEqual(expectedOutput, writer.ToString());
     reader.Dispose();
     writer.Dispose();
 }
コード例 #43
0
ファイル: Asycuda10.cs プロジェクト: Alphaquest2005/WaterNut
        // Display any warnings or errors.


        public static bool CanDeserialize(string xml)
        {
            System.IO.StringReader stringReader = null;
            try
            {
                var settings = new XmlReaderSettings();
                settings.ValidationType = ValidationType.Schema;
                stringReader            = new System.IO.StringReader(xml);
                return(Serializer.CanDeserialize(System.Xml.XmlReader.Create(stringReader, settings)));
            }
            finally
            {
                if ((stringReader != null))
                {
                    stringReader.Dispose();
                }
            }
        }
コード例 #44
0
        private static NoteDataXML_Table LoadStringAsTable(string data)
        {
            // Loading existing table
            System.IO.StringReader LinkTableReader = new System.IO.StringReader(data);
            System.Xml.Serialization.XmlSerializer LinkTableXML = new System.Xml.Serialization.XmlSerializer(typeof(NoteDataXML_Table));

            NoteDataXML_Table table = new NoteDataXML_Table();

            table = (NoteDataXML_Table)LinkTableXML.Deserialize(LinkTableReader);
            //						if (table != null)
            //						{
            //							MyLinkTable.SetTable (table.dataSource);
            //						}
            //NewMessage.Show("Loading a link table with GUID = " + table.GuidForNote);
            LinkTableXML = null;
            LinkTableReader.Close();
            LinkTableReader.Dispose();
            return(table);
        }
コード例 #45
0
		/// <summary>
		/// Deserializes an object from a string.
		/// </summary>
		/// <param name="encoded">The encoded value of the object.</param>
		/// <param name="type">The type of object to deserialize.</param>
		/// <returns>The deserialized object.</returns>
		public static object Deserialize(string encoded, Type type)
		{
			DataContractSerializer serializer = new DataContractSerializer(type);

			StringReader reader = new StringReader(encoded);
			try
			{
				using (XmlTextReader xr = new XmlTextReader(reader))
				{
					reader = null;
					return serializer.ReadObject(xr);
				}
			}
			finally
			{
				if (reader != null)
					reader.Dispose();
			}
		}
コード例 #46
0
ファイル: ByteUtils.cs プロジェクト: sidshetye/BouncyBench
        public static byte[] InitTo(string hex)
        {
            int NumberChars = hex.Length / 2;
            byte[] bytes = new byte[NumberChars];
            StringReader sr = new StringReader(hex);
            for (int i = 0; i < NumberChars; i++)
            {
                var twoChars = new char[2] { (char)sr.Read(), (char)sr.Read() };
                bytes[i] = Convert.ToByte(new string(twoChars), 16);
            }
            sr.Dispose();
            return bytes;

            //byte[] result = new byte[value.Length / 2];
            //for (int i = 0; i < value.Length; i++)
            //{
            //    result[i] = Convert.ToByte(value[i]);
            //}
            //return result;
        }
コード例 #47
0
 public static EmptyPrintStyleAlign Deserialize(string xml)
 {
     StringReader stringReader = null;
     try
     {
         stringReader = new StringReader(xml);
         return
             ((EmptyPrintStyleAlign)
              (Serializer.Deserialize(XmlReader.Create(stringReader,
                                                       new XmlReaderSettings
                                                           {DtdProcessing = DtdProcessing.Parse}))));
     }
     finally
     {
         if ((stringReader != null))
         {
             stringReader.Dispose();
         }
     }
 }
コード例 #48
0
        /// <summary>
        /// Parses strig to
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static Matrix3d Parse(this Matrix3d mat, string str)
        {
            string working = str.Trim();

            if (str.StartsWith("["))
            {
                return(mat.ParseMatLab(str));
            }
            else if (str.StartsWith("{"))
            {
                return(mat.ParseMathematica(str));
            }
            else
            {
                System.IO.StringReader reader = new System.IO.StringReader(str);
                mat = mat.Load(reader);
                reader.Close();
                reader.Dispose();
                return(mat);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            TextReader rdr = new StringReader(textBox1.Text);

            IList<ParseError> errors = null;
            TSql120Parser parser = new TSql120Parser(true);
            TSqlFragment tree = parser.Parse(rdr, out errors);

            foreach(ParseError err in errors)
            {
                Console.WriteLine(err.Message);
            }

            Sql120ScriptGenerator scrGen = new Sql120ScriptGenerator();
            string formattedSQL = null;
            scrGen.GenerateScript(tree, out formattedSQL);

            textBox2.Text = formattedSQL;

            rdr.Dispose();
        }
コード例 #50
0
 /// <summary>
 /// json数据转对象
 /// </summary>
 /// <param name="strJson">json数据</param>
 /// <returns></returns>
 public static T ParseJson <T>(string strJson)
 {
     System.IO.StringReader s_reader = new System.IO.StringReader(strJson);
     try
     {
         Type   j_serializer = new JsonSerializer().GetType();        //Type.GetType("Newtonsoft.Json.JsonSerializer", true, true);
         Type   e_handel     = new MissingMemberHandling().GetType(); //Type.GetType("Newtonsoft.Json.MissingMemberHandling");
         object serializer   = Activator.CreateInstance(j_serializer);
         j_serializer.GetProperty("MissingMemberHandling").SetValue(serializer, e_handel.GetField("Ignore").GetValue(null), null);
         object value = j_serializer.GetMethod("Deserialize", new Type[] { typeof(System.IO.StringReader), typeof(Type) }).Invoke(serializer, new object[] { s_reader, typeof(T) });
         return((T)value);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         s_reader.Close();
         s_reader.Dispose();
     }
 }
コード例 #51
0
 public static BsonDocument ParseBsonDocument(this string json)
 {
     var stringReader = new StringReader(json);
     {
         // you can't do using(stringReader) because bsonReader will dispose of stringReader
         BsonReader bsonReader;
         try // this is lame, but needed to get FxCop happy.
             // it would be better if bsonReader didn't dispose of things it doesn't create/own!
         {
             bsonReader = BsonReader.Create(stringReader);
         }
         catch
         {
             stringReader.Dispose();
             throw;
         }
         var safeBsonReaderCreateNoCover = bsonReader;
         using (safeBsonReaderCreateNoCover)
         {
             return BsonDocument.ReadFrom(safeBsonReaderCreateNoCover);
         } // disposing of BsonReader will dispose stringReader
     }
 }
コード例 #52
0
 public static DataSet XmlToDataTable(string xmlStr)
 {
     if (!string.IsNullOrEmpty(xmlStr))
     {
         StringReader StrStream = null;
         XmlTextReader Xmlrdr = null;
         try
         {
             DataSet ds = new DataSet();
             //读取字符串中的信息
             StrStream = new StringReader(xmlStr);
             //获取StrStream中的数据
             Xmlrdr = new XmlTextReader(StrStream);
             //ds获取Xmlrdr中的数据                
             ds.ReadXml(Xmlrdr);
             return ds;
         }
         catch (Exception e)
         {
             throw e;
         }
         finally
         {
             //释放资源
             if (Xmlrdr != null)
             {
                 Xmlrdr.Close();
                 StrStream.Close();
                 StrStream.Dispose();
             }
         }
     }
     else
     {
         return null;
     }
 }
コード例 #53
0
        public TestDescriptionReader(string xmlContent)
        {
            TestDescription td = TestDescription.Deserialize(xmlContent);

            _document = XDocument.Parse(xmlContent);
            XElement root = _document.Root;
            _tsfLibraries = root.Element(NameSpaceLibrary.tdns + "TsfLibraries");
            _uut = root.Element(NameSpaceLibrary.tdns + "UUT");
            _interfaceRequirements = root.Element(NameSpaceLibrary.tdns + "nterfaceRequirements");
            _detailedTestInformation = root.Element(NameSpaceLibrary.tdns + "DetailedTestInformation");
            _failureFaultData = root.Element(NameSpaceLibrary.tdns + "FailureFaultData");

            StringReader stringReader = null;
            try
            {
                stringReader = new StringReader(_detailedTestInformation.ToString());
                XmlReader reader = XmlReader.Create(stringReader);
                var nsmanager = new XmlNamespaceManager(reader.NameTable);
                nsmanager.AddNamespace("td", "urn:IEEE-1671.1:2009:TestDescription");
                var serializer = new XmlSerializer(typeof (DetailedTestInformation));
                var dti = ((DetailedTestInformation) (serializer.Deserialize(reader)));

                int x = 0;
            }
            finally
            {
                if ((stringReader != null))
                {
                    stringReader.Dispose();
                }
            }

            DetailedTestInformation dt = DetailedTestInformation.Deserialize(_detailedTestInformation.ToString());

            int i = 0;
        }