実験的な目的のために、BSTをインスタンス化して唯一のノードまたは冗長ノードを保持するバイナリ検索ツリーライブラリを構築しようとしていますツリー内の別の値と同等の値)。再利用のために、私は単一の汎用インターフェース、ITreeと2つのサブインターフェース、IUniqueとIRedundantを定義しました。汎用インターフェイスライブラリ:アセンブリから型をロードできませんでした
namespace MyNS {
public interface INode<T,N>
where N : INode<T,N> {
N LChild { get; set; }
N RChild { get; set; }
T Value { get; set; }
}
public interface ITree<T,N,I>
where N : INode<T,N>
where I : ITree<T,N,I> {
void Add(N node);
}
public interface IUnique<T,N>
: ITree<T,N,IUnique<T,N>>
where N : INode<T,N> {
}
public interface IRedundant<T,N>
: ITree<T,N,IRedundant<T,N>>
where N : INode<T,N> {
}
public class Node<T>
: INode<T,Node<T>> {
public Node<T> LChild { get; set; }
public Node<T> RChild { get; set; }
public T Value { get; set; }
}
public class Tree<T>
: IUnique<T,Node<T>>,
IRedundant<T,Node<T>> {
void ITree<T,Node<T>,IUnique<T,Node<T>>>.Add(Node<T> node) {
/// Add node only if there is none with an equivalent value ///
}
void ITree<T,Node<T>,IRedundant<T,Node<T>>>.Add(Node<T> node) {
/// Add node regardless of its redundancy ///
}
}
}
そして例mainメソッド[ファイル名:メイン
Explicit C# interface implementation of interfaces that inherit from other interfacesに私の返事の理由なので、ライブラリコードは[:itest.csファイル名]を次のように実証することができます.cs]:次のエラーの主な実行結果とは別のアセンブリとしてライブラリをコンパイルしようと
public class ITest {
public static void Main() {
System.Console.WriteLine(typeof(MyNS.Tree<int>));
}
}
:
$ mcs -out:itest.dll -t:library itest.cs
$ mcs -out:itest.exe main.cs -reference:itest
error CS0011: Could not load type 'MyNS.ITree`3[T,N,MyNS.IUnique`2[T,N]]' from assembly 'itest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Compilation failed: 1 error(s), 0 warnings
はしかし、2つをコンパイルすると期待どおりに動作します:
$ mcs -out:itest.exe main.cs itest.cs
$ mono itest.exe
MyNS.Tree`1[System.Int32]
モジュール性を維持するために、どのように私は自分のアプリケーションロジックとは別のライブラリを維持できますか?
EDIT(Jan 11、2010):はい、Mono 2.8.xのバグで、バージョン2.10で修正されました。
.NETでうまく動作します。私はモノのバグをファイルします。 –
@ハンス・パッセンジャー、完了。 https://bugzilla.novell.com/show_bug.cgi?id=663727 – Dylon