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


C# IEnumerable.Single方法代码示例

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


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

示例1: BuildFilters

        protected override IEnumerable<ICommandFilter> BuildFilters(IEnumerable<CaptionFilter> filters)
        {
            yield return new CommandFilter("[property_type]=1");

            yield return new CommandFilter(string.Format("[cube_name]='{0}'"
                                                           , filters.Single(f => f.Target == Target.Perspectives).Caption
                                                           ));

            yield return new CommandFilter(string.Format("[dimension_unique_name]='[{0}]'"
                                                            , filters.Single(f => f.Target == Target.Dimensions).Caption
                                                            ));

            yield return new CommandFilter(string.Format("[hierarchy_unique_name]='[{0}].[{1}]'"
                                                , filters.Single(f => f.Target == Target.Dimensions).Caption
                                                , filters.Single(f => f.Target == Target.Hierarchies).Caption
                                                ));

            yield return new CommandFilter(string.Format("[level_unique_name]='[{0}].[{1}].[{2}]'"
                                                , filters.Single(f => f.Target == Target.Dimensions).Caption
                                                , filters.Single(f => f.Target == Target.Hierarchies).Caption
                                                , filters.Single(f => f.Target == Target.Levels).Caption
                                                ));

            var filter = filters.SingleOrDefault(f => f.Target == Target.Properties);
            if (filter!=null)
                yield return new CommandFilter(string.Format("[property_caption]='{0}'"
                                                           , filter.Caption
                                                           ));
        }
开发者ID:Waltervondehans,项目名称:NBi,代码行数:29,代码来源:PropertyDiscoveryCommandBuilder.cs

示例2: MessageBrokerConnection

        public MessageBrokerConnection(IEnumerable<KeyValuePair<string, string>> rabbitEnvironment)
        {
            this.Server = rabbitEnvironment.Single(kvp => kvp.Key == "RabbitMQServer").Value;
            this.Port = Convert.ToInt32(rabbitEnvironment.Single(kvp => kvp.Key == "RabbitMQPort").Value, CultureInfo.InvariantCulture);
            this.VHost = rabbitEnvironment.Single(kvp => kvp.Key == "RabbitMQVHost").Value;

            this.Connection = this.CreateConnection();
            this.Connection.ConnectionShutdown += Connection_ConnectionShutdown;
        }
开发者ID:dkearney1,项目名称:Default,代码行数:9,代码来源:MessageBrokerConnection.cs

示例3: CreateFromEntity

 public static GameStatus CreateFromEntity(Entity.Game entity, IEnumerable<Player> players)
 {
     return new Model.GameStatus(
                 players.Single(x => x.ID == entity.CurrentPlayerID),
                 players.Single(x => x.ID != entity.CurrentPlayerID),
                 players.FirstOrDefault(x => x.ID == entity.WinnerID),
                 entity.Active,
                 Model.GameMove.Empty,
                 Model.GameMoveResultType.Nothing,
                 null,
                 null);
 }
开发者ID:daniel-bytes,项目名称:rps.net,代码行数:12,代码来源:GameStatus.cs

示例4: GetResourceSet

 public static ResourceSet GetResourceSet(IEnumerable<PlanetResource> resources)
 {
     var metal = resources.Single(r => r.ResourceId == (int)ResourceItem.Metal);
     var crystal = resources.Single(r => r.ResourceId == (int)ResourceItem.Crystal);
     var deiterium = resources.Single(r => r.ResourceId == (int)ResourceItem.Deiterium);
     return new ResourceSet
     {
         Metal = metal,
         Crystal = crystal,
         Deiterium = deiterium
     };
 }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:12,代码来源:ResourceHelper.cs

示例5: BuildFilters

        protected override IEnumerable<ICommandFilter> BuildFilters(IEnumerable<CaptionFilter> filters)
        {
            yield return new CommandFilter(string.Format("[routine_schema]='{0}'"
                                                            , filters.Single(f => f.Target == Target.Perspectives).Caption
                                                            ));

            var filter = filters.SingleOrDefault(f => f.Target == Target.Routines);
            if (filter != null)
                yield return new CommandFilter(string.Format("[routine_name]='{0}'"
                                                           , filters.Single(f => f.Target == Target.Routines).Caption
                                                           ));
        }
开发者ID:Waltervondehans,项目名称:NBi,代码行数:12,代码来源:RoutineDiscoveryCommandBuilder.cs

示例6: FromQueryModel

        public static KpisViewModel FromQueryModel(IEnumerable<Kpi> data)
        {
            if (data == null || data.Count() == 0)
                return new KpisViewModel();

            return new KpisViewModel()
            {
                Employees = data.Single(i => i.Id == "Employees").Value,
                GrossPay = data.Single(i => i.Id == "GrossPay").Value,
                Benefits = data.Single(i => i.Id == "Benefits").Value,
                NetPay = data.Single(i => i.Id == "NetPay").Value
            };
        }
开发者ID:dilillo,项目名称:Benefits,代码行数:13,代码来源:KpisViewModel.cs

示例7: BuildFilters

        protected override IEnumerable<ICommandFilter> BuildFilters(IEnumerable<CaptionFilter> filters)
        {
            yield return new CommandFilter("len(measuregroup_name)>0");

            yield return new CommandFilter(string.Format("[cube_name]='{0}'"
                                    , filters.Single(f => f.Target == Target.Perspectives).Caption
                                    ));

            var mgFilter = filters.SingleOrDefault(f => f.Target == Target.MeasureGroups);
            if (mgFilter != null)
                yield return new CommandFilter(string.Format("[measuregroup_name]='{0}'"
                                                , filters.Single(f => f.Target == Target.MeasureGroups).Caption
                                                ));
        }
开发者ID:Waltervondehans,项目名称:NBi,代码行数:14,代码来源:MeasureGroupDiscoveryCommandBuilder.cs

示例8: BuildFilters

        protected override IEnumerable<ICommandFilter> BuildFilters(IEnumerable<CaptionFilter> filters)
        {
            yield return new CommandFilter(string.Format("[table_schema]='{0}'"
                                                            , filters.Single(f => f.Target == Target.Perspectives).Caption
                                                            ));

            yield return new CommandFilter(string.Format("[table_name]='{0}'"
                                                           , filters.Single(f => f.Target == Target.Tables).Caption
                                                           ));

            yield return new CommandFilter(string.Format("[column_name]='{0}'"
                                                           , filters.Single(f => f.Target == Target.Columns).Caption
                                                           ));
        }
开发者ID:Waltervondehans,项目名称:NBi,代码行数:14,代码来源:ColumnDiscoveryCommandBuilder.cs

示例9: ParameterSetResolver

        public ParameterSetResolver(Object target, IEnumerable<ParameterSet> parameterSets)
        {
            if (target == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(target));
            }

            if (parameterSets == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(parameterSets));
            }

            if (!parameterSets.Any())
            {
                throw Logger.Fatal.ArgumentEmptySequence(nameof(parameterSets));
            }

            DefaultParameterSet = parameterSets.Single(
                set => set.IsDefault
            );

            ParameterSets = parameterSets.ToImmutableDictionary(
                set => set.Name,
                ParameterSet.NameComparer
            );

            Target = target;
        }
开发者ID:NaseUkolyCZ,项目名称:HarshPoint,代码行数:28,代码来源:ParameterSetResolver.cs

示例10: EnsureNonDuplicationOfParty

        private void EnsureNonDuplicationOfParty(IEnumerable<DataCollectionParty> dataCollectionParties)
        {
            var newUrdmsParties = (from o in dataCollectionParties
                                    where o.Party.Id < 1 && !string.IsNullOrWhiteSpace(o.Party.UserId)
                                    select o.Party).ToList();
            if (newUrdmsParties.Count != 0)
            {
                var parties = _session.QueryOver<Party>().List();

                foreach (var newUrdmsParty in newUrdmsParties)
                {
                    var key = newUrdmsParty.UserId;
                    var existingParty = parties.Where(o => o.UserId == key).Take(1).FirstOrDefault();
                    if (existingParty != null)
                    {
                        existingParty.FirstName = newUrdmsParty.FirstName;
                        existingParty.LastName = newUrdmsParty.LastName;
                        existingParty.FullName = newUrdmsParty.FullName;
                        existingParty.Email = newUrdmsParty.Email;
                        var dataCollectionParty = dataCollectionParties.Single(o => o.Party.UserId == key);
                        dataCollectionParty.Party = existingParty;
                    }
                }
            }
        }
开发者ID:SharePointSusan,项目名称:Research-Data-Manager,代码行数:25,代码来源:DataCollectionRepository.cs

示例11: Convolute

 public Expr Convolute(IContext context, IEnumerable<Expr> args)
 {
     var arg = args.Single();
     return EvalConvolution(arg) ??
         ConstantConvolution(arg) ??
         SpecificConvolution(context, arg);
 }
开发者ID:VitalyTVA,项目名称:SharpAlg2,代码行数:7,代码来源:SingleArgumentDifferentiableFunction.cs

示例12: foreach

        IEnumerable<Price> IMarketPriceRepository.FetchPrices(IEnumerable<Item> items, SolarSystem system)
        {
            string urlData = "";
            foreach (Item item in items)
            {
                urlData += "typeid=" + item.ApiId + "&";
            }
            urlData += "usesystem=" + system.ApiId;

            XDocument doc = XDocument.Load(String.Format(String.Format(_priceURL, urlData)));
            IEnumerable<XElement> itemElements = doc.Element("evec_api").Element("marketstat").Elements("type");
            IList<Price> prices = new List<Price>();
            foreach (XElement itemElement in itemElements)
            {
                string itemApi = itemElement.Attribute("id").Value;
                Item currentItem = items.Single(i => i.ApiId.Equals(itemApi));
                Price price = new Price
                {
                    Item = currentItem,
                    SolarSystem = system,
                    Buy = Double.Parse(itemElement.Element("buy").Element("max").Value, CultureInfo.InvariantCulture),
                    Sell = Double.Parse(itemElement.Element("sell").Element("min").Value, CultureInfo.InvariantCulture),
                    Date = DateTime.Today
                };
                prices.Add(price);
            }
            return prices.AsEnumerable();
        }
开发者ID:Hybrid,项目名称:WebEve,代码行数:28,代码来源:EveCentralRepository.cs

示例13: GetCentralPosition

        public static Position GetCentralPosition(IEnumerable<Position> geoCoordinates)
        {
            if (geoCoordinates.Count() == 1) {
                return geoCoordinates.Single ();
            }

            double x = 0;
            double y = 0;
            double z = 0;

            foreach (var geoCoordinate in geoCoordinates) {
                var latitude = geoCoordinate.Latitude * Math.PI / 180;
                var longitude = geoCoordinate.Longitude * Math.PI / 180;

                x += Math.Cos (latitude) * Math.Cos (longitude);
                y += Math.Cos (latitude) * Math.Sin (longitude);
                z += Math.Sin (latitude);
            }

            var total = geoCoordinates.Count();

            x = x / total;
            y = y / total;
            z = z / total;

            var centralLongitude = Math.Atan2 (y, x);
            var centralSquareRoot = Math.Sqrt (x * x + y * y);
            var centralLatitude = Math.Atan2 (z, centralSquareRoot);

            return new Position (
                centralLatitude * 180 / Math.PI,
                centralLongitude * 180 / Math.PI
            );
        }
开发者ID:harrysaggu,项目名称:xamarin-plugins,代码行数:34,代码来源:GeoHelper.cs

示例14: SetIndex

 public override object SetIndex(Func<object> proceed, dynamic self, IEnumerable<object> keys, object value) {
     if (keys.Count() == 1) {
         var name = keys.Single().ToString();
         if (name.Equals("Id")) {
             // need to mutate the actual type
             var s = self as Shape;
             if (s != null) {
                 s.Id = System.Convert.ToString(value);
             }
             return value;
         }
         if (name.Equals("Classes")) {
             var args = Arguments.From(new[] { value }, Enumerable.Empty<string>());
             MergeClasses(args, self.Classes);
             return value;
         }
         if (name.Equals("Attributes")) {
             var args = Arguments.From(new[] { value }, Enumerable.Empty<string>());
             MergeAttributes(args, self.Attributes);
             return value;
         }
         if (name.Equals("Items")) {
             var args = Arguments.From(new[] { value }, Enumerable.Empty<string>());
             MergeItems(args, self);
             return value;
         }
     }
     return proceed();
 }
开发者ID:akhurst,项目名称:ricealumni,代码行数:29,代码来源:Shape.cs

示例15: UpdateSession

        public void UpdateSession(IEnumerable<EventSourceSettings> updatedEventSources)
        {
            Guard.ArgumentNotNull(updatedEventSources, "updatedEventSources");

            var eventSourceComparer = new EventSourceSettingsEqualityComparer(nameOnly: true);

            // updated sources
            foreach (var currentSource in this.eventSources.Intersect(updatedEventSources, eventSourceComparer).ToArray())
            {
                var updatedSource = updatedEventSources.Single(s => s.Name == currentSource.Name);
                if (updatedSource.Level != currentSource.Level ||
                    updatedSource.MatchAnyKeyword != currentSource.MatchAnyKeyword)
                {
                    TraceEventUtil.EnableProvider(this.session, updatedSource.EventSourceId, updatedSource.Level, updatedSource.MatchAnyKeyword, sendManifest: false);
                    currentSource.Level = updatedSource.Level;
                    currentSource.MatchAnyKeyword = updatedSource.MatchAnyKeyword;
                }
            }

            // new sources
            foreach (var newSource in updatedEventSources.Except(this.eventSources, eventSourceComparer).ToArray())
            {
                TraceEventUtil.EnableProvider(this.session, newSource.EventSourceId, newSource.Level, newSource.MatchAnyKeyword, sendManifest: true);
                this.eventSources.Add(newSource);
            }

            // removed sources
            foreach (var removedSource in this.eventSources.Except(updatedEventSources, eventSourceComparer).ToArray())
            {
                this.session.DisableProvider(removedSource.EventSourceId);
                this.eventSources.Remove(removedSource);
            }
        }
开发者ID:Brar,项目名称:entlib,代码行数:33,代码来源:TraceEventServiceWorker.cs


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