• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamephpguicwindows翻訳pythonomegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

FreeTrainの進化系を目指す


Commit MetaInfo

Revision70 (tree)
Zeit2017-05-04 13:43:03
Autorc477

Log Message

Repository のパッケージ移動、 _ICommandTriggerFactory.cs削除

Ändern Zusammenfassung

Diff

--- trunk/TestCoreProject/core/RepositoryBaseTest.cs (revision 69)
+++ trunk/TestCoreProject/core/RepositoryBaseTest.cs (revision 70)
@@ -1,6 +1,6 @@
11 using System;
22 using Microsoft.VisualStudio.TestTools.UnitTesting;
3-using nft.core.data;
3+using nft.framework.repository;
44 using nft.framework;
55 using static System.Diagnostics.Trace;
66 using static Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
@@ -76,7 +76,7 @@
7676 }
7777
7878 [TestMethod]
79- public void IModelRepositoryExtension()
79+ public void IRepositoryExtension()
8080 {
8181 this.repository = new TestRepository();
8282 WriteLine("IModelRepository拡張メソッドのテスト");
--- trunk/core/core/data/IModelRepository.cs (revision 69)
+++ trunk/core/core/data/IModelRepository.cs (nonexistent)
@@ -1,82 +0,0 @@
1-using nft.framework;
2-using System;
3-using System.Collections.Generic;
4-using System.Linq;
5-using System.Text;
6-using System.Threading.Tasks;
7-
8-namespace nft.core.data
9-{
10- /// <summary>
11- /// データリポジトリのコアインターフェース
12- /// 標準実装はRepositoryBase
13- /// </summary>
14- /// <typeparam name="T"></typeparam>
15- public interface IRepository<T> where T: IHasNameAndID
16- {
17- /// <summary>
18- /// モデルを追加する。既にモデル
19- /// </summary>
20- /// <param name="model"></param>
21- void Add(T model);
22-
23- /// <summary>
24- /// IDで指定したモデルを削除し、削除したモデルを返す。該当モデルが存在しない場合エラーにはならず、nullを返す。
25- /// </summary>
26- /// <param name="id"></param>
27- /// <returns>removed model or null if not exist</returns>
28- T RemoveByID(string id);
29-
30- /// <summary>
31- /// IDを指定してモデルを取得する。
32- /// setがないのは、間違ったIDでmodel登録されるのを防ぐため。Addを使用してください。
33- /// </summary>
34- /// <param name="id"></param>
35- /// <returns></returns>
36- T this[string id] { get; }
37-
38- /// <summary>
39- /// リポジトリに含まれるすべてのモデルのリストを取得します
40- /// </summary>
41- IEnumerable<T> List { get; }
42-
43- /// <summary>
44- /// リポジトリに含まれるモデルの数を取得します
45- /// </summary>
46- int Count { get; }
47- }
48-
49- /// <summary>
50- /// IRepositoryの拡張メソッド
51- /// </summary>
52- public static class RepositoryExtesion
53- {
54- /// <summary>
55- /// 指定したモデルを削除する。
56- /// </summary>
57- /// <typeparam name="T"></typeparam>
58- /// <param name="repository"></param>
59- /// <param name="model">The model to be removed</param>
60- public static void Remove<T>(this IRepository<T> repository, T model) where T: IHasNameAndID
61- {
62- repository.RemoveByID(model.ID);
63- }
64-
65- /// <summary>
66- /// リポジトリに指定したIDのモデルが存在するかどうか調べる。存在すればtrue
67- /// </summary>
68- /// <typeparam name="T"></typeparam>
69- /// <param name="repository"></param>
70- /// <param name="model"></param>
71- /// <returns>true if the model correspond to the id is exist.</returns>
72- public static bool HasID<T>(this IRepository<T> repository, T model) where T : class, IHasNameAndID
73- {
74- return repository[model.ID] != null;
75- }
76-
77- public static T findByID<T>(this IRepository<T> repository, string id, T _default = null) where T : class, IHasNameAndID
78- {
79- return repository[id] ?? _default;
80- }
81- }
82-}
--- trunk/core/core/data/RepositoryBase.cs (revision 69)
+++ trunk/core/core/data/RepositoryBase.cs (nonexistent)
@@ -1,52 +0,0 @@
1-using nft.framework;
2-using System;
3-using System.Collections.Generic;
4-using System.Linq;
5-using System.Text;
6-using System.Threading.Tasks;
7-
8-namespace nft.core.data
9-{
10- public class RepositoryBase<T> : IRepository<T> where T: class, IHasNameAndID
11- {
12- protected Dictionary<string, T> dictionary = new Dictionary<string, T>();
13-
14- public T this[string id]
15- {
16- get
17- {
18- T ret;
19- if( dictionary.TryGetValue(id, out ret) ) return ret;
20- return null;
21- }
22- }
23-
24- public int Count
25- {
26- get
27- {
28- return dictionary.Count;
29- }
30- }
31-
32- public IEnumerable<T> List
33- {
34- get
35- {
36- return dictionary.Values;
37- }
38- }
39-
40- public void Add(T model)
41- {
42- dictionary.Add(model.ID, model);
43- }
44-
45- public T RemoveByID(string id)
46- {
47- T ret = this[id];
48- dictionary.Remove(id);
49- return ret;
50- }
51- }
52-}
--- trunk/framework/framework/repository/DefaultRepositoryBuilder.cs (nonexistent)
+++ trunk/framework/framework/repository/DefaultRepositoryBuilder.cs (revision 70)
@@ -0,0 +1,39 @@
1+using nft.framework;
2+using System;
3+using System.Collections.Generic;
4+using System.Linq;
5+using System.Reflection;
6+using System.Text;
7+using System.Threading.Tasks;
8+
9+namespace nft.framework.repository
10+{
11+ public class DefaultRepositoryBuilder<T,U> : IRepositoryBuilder<T> where T: class, IHasNameAndID where U: IRepository<T>
12+ {
13+ protected Dictionary<string, T> dictionary = new Dictionary<string, T>();
14+
15+ public void Add(T model)
16+ {
17+ dictionary.Add(model.ID, model);
18+ }
19+
20+ public T RemoveByID(string id)
21+ {
22+ T ret;
23+ if (!dictionary.TryGetValue(id, out ret)) {
24+ ret = null;
25+ }
26+ dictionary.Remove(id);
27+ return ret;
28+ }
29+
30+ public IRepository<T> Finalize()
31+ {
32+ Type[] types = { typeof(IDictionary<string, T>) };
33+ ConstructorInfo ci = typeof(U).GetConstructor(types);
34+ object[] args = { this.dictionary };
35+ U repository = (U) ci.Invoke( args );
36+ return repository;
37+ }
38+ }
39+}
--- trunk/framework/framework/repository/IRepository.cs (nonexistent)
+++ trunk/framework/framework/repository/IRepository.cs (revision 70)
@@ -0,0 +1,82 @@
1+using nft.framework;
2+using System;
3+using System.Collections.Generic;
4+using System.Linq;
5+using System.Text;
6+using System.Threading.Tasks;
7+
8+namespace nft.framework.repository
9+{
10+ /// <summary>
11+ /// データリポジトリのコアインターフェース
12+ /// 標準実装はRepositoryBase
13+ /// </summary>
14+ /// <typeparam name="T"></typeparam>
15+ public interface IRepository<T> where T: IHasNameAndID
16+ {
17+ /// <summary>
18+ /// モデルを追加する。既にモデル
19+ /// </summary>
20+ /// <param name="model"></param>
21+ void Add(T model);
22+
23+ /// <summary>
24+ /// IDで指定したモデルを削除し、削除したモデルを返す。該当モデルが存在しない場合エラーにはならず、nullを返す。
25+ /// </summary>
26+ /// <param name="id"></param>
27+ /// <returns>removed model or null if not exist</returns>
28+ T RemoveByID(string id);
29+
30+ /// <summary>
31+ /// IDを指定してモデルを取得する。
32+ /// setがないのは、間違ったIDでmodel登録されるのを防ぐため。Addを使用してください。
33+ /// </summary>
34+ /// <param name="id"></param>
35+ /// <returns></returns>
36+ T this[string id] { get; }
37+
38+ /// <summary>
39+ /// リポジトリに含まれるすべてのモデルのリストを取得します
40+ /// </summary>
41+ IEnumerable<T> List { get; }
42+
43+ /// <summary>
44+ /// リポジトリに含まれるモデルの数を取得します
45+ /// </summary>
46+ int Count { get; }
47+ }
48+
49+ /// <summary>
50+ /// IRepositoryの拡張メソッド
51+ /// </summary>
52+ public static class RepositoryExtesion
53+ {
54+ /// <summary>
55+ /// 指定したモデルを削除する。
56+ /// </summary>
57+ /// <typeparam name="T"></typeparam>
58+ /// <param name="repository"></param>
59+ /// <param name="model">The model to be removed</param>
60+ public static void Remove<T>(this IRepository<T> repository, T model) where T: IHasNameAndID
61+ {
62+ repository.RemoveByID(model.ID);
63+ }
64+
65+ /// <summary>
66+ /// リポジトリに指定したIDのモデルが存在するかどうか調べる。存在すればtrue
67+ /// </summary>
68+ /// <typeparam name="T"></typeparam>
69+ /// <param name="repository"></param>
70+ /// <param name="model"></param>
71+ /// <returns>true if the model correspond to the id is exist.</returns>
72+ public static bool HasID<T>(this IRepository<T> repository, T model) where T : class, IHasNameAndID
73+ {
74+ return repository[model.ID] != null;
75+ }
76+
77+ public static T findByID<T>(this IRepository<T> repository, string id, T _default = null) where T : class, IHasNameAndID
78+ {
79+ return repository[id] ?? _default;
80+ }
81+ }
82+}
--- trunk/framework/framework/repository/IRepositoryBuilder.cs (nonexistent)
+++ trunk/framework/framework/repository/IRepositoryBuilder.cs (revision 70)
@@ -0,0 +1,36 @@
1+using nft.framework;
2+using System;
3+using System.Collections.Generic;
4+using System.Linq;
5+using System.Text;
6+using System.Threading.Tasks;
7+
8+namespace nft.framework.repository
9+{
10+ /// <summary>
11+ /// データリポジトリビルダーのインターフェース
12+ /// 標準実装はRepositoryBuilderBase
13+ /// </summary>
14+ /// <typeparam name="T"></typeparam>
15+ public interface IRepositoryBuilder<T> where T: IHasNameAndID
16+ {
17+ /// <summary>
18+ /// モデルを追加する。既にモデル
19+ /// </summary>
20+ /// <param name="model"></param>
21+ void Add(T model);
22+
23+ /// <summary>
24+ /// IDで指定したモデルを削除し、削除したモデルを返す。該当モデルが存在しない場合エラーにはならず、nullを返す。
25+ /// </summary>
26+ /// <param name="id"></param>
27+ /// <returns>removed model or null if not exist</returns>
28+ T RemoveByID(string id);
29+
30+
31+ IRepository<T> Finalize();
32+ }
33+
34+
35+
36+}
--- trunk/framework/framework/repository/RepositoryBase.cs (nonexistent)
+++ trunk/framework/framework/repository/RepositoryBase.cs (revision 70)
@@ -0,0 +1,52 @@
1+using nft.framework;
2+using System;
3+using System.Collections.Generic;
4+using System.Linq;
5+using System.Text;
6+using System.Threading.Tasks;
7+
8+namespace nft.framework.repository
9+{
10+ public class RepositoryBase<T> : IRepository<T> where T: class, IHasNameAndID
11+ {
12+ protected Dictionary<string, T> dictionary = new Dictionary<string, T>();
13+
14+ public T this[string id]
15+ {
16+ get
17+ {
18+ T ret;
19+ if( dictionary.TryGetValue(id, out ret) ) return ret;
20+ return null;
21+ }
22+ }
23+
24+ public int Count
25+ {
26+ get
27+ {
28+ return dictionary.Count;
29+ }
30+ }
31+
32+ public IEnumerable<T> List
33+ {
34+ get
35+ {
36+ return dictionary.Values;
37+ }
38+ }
39+
40+ public void Add(T model)
41+ {
42+ dictionary.Add(model.ID, model);
43+ }
44+
45+ public T RemoveByID(string id)
46+ {
47+ T ret = this[id];
48+ dictionary.Remove(id);
49+ return ret;
50+ }
51+ }
52+}
--- trunk/framework/ui/command/_CommandTriggerFactory.cs (revision 69)
+++ trunk/framework/ui/command/_CommandTriggerFactory.cs (nonexistent)
@@ -1,24 +0,0 @@
1-using System;
2-using System.Windows.Forms;
3-
4-namespace nft.ui.command
5-{
6- /// <summary>
7- /// CommandTriggerFactory の概要の説明です。
8- /// </summary>
9- public class CommandTriggerFactory
10- {
11- public static ICommandTrigger Create(ToolStripMenuItem item)
12- { return new MenuItemTrigger(item); }
13- public static ICommandTrigger Create( Button item )
14- { return new ButtonTrigger(item); }
15- public static ICommandTrigger Create( CheckBox item )
16- { return new CheckBoxTrigger(item); }
17- public static ICommandTrigger Create( ToolStripButton item )
18- { return new ToolBarItemTrigger(item); }
19- public static ICommandTrigger Create( ToolBarButton item )
20- { return new ToolBarButtonTrigger(item); }
21- public static ICommandTrigger Create( Control item )
22- { return new ControlTrigger(item); }
23- }
24-}
--- trunk/ui_jp/ui/core/BuildTool.Designer.cs (revision 69)
+++ trunk/ui_jp/ui/core/BuildTool.Designer.cs (revision 70)
@@ -24,10 +24,10 @@
2424 /// </summary>
2525 private void InitializeComponent() {
2626 this.panel1 = new System.Windows.Forms.Panel();
27+ this.cbList = new System.Windows.Forms.ComboBox();
2728 this.panel2 = new System.Windows.Forms.Panel();
29+ this.tbInfo = new System.Windows.Forms.TextBox();
2830 this.renderView = new nft.framework.drawing.RenderViewPanel();
29- this.lbCaption = new System.Windows.Forms.Label();
30- this.tbInfo = new System.Windows.Forms.TextBox();
3131 this.panel1.SuspendLayout();
3232 this.panel2.SuspendLayout();
3333 this.SuspendLayout();
@@ -35,13 +35,23 @@
3535 // panel1
3636 //
3737 this.panel1.AutoSize = true;
38- this.panel1.Controls.Add(this.lbCaption);
38+ this.panel1.Controls.Add(this.cbList);
3939 this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
4040 this.panel1.Location = new System.Drawing.Point(0, 0);
4141 this.panel1.Name = "panel1";
42- this.panel1.Size = new System.Drawing.Size(200, 20);
42+ this.panel1.Size = new System.Drawing.Size(200, 23);
4343 this.panel1.TabIndex = 3;
4444 //
45+ // cbList
46+ //
47+ this.cbList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
48+ | System.Windows.Forms.AnchorStyles.Right)));
49+ this.cbList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
50+ this.cbList.Location = new System.Drawing.Point(0, 0);
51+ this.cbList.Name = "cbList";
52+ this.cbList.Size = new System.Drawing.Size(200, 20);
53+ this.cbList.TabIndex = 0;
54+ //
4555 // panel2
4656 //
4757 this.panel2.AutoSize = true;
@@ -52,28 +62,6 @@
5262 this.panel2.Size = new System.Drawing.Size(200, 60);
5363 this.panel2.TabIndex = 4;
5464 //
55- // renderView
56- //
57- this.renderView.Dock = System.Windows.Forms.DockStyle.Fill;
58- this.renderView.Location = new System.Drawing.Point(0, 20);
59- this.renderView.Name = "renderView";
60- this.renderView.Size = new System.Drawing.Size(200, 157);
61- this.renderView.SurfaceUsage = nft.framework.drawing.SurfaceUsage.Normal;
62- this.renderView.TabIndex = 5;
63- //
64- // lbCaption
65- //
66- this.lbCaption.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
67- | System.Windows.Forms.AnchorStyles.Right)));
68- this.lbCaption.AutoEllipsis = true;
69- this.lbCaption.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
70- this.lbCaption.Location = new System.Drawing.Point(0, 0);
71- this.lbCaption.Name = "lbCaption";
72- this.lbCaption.Size = new System.Drawing.Size(200, 20);
73- this.lbCaption.TabIndex = 0;
74- this.lbCaption.Text = "label1";
75- this.lbCaption.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
76- //
7765 // tbInfo
7866 //
7967 this.tbInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@@ -87,6 +75,15 @@
8775 this.tbInfo.Size = new System.Drawing.Size(200, 57);
8876 this.tbInfo.TabIndex = 0;
8977 //
78+ // renderView
79+ //
80+ this.renderView.Dock = System.Windows.Forms.DockStyle.Fill;
81+ this.renderView.Location = new System.Drawing.Point(0, 23);
82+ this.renderView.Name = "renderView";
83+ this.renderView.Size = new System.Drawing.Size(200, 154);
84+ this.renderView.SurfaceUsage = nft.framework.drawing.SurfaceUsage.Normal;
85+ this.renderView.TabIndex = 5;
86+ //
9087 // BuildTool
9188 //
9289 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -107,10 +104,9 @@
107104 #endregion
108105
109106 private System.Windows.Forms.Panel panel1;
110- private System.Windows.Forms.Label lbCaption;
111107 private System.Windows.Forms.Panel panel2;
112108 private System.Windows.Forms.TextBox tbInfo;
113109 private framework.drawing.RenderViewPanel renderView;
114-
110+ private System.Windows.Forms.ComboBox cbList;
115111 }
116112 }