示例#1
0
文件: FormField.cs 项目: zzy092/npoi
 private void AddNewObject(object obj, FFDataItemsType type)
 {
     lock (this)
     {
         this.itemsElementNameField.Add(type);
         this.itemsField.Add(obj);
     }
 }
示例#2
0
文件: FormField.cs 项目: zzy092/npoi
        private T AddNewObject <T>(FFDataItemsType type) where T : class, new()
        {
            T t = new T();

            lock (this)
            {
                this.itemsElementNameField.Add(type);
                this.itemsField.Add(t);
            }
            return(t);
        }
示例#3
0
 private void RemoveObject(FFDataItemsType type, int p)
 {
     lock (this)
     {
         int pos = GetObjectIndex(type, p);
         if (pos < 0 || pos >= this.itemsField.Count)
             return;
         itemsElementNameField.RemoveAt(pos);
         itemsField.RemoveAt(pos);
     }
 }
示例#4
0
 private T GetObjectArray<T>(int p, FFDataItemsType type)
     where T : class
 {
     lock (this)
     {
         int pos = GetObjectIndex(type, p);
         if (pos < 0 || pos >= this.itemsField.Count)
             return null;
         return itemsField[pos] as T;
     }
 }
示例#5
0
文件: FormField.cs 项目: zzy092/npoi
        private T InsertNewObject <T>(FFDataItemsType type, int p) where T : class, new()
        {
            T t = new T();

            lock (this)
            {
                int pos = GetObjectIndex(type, p);
                this.itemsElementNameField.Insert(pos, type);
                this.itemsField.Insert(pos, t);
            }
            return(t);
        }
示例#6
0
 private int SizeOfObjectArray(FFDataItemsType type)
 {
     lock (this)
     {
         int size = 0;
         for (int i = 0; i < itemsElementNameField.Count; i++)
         {
             if (itemsElementNameField[i] == type)
                 size++;
         }
         return size;
     }
 }
示例#7
0
 private List<T> GetObjectList<T>(FFDataItemsType type)
     where T : class
 {
     lock (this)
     {
         List<T> list = new List<T>();
         for (int i = 0; i < itemsElementNameField.Count; i++)
         {
             if (itemsElementNameField[i] == type)
                 list.Add(itemsField[i] as T);
         }
         return list;
     }
 }
示例#8
0
 private void SetObjectArray<T>(FFDataItemsType type, int p, T obj)
     where T : class
 {
     lock (this)
     {
         int pos = GetObjectIndex(type, p);
         if (pos < 0 || pos >= this.itemsField.Count)
             return;
         if (this.itemsField[pos] is T)
             this.itemsField[pos] = obj;
         else
             throw new Exception(string.Format(@"object types are difference, itemsField[{0}] is {1}, and parameter obj is {2}",
                 pos, this.itemsField[pos].GetType().Name, typeof(T).Name));
     }
 }
示例#9
0
 private int GetObjectIndex(FFDataItemsType type, int p)
 {
     int index = -1;
     int pos = 0;
     for (int i = 0; i < itemsElementNameField.Count; i++)
     {
         if (itemsElementNameField[i] == type)
         {
             if (pos == p)
             {
                 //return itemsField[p] as T;
                 index = i;
                 break;
             }
             else
                 pos++;
         }
     }
     return index;
 }