ソースを参照

More Utility functinos

Kenric Nugteren 1 年間 前
コミット
58026b62ff
3 ファイル変更30 行追加0 行削除
  1. 11 0
      InABox.Core/Client/Client.cs
  2. 17 0
      InABox.Core/Column.cs
  3. 2 0
      InABox.Core/FluentList.cs

+ 11 - 0
InABox.Core/Client/Client.cs

@@ -94,6 +94,17 @@ namespace InABox.Clients
             CheckClient<TEntity>().Save(entities, auditNote);
         }
 
+        public static void Save<TEntity>(TEntity entity, string auditNote, Action<TEntity, Exception?> callback)
+            where TEntity : Entity, IRemotable, IPersistent, new()
+        {
+            CheckClient<TEntity>().Save(entity, auditNote, callback);
+        }
+        public static void Save<TEntity>(IEnumerable<TEntity> entities, string auditNote, Action<IEnumerable<TEntity>, Exception?> callback)
+            where TEntity : Entity, IRemotable, IPersistent, new()
+        {
+            CheckClient<TEntity>().Save(entities, auditNote, callback);
+        }
+
         public static void Delete<TEntity>(TEntity entity, string auditNote)
             where TEntity : Entity, IRemotable, IPersistent, new()
         {

+ 17 - 0
InABox.Core/Column.cs

@@ -72,6 +72,12 @@ namespace InABox.Core
                 Expression = CoreUtils.CreateMemberExpression(typeof(T), property);
         }
 
+        public Column<TNew> Cast<TNew>()
+            where TNew: T
+        {
+            return new Column<TNew>(Property);
+        }
+
         public string Property { get; private set; }
 
         public override void Deserialize(SerializationInfo info, StreamingContext context)
@@ -188,6 +194,17 @@ namespace InABox.Core
             columns = new List<Column<T>>();
         }
 
+        public Columns<TNew> Cast<TNew>()
+            where TNew : T
+        {
+            var cols = new Columns<TNew>();
+            foreach(var column in columns)
+            {
+                cols.Add(column.Cast<TNew>());
+            }
+            return cols;
+        }
+
         public override string ToString()
         {
             return String.Join("; ", columns.Select(x => x.Property));

+ 2 - 0
InABox.Core/FluentList.cs

@@ -1,6 +1,8 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.ComponentModel;
 using System.Linq;
 
 namespace InABox.Core