本文整理汇总了C#中DirectoryEntry.Setup方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryEntry.Setup方法的具体用法?C# DirectoryEntry.Setup怎么用?C# DirectoryEntry.Setup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryEntry
的用法示例。
在下文中一共展示了DirectoryEntry.Setup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllocateRoot
/// <summary>
/// Allocates a vfs root directory entry.
/// </summary>
/// <param name="node">The vfs node, which corresponds to the root directory.</param>
/// <returns>The created directory entry.</returns>
/// <exception cref="System.ArgumentNullException">The specified node is invalid.</exception>
/// <remarks>
/// This method creates a directory entry, which has some special properties. The first one is, that
/// its parent is itself. This provides for the ability to cd .. on the root to stay on the root.
/// <para/>
/// The next ability is to create specialized root directories to isolate processes from the remainder
/// of the filesystem. Setting a root directory created using this method effectively limits the process
/// to access inside of the newly created namespace.
/// </remarks>
public static DirectoryEntry AllocateRoot(IVfsNode node)
{
#if VFS_NO_EXCEPTIONS
if (node == null)
throw new ArgumentNullException(@"node");
#endif // #if VFS_NO_EXCEPTIONS
DirectoryEntry result = new DirectoryEntry();
result.Setup(result, System.String.Empty, node);
return result;
}
示例2: Allocate
/// <summary>
/// Allocates a new DirectoryEntry object for the given settings.
/// </summary>
/// <param name="parent">The parent directory entry.</param>
/// <param name="name">The name of the entry to create.</param>
/// <param name="node">The vfs node referenced by the directory entry.</param>
/// <returns>The allocated directory entry.</returns>
/// <exception cref="System.ArgumentNullException">If any one of the parameters is null.</exception>
/// <exception cref="System.ArgumentException">If the name is zero-length.</exception>
/// <remarks>
/// This method is used to control the DirectoryEntry allocation and maintain a cache of them. Also used to
/// prevent infinite name allocations.
/// </remarks>
public static DirectoryEntry Allocate(DirectoryEntry parent, string name, IVfsNode node)
{
//#if VFS_NO_EXCEPTIONS
if (parent == null)
throw new System.ArgumentNullException(@"parent");
if (name == null)
throw new System.ArgumentNullException(@"name");
if (node == null)
throw new System.ArgumentNullException(@"node");
if (name.Length == 0)
throw new System.ArgumentException(@"Invalid directory entry name."); // , @"name"
// FIXME: Add precondition check for invalid characters
// FIXME: Localize exception messages
//#endif // #if VFS_NO_EXCEPTIONS
DirectoryEntry directory = new DirectoryEntry();
directory.Setup(parent, name, node);
return directory;
}