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


C# SortedSet.FirstOrDefault方法代码示例

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


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

示例1: Load

        /// <summary>
        /// FanIn
        /// </summary>
        public IEnumerable<Activity> Load(Feed feed)
        {
            var snapshot = new Dictionary<byte[], Queue<Activity>>(activityStreamStore.Count);
            foreach (var item in activityStreamStore)
            {
                snapshot.Add(item.Key, new Queue<Activity>(item.Value));
            }

            SortedSet<Activity> buffer = new SortedSet<Activity>(Activity.Comparer);
            var streams = feed.FeedStreams.ToList();
            var streamsCount = streams.Count;

            //  Init
            for (int streamIndexInsideSubsciption = 0; streamIndexInsideSubsciption < streamsCount; streamIndexInsideSubsciption++)
            {
                var streamId = streams[streamIndexInsideSubsciption];
                var activity = snapshot[streamId].Dequeue();
                buffer.Add(activity);
            }

            while (buffer.Count > 0)
            {
                Activity nextActivity = buffer.FirstOrDefault();
                buffer.Remove(nextActivity);
                var streamQueue = snapshot[nextActivity.StreamId];
                if (streamQueue.Count > 0)
                {
                    var candidate = snapshot[nextActivity.StreamId].Dequeue();
                    buffer.Add(candidate);
                }
                yield return nextActivity;
            }
        }
开发者ID:mentormate-kalinvenkov,项目名称:ActivityStreams,代码行数:36,代码来源:InMemoryActivityFeedRepository.cs

示例2: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (OpenId.Length < 10)
        {
            Response.Redirect("Error.aspx");
            return;
        }

        IList<QueryModel> qmList = new List<QueryModel>();
        qmList.Add(MakeUtil.getQueryModel("OpenId", "'", SqlWhere.WhereOperator.Equal, OpenId));
        var stuparent = _isjDepartStaffEbi.GetStudentParentDtoList(qmList, -1);
        var teacher = _teacherBindInfoEbi.getModel(qmList);
        var schoolNoSet = new SortedSet<string>();
        foreach (var stu in stuparent)
        {
            schoolNoSet.Add(stu.SchoolNo);
        }
        if (teacher.OpenId != "")
        {
            schoolNoSet.Add(teacher.SchoolNo);
        }
        if (schoolNoSet.Count <= 0)
        {
            Response.Redirect("Default.aspx");
        }
        if (schoolNoSet.Count == 1)
        {
            Response.Redirect("MainPage.aspx?SelectSchoolNo=" + schoolNoSet.FirstOrDefault());
        }
        qmList.Clear();
        var schoolSql = string.Join("','", schoolNoSet);
        qmList.Add(MakeUtil.getQueryModel("SchoolNo", "'", SqlWhere.WhereOperator.In, schoolSql));
        var schools = _schoolDataEbi.getModelList(qmList, -1);
        if (schools.Count <= 0)
        {
            Response.Redirect("Default.aspx");
        }
        if (schools.Count == 1)
        {
            Response.Redirect("MainPage.aspx?SelectSchoolNo=" + schoolNoSet.FirstOrDefault());
        }
        var jss = new JavaScriptSerializer();
        schoolJson = jss.Serialize(schools);
        //        repSchoolDetail.DataSource = schools;
        DataBind();
    }
开发者ID:jongking,项目名称:XueXiaoWeiXin,代码行数:46,代码来源:SchoolChose.aspx.cs

示例3: GetAllRunbookMetadata

 public static async Task<ISet<AutomationRunbook>> GetAllRunbookMetadata(AutomationManagementClient automationManagementClient, string workspace, string resourceGroupName, string accountName)
 {
     ISet<AutomationRunbook> result = new SortedSet<AutomationRunbook>();            
     IList<Runbook> cloudRunbooks = await DownloadRunbookMetadata(automationManagementClient, resourceGroupName, accountName);
     
     /* Create a Dictionary of (filename, filepath) tuples found on disk. This will come in handy */
     Dictionary<string, string> filePathForRunbook = new Dictionary<string, string>();
     if (Directory.Exists(workspace))
     {
         string[] localRunbookFilePaths = Directory.GetFiles(workspace, "*.ps1");
         foreach (string path in localRunbookFilePaths)
         {
             filePathForRunbook.Add(System.IO.Path.GetFileNameWithoutExtension(path), path);
         }
     }
     /* Start by checking the downloaded runbooks */
     foreach (Runbook cloudRunbook in cloudRunbooks)
     {
         /* Don't bother with graphical runbooks, since the ISE can't do anything with them */
         if (cloudRunbook.Properties.RunbookType != Constants.RunbookType.Graphical)
         {
             RunbookDraftGetResponse draftResponse;
             try
             {
                 CancellationTokenSource cts = new CancellationTokenSource();
                 cts.CancelAfter(TIMEOUT_MS);
                 draftResponse = await automationManagementClient.RunbookDraft.GetAsync(resourceGroupName, accountName, cloudRunbook.Name, cts.Token);
             }
             catch
             {
                 draftResponse = null;
             }
             if (filePathForRunbook.ContainsKey(cloudRunbook.Name))
             {
                 result.Add(new AutomationRunbook(new FileInfo(filePathForRunbook[cloudRunbook.Name]), cloudRunbook, draftResponse.RunbookDraft));
             }
             else
             {
                 result.Add(new AutomationRunbook(cloudRunbook, draftResponse.RunbookDraft));
             }
         }
     }
     /* Now find runbooks on disk that aren't yet accounted for */
     foreach (string localRunbookName in filePathForRunbook.Keys)
     {
         //Not great, but works for now
         if (result.FirstOrDefault(x => x.Name == localRunbookName) == null)
         {
             result.Add(new AutomationRunbook(new FileInfo(filePathForRunbook[localRunbookName])));
         }
     }
     return result;
 }
开发者ID:BruceLangworthy,项目名称:azure-automation-ise-addon,代码行数:53,代码来源:AutomationRunbookManager.cs

示例4: MakeAllPossibleWaysRec

        private IEnumerable<PrimaryFrameNode> MakeAllPossibleWaysRec(List<string> processed, ProjectionElement element, SortedSet<BoundingParameter> orderedParameters, int depth)
        {
            if (depth == int.MinValue)
                throw new InvalidOperationException("Ошибка при построении плана - слишком глубокая схема для разбора");
            if (depth == 0)
                return new PrimaryFrameNode[0];

            #region Проверка - был ли проверен текущий элемент, и добавление его к проверенным

            var hash = GetHashForElementAndParameters(element, new ParameterNames(orderedParameters.Select(k => k.Name)));

           
                if (processed.Contains(hash))
                    return new PrimaryFrameNode[0];

                processed.Add(hash);
            

            #endregion

            #region Добавление текущего элемента к родительским параметрам или обнуление глубины уже существующего параметра с данным именем

            foreach (var p in orderedParameters)
            {
                p.Depth++;
            }

            var parameter = orderedParameters.FirstOrDefault(k => k.Name == element.Name);
            int oldDepth;
            if (parameter == null)
            {
                parameter = new BoundingParameter(element.Name, 1);
                orderedParameters.Add(parameter);
                oldDepth = 0;
            }
            else
            {
                oldDepth = parameter.Depth;
                parameter.Depth = 1;
            }

            #endregion

            #region Обход детей дочерних нод

            var childElements = element.DownRelations
                .Select(k => new
                                 {
                                     relation = k,
                                     k.ChildElement,
                                     children =
                                 MakeAllPossibleWaysRec(processed, k.ChildElement, orderedParameters, depth - 1)
                                 }).ToArray();

            #endregion



            processed.Remove(hash);

            if (oldDepth == 0)
                orderedParameters.Remove(parameter);
            else
            {
                parameter.Depth = oldDepth;
            }


            #region Формирование списка нод вместе с дочерними

            var allNodes = childElements.Select(k =>
                                                new PrimaryFrameNode
                                                    {
                                                        Current = k.ChildElement,
                                                        OrderedParameters =
                                                            orderedParameters.Where(k2=>!StringComparer.InvariantCultureIgnoreCase.Equals(k2.Name,element.Name))
                                                                             .Select(k2 => new BoundingParameter(k2.Name, k2.Depth))
                                                                             .ToArray(),
                                                        Parent = element,
                                                        Relation = k.relation
                                                    })
                .Concat(childElements.SelectMany(k => k.children))
                .ToArray();

            #endregion


            foreach (var p in orderedParameters)
            {
                p.Depth--;
            }
          
            return allNodes;
        }
开发者ID:kayanme,项目名称:Dataspace,代码行数:94,代码来源:FramingPlanBuilder.cs


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