共有フォルダを表す Volume クラスの C# のコードです。
[DataObject()]
public sealed classVolume : DomainObject
{
#regionプライベートフィールド
private string[] _keywords;
#endregion
#regionインターナルコンストラクタ
//DirectoryEntry を指定して Volume クラスの新しいインスタンスを初期化します。
internal Volume(DirectoryEntry entry)
: base(entry)
{
_keywords = entry.Properties["keywords"].Cast<string>().ToArray();
}
#endregion
#regionパブリックプロパティ
//キーワードを取得または設定します。
public string[] Keywords
{
get
{
return _keywords;
}
set
{
if (base.IsDisposed)
{
throw newObjectDisposedException(this.GetType().Name);
}
base.Entry.Properties["keywords"].Value = value;
_keywords = base.Entry.Properties["keywords"].Cast<string>().ToArray();
}
}
//UNC パスを取得または設定します。
public string UncPath
{
get
{
if (base.IsDisposed)
{
throw newObjectDisposedException(this.GetType().Name);
}
return (string)base.Entry.Properties["uNCName"].Value;
}
set
{
if (base.IsDisposed)
{
throw newObjectDisposedException(this.GetType().Name);
}
base.Entry.Properties["uNCName"].Value = value;
}
}
#endregion
#regionパブリックメソッド
//指定した名前の共有フォルダを検索します。このメソッドはデータバインド用です。
[DataObjectMethod(DataObjectMethodType.Select)]
public staticVolume FindByName(string name)
{
return (Volume)DirectoryAccess.FindDirectoryObject(name, CategoryType.Volume);
}
//共有フォルダの一覧を取得します。このメソッドはデータバインド用です。
[DataObjectMethod(DataObjectMethodType.Select)]
public staticIList<Volume> GetVolumes()
{
returnDirectoryAccess.GetVolumes(); //共有フォルダを取得
}
#endregion
}
説明は VB のコードの方に書いてます。
データバインド用のメソッドは内部で DirectoryAccessクラスのメソッドを呼んでますが、これについては別途書きます。