Example #1
0
        /// <summary>
        ///   Closes the buffer by flushing the contents of its XmlDocument object (if necessary) and dettaching itself
        ///   from its <see cref="XmlBased" /> profile. </summary>
        /// <remarks>
        ///   This method may be used to explictly deactivate the <see cref="XmlBased" /> profile buffer.
        ///   This means that the buffer is flushed (if <see cref="NeedsFlushing" /> is true) and it gets
        ///   dettached from the profile. The <see cref="Dispose" /> method automatically calls this method. </remarks>
        /// <seealso cref="Flush" />
        /// <seealso cref="Dispose" />
        public void Close()
        {
            if (m_profile == null)
            {
                return;
            }

            if (m_needsFlushing)
            {
                Flush();
            }

            m_doc = null;

            if (m_file != null)
            {
                m_file.Close();
                m_file = null;
            }

            if (m_profile != null)
            {
                m_profile.m_buffer = null;
            }
            m_profile = null;
        }
Example #2
0
        /// <summary>
        ///   Initializes a new instance of the XmlBuffer class and optionally locks the file. </summary>
        /// <param name="profile">
        ///   The XmlBased object to associate with the buffer and to assign this object to. </param>
        /// <param name="lockFile">
        ///   If true and the file exists, the file is locked to prevent other processes from writing to it
        ///   until the buffer is closed. </param>
        /// <exception cref="InvalidOperationException">
        ///	  Attempting to lock the file  and the name is null or empty. </exception>
        /// <exception cref="SecurityException">
        ///	  Attempting to lock the file without the required permission. </exception>
        /// <exception cref="UnauthorizedAccessException">
        ///	  Attempting to lock the file and ReadWrite access is not permitted by the operating system. </exception>
        internal XmlBuffer(XmlBased profile, bool lockFile)
        {
            m_profile = profile;

            if (lockFile)
            {
                m_profile.VerifyName();
                if (File.Exists(m_profile.Name))
                {
                    m_file = new FileStream(m_profile.Name, FileMode.Open, m_profile.ReadOnly ? FileAccess.Read : FileAccess.ReadWrite, FileShare.Read);
                }
            }
        }
Example #3
0
 internal XmlBuffer(XmlBased profile, bool lockFile)
 {
     this.m_profile = profile;
     if (!lockFile)
     {
         return;
     }
     this.m_profile.VerifyName();
     if (!File.Exists(this.m_profile.Name))
     {
         return;
     }
     this.m_file = new FileStream(this.m_profile.Name, FileMode.Open, this.m_profile.ReadOnly ? FileAccess.Read : FileAccess.ReadWrite, FileShare.Read);
 }
Example #4
0
 public void Close()
 {
     if (this.m_profile == null)
     {
         return;
     }
     if (this.m_needsFlushing)
     {
         this.Flush();
     }
     this.m_doc = (XmlDocument)null;
     if (this.m_file != null)
     {
         this.m_file.Close();
         this.m_file = (FileStream)null;
     }
     if (this.m_profile != null)
     {
         this.m_profile.m_buffer = (XmlBuffer)null;
     }
     this.m_profile = (XmlBased)null;
 }
Example #5
0
 /// <summary>
 ///   Initializes a new instance of the XmlBased class based on another XmlBased object. </summary>
 /// <param name="profile">
 ///   The XmlBased profile object whose properties and events are used to initialize the object being constructed. </param>
 protected XmlBased(XmlBased profile) :
     base(profile)
 {
     m_encoding = profile.Encoding;
 }
Example #6
0
 protected XmlBased(XmlBased profile)
     : base((AMS.Profile.Profile)profile)
     => this.m_encoding = profile.Encoding;
Example #7
0
		/// <summary>
		///   Initializes a new instance of the XmlBased class based on another XmlBased object. </summary>
		/// <param name="profile">
		///   The XmlBased profile object whose properties and events are used to initialize the object being constructed. </param>
		protected XmlBased(XmlBased profile) :
			base(profile)
		{
			m_encoding = profile.Encoding;
		}
Example #8
0
		/// <summary>
		///   Closes the buffer by flushing the contents of its XmlDocument object (if necessary) and dettaching itself 
		///   from its <see cref="XmlBased" /> profile. </summary>
		/// <remarks>
		///   This method may be used to explictly deactivate the <see cref="XmlBased" /> profile buffer. 
		///   This means that the buffer is flushed (if <see cref="NeedsFlushing" /> is true) and it gets 
		///   dettached from the profile. The <see cref="Dispose" /> method automatically calls this method. </remarks>
		/// <seealso cref="Flush" />
		/// <seealso cref="Dispose" />
		public void Close()
		{
			if (m_profile == null)
				return;
				
			if (m_needsFlushing)
				Flush();

			m_doc = null;
		
			if (m_file != null)
			{
				m_file.Close();
				m_file = null;
			}

			if (m_profile != null)
				m_profile.m_buffer = null;
			m_profile = null;
		}
Example #9
0
		/// <summary>
		///   Initializes a new instance of the XmlBuffer class and optionally locks the file. </summary>
		/// <param name="profile">
		///   The XmlBased object to associate with the buffer and to assign this object to. </param>
		/// <param name="lockFile">
		///   If true and the file exists, the file is locked to prevent other processes from writing to it
		///   until the buffer is closed. </param>
		/// <exception cref="InvalidOperationException">
		///	  Attempting to lock the file  and the name is null or empty. </exception>
		/// <exception cref="SecurityException">
		///	  Attempting to lock the file without the required permission. </exception>
		/// <exception cref="UnauthorizedAccessException">
		///	  Attempting to lock the file and ReadWrite access is not permitted by the operating system. </exception>
		internal XmlBuffer(XmlBased profile, bool lockFile)
		{
			m_profile = profile;

			if (lockFile)
			{
				m_profile.VerifyName();
				if (File.Exists(m_profile.Name))
					m_file = new FileStream(m_profile.Name, FileMode.Open, m_profile.ReadOnly ? FileAccess.Read : FileAccess.ReadWrite, FileShare.Read);
			}
		}