Exemplo n.º 1
0
        public IStrategy AddCareList(params string[] fields)
        {
            if (FilterList == null)
            {
                ResetFilterList(FilterListType.Care);
            }
            if (FilterList.TYPE == FilterListType.Care)
            {
                if (fields != null && fields.Length > 0)
                {
                    FilterList.Add(fields);
                }
            }

            return(this);
        }
Exemplo n.º 2
0
 private void ResetFilterList(FilterListType type)
 {
     if (FilterList != null)
     {
         if (FilterList.TYPE == type)
         {
             FilterList.Clear();
         }
         else
         {
             ResetFilterList();
             FilterList = new FilterList(type);
         }
     }
     else
     {
         FilterList = new FilterList(type);
     }
 }
Exemplo n.º 3
0
 public IStrategy ResetFilterList()
 {
     FilterList.Clear();
     FilterList = null;
     return(this);
 }
Exemplo n.º 4
0
        private List <Pair> GetMappingList(object obj1, object obj2)
        {
            var list = new List <Pair>();



            var members1 = obj1.GetType().GetMembers().Where(m => m.MemberType == System.Reflection.MemberTypes.Field || m.MemberType == System.Reflection.MemberTypes.Property).ToArray();

            var members2 = obj2.GetType().GetMembers().Where(m => m.MemberType == System.Reflection.MemberTypes.Field || m.MemberType == System.Reflection.MemberTypes.Property).ToArray();

            if (FilterList != null)
            {
                switch (FilterList.TYPE)
                {
                case FilterListType.Care:
                    foreach (var mem2 in members2)
                    {
                        if (FilterList.IsEmpty || FilterList.Contains(mem2.Name))
                        {
                            var mem1 = members1.FirstOrDefault(m => m.Name == mem2.Name);

                            if (mem1 != null)

                            {
                                var pair = Pair.Create(mem1.Name, mem2.Name);

                                if (pair != null)
                                {
                                    list.Add(pair);
                                }
                            }
                        }
                    }
                    break;

                case FilterListType.Ignore:
                    if (!FilterList.IsEmpty)
                    {
                        foreach (var mem2 in members2)
                        {
                            if (!FilterList.Contains(mem2.Name))
                            {
                                var mem1 = members1.FirstOrDefault(m => m.Name == mem2.Name);

                                if (mem1 != null)

                                {
                                    var pair = Pair.Create(mem1.Name, mem2.Name);

                                    if (pair != null)
                                    {
                                        list.Add(pair);
                                    }
                                }
                            }
                        }
                    }
                    break;
                }
            }

            //增加Mapping绑定
            if (MappingList.Count > 0)
            {
                foreach (var pair in MappingList)
                {
                    var index = list.FindIndex(itm => itm.Member2.Equals(pair.Member2));
                    if (index >= 0)
                    {
                        list.RemoveAt(index);
                    }
                    list.Add(pair);
                }
            }

            return(list);
        }
Exemplo n.º 5
0
 private FilterList(FilterList list)
 {
     this.TYPE = list.TYPE;
     this.List = new List <string>();
     list.List.ForEach(item => this.List.Add(item));
 }