Commits

Anonymous committed 300dac1

move GenericItemList out

Comments (0)

Files changed (1)

Usually/Resolve.cs

             }
         }
     }
-    public class Settler<T> where T: class
+    public class GenericItemList<T> where T: class
     {
-        private class GenericItemList
+        private class MetaInfoAdapter : MetaInfoBuilderBase<T>
         {
-            private class MetaInfoAdapter : MetaInfoBuilderBase<T>
+            public IMetaInfo<object[]> Adapt()
             {
-                public IMetaInfo<object[]> Adapt()
+                var names = new List<string>();
+                var indices = new Dictionary<string, int>();
+                this.ForEachInfoValue(null, (k, v) =>
                 {
-                    var names = new List<string>();
-                    var indices = new Dictionary<string, int>();
-                    this.ForEachInfoValue(null, (k, v) =>
+                    if (!indices.ContainsKey(k))
                     {
-                        if (! indices.ContainsKey(k))
-                        {
-                            indices.Add(k, names.Count);
-                            names.Add(k);
-                        }
+                        indices.Add(k, names.Count);
+                        names.Add(k);
+                    }
+                });
+                Func<string, Func<object[], object>> createGetter = name =>
+                {
+                    int i = indices[name];
+                    return array => array[i];
+                };
+                var b = new MetaInfoBuilder<object[]>() as IMetaBuilder<object[]>;
+                b.Table(this.tableName);
+                this.keys.ForEach(null, (k, v) =>
+                {
+                    b.Key(k, createGetter(k), value => this.keys.GeneratorExpr(k, value));
+                });
+                foreach (var g in this.extraKeys.Keys)
+                {
+                    var source = this.extraKeys[g];
+                    var target = b.ExtraKey(g);
+                    source.ForEach(null, (k, v) =>
+                    {
+                        target.Key(k, createGetter(k), value => source.GeneratorExpr(k, value));
                     });
-                    Func<string, Func<object[], object>> createGetter = name =>
+                }
+                if (!String.IsNullOrEmpty(this.group)) b.MasterExtaKey(this.group);
+                this.values.ForEach(null, (k, v) =>
+                {
+                    if (this.refList.Contains(k))
                     {
-                        int i = indices[name];
-                        return array => array[i];
-                    };
-                    var b = new MetaInfoBuilder<object[]>() as IMetaBuilder<object[]>;
-                    b.Table(this.tableName);
-                    this.keys.ForEach(null, (k, v) =>
+                        b.Ref(k, createGetter(k));
+                    }
+                    else
                     {
-                        b.Key(k, createGetter(k), value => this.keys.GeneratorExpr(k, value));
-                    });
-                    foreach (var g in this.extraKeys.Keys)
-                    {
-                        var source = this.extraKeys[g];
-                        var target = b.ExtraKey(g);
-                        source.ForEach(null, (k, v) =>
-                        {
-                            target.Key(k, createGetter(k), value => source.GeneratorExpr(k, value));
-                        });
+                        b.Value(k, createGetter(k));
                     }
-                    if (! String.IsNullOrEmpty(this.group)) b.MasterExtaKey(this.group);
-                    this.values.ForEach(null, (k, v) =>
-                    {
-                        if (this.refList.Contains(k))
-                        {
-                            b.Ref(k, createGetter(k));
-                        }
-                        else
-                        {
-                            b.Value(k, createGetter(k));
-                        }
-                    });
-                    return b as IMetaInfo<object[]>;
-                }
-            }
-            private IMetaInfo<T> info = null;
-            private List<object[]> items = new List<object[]>();
-            private Dictionary<string, int> indexByName = null;
-            private int[] indexByNumber = null;
-            private void BuildValueNames(T obj)
-            {
-                if (this.indexByName == null)
-                {
-                    var byName = new Dictionary<string, int>();
-                    var byNumber = new List<int>();
-                    this.info.ForEachInsertValue(obj, (k, v) =>
-                    {
-                        var i = byName.ContainsKey(k) ? byName[k] : byName.Count;
-                        byNumber.Add(i);
-                        byName[k] = i;
-                    });
-                    this.indexByName = byName;
-                    this.indexByNumber = byNumber.ToArray();
-                }
-            }
-            public GenericItemList(IMetaInfo<T> info)
-            {
-                this.info = info;
-            }
-            private static bool FAST = true;
-            public object[] Add(T obj)
-            {
-                this.BuildValueNames(obj);
-                var item = new object[this.indexByName.Count];
-                int i = 0;
-                if (FAST)
-                {
-                    this.info.ForEachInsertValue(obj, (k, v) => item[this.indexByNumber[i++]] = v);
-                }
-                else
-                {
-                    this.info.ForEachInsertValue(obj, (k, v) => item[this.indexByName[k]] = v);
-                }
-                this.items.Add(item);
-                return item;
-            }
-            public void Clear()
-            {
-                this.items.Clear();
-            }
-            public int Count { get { return this.items.Count; } }
-            public void ForEach(Action<object[]> action)
-            {
-                this.items.ForEach(action);
-            }
-            public static Meta<object[]> GetMeta(Meta<T> inner)
-            {
-              //      public delegate void Meta<T>(IMetaBuilder<T> m);
-                return m => {
-                    //inner(
-                };
-            //Action<object[]>
+                });
+                return b as IMetaInfo<object[]>;
             }
         }
+        private IMetaInfo<T> info = null;
+        private List<object[]> items = new List<object[]>();
+        private Dictionary<string, int> indexByName = null;
+        private int[] indexByNumber = null;
+        private void BuildValueNames(T obj)
+        {
+            if (this.indexByName == null)
+            {
+                var byName = new Dictionary<string, int>();
+                var byNumber = new List<int>();
+                this.info.ForEachInsertValue(obj, (k, v) =>
+                {
+                    var i = byName.ContainsKey(k) ? byName[k] : byName.Count;
+                    byNumber.Add(i);
+                    byName[k] = i;
+                });
+                this.indexByName = byName;
+                this.indexByNumber = byNumber.ToArray();
+            }
+        }
+        public GenericItemList(IMetaInfo<T> info)
+        {
+            this.info = info;
+        }
+        private static bool FAST = true;
+        public object[] Add(T obj)
+        {
+            this.BuildValueNames(obj);
+            var item = new object[this.indexByName.Count];
+            int i = 0;
+            if (FAST)
+            {
+                this.info.ForEachInsertValue(obj, (k, v) => item[this.indexByNumber[i++]] = v);
+            }
+            else
+            {
+                this.info.ForEachInsertValue(obj, (k, v) => item[this.indexByName[k]] = v);
+            }
+            this.items.Add(item);
+            return item;
+        }
+        public void Clear()
+        {
+            this.items.Clear();
+        }
+        public int Count { get { return this.items.Count; } }
+        public void ForEach(Action<object[]> action)
+        {
+            this.items.ForEach(action);
+        }
+        public static Meta<object[]> GetMeta(Meta<T> inner)
+        {
+            //      public delegate void Meta<T>(IMetaBuilder<T> m);
+            return m =>
+            {
+                //inner(
+            };
+            //Action<object[]>
+        }
+    }
+    public class Settler<T> where T : class
+    {
         public class SettlerItem
         {
             public SettlerItem Add(string name, Meta<T> meta)