示例#1
0
 public SearchViewModel()
 {
     foreach (var p in
              PropertySearcher.GetSearchProperties(typeof(TEntity)))
     {
         SingleProperty property = ContainerManager.RegisterProperty(p);
         SearchProperties.Add(property);
     }
 }
示例#2
0
        public virtual void Search(object sender, EventArgs args)
        {
            LinkedList <TEntity> temp =
                new LinkedList <TEntity>(_repo.GetAll());

            Entities.Clear();

            foreach (var f in Filters)
            {
                bool isNested = true;

                object owner;
                Type   ownerType = f.SingleProperty.PropertyInfo.DeclaringType;

                if (typeof(TEntity) == ownerType)
                {
                    isNested = false;
                }

                foreach (var a in _repo.GetAll())
                {
                    if (isNested)
                    {
                        owner =
                            PropertySearcher.GetNestedEntity(a, ownerType);
                    }
                    else
                    {
                        owner = a;
                    }

                    if (!f.IsContainsSearchString(owner))
                    {
                        temp.Remove(a);
                    }
                }
            }

            foreach (var e in temp)
            {
                Entities.Add(e);
            }
        }
            /// <summary>The bind.</summary>
            public void Bind()
            {
                Free();

                if (DataContext == null) return;

                object dataContext = DataContext.Target;
                DependencyObject target = Target;
                string commandTarget = CommandTarget;
                if (dataContext == null || target == null || commandTarget == null)
                {
                    CommonWpfConstans.LogCommon(false, "CommandBinder: No Binding: {0}", commandTarget);

                    return;
                }

                string customProperty = GetCustomPropertyName(target);
                bool useDirect = GetUseDirect(target);
                ICommand targetCommand = GetTargetCommand(target);
                if (targetCommand == null)
                {
                    CommonWpfConstans.LogCommon(false, "CommandBinder: No ICommand: {0}", commandTarget);
                    return;
                }

                if (_factory == null) _factory = new CommandFactory(DataContext, commandTarget);
                else
                {
                    _factory.Name = commandTarget;
                    _factory.Target = DataContext;
                }

                if (!useDirect) _factory.Connect(targetCommand, target, TaskScheduler, commandTarget);

                if (_searcher == null) _searcher = new PropertySearcher(Source, customProperty, targetCommand);
                else
                {
                    _searcher.CustomName = customProperty;
                    _searcher.Command = _factory.GetCommand(); //TODO GetCommand Not Correct
                }

                _searcher.SetCommand();
            }