/*
		 * SaveConfig
		 */

		/// <summary>
		/// Saves the current state to the specified <see cref="T:Stream"/>.
		/// </summary>
		/// <param name="stream">Specifies the <see cref="T:Stream"/> to save the current state to.</param>
		/// <exception cref="T:System.ArgumentNullException"><paramref name="stream"/> is <see langword="null"/>.</exception>
		public void SaveConfig(Stream stream)
		{
			if (stream == null)
			{
				throw new ArgumentNullException("stream");
			}

			NuGenXmlTextWriter xmlTextWriter = new NuGenXmlTextWriter(stream);
			
			xmlTextWriter.WriteStartDocument(true);
			this.SaveConfig(xmlTextWriter);
			xmlTextWriter.WriteEndDocument();
			
			xmlTextWriter.Flush();
		}
		public void Serialize(object obj, Stream stream, string application)
		{
			if (stream == null)
			{
				throw new ArgumentNullException("stream");
			}

			CultureInfo currentCulture = Application.CurrentCulture;

			try
			{
				Application.CurrentCulture = NuGenCulture.enUS;

				NuGenXmlTextWriter writer = new NuGenXmlTextWriter(stream);

				writer.WriteStartDocument(true);
				writer.WriteStartElement(this.Name);
				writer.WriteAttributeString(Resources.XmlAttribute_Version, this.Version);
				writer.WriteAttributeString(Resources.XmlAttribute_Version, application);

				_graph = new NuGenGraph();
				_references = new NuGenReferenceCollection();

				NuGenPropertyInfoCollection propertyInfoCollection = this.SerializeObject(obj);

				this.SetReferenceSerializing();

				this.SerializeObject(writer, propertyInfoCollection);

				writer.WriteEndElement();
				writer.Flush();
			}
			catch
			{
				throw;
			}
			finally
			{
				Application.CurrentCulture = currentCulture;
			}
		}