コード例 #1
0
ファイル: TestCollections.cs プロジェクト: rururu387/C-
        public void countTime(int i)
        {
            System.Diagnostics.Stopwatch SW = new System.Diagnostics.Stopwatch();
            SW.Start();
            testListKey.FindAll(someEd => someEd.Equals(elementGen(i).Value));
            SW.Stop();
            Console.WriteLine("Duration of search of all in List<Edition>:" + SW.ElapsedMilliseconds + " Miliseconds");
            SW.Reset();
            SW.Start();
            testListStr.FindAll(someStr => someStr == i.ToString());
            SW.Stop();
            Console.WriteLine("Duration of search of all in List<String>:" + SW.ElapsedMilliseconds + " Miliseconds");
            SW.Reset();
            TValue tempMag;

            SW.Start();
            try
            {
                tempMag = testKeyDictionary[elementGen(i).Key];
            }
            catch
            {}
            SW.Stop();
            Console.WriteLine("Duration of search of all in Dictionary<Edition, Magazine>:" + SW.ElapsedMilliseconds + " Miliseconds");
            SW.Restart();
            try
            {
                tempMag = testStrDictionary[i.ToString()];
            }
            catch {}
            SW.Stop();
            Console.WriteLine("Duration of search of all in Dictionary<String, Magazine>:" + SW.ElapsedMilliseconds + " Miliseconds");
        }
コード例 #2
0
ファイル: ModifyCategory.cs プロジェクト: ngochoanhbr/dahuco
        public System.Collections.Generic.List <CategoryInfo> GetRelationNodeList(System.Collections.Generic.List <CategoryInfo> list, int intParentID)
        {
            System.Collections.Generic.List <CategoryInfo> list2 = list.FindAll((CategoryInfo parameterA) => parameterA.ParentID == intParentID);
            System.Collections.Generic.List <CategoryInfo> list3 = new System.Collections.Generic.List <CategoryInfo>();
            int num = 0;

            foreach (CategoryInfo current in list2)
            {
                if (num == list2.Count - 1)
                {
                    current.CategoryName = ((current.ParentID == 0) ? "" : StringUtils.GetCatePrefix(current.Depth - 1, true)) + StringUtils.GetChineseSpell(current.CategoryName).Substring(0, 1) + current.CategoryName;
                }
                else
                {
                    current.CategoryName = ((current.ParentID == 0) ? "" : StringUtils.GetCatePrefix(current.Depth - 1, false)) + StringUtils.GetChineseSpell(current.CategoryName).Substring(0, 1) + current.CategoryName;
                }
                list3.Add(current);
                if (current.ChildCount > 0)
                {
                    list3.AddRange(this.GetRelationNodeList(list, current.AutoID));
                }
                num++;
            }
            return(list3);
        }
コード例 #3
0
        static int _m_FindAll(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                System.Collections.Generic.List <string> gen_to_be_invoked = (System.Collections.Generic.List <string>)translator.FastGetCSObj(L, 1);



                {
                    System.Predicate <string> _match = translator.GetDelegate <System.Predicate <string> >(L, 2);

                    System.Collections.Generic.List <string> gen_ret = gen_to_be_invoked.FindAll(
                        _match);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
コード例 #4
0
ファイル: MemoryCacheManager.cs プロジェクト: Mualumene/SGP
        /// <summary>
        /// Removes items by pattern
        /// </summary>
        /// <param name="pattern">pattern</param>
        public void RemoveByPattern(string pattern)
        {
            var keysToRemove = cacheKeys.FindAll(p => p.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) != -1);

            foreach (string key in keysToRemove)
            {
                Remove(key);
            }
        }
コード例 #5
0
ファイル: BreakpointManager.cs プロジェクト: wiktork/MIEngine
        public async Task BindAsync()
        {
            List <AD7PendingBreakpoint> breakpointsToBind;

            lock (_pendingBreakpoints)
            {
                breakpointsToBind = _pendingBreakpoints.FindAll((b) => b.PendingBreakpoint != null && b.PendingBreakpoint.IsPending);
            }

            if (breakpointsToBind != null)
            {
                foreach (var b in breakpointsToBind)
                {
                    var bpList = await b.PendingBreakpoint.SyncBreakpoint(_engine.DebuggedProcess);

                    RebindAddresses(b, bpList);
                }
            }
        }
コード例 #6
0
        protected override IEnumerable <IFightResult> GenerateResults()
        {
            System.Collections.Generic.List <IFightResult> list = new System.Collections.Generic.List <IFightResult>();
            list.AddRange(
                from entry in base.GetAllFightersWithLeavers()
                where !(entry is IOwnable)
                select entry.GetFightResult());

            FightTeam[] teams = new FightTeam[] { BlueTeam, RedTeam };
            for (int i = 0; i < teams.Length; i++)
            {
                int xpBonusPercent = 0;

                int dropBonusPercent = 0;

                if (teams[i] == GetTeamChallenged())
                {
                    xpBonusPercent   += GetChallengesExpPercentBonus();
                    dropBonusPercent += GetChallengesDropPercentBonus();
                }

                FightTeam team = teams[i];
                System.Collections.Generic.IEnumerable <Fighter> enumerable = ((team == base.RedTeam) ? base.BlueTeam : base.RedTeam).GetDeads();
                IOrderedEnumerable <IFightResult> orderedEnumerable         = list.FindAll(x => x.CanLoot(team)).OrderBy(x => x.Prospecting);

                int teamPP = team.GetFighters(false).Sum((Fighter entry) => entry.Stats.Prospecting.TotalInContext());
                teamPP += teamPP.GetPercentageOf(dropBonusPercent);

                long baseKamas = enumerable.Sum((Fighter entry) => (long)((ulong)entry.GetDroppedKamas()));
                using (System.Collections.Generic.IEnumerator <IFightResult> enumerator = orderedEnumerable.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        IFightResult looter = enumerator.Current;
                        looter.Loot.Kamas = FormulasProvider.Instance.AdjustDroppedKamas(looter, teamPP, baseKamas, dropBonusPercent);
                        System.Collections.Generic.IEnumerable <Fighter> arg_1F0_0 = enumerable;
                        Func <Fighter, System.Collections.Generic.IEnumerable <DroppedItem> > selector = (Fighter dropper) => dropper.RollLoot(looter, dropBonusPercent);
                        foreach (DroppedItem current in arg_1F0_0.SelectMany(selector))
                        {
                            looter.Loot.AddItem(current);
                        }
                        if (looter is FightPlayerResult && looter.Outcome == FightOutcomeEnum.RESULT_VICTORY)
                        {
                            (looter as FightPlayerResult).AddEarnedExperience(xpBonusPercent);
                        }
                    }
                }
            }
            return(list);
        }
コード例 #7
0
 static public int FindAll(IntPtr l)
 {
     try {
         System.Collections.Generic.List <WWWRequest> self = (System.Collections.Generic.List <WWWRequest>)checkSelf(l);
         System.Predicate <WWWRequest> a1;
         checkDelegate(l, 2, out a1);
         var ret = self.FindAll(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #8
0
        public async Task DeleteBreakpointsPendingDeletion()
        {
            //push all of the pending breakpoints to delete into a new list so that we avoid iterator invalidation
            List <AD7PendingBreakpoint> breakpointsPendingDeletion = null;

            lock (_pendingBreakpoints)
            {
                breakpointsPendingDeletion = _pendingBreakpoints.FindAll((b) => b.PendingDelete);
                _pendingBreakpoints.RemoveAll((b) => b.PendingDelete);
            }

            if (breakpointsPendingDeletion != null)
            {
                foreach (var b in breakpointsPendingDeletion)
                {
                    await b.DeletePendingDelete();
                }
            }
        }
コード例 #9
0
 public override void RetrieveCurrentValues(System.Collections.Generic.List <ConfigurationItem> configs)
 {
     foreach (string pageCode in configs.Select(x => x.DefaultKey1).Distinct())
     {
         var lstConfigs    = configs.FindAll(x => x.DefaultKey1 == pageCode);
         var currentValues = RetrieveCurrentValues(businessUnit, lstConfigs);
         AddMissingValues(lstConfigs, currentValues);
         foreach (ConfigurationItem config in lstConfigs)
         {
             string currentValue = "";
             if (currentValues.ContainsKey(config.DefaultName))
             {
                 currentValue        = currentValues[config.DefaultName];
                 config.CurrentValue = currentValue;
                 config.UpdatedValue = currentValue;
             }
         }
     }
 }
コード例 #10
0
 public override void RetrieveCurrentValues(System.Collections.Generic.List <ConfigurationItem> configs)
 {
     // loop throguh control code --> different control code configs to be shown on the same page can create a trouble when having same attr_name value
     foreach (string controlCode in configs.Select(x => x.DefaultKey1).Distinct())
     {
         var lstConfigs    = configs.FindAll(x => x.DefaultKey1 == controlCode);
         var currentValues = RetrieveCurrentValues(businessUnit, lstConfigs);
         AddMissingValues(lstConfigs, currentValues);
         string currentValue = "";
         foreach (ConfigurationItem config in lstConfigs)
         {
             if (currentValues.ContainsKey(config.DefaultName))
             {
                 currentValue        = currentValues[config.DefaultName];
                 config.CurrentValue = currentValue;
                 config.UpdatedValue = currentValue;
             }
         }
     }
 }
コード例 #11
0
 public static System.Collections.Generic.List <object> GetPortFriendlyName()
 {
     System.Collections.Generic.List <object> result = null;
     try
     {
         using (ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("SELECT * FROM WIN32_SerialPort"))
         {
             string[] portNames = SerialPort.GetPortNames();
             System.Collections.Generic.List <ManagementBaseObject> list = managementObjectSearcher.Get().Cast <ManagementBaseObject>().ToList <ManagementBaseObject>();
             list   = list.FindAll((ManagementBaseObject x) => x["PNPDeviceID"].ToString().Contains("VID_04D8&PID_00DF&MI_00")).ToList <ManagementBaseObject>();
             result = (from n in portNames
                       join p in list on n equals p["DeviceID"].ToString()
                       select p["Caption"]).ToList <object>();
         }
     }
     catch (System.Exception e)
     {
         ErrorXMLProcess.ExceptionProcess(e);
     }
     return(result);
 }
コード例 #12
0
ファイル: Tests1.cs プロジェクト: Dblind/codewar
        public static void MainTe()
        {
            System.Collections.Generic.List <Tests1> arrList = Tests1.GetListTests();
            //arrList.Sort(new TestsComparer());
            arrList.Sort(delegate(Tests1 x, Tests1 y) { return(x.Name.CompareTo(y.Name)); });
            ArrayList L = new ArrayList(); L.Sort();

            foreach (Tests1 e in arrList)
            {
                System.Console.WriteLine(e.Name);
            }
            Tests1 tests1 = new Tests1();

            // Tests2 tests2 = (Tests2) tests1;
            System.Console.WriteLine(new string('-', 30));

            Predicate <Tests1> deltest = delegate(Tests1 t) { return(t.Price > 10); };
            List <Tests1>      matches = arrList.FindAll(deltest);
            Action <Tests1>    print   = Console.WriteLine;

            matches.ForEach(print);
        }
コード例 #13
0
        static int FindAll(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            System.Collections.Generic.List <int> __cl_gen_to_be_invoked = (System.Collections.Generic.List <int>)translator.FastGetCSObj(L, 1);


            try {
                {
                    System.Predicate <int> match = translator.GetDelegate <System.Predicate <int> >(L, 2);

                    System.Collections.Generic.List <int> __cl_gen_ret = __cl_gen_to_be_invoked.FindAll(match);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
コード例 #14
0
 public System.Collections.Generic.List <T> FindAll(System.Predicate <T> matcher)
 {
     System.Collections.Generic.List <T> items = base.Items as System.Collections.Generic.List <T>;
     return(items.FindAll(matcher));
 }
コード例 #15
0
        public List <Bachelor> PretraziStudente(string im)
        {
            List <Bachelor> vrati = Studenti.FindAll(x => x.Ime == im);

            return(vrati);
        }
コード例 #16
0
        public List <Osoba> PretraziUposlene(string im)
        {
            List <Osoba> vrati = Uposleni.FindAll(x => x.Ime == im);

            return(vrati);
        }
コード例 #17
0
        private bool CreateTransaction()
        {
            if (total > 0)
            {
                // Are you sure you want to save these amounts....
                DialogResult result = DialogResult.None;
                using (frmMessage dialog = new frmMessage(LSRetailPosis.ApplicationLocalizer.Language.Translate(1953), System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                    result = dialog.DialogResult;
                }

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    TenderLineItem tenderLine;
                    int            i = 0; //counter variable for the int Array

                    // Did we count cash?
                    if (cashCounted)
                    {
                        TenderViewModel cashViewTender = gridSource.First(tender => tender.TenderOperationType == PosisOperations.PayCash);
                        string          cashTenderId   = cashViewTender.TenderTypeId;
                        string          cashTenderDesc = cashViewTender.TenderName;
                        string          cashTenderCode = ApplicationSettings.Terminal.StoreCurrency;

                        decimal totalCashAmount = gridSource.Sum(tender => tender.TenderOperationType == PosisOperations.PayCash ? tender.Total : 0m);

                        //This allows the operator to recount a given number of times.
                        if (transaction is TenderDeclarationTransaction)
                        {
                            int rowHandle = gridSource.IndexOf(cashViewTender);

                            if (NeedForRecount(cashTenderId, totalCashAmount, cashTenderDesc, ref i))
                            {
                                // Select the cash row
                                if (rowHandle != -1)
                                {
                                    gvTenders.SelectRow(rowHandle);
                                }

                                return(false);
                            }
                            else
                            {
                                // Disable the cash tender row
                                cashViewTender.Enabled = false;
                                gvTenders.InvalidateRow(rowHandle);

                                i++; //proceed to the next counter that belongs to the next tendertype.
                            }
                        }

                        //Adding a Tenderline (or not)
                        if (totalCashAmount > 0)
                        {
                            tenderLine                       = (TenderLineItem)Dialog.InternalApplication.BusinessLogic.Utility.CreateTenderLineItem();
                            tenderLine.Amount                = totalCashAmount;
                            tenderLine.TenderTypeId          = cashTenderId;
                            tenderLine.Description           = cashTenderDesc;
                            tenderLine.ExchrateMST           = Dialog.InternalApplication.Services.Currency.ExchangeRate(transaction.StoreCurrencyCode) * 100;
                            tenderLine.CompanyCurrencyAmount = Dialog.InternalApplication.Services.Currency.CurrencyToCurrency(transaction.StoreCurrencyCode, ApplicationSettings.Terminal.CompanyCurrency, totalCashAmount);
                            tenderLine.CurrencyCode          = transaction.StoreCurrencyCode;
                            transaction.Add(tenderLine);
                        }
                    }

                    // Did we count other tenders?
                    if (otherTendersCounted)
                    {
                        List <TenderViewModel> otherTenders = gridSource.FindAll(
                            tender => tender.TenderOperationType != PosisOperations.PayCash && tender.TenderOperationType != PosisOperations.PayCurrency);

                        foreach (TenderViewModel otherCount in otherTenders)
                        {
                            if (transaction is TenderDeclarationTransaction)
                            {
                                int rowHandle = gridSource.IndexOf(otherCount);

                                if (NeedForRecount(otherCount.TenderTypeId, otherCount.Total, otherCount.TenderName, ref i))
                                {
                                    // Select the row
                                    if (rowHandle != -1)
                                    {
                                        gvTenders.SelectRow(rowHandle);
                                    }

                                    return(false);
                                }
                                else
                                {
                                    // Disable the row
                                    otherCount.Enabled = false;
                                    gvTenders.InvalidateRow(rowHandle);
                                    i++;
                                }
                            }

                            if (otherCount.Total > 0)
                            {
                                tenderLine                       = (TenderLineItem)Dialog.InternalApplication.BusinessLogic.Utility.CreateTenderLineItem();
                                tenderLine.Amount                = otherCount.Total;
                                tenderLine.TenderTypeId          = otherCount.TenderTypeId;
                                tenderLine.Description           = otherCount.TenderName;
                                tenderLine.ExchrateMST           = Dialog.InternalApplication.Services.Currency.ExchangeRate(transaction.StoreCurrencyCode) * 100;
                                tenderLine.CompanyCurrencyAmount = Dialog.InternalApplication.Services.Currency.CurrencyToCurrency(transaction.StoreCurrencyCode, ApplicationSettings.Terminal.CompanyCurrency, otherCount.Total);
                                tenderLine.CurrencyCode          = transaction.StoreCurrencyCode;
                                transaction.Add(tenderLine);
                            }
                        }
                    }

                    // Did we count foreign currency?
                    if (foreignCurrencyCounted)
                    {
                        List <TenderViewModel> currencyTenders = gridSource.FindAll(tender => tender.TenderOperationType == PosisOperations.PayCurrency);

                        foreach (TenderViewModel currencyCount in currencyTenders)
                        {
                            //Convert to StoreCurrency...
                            decimal currAmountInStoreCurr = Dialog.InternalApplication.Services.Currency.CurrencyToCurrency(
                                currencyCount.Currency, ApplicationSettings.Terminal.StoreCurrency, currencyCount.Total);

                            if (transaction is TenderDeclarationTransaction)
                            {
                                int rowHandle = gridSource.IndexOf(currencyCount);

                                if (NeedForRecount(currencyCount.TenderTypeId, currAmountInStoreCurr, currencyCount.Currency, ref i))
                                {
                                    // Select the row
                                    if (rowHandle != -1)
                                    {
                                        gvTenders.SelectRow(rowHandle);
                                    }

                                    return(false);
                                }
                                else
                                {
                                    // Disable the row
                                    currencyCount.Enabled = false;
                                    gvTenders.InvalidateRow(rowHandle);

                                    i++;
                                }
                            }

                            if (currencyCount.Total > 0)
                            {
                                tenderLine        = (TenderLineItem)Dialog.InternalApplication.BusinessLogic.Utility.CreateTenderLineItem();
                                tenderLine.Amount = currencyCount.Total;
                                tenderLine.ForeignCurrencyAmount = currAmountInStoreCurr;
                                tenderLine.CompanyCurrencyAmount = Dialog.InternalApplication.Services.Currency.CurrencyToCurrency(currencyCount.Currency, ApplicationSettings.Terminal.CompanyCurrency, currencyCount.Total);
                                tenderLine.ExchangeRate          = ((Dialog.InternalApplication.Services.Currency.ExchangeRate(currencyCount.Currency)) / (Dialog.InternalApplication.Services.Currency.ExchangeRate(ApplicationSettings.Terminal.StoreCurrency))) * 100;
                                tenderLine.ExchrateMST           = Dialog.InternalApplication.Services.Currency.ExchangeRate(currencyCount.Currency) * 100;
                                tenderLine.TenderTypeId          = currencyCount.TenderTypeId;
                                tenderLine.Description           = currencyCount.TenderName;
                                tenderLine.CurrencyCode          = currencyCount.Currency;
                                transaction.Add(tenderLine);
                            }
                        }
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            // No amount has been entered yet
            using (frmMessage frm = new frmMessage(LSRetailPosis.ApplicationLocalizer.Language.Translate(1959), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand))
            {
                LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(frm);
            }

            return(false);
        }
コード例 #18
0
ファイル: GenericCollection.cs プロジェクト: sasiit23/smah1
 public virtual System.Collections.Generic.List <T> FindAll(Predicate <T> match)
 {
     return(list.FindAll(match));
 }
コード例 #19
0
    private void Output(DataTable oTable)
    {
        StringBuilder sbText = new StringBuilder();

        System.Collections.Generic.List <Survey> surveyList = new System.Collections.Generic.List <Survey>();

        foreach (DataRow dr in oTable.Rows)
        {
            Survey model = new Survey();
            model.Answer         = dr["Answer"].ToString();
            model.CreateDateTime = Convert.ToDateTime(dr["CreateDateTime"]);
            model.GUID           = dr["GUID"].ToString();
            model.Question       = dr["Question"].ToString();
            model.TrackId        = dr["TrackId"].ToString();
            surveyList.Add(model);
        }

        Dictionary <string, string> fileds = new Dictionary <string, string>();
        Dictionary <string, string> guids  = new Dictionary <string, string>();

        //把标题分组
        foreach (Survey item in surveyList)
        {
            if (!fileds.ContainsKey(item.Question))
            {
                fileds.Add(item.Question, item.Question);
            }
            if (!guids.ContainsKey(item.GUID))
            {
                guids.Add(item.GUID, item.GUID);
            }
        }
        foreach (KeyValuePair <string, string> item in fileds)
        {
            sbText.AppendFormat("{0},", item.Value);
        }
        sbText.AppendFormat("{0},{1},{2}", "TrackId", "GUID", "CreateDateTime");
        sbText.AppendLine();


        foreach (KeyValuePair <string, string> item in guids)
        {
            string guid = item.Value;
            List <Survey> signleGuidList = surveyList.FindAll(delegate(Survey m)
            {
                return(m.GUID == guid);
            });
            if (signleGuidList.Count > 0)
            {
                //每一个用户
                //根据问题获取答案
                foreach (KeyValuePair <string, string> question in fileds)
                {
                    //循环每一个问题
                    List <string> answerList = new List <string>();

                    //防止有一个问题有多中答案
                    List <Survey> qList = signleGuidList.FindAll(delegate(Survey q)
                    {
                        return(q.Question == question.Value);
                    });
                    if (qList.Count > 0)
                    {
                        foreach (Survey s in qList)
                        {
                            string answer = s.Answer;
                            answer = Regex.Replace(answer, @"[\f\n\r\t\v]", string.Empty);
                            answer = answer.Replace(",", ".");
                            answerList.Add(answer);
                        }
                        sbText.Append(string.Join("|", answerList.ToArray()));
                    }
                    sbText.Append(",");
                }

                //取第一个添加TrackId,Guid,CreateDateTime
                Survey firstSurvey = signleGuidList[0];
                sbText.AppendFormat("{0},{1},{2}", firstSurvey.TrackId, firstSurvey.GUID, firstSurvey.CreateDateTime);
                sbText.AppendLine();
            }/**/
        }

        Response.Clear();
        Response.AppendHeader("Content-Disposition", string.Format("attachment;filename=survey_{0}.csv", DateTime.Now.ToString("yyyyMMddHHmm")));
        Response.ContentType     = "application/ms-excel";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
        Response.Write(sbText.ToString());
        Response.End();
    }
コード例 #20
0
        public List <Predmeti> PretraziPredmete(string im)
        {
            List <Predmeti> vrati = Predmeti.FindAll(x => x.Naziv == im);

            return(vrati);
        }