public void AddRemoveDataSource()
        {
            DataSourceManager dsManager = new DataSourceManager();
            MemoryDataSource dataSource = new MemoryDataSource();

            dsManager.AddDataSource(dataSource);
            Assert.AreEqual(1, dsManager.DataSources.Count);

            dsManager.AddDataSource(dataSource);
            Assert.AreEqual(1, dsManager.DataSources.Count);

            dsManager.RemoveDataSource(dataSource.Id);
            Assert.AreEqual(0, dsManager.DataSources.Count);
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DataSourceManager dataSourceMgr = new DataSourceManager();
            DBDataSource dbSource = new DBDataSource();
            dataSourceMgr.AddDataSource(dbSource);

            //List<DataItem> dataItemList = dbSource.GetDataItems();

            List<IFilter> filetList = new List<IFilter>();
            ContentFilter contentFilter = new ContentFilter("mail");
            filetList.Add(contentFilter);

            SimpleSearchEngine searchEngine = new SimpleSearchEngine();

            List<DataItem> results = searchEngine.Search(dataSourceMgr, filetList);

            contentFilter.Content = "mail";
        }
        public void Search()
        {
            SimpleSearchEngine simpleSearchEngin = new SimpleSearchEngine();
            DataSourceManager dsManager = new DataSourceManager();
            MemoryDataSource dataSource = new MemoryDataSource();
            dsManager.AddDataSource(dataSource);

            // Item 1
            {
                DataItem dataItem = new DataItem();
                dataItem.Id = "dummyId";

                dataItem.Key = "mk";
                dataItem.Title = "mailTitle";
                dataItem.Value = "this is the value of the mail item";
                dataItem.Comments = "the comments for the mail is added here";

                dataItem.Labels = "mail;dummy";
                dataItem.AccessCounter = 2;

                dataSource.AddDataItem(dataItem);
            }
        }
        public List<DataItem> Search(DataSourceManager dataSourceMgr, List<IFilter> filterList)
        {
            if (dataSourceMgr == null || filterList == null)
                return null;

            List<DataItem> results = new List<DataItem>();

            foreach (IDataSource dataSource in dataSourceMgr.DataSources)
            {
                List<DataItem> candidateItems = dataSource.GetDataItems();
                if (candidateItems == null)
                    continue;

                if (filterList.Count == 0)
                    results.AddRange(candidateItems);
                else
                {
                    foreach (IFilter filter in filterList)
                    {
                        if (filter == null)
                            continue;

                        foreach (DataItem dataItem in candidateItems)
                        {
                            if (dataItem == null)
                                continue;

                            UInt32 matchingFactor = filter.GetMatchingFactor(dataItem);
                            if (matchingFactor > 0) // Match
                                results.Add(dataItem);
                        }
                    }
                }
            }

            return results;
        }
Beispiel #5
0
        public Form1()
        {
            InitializeComponent();

            mSearchEngine = new SimpleSearchEngine();
            mDsManager = new DataSourceManager();
            mDataSource = new MemoryDataSource();
            mDsManager.AddDataSource(mDataSource);

            mExtToolMgr = new ExternalToolManager();

            bool bSucc = mExtToolMgr.Load("S:\\Build Tools\\pc\\_ExternalTools.xml");

            if(bSucc)
            {
                List<ExternalTool> extTools = mExtToolMgr.GetAllExternalTools();
                for (int i =0; i < extTools.Count; i++)
                {
                    ExternalTool et = extTools[i];
                    TitleList.Items.Add(et.GetTitle());

                    DataItem dataItem = new DataItem();
                    dataItem.Id = i.ToString();

                    dataItem.Key = et.GetTitle();
                    dataItem.Title = et.GetTitle();
                    dataItem.Value = et.GetCommand() + " " + et.GetParameter();
                    dataItem.Comments = i.ToString(); // save the indes in the comments

                    dataItem.Labels = "";
                    dataItem.AccessCounter = 0;

                    mDataSource.AddDataItem(dataItem);
                }
            }
        }
 public void Constructor()
 {
     DataSourceManager dsManager = new DataSourceManager();
     Assert.AreEqual(0, dsManager.DataSources.Count);
 }