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


C# List.IsNullOrEmpty方法代码示例

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


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

示例1: GetListings

        public static List<ClassifiedsListing> GetListings(Item item, ListingProperties props, 
			OrderType orderType)
        {
            VersatileIO.Info("Searching bp.tf classifieds for {0}...", props.ToString(item));
            List<ClassifiedsListing> all = ClassifiedsScraper.GetClassifieds(item, props);

            List<ClassifiedsListing> res = new List<ClassifiedsListing>();
            foreach (ClassifiedsListing c in all)
            {
                if (c.ItemInstance.Item.IsSkin())
                {
                    continue;
                }

                if (c.OrderType == orderType)
                {
                    res.Add(c);
                }
            }

            if (res.IsNullOrEmpty())
            {
                VersatileIO.Warning("No classifieds found for {0}.", props.ToString(item));
                return res.EmptyIfNull().ToList();
            }

            VersatileIO.Info("{0} listings found.", res.Count);
            return res;
        }
开发者ID:einsteinsci,项目名称:custom-steam-tools,代码行数:29,代码来源:CmdClassifiedsBase.cs

示例2: GroupSearchResults

        private async Task GroupSearchResults(List<SearchHint> items)
        {
            if (items.IsNullOrEmpty())
            {
                return;
            }

            await TaskEx.Run(() =>
            {
                var emptyGroups = new List<Group<SearchHint>>();

                var types = items.Select(x => x.Type).Distinct().ToList();

                types.ForEach(type => emptyGroups.Add(new Group<SearchHint>(type, new List<SearchHint>())));

                var groupedItems = (from t in items
                    group t by t.Type
                    into grp
                    orderby grp.Key
                    select new Group<SearchHint>(grp.Key, grp)).ToList();

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    SearchResults = (from g in groupedItems.Union(emptyGroups)
#if WP8
                        where g.Count > 0
#else
                                     where g.HasItems

#endif
                        orderby g.Title
                        select g).ToList();
                });
            });
        }
开发者ID:EchoDemon,项目名称:MediaBrowser.WindowsPhone,代码行数:35,代码来源:SearchViewModel.cs

示例3: AllotPower

        /// <summary>
        /// 给某个角色分配权限
        /// </summary>
        /// <param name="roleNum"></param>
        /// <param name="resItems"></param>
        /// <returns></returns>
        public int AllotPower(string roleNum, List<string> resItems)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                int line = 0;
                if (!resItems.IsNullOrEmpty())
                {
                    SysRelationEntity entity = new SysRelationEntity();
                    entity.Where(a => a.RoleNum == roleNum);
                    line = this.SysRelation.Delete(entity);

                    SysResourceProvider provider = new SysResourceProvider();

                    List<SysRelationEntity> list = new List<SysRelationEntity>();
                    foreach (string resNum in resItems)
                    {
                        SysResourceEntity resource = provider.GetResource(resNum);
                        short ResType = resource != null ? resource.ResType : (short)EResourceType.Page;
                        entity = new SysRelationEntity() { RoleNum = roleNum, ResNum = resNum, ResType = ResType };
                        entity.IncludeAll();
                        list.Add(entity);
                    }
                    line += this.SysRelation.Add(list);
                }
                ts.Complete();
                if (line > 0)
                {
                    CacheHelper.Remove(string.Format(CacheKey.JOOSHOW_ROLEPOWER_CACHE, roleNum));
                    CacheHelper.Remove(CacheKey.JOOSHOW_ALLOTPOWER_CACHE);
                }
                return line;
            }
        }
开发者ID:ZhangHanLong,项目名称:gitwms,代码行数:39,代码来源:PowerProvider.cs

示例4: Create

        /// <summary>
        /// 创建报表文件格式
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public int Create(ReportsEntity entity,List<ReportParamsEntity> list)
        {
            if (!entity.ReportNum.IsEmpty())
            {
                return Update(entity,list);
            }
            int line = 0;
            using (TransactionScope ts = new TransactionScope())
            {
                entity.ReportNum = entity.ReportNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(ReportsEntity)) : entity.ReportNum;
                entity.IncludeAll();
                line += this.Reports.Add(entity);

                if (!list.IsNullOrEmpty())
                {
                    foreach (ReportParamsEntity item in list)
                    {
                        item.ParamNum = item.ParamNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(ReportParamsEntity)) : item.ParamNum;
                        item.ReportNum = entity.ReportNum;
                        item.IncludeAll();
                    }
                    this.ReportParams.Add(list);
                }
                ts.Complete();
            }

            return line;
        }
开发者ID:ZhangHanLong,项目名称:gitwms,代码行数:34,代码来源:ReportProvider.cs

示例5: ReturnsTrueWhenValueIsHasZeroElements

            public void ReturnsTrueWhenValueIsHasZeroElements()
            {
                var emptyString = new List<string>();
                var emptyInt = new List<int>();

                emptyString.IsNullOrEmpty().Should().BeTrue();
                emptyInt.IsNullOrEmpty().Should().BeTrue();
            }
开发者ID:OpenMagic,项目名称:OpenMagic,代码行数:8,代码来源:EnumerableExtensionsTests.cs

示例6: WhenHasElements_ShouldReturnFalse

            public void WhenHasElements_ShouldReturnFalse()
            {
                var enumerable = new List<object>();
                enumerable.Add(new { });
                var actual = enumerable.IsNullOrEmpty();

                Assert.False(actual);
            }
开发者ID:rbwestmoreland,项目名称:lighthouse,代码行数:8,代码来源:IEnumerableExtensionsTests.cs

示例7: ReturnsFalseWhenValueHasElements

            public void ReturnsFalseWhenValueHasElements()
            {
                var enumerableString = new List<string> { "a", "b" };
                var enumerableInt = new List<int> { 1, 2 };

                enumerableString.IsNullOrEmpty().Should().BeFalse();
                enumerableInt.IsNullOrEmpty().Should().BeFalse();
            }
开发者ID:OpenMagic,项目名称:OpenMagic,代码行数:8,代码来源:EnumerableExtensionsTests.cs

示例8: Remove

 public void Remove(List<TagEntity> tags)
 {
     if (tags.IsNullOrEmpty())
     {
         return;
     }
     tags.Iter(x => _tags.Remove(x.EntityId));
     _tagRepository.Remove(tags);
 }
开发者ID:GSerjo,项目名称:ImagePocket,代码行数:9,代码来源:TagCache.cs

示例9: CurrentBindDynamicRow

        public static void CurrentBindDynamicRow(
			this DbDataReader reader, 
			List<DynamicColumn> columns,
			ref DynamicRow row)
        {
            if(null == reader) { return; }
            if(columns.IsNullOrEmpty()) { return; }

            var dbValues = new object[columns.Count];
            reader.GetValues(dbValues);

            var flatValues = new List<Any>();
            var values = new List<Any>();
            var hashCodes = new List<Any>();
            var dbNulls = new List<string>();
            var columnIndex = -1;

            foreach(var column in columns) {
                columnIndex++;
                var value = dbValues[columnIndex];
                if(DBNull.Value == value) {
                    dbNulls.Add(column.BaseColumnName);
                    value = null;
                }
                flatValues.SafeAdd(column.ColumnName, value);
                flatValues.SafeAdd(column.BaseColumnName, value);
                values.Add(column.BaseColumnName, value);

                if(null != value) {
                    int hashCode = value.GetHashCode();
                    hashCodes.Add(
                        column.BaseColumnName, hashCode
                    );
                }
            }

            row.__ReturnAny = true;
            row.__DatabaseFirst = true;
            row.__DynamicColumns = columns;
            row.__FlatValues = flatValues;
            row.__DynamicValues = values;
            row.__DynamicOriginalValues = values;
            row.__OriginalHashCodes = hashCodes;
            row.__DynamicDbNulls = dbNulls;
            row.__OriginalHashCode = row.GetHashCode();

            if(dbNulls.Any()) {
                foreach(var dbNull in dbNulls) {
                    hashCodes.Add(
                        dbNull,
                        row.__OriginalHashCode
                    );
                }
            }
            row.__OriginalHashCodes = hashCodes;
        }
开发者ID:Kuick,项目名称:Kuicker,代码行数:56,代码来源:DynamicExtender.cs

示例10: GetRandomLocation

 /// <summary>
 /// Method searches for a random location on the map. Give true for a list of availible points and false for all points.
 /// </summary>
 /// <param name="searchForFreePoints"></param>
 /// <returns></returns>
 public Vector2 GetRandomLocation(bool searchForFreePoints, List<SpawnPoint> points, bool setTaken)
 {
     if (points.IsNullOrEmpty())
     {
         return Vector2.zero;
     }
     SpawnPoint temp = points[(Random.Range(0, points.Count - 1))];
     temp.taken = setTaken;
     return temp.location;
 }
开发者ID:SHEePYTaGGeRNeP,项目名称:ProftaakMobileGDT,代码行数:15,代码来源:SpawnGrid.cs

示例11: IsNullOrEmpty_OneItemEnumerable_ReturnsFalse

        public void IsNullOrEmpty_OneItemEnumerable_ReturnsFalse()
        {
            // arrange
            IEnumerable<object> oneItemEnumerable = new List<object> {new object()};

            // act

            // assert
            Assert.False(oneItemEnumerable.IsNullOrEmpty());
        }
开发者ID:TrangHoang,项目名称:Scratchpad,代码行数:10,代码来源:EnumerableExtensionsTest.cs

示例12: IsNullOrEmpty_EmptyEnumerable_ReturnsTrue

        public void IsNullOrEmpty_EmptyEnumerable_ReturnsTrue()
        {
            // arrange
            IEnumerable<object> emptyEnumerable = new List<object>();

            // act

            // assert
            Assert.True(emptyEnumerable.IsNullOrEmpty());
        }
开发者ID:TrangHoang,项目名称:Scratchpad,代码行数:10,代码来源:EnumerableExtensionsTest.cs

示例13: CreatePackage

        public ActionResult CreatePackage(string newPkgName, string newFunctions, string newMaterials, string newCompanies)
        {
            try
            {
                Package newPkg = new Package {PackageName = newPkgName};
                StringToCollections(newPkg, newMaterials, newFunctions, newCompanies);

                //check for repeated functions in packages
                List<string> repeatedPackageNames = new List<string>();
                List<string> repeatedFunctionNames = new List<string>();
                IEnumerable<Employee_Function> tmpFunctionsInt;
                foreach (Package aPackage in DB.Packages)
                {
                    tmpFunctionsInt = aPackage.Functions.Intersect(newPkg.Functions);
                    if (tmpFunctionsInt.Any())
                    {
                        repeatedPackageNames.Add(aPackage.PackageName);
                        foreach (Employee_Function aFunction in tmpFunctionsInt)
                        {
                            if (!repeatedFunctionNames.Contains(aFunction.Label))
                            {
                                repeatedFunctionNames.Add(aFunction.Label);
                            }
                        }
                    }
                }

                if (!repeatedPackageNames.IsNullOrEmpty())
                {
                    return new HttpStatusCodeResult(HttpStatusCode.Conflict, "Packages " + String.Join(", ", repeatedPackageNames)
                        + " already have the following functions: " + String.Join(", ", repeatedFunctionNames));
                }

                newPkg.CreatedDate = DateTime.Now;
                DB.Packages.Add(newPkg);
                DB.SaveChanges();

                Dictionary<string, string> rowInfo = new Dictionary<string, string>();
                rowInfo.Add("id", newPkg.PackageId.ToString());
                rowInfo.Add("pkgName", newPkg.PackageName);
                rowInfo.Add("materials", String.Join(" | ", newPkg.GenericMaterials.ToDictionary(mat => mat.GenericMaterialId, mat => mat.Label).Values));
                rowInfo.Add("functions", String.Join(" | ", newPkg.Functions.ToDictionary(fun => fun.FunctionId, fun => fun.Label).Values));
                rowInfo.Add("companies", newPkg.Companies.Any() ? String.Join(" | ", newPkg.Companies.ToDictionary(com => com.ID, com => com.CompanyCodeName).Values) : "All Companies");
                rowInfo.Add("deleteLink", Url.Action("Delete", "Package"));
                rowInfo.Add("editLink", Url.Action("GetPackageDetails", "Package"));

                return Json(rowInfo);
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message);
            }
        }
开发者ID:dangokc,项目名称:CodeSnippets,代码行数:53,代码来源:PackageController.cs

示例14: GainItem

	public void GainItem(List<string> args)
	{
		if(args.IsNullOrEmpty())
			throw new ArgumentNullException("GainItem requires a list containing the item to gain, and the quantity.");

		string itemName = args[0];
		int quantity = Convert.ToInt32(args[1]);

		InventoryItem item = _itemDatabase.FindItemWithName(itemName);
		if(item != default(InventoryItem))
			_inventory.GainItem(item, quantity);

		DebugMessage("Could not find item " + itemName + " in the inventory database.", LogLevel.LogicError);
	}
开发者ID:Asvarduil,项目名称:Sara-The-Shieldmage,代码行数:14,代码来源:ConversationItemEvents.cs

示例15: GenerateFilterLocationRequest

        public static string GenerateFilterLocationRequest(List<ILocation> locations)
        {
            if (locations.IsNullOrEmpty())
            {
                return String.Empty;
            }

            StringBuilder queryBuilder = new StringBuilder();
            // queryBuilder.Append("locations=");
            for (int i = 0; i < locations.Count - 1; ++i)
            {
                queryBuilder.Append(GenerateLocationParameters(locations[i], false));
            }

            queryBuilder.Append(GenerateLocationParameters(locations[locations.Count - 1], true));

            return String.Format("locations={0}", StringFormater.UrlEncode(queryBuilder.ToString()));
        }
开发者ID:SowaLabs,项目名称:Tweetinvi-obsolete,代码行数:18,代码来源:QueryGeneratorHelper.cs


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