当前位置: 首页>>代码示例>>C#>>正文


C# SortedList.Last方法代码示例

本文整理汇总了C#中SortedList.Last方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.Last方法的具体用法?C# SortedList.Last怎么用?C# SortedList.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SortedList的用法示例。


在下文中一共展示了SortedList.Last方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: leastError

 private static double leastError(SortedList<int, int> executionTimes, Func<int,double> fn)
 {
     var kvp = executionTimes.Last();
     var m = kvp.Value / fn(kvp.Key);
     var result = leastSquare(executionTimes, (num) => m * fn(num));
     return result;
 }
开发者ID:aquamoth,项目名称:CodeinGame,代码行数:7,代码来源:Program.cs

示例2: CreateNavigationLinks

    private void CreateNavigationLinks(Collective.Offer.SortType sortBy, bool isAsc, int currPage, int numOfRows, int totalPageCount)
    {
        string basicUrl = Request.Url.ToString();
        basicUrl = basicUrl.Substring(0, basicUrl.IndexOf(".aspx") + ".aspx".Count());

        // sort linkovi
        HyperLink hlOfferNameSort = (HyperLink)this.grdOffers.HeaderRow.FindControl("hlOfferNameSort");
        if (sortBy == Collective.Offer.SortType.OfferName)
        {
            hlOfferNameSort.NavigateUrl = basicUrl + "?sortby=" + Collective.Offer.SortType.OfferName.ToString() + "&asc=" + (!isAsc).ToString() + "&page=" + currPage.ToString() + "&rows=" + numOfRows.ToString();
            hlOfferNameSort.Text = isAsc ? "Offer Name ↑" : "Offer Name ↓";
        }
        else
        {
            hlOfferNameSort.NavigateUrl = basicUrl + "?sortby=" + Collective.Offer.SortType.OfferName.ToString() + "&asc=" + true.ToString() + "&page=" + currPage.ToString() + "&rows=" + numOfRows.ToString();
            hlOfferNameSort.Text = "Offer Name ↑";
        }

        HyperLink hlOfferIdSort = (HyperLink)this.grdOffers.HeaderRow.FindControl("hlOfferIdSort");
        if (sortBy == Collective.Offer.SortType.OfferId)
        {
            hlOfferIdSort.NavigateUrl = basicUrl + "?sortby=" + Collective.Offer.SortType.OfferId.ToString() + "&asc=" + (!isAsc).ToString() + "&page=" + currPage.ToString() + "&rows=" + numOfRows.ToString();
            hlOfferIdSort.Text = isAsc ? "ID ↑" : "ID ↓";
        }
        else
        {
            hlOfferIdSort.NavigateUrl = basicUrl + "?sortby=" + Collective.Offer.SortType.OfferId.ToString() + "&asc=" + true.ToString() + "&page=" + currPage.ToString() + "&rows=" + numOfRows.ToString();
            hlOfferIdSort.Text = "ID ↑";
        }

        HyperLink hlCategoryNameSort = (HyperLink)this.grdOffers.HeaderRow.FindControl("hlCategoryNameSort");
        if (sortBy == Collective.Offer.SortType.CategotyName)
        {
            hlCategoryNameSort.NavigateUrl = basicUrl + "?sortby=" + Collective.Offer.SortType.CategotyName.ToString() + "&asc=" + (!isAsc).ToString() + "&page=" + currPage.ToString() + "&rows=" + numOfRows.ToString();
            hlCategoryNameSort.Text = isAsc ? "Category Name ↑" : "Category Name ↓";
        }
        else
        {
            hlCategoryNameSort.NavigateUrl = basicUrl + "?sortby=" + Collective.Offer.SortType.CategotyName.ToString() + "&asc=" + true.ToString() + "&page=" + currPage.ToString() + "&rows=" + numOfRows.ToString();
            hlCategoryNameSort.Text = "Category Name ↑";
        }

        HyperLink hlBoughtCountSort = (HyperLink)this.grdOffers.HeaderRow.FindControl("hlBoughtCountSort");
        if (sortBy == Collective.Offer.SortType.BoughtCount)
        {
            hlBoughtCountSort.NavigateUrl = basicUrl + "?sortby=" + Collective.Offer.SortType.BoughtCount.ToString() + "&asc=" + (!isAsc).ToString() + "&page=" + currPage.ToString() + "&rows=" + numOfRows.ToString();
            hlBoughtCountSort.Text = isAsc ? "Bought Count ↑" : "Bought Count ↓";
        }
        else
        {
            hlBoughtCountSort.NavigateUrl = basicUrl + "?sortby=" + Collective.Offer.SortType.BoughtCount.ToString() + "&asc=" + true.ToString() + "&page=" + currPage.ToString() + "&rows=" + numOfRows.ToString();
            hlBoughtCountSort.Text = "Bought Count ↑";
        }

        HyperLink hlDateStartSort = (HyperLink)this.grdOffers.HeaderRow.FindControl("hlDateStartSort");
        if (sortBy == Collective.Offer.SortType.DateStart)
        {
            hlDateStartSort.NavigateUrl = basicUrl + "?sortby=" + Collective.Offer.SortType.DateStart.ToString() + "&asc=" + (!isAsc).ToString() + "&page=" + currPage.ToString() + "&rows=" + numOfRows.ToString();
            hlDateStartSort.Text = isAsc ? "Date Start ↑" : "Date Start ↓";
        }
        else
        {
            hlDateStartSort.NavigateUrl = basicUrl + "?sortby=" + Collective.Offer.SortType.DateStart.ToString() + "&asc=" + true.ToString() + "&page=" + currPage.ToString() + "&rows=" + numOfRows.ToString();
            hlDateStartSort.Text = "Date Start ↑";
        }

        // paging linovi
        this.hlFirst.NavigateUrl = basicUrl + "?sortby=" + sortBy.ToString() + "&asc=" + isAsc.ToString() + "&page=" + 1.ToString() + "&rows=" + numOfRows.ToString();
        this.hlLast.NavigateUrl = basicUrl + "?sortby=" + sortBy.ToString() + "&asc=" + isAsc.ToString() + "&page=" + totalPageCount.ToString() + "&rows=" + numOfRows.ToString();
        this.hlPrev.NavigateUrl = basicUrl + "?sortby=" + sortBy.ToString() + "&asc=" + isAsc.ToString() + "&page=" + (currPage - 1).ToString() + "&rows=" + numOfRows.ToString();
        this.hlNext.NavigateUrl = basicUrl + "?sortby=" + sortBy.ToString() + "&asc=" + isAsc.ToString() + "&page=" + (currPage + 1).ToString() + "&rows=" + numOfRows.ToString();
        this.hlPrev.Visible = this.hlFirst.Visible = currPage > 1;
        this.hlNext.Visible = this.hlLast.Visible = currPage < totalPageCount;

        SortedList<int, int> pags = new SortedList<int, int>();
        pags.Add(currPage, currPage);
        int pl = currPage;
        int pr = currPage;

        for (int i = 0; i < 3; ++i)
        {
            if (--pl >= 1)
            {
                pags.Add(pl, pl);
            }
            else if (++pr <= totalPageCount)
            {
                pags.Add(pr, pr);
            }

            if (++pr <= totalPageCount)
            {
                pags.Add(pr, pr);
            }
            else if (--pl >= 1)
            {
                pags.Add(pl, pl);
            }
        }

//.........这里部分代码省略.........
开发者ID:bneuhold,项目名称:pb-dev,代码行数:101,代码来源:OfferList.aspx.cs

示例3: getCatchupUrls

        string getCatchupUrls(VideoInfo video)
        {
            WebProxy proxyObj = getProxy();
            Match m = videoPidRegex.Match(GetWebData(video.VideoUrl, proxy: proxyObj));
            if (!m.Success)
            {
                Log.Warn("BBCiPlayer: Failed to parse vpid from '{0}'", video.VideoUrl);
                return null;
            }

            string vpid = m.Groups[1].Value;
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(GetWebData(MEDIA_SELECTOR_URL + vpid, proxy: proxyObj)); //uk only
            XmlNamespaceManager nsmRequest = new XmlNamespaceManager(doc.NameTable);
            nsmRequest.AddNamespace("ns1", "http://bbc.co.uk/2008/mp/mediaselection");

            if (RetrieveSubtitles)
            {
                XmlNode captionNode = doc.SelectSingleNode("//ns1:media[@kind='captions']", nsmRequest);
                if (captionNode != null)
                {
                    XmlNode captionConnection = captionNode.SelectSingleNode("ns1:connection", nsmRequest);
                    if (captionConnection != null && captionConnection.Attributes["href"] != null)
                    {
                        string sub = GetWebData(captionConnection.Attributes["href"].Value);
                        video.SubtitleText = OnlineVideos.Sites.Utils.SubtitleReader.TimedText2SRT(sub);
                    }
                }
            }

            SortedList<string, string> sortedPlaybackOptions = new SortedList<string, string>(new StreamComparer());
            foreach (XmlElement mediaElem in doc.SelectNodes("//ns1:media[@kind='video']", nsmRequest))
            {
                string info = "";
                string resultUrl = "";
                foreach (XmlElement connectionElem in mediaElem.SelectNodes("ns1:connection", nsmRequest))
                {
                    string supplier = connectionElem.Attributes["supplier"].Value; //"kind"
                    if (Array.BinarySearch<string>(new string[] { "akamai", "level3", "limelight" }, supplier) >= 0)
                    {
                        // rtmp
                        if (connectionElem.Attributes["protocol"] == null || connectionElem.Attributes["protocol"].Value != "rtmp")
                            continue;

                        string server = connectionElem.Attributes["server"].Value;
                        string identifier = connectionElem.Attributes["identifier"].Value;
                        string auth = connectionElem.Attributes["authString"].Value;
                        string application = connectionElem.GetAttribute("application");
                        if (string.IsNullOrEmpty(application)) application = "ondemand";
                        string SWFPlayer = "http://www.bbc.co.uk/emp/releases/iplayer/revisions/617463_618125_4/617463_618125_4_emp.swf"; // "http://www.bbc.co.uk/emp/10player.swf";

                        info = string.Format("{0}x{1} | {2} kbps | {3}", mediaElem.GetAttribute("width"), mediaElem.GetAttribute("height"), mediaElem.GetAttribute("bitrate"), supplier);
                        resultUrl = "";
                        if (supplier == "limelight")
                        {
                            resultUrl = new MPUrlSourceFilter.RtmpUrl(string.Format("rtmp://{0}:1935/{1}", server, application + "?" + auth), server, 1935)
                            {
                                App = application + "?" + auth,
                                PlayPath = identifier,
                                SwfUrl = SWFPlayer,
                                SwfVerify = true,
                            }.ToString();
                        }
                        else if (supplier == "level3")
                        {
                            resultUrl = new MPUrlSourceFilter.RtmpUrl(string.Format("rtmp://{0}:1935/{1}", server, application + "?" + auth), server, 1935)
                            {
                                App = application + "?" + auth,
                                PlayPath = identifier,
                                SwfUrl = SWFPlayer,
                                SwfVerify = true,
                                Token = auth,
                            }.ToString();
                        }
                        else if (supplier == "akamai")
                        {
                            resultUrl = new MPUrlSourceFilter.RtmpUrl(string.Format("rtmp://{0}:1935/{1}?{2}", server, application, auth))
                            {
                                PlayPath = identifier + "?" + auth,
                                SwfUrl = SWFPlayer,
                                SwfVerify = true,
                            }.ToString();
                        }
                    }
                    if (resultUrl != "") sortedPlaybackOptions.Add(info, resultUrl);
                }
            }

            video.PlaybackOptions = new Dictionary<string, string>();
            if (sortedPlaybackOptions.Count > 0)
            {
                if (AutoSelectStream)
                {
                    var last = sortedPlaybackOptions.Last();
                    video.PlaybackOptions.Add(last.Key, last.Value);
                    return last.Value;
                }
                else
                {
                    foreach (var option in sortedPlaybackOptions)
//.........这里部分代码省略.........
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:101,代码来源:BBCiPlayerUtil.cs

示例4: CalculateSqDistances

        public static void CalculateSqDistances(List<VisitedSystemsClass> vs, SortedList<double, ISystem> distlist, double x, double y, double z, int maxitems, bool removezerodiststar)
        {
            double dist;
            double dx, dy, dz;
            Dictionary<long, ISystem> systems = distlist.Values.GroupBy(s => s.id).ToDictionary(g => g.Key, g => g.First());

            foreach (VisitedSystemsClass pos in vs)
            {
                if (pos.HasTravelCoordinates && pos.curSystem != null && !systems.ContainsKey(pos.curSystem.id))   // if co-ords, and not in list already..
                {
                    dx = (pos.X - x);
                    dy = (pos.Y - y);
                    dz = (pos.Z - z);
                    dist = dx * dx + dy * dy + dz * dz;

                    if (dist > 0.001 || !removezerodiststar)
                    {
                        if (distlist.Count < maxitems)          // if less than max, add..
                            distlist.Add(dist, pos.curSystem);
                        else if (dist < distlist.Last().Key)   // if last entry (which must be the biggest) is greater than dist..
                        {
                            distlist.Add(dist, pos.curSystem);           // add in
                            distlist.RemoveAt(maxitems);        // remove last..
                        }
                    }
                }
            }
        }
开发者ID:mwerle,项目名称:EDDiscovery,代码行数:28,代码来源:VisitedSystemsClass.cs

示例5: FindTopDesiresForNotice

        public int FindTopDesiresForNotice(Notice n, out SortedList<int, NabfAgent> topDesires, out List<NabfAgent> agents)
        {
            int desire = 0, lowestDesire = -(n.GetAgentsApplied().Count + 1);

            agents = new List<NabfAgent>();
            topDesires = new SortedList<int, NabfAgent>(new InvertedComparer<int>());
            for (int i = 0; i < n.AgentsNeeded; i++)
            {
                topDesires.Add(lowestDesire--, null);
            }
            desire = 0;
            lowestDesire = -1;

            foreach (NabfAgent a in n.GetAgentsApplied())
            {
                n.TryGetValueAgentToDesirabilityMap(a, out desire);
                if (desire > lowestDesire)
                {
                    topDesires.Add(desire, a);
                    agents.Add(a);
                    agents.Remove(topDesires.Last().Value);
                    topDesires.RemoveAt(n.AgentsNeeded);
                    lowestDesire = topDesires.Keys[n.AgentsNeeded - 1];
                }
            }

            return lowestDesire;
        }
开发者ID:jannickj,项目名称:nabf,代码行数:28,代码来源:NoticeBoard.cs

示例6: calcPrognoz

        public void calcPrognoz()
        {
            if (PArr.Count % 24 != 0) {
                int addCnt=24 - PArr.Count % 24;
                for (int i=0; i < addCnt; i++) {
                    DateTime last=PArr.Last().Key;
                    PArr.Add(last.AddMinutes(30), PArr[last]);
                }
            }

            SortedList<int,double>prevDataRashodArray=new SortedList<int, double>();
            SortedList<int,double>prevDataNBArray=new SortedList<int, double>();
            SortedList<int,double>prevDataVBArray=new SortedList<int, double>();
            prognoz=new SortedList<DateTime, double>();

            int index=0;
            double k=0;
            foreach (DateTime date in FirstData.Keys) {
                prevDataRashodArray.Add(index, FirstData[date].Q);
                prevDataNBArray.Add(index, FirstData[date].NB);
                prevDataVBArray.Add(index, FirstData[date].VB);
                k = FirstData[date].Q / RashodTable.getStationRashod(FirstData[date].P, FirstData[date].VB - FirstData[date].NB, RashodCalcMode.avg);
                index++;
            }

            napors=new SortedList<DateTime, double>();
            rashods = new SortedList<DateTime, double>();

            double napor=prevDataVBArray.Last().Value - prevDataNBArray.Last().Value;
            foreach (KeyValuePair<DateTime,double>de in pArr) {
                napors.Add(de.Key, napor);
            }

            foreach (KeyValuePair<DateTime,double> de in PArr) {
                double rashod=IsQFakt ? de.Value : RashodTable.getStationRashod(de.Value, napors[de.Key], RashodCalcMode.avg) * k;
                rashods.Add(de.Key, rashod);
                prognoz.Add(de.Key, 0);
            }
            //prognoz.Add(rashods.First().Key.AddMinutes(-30), prevDataNBArray[4]);

            double currentNapor=napors.First().Value;
            SortedList<DateTime,double> dataForPrognoz=new SortedList<DateTime, double>();
            SortedList<DateTime,double> naporsForPrognoz=new SortedList<DateTime, double>();
            for (int indexPoint=0; indexPoint < pArr.Keys.Count; indexPoint++) {
                DateTime Key=pArr.Keys[indexPoint];
                dataForPrognoz.Add(Key, pArr[Key]);
                naporsForPrognoz.Add(Key, napors[Key]);
                if (dataForPrognoz.Count == 24) {
                    SortedList<int,double> outputVector=new SortedList<int, double>();
                    for (int step=0; step <= 3; step++) {
                        SortedList<int, double> inputVector=new SortedList<int, double>();
                        inputVector[0] = DatePrognozStart.Year;
                        inputVector[1] = DatePrognozStart.DayOfYear;
                        inputVector[2] = T;

                        inputVector[3] = prevDataVBArray[1];
                        inputVector[4] = prevDataVBArray[2];
                        inputVector[5] = prevDataVBArray[3];
                        inputVector[6] = prevDataVBArray[4];

                        inputVector[7] = prevDataRashodArray[1];
                        inputVector[8] = prevDataRashodArray[2];
                        inputVector[9] = prevDataRashodArray[3];
                        inputVector[10] = prevDataRashodArray[4];

                        for (int i=0; i < 24; i++) {
                            double rashod=0;
                            if (!IsQFakt) {
                                rashod = RashodTable.getStationRashod(pArr[dataForPrognoz.Keys[i]], naporsForPrognoz[dataForPrognoz.Keys[i]], RashodCalcMode.avg)*k;
                            } else {
                                rashod = rashods[dataForPrognoz.Keys[i]];
                            }

                            rashods[dataForPrognoz.Keys[i]] = rashod;
                            inputVector[i + 11] = rashod;
                        }

                        inputVector[35] = prevDataNBArray[1];
                        inputVector[36] = prevDataNBArray[2];
                        inputVector[37] = prevDataNBArray[3];
                        inputVector[38] = prevDataNBArray[4];

                        outputVector = nnet.calc(inputVector);

                        for (int i=0; i < outputVector.Count; i++) {
                            prognoz[dataForPrognoz.Keys[i]] = outputVector[i];
                        }

                        for (int i=0; i < 24; i++) {
                            naporsForPrognoz[dataForPrognoz.Keys[i]] = prevDataVBArray[4] - prognoz[dataForPrognoz.Keys[i]];
                            napors[dataForPrognoz.Keys[i]] = naporsForPrognoz[dataForPrognoz.Keys[i]];
                        }
                    }

                    for (int i=0; i <= 4; i++) {
                        prevDataNBArray[i] = prognoz[dataForPrognoz.Keys[19 + i]];
                        prevDataRashodArray[i] = rashods[dataForPrognoz.Keys[19 + i]];
                    }

                    dataForPrognoz.Clear();
//.........这里部分代码省略.........
开发者ID:rj128x,项目名称:VotGES,代码行数:101,代码来源:PrognozNB.cs

示例7: populateUrlsFromXml

        string populateUrlsFromXml(VideoInfo video, XmlDocument streamPlaylist, bool live)
        {
            if (streamPlaylist == null)
            {
                Log.Warn("ITVPlayer: Stream playlist is null");
                return "";
            }

            XmlNode videoEntry = streamPlaylist.SelectSingleNode("//VideoEntries/Video");
            if (videoEntry == null)
            {
                Log.Warn("ITVPlayer: Could not find video entry");
                return "";
            }

            XmlNode node;
            node = videoEntry.SelectSingleNode("./MediaFiles");
            if (node == null || node.Attributes["base"] == null)
            {
                Log.Warn("ITVPlayer: Could not find base url");
                return "";
            }

            string rtmpUrl = node.Attributes["base"].Value;
            SortedList<string, string> options = new SortedList<string, string>(new StreamComparer());
            foreach (XmlNode mediaFile in node.SelectNodes("./MediaFile"))
            {
                if (mediaFile.Attributes["delivery"] == null || mediaFile.Attributes["delivery"].Value != "Streaming")
                    continue;

                string title = "";
                if (mediaFile.Attributes["bitrate"] != null)
                {
                    title = mediaFile.Attributes["bitrate"].Value;
                    int bitrate;
                    if (int.TryParse(title, out bitrate))
                        title = string.Format("{0} kbps", bitrate / 1000);
                }

                if (!options.ContainsKey(title))
                {
                    string url = new MPUrlSourceFilter.RtmpUrl(rtmpUrl)
                    {
                        PlayPath = mediaFile.InnerText,
                        SwfUrl = "http://mediaplayer.itv.com/2.18.5%2Bbuild.ad408a9c67/ITVMediaPlayer.swf",
                        SwfVerify = true,
                        Live = live
                    }.ToString();
                    options.Add(title, url);
                }
            }

            if (RetrieveSubtitles)
            {
                node = videoEntry.SelectSingleNode("./ClosedCaptioningURIs");
                if (node != null && Helpers.UriUtils.IsValidUri(node.InnerText))
                    video.SubtitleText = SubtitleReader.TimedText2SRT(GetWebData(node.InnerText));
            }

            video.PlaybackOptions = new Dictionary<string, string>();
            if (options.Count == 0)
                return null;

            if (AutoSelectStream)
            {
                var last = options.Last();
                video.PlaybackOptions.Add(last.Key, last.Value);
            }
            else
            {
                foreach (KeyValuePair<string, string> key in options)
                    video.PlaybackOptions.Add(key.Key, key.Value);
            }
            return options.Last().Value;
        }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:75,代码来源:ITVPlayerUtil.cs

示例8: FillHourGaps

        internal static SortedList<DateTime, MeasureKwH> FillHourGaps(SortedList<DateTime, MeasureKwH> hourlyKwH
                                                                        , int startHour, int endHour)
        {
            //break if we have no data
              if (hourlyKwH.Count == 0)
              {
            return hourlyKwH;
              }
              int privateInverterID = hourlyKwH.Values.First().PrivateInverterId;
              int publicInverterId = hourlyKwH.Values.First().PublicInverterId;

              DateTime firstMeasureDate = hourlyKwH.First().Value.DateTime;
              DateTime lastMeasureDate = hourlyKwH.Last().Value.DateTime;

              //build startDate and endDate we need
              DateTime startDate = new DateTime(firstMeasureDate.Year
              , firstMeasureDate.Month
              , firstMeasureDate.Day
              , startHour, 0, 0);

              DateTime endDate = new DateTime(lastMeasureDate.Year
              , lastMeasureDate.Month
              , lastMeasureDate.Day
              , endHour, 0, 0);

              //counter
              var countDate = startDate;

              while (countDate <= endDate)
              {
            if (!hourlyKwH.ContainsKey(countDate))
            {
              MeasureKwH dummyMeasure = new MeasureKwH();
              dummyMeasure.DateTime = countDate;
              dummyMeasure.Value = 0;
              dummyMeasure.PrivateInverterId = privateInverterID;
              dummyMeasure.PublicInverterId = publicInverterId;
              hourlyKwH.Add(countDate, dummyMeasure);
            }

            //increase hour until endHour, then jump to the next day
            countDate = countDate.AddHours(1);
            if (countDate.Hour > endHour)
            {
              countDate = countDate.AddHours(24 - countDate.Hour + startHour);
            }
              }
              return hourlyKwH;
        }
开发者ID:Epstone,项目名称:mypvlog,代码行数:49,代码来源:KwhCalculator.cs

示例9: SelectFilesToKeep

        static bool SelectFilesToKeep(HashPointers ptr, out List<int> toKeep)
        {
            bool selectionSuccess = false;
            toKeep = new List<int>(Enumerable.Range(1, ptr.FileEntries.Count));
            bool decided = false;
            int choice = 0;

            bool canAutoSelect = false;
            List<int> oldestIDs = new List<int>();
            List<int> newestIDs = new List<int>();
            {
                // Read and register the timestamp when the files were last accessed
                // The oldest file (lowest timestamp) will be on the top of the list
                SortedList<DateTime, List<int>> timeStamps = new SortedList<DateTime, List<int>>(ptr.FileEntries.Count);
                PathEntry entry = new PathEntry();
                int currentID = 1;
                foreach (long offset in ptr.FileEntries)
                {
                    PathsFile.GetRecordAt(offset, out entry);
                    FileInfo fi = new FileInfo(entry.Path);

                    IEnumerable<DateTime> tsRegistered = timeStamps.Select(ts => ts.Key)
                        .Where(ts => ts.Date == fi.LastAccessTime.Date
                            && ts.Hour == fi.LastAccessTime.Hour
                            && ts.Minute == fi.LastAccessTime.Minute
                            && ts.Second == fi.LastAccessTime.Second);
                    if (tsRegistered.Count() == 1)
                        timeStamps[tsRegistered.First()].Add(currentID);
                    else
                    {
                        List<int> idList = new List<int>(1);
                        idList.Add(currentID);
                        timeStamps.Add(fi.LastAccessTime, idList);
                    }
                    ++currentID;
                }

                // If the oldest and newest files are the same, don't select any of them
                if (timeStamps.Count == 1 && (AutoOldest || AutoNewest))
                    Console.WriteLine("The files' age are equal. Unable to select oldest and newest ones.");
                else
                {
                    oldestIDs.AddRange(timeStamps.First().Value);
                    newestIDs.AddRange(timeStamps.Last().Value);
                    canAutoSelect = true;
                }
            }

            while (!selectionSuccess)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(new String('-', Console.WindowWidth - 1));
                DuplicateFileLog.WriteLine(new String('-', 24));
                Console.WriteLine("The following " + ptr.FileEntries.Count + " files are duplicate of each other");
                DuplicateFileLog.WriteLine("The following " + ptr.FileEntries.Count + " files are duplicate of each other");
                Console.ResetColor();
                if (Verbose)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("Hash: " + ptr.Hash);
                    DuplicateFileLog.WriteLine("Hash: " + ptr.Hash);
                    Console.ResetColor();
                }

                if (!DryRun)
                {
                    Console.Write("Files marked ");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("[ KEEP ]");
                    Console.ResetColor();
                    Console.Write(" will be kept. Files marked ");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("[DELETE]");
                    Console.ResetColor();
                    Console.WriteLine(" will be deleted.");

                    if (!AutoNewest && !AutoOldest)
                        Console.WriteLine("Please select the files you wish to keep or delete.");
                    else
                        if (!canAutoSelect)
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Was unable to automatically select " + (AutoOldest ? "oldest" : "newest") + " file to keep");
                            Console.ResetColor();
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Automatically selecting the " + (AutoOldest ? "OLDEST" : "NEWEST") + " file to keep");
                            Console.ResetColor();
                            toKeep.Clear();

                            if (AutoOldest)
                                toKeep.AddRange(oldestIDs);
                            else if (AutoNewest)
                                toKeep.AddRange(newestIDs);
                        }
                }

                // Print the file list with a choice
//.........这里部分代码省略.........
开发者ID:whisperity,项目名称:DuplicateDestroyer,代码行数:101,代码来源:Program.cs

示例10: FillPlaybackOptions

        private string FillPlaybackOptions(VideoInfo video, AMFArray renditions)
        {
            SortedList<string, string> options = new SortedList<string, string>(new StreamComparer());

            for (int i = 0; i < renditions.Count; i++)
            {
                AMFObject rendition = renditions.GetObject(i);
                int encodingRate = rendition.GetIntProperty("encodingRate");
                string nm = String.Format("{0}x{1} | {2} kbps",
                    rendition.GetIntProperty("frameWidth"), rendition.GetIntProperty("frameHeight"),
                    encodingRate / 1000);
                string url = HttpUtility.UrlDecode(rendition.GetStringProperty("defaultURL"));
                if (url.StartsWith("rtmp"))
                {
                    string auth = String.Empty;
                    if (url.Contains('?'))
                        auth = '?' + url.Split('?')[1];
                    string[] parts = url.Split('&');

                    string rtmp = parts[0] + auth;
                    string playpath = parts[1].Split('?')[0] + auth;

                    url = new MPUrlSourceFilter.RtmpUrl(rtmp) 
                    { 
                        PlayPath = playpath,
                        SwfUrl = "http://admin.brightcove.com/viewer/us20111207.0737/connection/ExternalConnection_2.swf",
                        SwfVerify = true
                    }.ToString();
                }
                if (!options.ContainsKey(nm))
                    options.Add(nm, url);
            }

            video.PlaybackOptions = new Dictionary<string, string>();
            foreach (KeyValuePair<string, string> key in options)
                video.PlaybackOptions.Add(key.Key, key.Value);

            return options.Count > 0 ? options.Last().Value : null;
        }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:39,代码来源:Demand5Util.cs

示例11: CreateNavigationLinks

    private void CreateNavigationLinks(int currPage, int numOfRows, int totalPageCount, string email, string firstName, string lastName)
    {
        string basicUrl = "http://" + Request.Url.Authority + "/admin/CouponsList.aspx";
        string searchUrlPart = (!String.IsNullOrEmpty(email) ? "&email=" + email : string.Empty) +
            (!String.IsNullOrEmpty(firstName) ? "&firstname=" + firstName : string.Empty) + (!String.IsNullOrEmpty(lastName) ? "&lastname=" + lastName : string.Empty);

        // paging linovi
        this.hlFirst.NavigateUrl = basicUrl + "?page=" + 1.ToString() + "&rows=" + numOfRows.ToString() + searchUrlPart;
        this.hlLast.NavigateUrl = basicUrl + "?page=" + totalPageCount.ToString() + "&rows=" + numOfRows.ToString() + searchUrlPart;
        this.hlPrev.NavigateUrl = basicUrl + "?page=" + (currPage - 1).ToString() + "&rows=" + numOfRows.ToString() + searchUrlPart;
        this.hlNext.NavigateUrl = basicUrl + "?page=" + (currPage + 1).ToString() + "&rows=" + numOfRows.ToString() + searchUrlPart;

        this.hlPrev.Visible = this.hlFirst.Visible = currPage > 1;
        this.hlNext.Visible = this.hlLast.Visible = currPage < totalPageCount;

        SortedList<int, int> pags = new SortedList<int, int>();
        pags.Add(currPage, currPage);
        int pl = currPage;
        int pr = currPage;

        for (int i = 0; i < 3; ++i)
        {
            if (--pl >= 1)
            {
                pags.Add(pl, pl);
            }
            else if (++pr <= totalPageCount)
            {
                pags.Add(pr, pr);
            }

            if (++pr <= totalPageCount)
            {
                pags.Add(pr, pr);
            }
            else if (--pl >= 1)
            {
                pags.Add(pl, pl);
            }
        }

        if (pags.First().Value > 1)
        {
            phPages.Controls.Add(new Literal() { Text = "... " });
        }

        foreach (KeyValuePair<int, int> kwp in pags)
        {
            if (kwp.Value == currPage)
            {
                phPages.Controls.Add(new Literal() { Text = kwp.Value.ToString() });
            }
            else
            {
                phPages.Controls.Add(new HyperLink()
                {
                    Text = kwp.Value.ToString(),
                    NavigateUrl = basicUrl + "?page=" + kwp.Value.ToString() + "&rows=" + numOfRows.ToString() + searchUrlPart
                });
            }
            phPages.Controls.Add(new Literal() { Text = " " });
        }
        if (pags.Last().Value < totalPageCount)
        {
            phPages.Controls.Add(new Literal() { Text = " ..." });
        }
    }
开发者ID:bneuhold,项目名称:pb-dev,代码行数:67,代码来源:CouponsList.aspx.cs

示例12: CheckLatest

        public DateTime? CheckLatest(IField field)
        {
            if (!this.FieldExists(field))
                return null;

            this.LoadField(field);

            var outList = new SortedList<DateTime, dynamic>();
            this.loadedValues.TryGetValue(field.FieldNickName, out outList);

            return outList.Last().Key;
        }
开发者ID:jozefRudy,项目名称:BBdownloader,代码行数:12,代码来源:Share.cs

示例13: isTooClose

 static bool isTooClose(KeyValuePair<int, DateTime> keyVal, SortedList<int, DateTime> lst)
 {
     if (keyVal.Key == lst.First().Key || keyVal.Key == lst.Last().Key)
         return false;
     foreach (var kv in lst)
     {
         if (kv.Key > keyVal.Key && Math.Abs((kv.Value - keyVal.Value).TotalMinutes) < 2)
             return true;
     }
     return false;
 }
开发者ID:JBetser,项目名称:MiDax,代码行数:11,代码来源:MarketSelector.cs


注:本文中的SortedList.Last方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。