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


C# IGrouping.ToArray方法代码示例

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


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

示例1: CreateDailyModel

		private static DailyWeatherDataModel CreateDailyModel(IGrouping<DateTime, WeatherData> gr)
		{
			if (gr == null)
			{
				return null;
			}

			var items = gr.ToArray();

			if (!items.Any())
			{
				return null;
			}

			var first = items.OrderByDescending(item => item.WeatherCode).First();

			decimal minT = items.Min(d => d.Temperature);
			decimal maxT = items.Max(d => d.Temperature);

			decimal minP = items.Min(d => d.Pressure);
			decimal maxP = items.Max(d => d.Pressure);

			int minH = items.Min(d => d.Humidity);
			int maxH = items.Max(d => d.Humidity);

			return new DailyWeatherDataModel
				{
					DateTime = gr.Key,
					MinTemperature = Convert.ToInt32(minT),
					MaxTemperature = Convert.ToInt32(maxT),

					MinPressure = Convert.ToInt32(minP),
					MaxPressure = Convert.ToInt32(maxP),

					MinHumidity = Convert.ToInt32(minH),
					MaxHumidity = Convert.ToInt32(maxH),
					Code = first.WeatherCode,
					Description = first.WeatherDescription
				};
		}
开发者ID:3660628,项目名称:thinking-home,代码行数:40,代码来源:ModelBuilder.cs

示例2: DrawTestGroup

		private void DrawTestGroup (string group, IGrouping<string, UnitTestResult> unitTestResult)
		{
			if (PrintFoldoutAndCheckIfCollapsed(group, unitTestResult.Key, unitTestResult)) return;

			//puting this to the loop fails to order elements
			var tests = unitTestResult.ToArray().OrderBy( t => t.Test.MethodName );
			indentLevel++;
			foreach (var testResult in tests)
			{
				var testName = testResult.Test.MethodName + '(' + testResult.Test.ParamName + ')';
				PrintTest(testName, testResult);
			}
			indentLevel--;
		}
开发者ID:eyalzur,项目名称:CodeSamplesPublic,代码行数:14,代码来源:GroupedByHierarchyRenderer.cs

示例3: MakeStubsForTypeMembers

        private StringBuilder MakeStubsForTypeMembers(IGrouping<FixedType.Class, MemberImplInfo> stubInfos)
        {
            var writer = new System.IO.StringWriter();
            var members = stubInfos.ToArray();
            var isInterface = stubInfos.Key.IsInterface;
            var ty = isInterface ? stubInfos.Key : _ty.GetMemType();

            foreach (var memberImplInfo in members)
            {
                var member = memberImplInfo.Member;
                var @explicit = memberImplInfo.Explicit;
                var accessModifier = memberImplInfo.AccessModifier;
                var implementationName = memberImplInfo.ImplementationName;

                if (isInterface)
                    NUtils.GenerateMemberImplementation(writer, _source.FileIndex,
                                                                                            ty, member, @explicit, accessModifier, implementationName,
                                                                                            _cbGenerateXmlDoc.Checked);
                else
                {
                    // Генерируем override-методы. Для них нужно сформировать правильны модификатор доступа.
                    var am = (member.Attributes | NemerleModifiers.Override)
                                     & ~(NemerleModifiers.Abstract | NemerleModifiers.Virtual | NemerleModifiers.SpecialName);
                    var acessMods = am.ToString().ToLower().Replace(",", "");

                    NUtils.GenerateMemberImplementation(writer, _source.FileIndex,
                                                                                            ty, member, false, acessMods, "",
                                                                                            _cbGenerateXmlDoc.Checked);
                }

                writer.WriteLine(); // разделяем члены пустой строкой
            }

            return writer.GetStringBuilder();
        }
开发者ID:vestild,项目名称:nemerle,代码行数:35,代码来源:ImplementMembersForm.cs

示例4: IncrementalHash

        private void IncrementalHash(IGrouping<string, DupItem> quickHashGroup)
        {
            var groups = quickHashGroup.ToArray();
            var first = groups.First();
            var length = first.Size / BufferSize;
            if (length == 0)
                length = 1;
            var position = 0;
            for (var i = 0; i < length; i++)
            {
                position += BufferSize;
                foreach (var group in groups.GroupBy(g => i == 0 ? string.Empty : g.HashSections[i - 1]))
                {
                    foreach (var groupFile in group)
                    {
                        if (groupFile.HashSections == null)
                            groupFile.HashSections = new List<string>();
                        groupFile.HashSections.Add(HashTool.HashFile(groupFile.FileName, position, BufferSize));
                    }
                }
            }

            foreach (var groupFile in groups)
            {
                groupFile.FullHash = string.Join(string.Empty, groupFile.HashSections);
            }
        }
开发者ID:unruledboy,项目名称:SharpDups,代码行数:27,代码来源:DupDetectorV3.cs


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