Any VBNET equivalence of C# where generic constraint keyword?
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:
- VS2005 VBNET
- .NET 2.0
- Active Directory
- 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 })
精彩评论