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


C# ICollection.IsNotNull方法代码示例

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


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

示例1: CacheImplementationSelector

        /// <summary>
        ///   Implementations placed in a dictionary indexed by fullname for convenience of use
        ///   elsewhere in the system.
        /// </summary>
        public CacheImplementationSelector(ICollection<ICacheImplementation> implementations,
                                           CacheImplementationSelectorDelegate selectorDelegate)
        {
            Ensure.That(implementations.IsNotNull(), "key not supplied")
                .And(selectorDelegate.IsNotNull(), "selectorDelegate not supplied")
                .And(implementations.Count.IsBetweenInclusive(1, MaxImplementations), "invalid number of cacheImplementations");

            _selectorDelegate = selectorDelegate;
            foreach (var i in implementations.Where(i => i != null))
            {
                _implementations.Add(i.GetType().FullName, i);
            }

            if (!_implementations.Where(i => i.Value.IsEnabled).Any())
                throw new ArgumentException("One or more implementations supplied must be enabled.", "implementations");
        }
开发者ID:benaston,项目名称:NCacheFacade,代码行数:20,代码来源:CacheImplementationSelector.cs

示例2: GetAutoCompleteOptions

        private static IEnumerable GetAutoCompleteOptions(string term, ICollection<string> data, IEnumerable<string> defaults)
        {
            // begin with the defaults
            var merged = defaults.ToList();

            // mix in the data
            if (data.IsNotNull() && data.Any()) merged.AddRange(data);

            // to not return anything for exact matches
            if (term.IsNotNullOrWhiteSpace())
            {
                var exact = merged.SingleOrDefault(term.Equals);
                var others = merged.Where(s => !term.Equals(s) && s.StartsWith(term));
                if (exact.IsNotNull() && !others.Any())
                    return Enumerable.Empty<object>();
            }

            // apply term
            if (term.IsNotNullOrWhiteSpace())
                merged = merged.Where(s => s != SalutationAndSuffixNullValueLabel && s.StartsWith(term)).ToList();

            // sort and convert to autocomplete anonymous object
            var options = merged.OrderBy(s => s).Select(s => new
            {
                label = s,
                value = s != SalutationAndSuffixNullValueLabel ? s : string.Empty,
            });

            return options;
        }
开发者ID:danludwig,项目名称:UCosmic,代码行数:30,代码来源:PersonNameController.cs

示例3: SerializeJobRequest

        private IEnumerable<KeyValuePair<string, string>> SerializeJobRequest(string userName, JobCreateParameters details, string jobName, ICollection<string> arguments, IDictionary<string, string> defines)
        {
            var values = new List<KeyValuePair<string, string>>();

            if (defines.IsNotNull())
            {
                if (jobName.IsNotNullOrEmpty() && !defines.ContainsKey(WebHCatConstants.DefineJobName))
                {
                    defines.Add(WebHCatConstants.DefineJobName, jobName);
                }

                values.AddRange(this.BuildNameValueList(WebHCatConstants.Define, defines));
            }

            if (arguments.IsNotNull())
            {
                if (jobName.IsNotNullOrEmpty() && defines.IsNull())
                {
                    arguments.Add(string.Format(CultureInfo.InvariantCulture, "{0}={1}", WebHCatConstants.DefineJobName, jobName));
                }

                values.AddRange(this.BuildList(WebHCatConstants.Arg, arguments));
            }

            values.Add(new KeyValuePair<string, string>(WebHCatConstants.StatusDirectory, details.StatusFolder));
            values.Add(new KeyValuePair<string, string>(WebHCatConstants.Files, this.BuildCommaSeparatedList(details.Files)));
            values.Add(new KeyValuePair<string, string>(WebHCatConstants.UserName, userName));
            values.Add(new KeyValuePair<string, string>(WebHCatConstants.Callback, details.Callback));
            values.Add(new KeyValuePair<string, string>(HadoopRemoteRestConstants.EnableLogging, details.EnableTaskLogs.ToString().ToLowerInvariant()));

            return values;
        }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:32,代码来源:PayloadConverterBase.cs


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