0

データをエクスポートする必要がある Web アプリケーションを作成しています。問題は、すべてのクライアントが異なるフォーマットを必要とすることです。タブ区切り、コンマ区切り、さらには固定幅が必要な場合もあります。

エクスポートごとに異なるデータが必要になる場合もあります。

各クライアントが独自のフォーマットを持つことができるようにするには、どのようなアプローチを検討する必要がありますか?

4

2 に答える 2

1

あなたと同じ要件が必要でした。

この設計パターンを実装するのに役立った質問へのリンクをいくつか示します。戦略パターンとオブザーバー パターンが混在していると思います。

すべての「フォーマッター」を同じアセンブリに格納する場合は、リフレクションなしで簡単に行うことができます。クラス名をクライアント構成に保存するだけで、クライアントが構成したクラスに応じてフォーマッタ オブジェクトを作成できます。

リフレクション & アプリケーション設計
継承 & イベント

実際の例が必要な場合は、午前中に投稿できます。

于 2009-04-08T06:07:45.983 に答える
1

I would create a class which retrieves the data that you're interested in.

I would also create a class (or set of classes) which contains / represents the data that you have retrieved.

Then, I think I would create an interface or abstract base-class 'Printer' or 'Formatter', or whathever name is suitable, which would be responsible for formatting the data into the desired format. You could then create specific subclasses which implement the logic that is required to put the data in the correct format.

于 2009-04-07T10:00:26.107 に答える