BuildReportTool.Util.OpenSerializedBuildInfo C# (CSharp) Метод

OpenSerializedBuildInfo() публичный статический Метод

public static OpenSerializedBuildInfo ( string serializedBuildInfoFilePath, bool fromMainThread = true ) : BuildInfo
serializedBuildInfoFilePath string
fromMainThread bool
Результат BuildInfo
	public static BuildInfo OpenSerializedBuildInfo(string serializedBuildInfoFilePath, bool fromMainThread = true)
	{
		BuildInfo ret = null;

		XmlSerializer x = new XmlSerializer( typeof(BuildInfo) );

		string correctedXmlData = FixXmlBuildReportFile(serializedBuildInfoFilePath);

		try
		{
			// when the string has contents, it means there were corrections to the xml data
			// and we should load that updated content instead of reading the file
			if (!string.IsNullOrEmpty(correctedXmlData))
			{
				TextReader reader = new StringReader(correctedXmlData);
				ret = (BuildInfo)x.Deserialize(reader);
			}
			else
			{
				// no corrections in the xml file
				// proceed to open the file normally
				using(FileStream fs = new FileStream(serializedBuildInfoFilePath, FileMode.Open))
				{
					XmlReader reader = new XmlTextReader(fs);
					ret = (BuildInfo)x.Deserialize(reader);
					fs.Close();
				}
			}
		}
		catch (Exception e)
		{
			Debug.LogError(e);
		}

		if (fromMainThread)
		{
			if (BuildInfoHasContents(ret))
			{
				ret.OnDeserialize();
				ret.SetSavedPath(serializedBuildInfoFilePath);
			}
			else
			{
				Debug.LogError("Build Report Tool: Invalid data in build info file: " + serializedBuildInfoFilePath);
			}
		}

		return ret;
	}