开发者

Any VBNET equivalence of C# where generic constraint keyword?

开发者 https://www.devze.com 2022-12-29 15:26 出处:网络
First, I wish to write myself a generic type for operations against the underlying Active Directory. For those of you who know about AD and the System.DirectoryServices namespace, the DirectoryEntry

First, I wish to write myself a generic type for operations against the underlying Active Directory.

For those of you who know about AD and the System.DirectoryServices namespace, the DirectoryEntry class is the top most important along with the DirectorySearcher class.

When speaking the AD language, everything is a DirectoryEntry. With that said, my application needs to manage Users, Groups and Organizational Units (OU). Each of these objects are AD entries. Then, this sounds to me a good candidate for GenericTypes.

What I wish to accomplish is this:

public interface ITop {
    string Path { get; set; }
    string ObjectClass { get; }
    string ContainerName { get; set; }
    // [...]
}

public interface IGroup : ITop {
    // Speciality properties here...
}

public interface IUser : ITop {
    // Speciality properties here...
}

// And so forth...

public sealed class DirectorySource<T> where T : ITop {
    // Methods against AD here...
}

My class library MUST respond to the follow开发者_运维技巧ing organical criterion:

  1. VS2005 VBNET
  2. .NET 2.0
  3. Active Directory
  4. Windows Forms

Well, I guess I have already given too much details for the purpose of my question, but any suggestion on the architecture and design patterns are welcome as well. My question is:

Is there a VBNET 2.0 equivalence of C# where (generic type constraint) keyword, or any best practice workarounds?

The results of my searches seem to end with the undoable conclusion. So I'm asking...


Like this:

Public Class DirectorySource(Of T As ITop)

Multiple constraints are enclosed by braces, like this:

Public Class DirectorySource(Of T As { ITop, IDisposable, Class, New })
0

精彩评论

暂无评论...
验证码 换一张
取 消