예제 #1
0
 /// <summary>
 /// 粗暴删除,不匹配原始优先级
 /// </summary>
 /// <param name="handle"></param>
 public void Remove(Action handle)
 {
     if (handles != null)
     {
         int c = handles.Count;
         for (int i = 0; i < c; i++)
         {
             if (handles[i].action == handle || handles[i].action.Target == handle.Target && handles[i].action.Method == handle.Method)
             {
                 handles.RemoveAt(i);
                 break;
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// 当需要持久化数据Provider中没有的信息时,用此类来合并Provider的数据
        /// 和本地json数据文件。
        /// </summary>
        /// <returns>合并后的数据列表</returns>
        public IEnumerable <AppRole> GetData()
        {
            var dbData = mProvider.GetData();

            lock (mCachedData)
            {
                foreach (AppRole dbItem in dbData)
                {
                    AppRole chItem = mCachedData.FirstOrDefault(ch => ch.Id == dbItem.Id);
                    if (chItem != null)
                    {
                        dbItem.FunctionIds = chItem.FunctionIds;
                        mCachedData[mCachedData.IndexOf(chItem)] = dbItem;
                    }
                    else
                    {
                        mCachedData.Add(dbItem);
                    }
                }
                //移除Provider中没有的值
                for (int i = mCachedData.Count - 1; i >= 0; i--)
                {
                    if (!dbData.Any(d => d.Id == mCachedData[i].Id))
                    {
                        mCachedData.RemoveAt(i);
                    }
                }
                return(mCachedData);
            }
        }