示例#1
0
		/////////////////////////////////////////////////////////////////////////////
		public bool Save(string sFileName)
		{
			try
			{
				Serializer serializer = new Serializer(true/*bXml*/);
				string sDocument = serializer.Serialize<Document>(this);
				if (sDocument == null)
					return false;

				DocumentIO docIO = new DocumentIO();
				bool bOK = docIO.Open(sFileName, true/*bWriter*/);
				if (!bOK)
					return false;

				docIO.Write(sDocument);
				docIO.Close();
				return true;
			}
			catch (Exception e)
			{
				System.Diagnostics.Debug.WriteLine(e.Message);
				e.Assert();
			}

			return false;
		}
示例#2
0
		/////////////////////////////////////////////////////////////////////////////
		public static Document Open(string sFileName)
		{
			try
			{
				DocumentIO docIO = new DocumentIO();
				bool bOK = docIO.Open(sFileName, false/*bWriter*/);
				if (!bOK)
					return null;

				string sDocument = docIO.ReadToEnd();
				docIO.Close();
				if (sDocument == null)
					return null;

				Serializer serializer = new Serializer(true/*bXml*/);
				return serializer.Deserialize<Document>(sDocument);
			}
			catch (Exception e)
			{
				System.Diagnostics.Debug.WriteLine(e.Message);
				e.Assert();
			}

			return null;
		}