예제 #1
0
        public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            ArgumentValidation.CheckForNullReference(info, "info");

            info.AddValue("ReadOnly", readOnly);
            info.AddValue("HashProvider", hashCodeProvider, typeof(IHashCodeProvider));
            info.AddValue("Comparer", comparer, typeof(IComparer));

            int count = entries.Count;

            info.AddValue("Count", count);

            String[] keys   = new String[count];
            Object[] values = new Object[count];

            for (int i = 0; i < count; i++)
            {
                DataObjectEntry entry = (DataObjectEntry)entries[i];
                keys[i]   = entry.Key;
                values[i] = entry.Value;
            }

            info.AddValue("Keys", keys, typeof(String[]));
            info.AddValue("Values", values, typeof(Object[]));
        }
예제 #2
0
        /// <summary>
        /// <para>Creat a zero byte length file in the specified path.</para>
        /// </summary>
        /// <param name="filePath">
        /// <para>The absolute path to the file to create.</para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="filePath"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">
        /// <para>The caller does not have the required permission.</para>para>
        /// <para>-or-</para>
        /// <para><paramref name="filePath"/> specified a file that is read-only.</para>
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <para><paramref name="filePath"/> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="Path.InvalidPathChars"/>.</para>
        /// </exception>
        /// <exception cref="PathTooLongException">
        /// <para>The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.</para>
        /// </exception>
        /// <exception cref="DirectoryNotFoundException">
        /// <para>The specified path is invalid, such as being on an unmapped drive.</para>
        /// </exception>
        /// <exception cref="IOException">
        /// <para>An I/O error occurred while creating the file.</para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="filePath"/> is in an invalid format.</para>
        /// </exception>
        /// <seealso cref="System.IO.File.Create(string)"/>
        public static void CreateZeroByteFile(string filePath)
        {
            ArgumentValidation.CheckForNullReference(filePath, "filePath");

            using (File.Create(filePath))
            {
            }
        }
예제 #3
0
        /// <summary>
        /// <para>Reset the file attributes of a file so it can be overwritten.</para>
        /// </summary>
        /// <param name="filePath">
        /// <para>The fully qualified path to the file.</para>
        /// </param>
        public static void ChangeFileAttributesToWritable(string filePath)
        {
            ArgumentValidation.CheckForNullReference(filePath, "filePath");

            if (!File.Exists(filePath))
            {
                return;
            }
            FileAttributes attributes = File.GetAttributes(filePath);
            FileAttributes attr       = attributes | FileAttributes.ReadOnly;

            if (attr == attributes)
            {
                attributes ^= FileAttributes.ReadOnly;
                File.SetAttributes(filePath, attributes);
            }
        }
예제 #4
0
 /// <summary>
 /// <para>Removes the entry with the specified <paramref name="name"/> from the collection.</para>
 /// </summary>
 /// <param name="name">
 /// <para>The name of the item to remove.</para>
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="name"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
 /// </exception>
 public void Remove(string name)
 {
     ArgumentValidation.CheckForNullReference(name, "name");
     BaseRemove(name);
 }