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


C# ICollection.IsEmpty方法代码示例

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


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

示例1: AssignRoles

        /// <summary>
        /// Creates the required missing tables or DB schema 
        /// </summary>
        public static void AssignRoles(this IAuthRepository UserAuthRepo, IUserAuth userAuth,
            ICollection<string> roles = null, ICollection<string> permissions = null)
        {
            var managesRoles = UserAuthRepo as IManageRoles;
            if (managesRoles != null)
            {
                managesRoles.AssignRoles(userAuth.Id.ToString(), roles, permissions);
            }
            else
            {
                if (!roles.IsEmpty())
                {
                    foreach (var missingRole in roles.Where(x => !userAuth.Roles.Contains(x)))
                    {
                        userAuth.Roles.Add(missingRole);
                    }
                }

                if (!permissions.IsEmpty())
                {
                    foreach (var missingPermission in permissions.Where(x => !userAuth.Permissions.Contains(x)))
                    {
                        userAuth.Permissions.Add(missingPermission);
                    }
                }

                UserAuthRepo.SaveUserAuth(userAuth);
            }
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:32,代码来源:UserAuthRepositoryExtensions.cs

示例2: WithEnumTypes

        /// <summary>
        ///     Allows individual enumeration types to be specified.
        ///     Multiple calls will add to the existing list.
        /// </summary>
        public IEnumSerializerConfigurator WithEnumTypes(ICollection<Type> enumTypes)
        {
            if (!enumTypes.IsEmpty())
            {
                var publicEnums = enumTypes.GetPublicEnums();
                _enumTypes.UnionWith(publicEnums);
            }

            return this;
        }
开发者ID:kharabasz,项目名称:ServiceStack.Text.EnumMemberSerializer,代码行数:14,代码来源:EnumSerializerConfigurator.cs

示例3: WithAssemblies

        /// <summary>
        ///     Search the provided assemblies for enumerations to configure.
        ///     Multiple calls will add to the existing list.
        /// </summary>
        /// <param name="assembliesToScan"></param>
        public IEnumSerializerConfigurator WithAssemblies(ICollection<Assembly> assembliesToScan)
        {
            if (!assembliesToScan.IsEmpty())
            {
                foreach (var assembly in assembliesToScan)
                {
                    if (assembly != null)
                    {
                        _assembliesToScan.Add(assembly);
                    }
                }
            }

            return this;
        }
开发者ID:kharabasz,项目名称:ServiceStack.Text.EnumMemberSerializer,代码行数:20,代码来源:EnumSerializerConfigurator.cs

示例4: Fetch

        /// <summary>Fetch objects and refs from the remote repository to the local one.</summary>
        /// <remarks>
        /// Fetch objects and refs from the remote repository to the local one.
        /// <p>
        /// This is a utility function providing standard fetch behavior. Local
        /// tracking refs associated with the remote repository are automatically
        /// updated if this transport was created from a
        /// <see cref="RemoteConfig">RemoteConfig</see>
        /// with
        /// fetch RefSpecs defined.
        /// </remarks>
        /// <param name="monitor">
        /// progress monitor to inform the user about our processing
        /// activity. Must not be null. Use
        /// <see cref="NGit.NullProgressMonitor">NGit.NullProgressMonitor</see>
        /// if
        /// progress updates are not interesting or necessary.
        /// </param>
        /// <param name="toFetch">
        /// specification of refs to fetch locally. May be null or the
        /// empty collection to use the specifications from the
        /// RemoteConfig. Source for each RefSpec can't be null.
        /// </param>
        /// <returns>information describing the tracking refs updated.</returns>
        /// <exception cref="System.NotSupportedException">
        /// this transport implementation does not support fetching
        /// objects.
        /// </exception>
        /// <exception cref="NGit.Errors.TransportException">
        /// the remote connection could not be established or object
        /// copying (if necessary) failed or update specification was
        /// incorrect.
        /// </exception>
        public virtual FetchResult Fetch(ProgressMonitor monitor, ICollection<RefSpec> toFetch
			)
        {
            if (toFetch == null || toFetch.IsEmpty())
            {
                // If the caller did not ask for anything use the defaults.
                //
                if (fetch.IsEmpty())
                {
                    throw new TransportException(JGitText.Get().nothingToFetch);
                }
                toFetch = fetch;
            }
            else
            {
                if (!fetch.IsEmpty())
                {
                    // If the caller asked for something specific without giving
                    // us the local tracking branch see if we can update any of
                    // the local tracking branches without incurring additional
                    // object transfer overheads.
                    //
                    ICollection<RefSpec> tmp = new AList<RefSpec>(toFetch);
                    foreach (RefSpec requested in toFetch)
                    {
                        string reqSrc = requested.GetSource();
                        foreach (RefSpec configured in fetch)
                        {
                            string cfgSrc = configured.GetSource();
                            string cfgDst = configured.GetDestination();
                            if (cfgSrc.Equals(reqSrc) && cfgDst != null)
                            {
                                tmp.AddItem(configured);
                                break;
                            }
                        }
                    }
                    toFetch = tmp;
                }
            }
            FetchResult result = new FetchResult();
            new FetchProcess(this, toFetch).Execute(monitor, result);
            return result;
        }
开发者ID:kenji-tan,项目名称:ngit,代码行数:77,代码来源:Transport.cs

示例5: Push

        /// <summary>Push objects and refs from the local repository to the remote one.</summary>
        /// <remarks>
        /// Push objects and refs from the local repository to the remote one.
        /// <p>
        /// This is a utility function providing standard push behavior. It updates
        /// remote refs and send there necessary objects according to remote ref
        /// update specification. After successful remote ref update, associated
        /// locally stored tracking branch is updated if set up accordingly. Detailed
        /// operation result is provided after execution.
        /// <p>
        /// For setting up remote ref update specification from ref spec, see helper
        /// method
        /// <see cref="FindRemoteRefUpdatesFor(System.Collections.Generic.ICollection{E})">FindRemoteRefUpdatesFor(System.Collections.Generic.ICollection&lt;E&gt;)
        /// 	</see>
        /// , predefined refspecs
        /// (
        /// <see cref="REFSPEC_TAGS">REFSPEC_TAGS</see>
        /// ,
        /// <see cref="REFSPEC_PUSH_ALL">REFSPEC_PUSH_ALL</see>
        /// ) or consider using
        /// directly
        /// <see cref="RemoteRefUpdate">RemoteRefUpdate</see>
        /// for more possibilities.
        /// <p>
        /// When
        /// <see cref="IsDryRun()">IsDryRun()</see>
        /// is true, result of this operation is just
        /// estimation of real operation result, no real action is performed.
        /// </remarks>
        /// <seealso cref="RemoteRefUpdate">RemoteRefUpdate</seealso>
        /// <param name="monitor">
        /// progress monitor to inform the user about our processing
        /// activity. Must not be null. Use
        /// <see cref="NGit.NullProgressMonitor">NGit.NullProgressMonitor</see>
        /// if
        /// progress updates are not interesting or necessary.
        /// </param>
        /// <param name="toPush">
        /// specification of refs to push. May be null or the empty
        /// collection to use the specifications from the RemoteConfig
        /// converted by
        /// <see cref="FindRemoteRefUpdatesFor(System.Collections.Generic.ICollection{E})">FindRemoteRefUpdatesFor(System.Collections.Generic.ICollection&lt;E&gt;)
        /// 	</see>
        /// . No
        /// more than 1 RemoteRefUpdate with the same remoteName is
        /// allowed. These objects are modified during this call.
        /// </param>
        /// <returns>
        /// information about results of remote refs updates, tracking refs
        /// updates and refs advertised by remote repository.
        /// </returns>
        /// <exception cref="System.NotSupportedException">
        /// this transport implementation does not support pushing
        /// objects.
        /// </exception>
        /// <exception cref="NGit.Errors.TransportException">
        /// the remote connection could not be established or object
        /// copying (if necessary) failed at I/O or protocol level or
        /// update specification was incorrect.
        /// </exception>
        public virtual PushResult Push(ProgressMonitor monitor, ICollection<RemoteRefUpdate
			> toPush)
        {
            if (toPush == null || toPush.IsEmpty())
            {
                // If the caller did not ask for anything use the defaults.
                try
                {
                    toPush = FindRemoteRefUpdatesFor(push);
                }
                catch (IOException e)
                {
                    throw new TransportException(MessageFormat.Format(JGitText.Get().problemWithResolvingPushRefSpecsLocally
                        , e.Message), e);
                }
                if (toPush.IsEmpty())
                {
                    throw new TransportException(JGitText.Get().nothingToPush);
                }
            }
            PushProcess pushProcess = new PushProcess(this, toPush);
            return pushProcess.Execute(monitor);
        }
开发者ID:kenji-tan,项目名称:ngit,代码行数:83,代码来源:Transport.cs

示例6: Join

		private static string Join(ICollection<object> objs, string delimiter)
		{
			if (objs == null || objs.IsEmpty())
			{
				return string.Empty;
			}
			IEnumerator<object> iter = objs.GetEnumerator();
			if (!iter.HasNext())
			{
				return string.Empty;
			}
			StringBuilder builder = new StringBuilder(iter.Next().ToString());
			while (iter.HasNext())
			{
				builder.Append(delimiter).Append(iter.Next().ToString());
			}
			return builder.ToString();
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:18,代码来源:NativeJSON.cs

示例7: UnAssignRoles

        /// <summary>
        /// Unassign role(s) from the user.
        /// </summary>
        /// <param name="userAuthId">The UserAuth id.</param>
        /// <param name="roles">The roles.</param>
        /// <param name="permissions">The permissions.</param>
        public void UnAssignRoles(string userAuthId, ICollection<string> roles = null, ICollection<string> permissions = null)
        {
            var userAuth = this.GetUserAuth(userAuthId);

            if (!this.UseDistinctRoleTables)
            {
                if (roles != null && !roles.IsEmpty())
                {
                    var userRoles = userAuth.Roles;
                    foreach (var role in roles)
                    {
                        userRoles.Remove(role);
                    }

                    userAuth.Roles = userRoles;
                }

                if (permissions != null && !permissions.IsEmpty())
                {
                    var userPermissions = userAuth.Permissions;
                    foreach (var permission in permissions)
                    {
                        userPermissions.Remove(permission);
                    }

                    userAuth.Permissions = userPermissions;
                }

                if (roles != null || permissions != null)
                {
                    this.SaveUserAuth(userAuth);
                }
            }
            else
            {
                var hasChanged = false;
                var rolesAndPermissions =
                    this.unitOfWork.UserAuthRoles
                        .Where(x => x.UserAuthId == userAuth.Id)
                        .ToList();

                if (!roles.IsEmpty())
                {
                    var rolesToRemove =
                        rolesAndPermissions.Where(q =>
                            roles.Contains(q.Role));

                    this.unitOfWork.Remove(rolesToRemove);
                    hasChanged = true;
                }

                if (!permissions.IsEmpty())
                {
                    var permissionsToRemove =
                        rolesAndPermissions.Where(q =>
                            permissions.Contains(q.Permission));

                    this.unitOfWork.Remove(permissionsToRemove);
                    hasChanged = true;
                }

                if (hasChanged)
                {
                    this.unitOfWork.SaveChanges();
                }
            }
        }
开发者ID:hhandoko,项目名称:ServiceStack.Authentication.LightSpeed,代码行数:73,代码来源:LightSpeedManageRoles.cs

示例8: AssignRoles

        /// <summary>
        /// Assign role(s) to the user.
        /// </summary>
        /// <param name="userAuthId">The UserAuth id.</param>
        /// <param name="roles">The roles.</param>
        /// <param name="permissions">The permissions.</param>
        public void AssignRoles(string userAuthId, ICollection<string> roles = null, ICollection<string> permissions = null)
        {
            var userAuth = this.GetUserAuth(userAuthId) as UserAuth;
            if (userAuth == null)
            {
                throw new Exception("No user found in the database with the given id.");
            }

            if (!this.UseDistinctRoleTables)
            {
                if (roles != null && !roles.IsEmpty())
                {
                    var userRoles = userAuth.Roles;
                    foreach (var role in roles)
                    {
                        userRoles.AddIfNotExists(role);
                    }

                    userAuth.Roles = userRoles;
                }

                if (permissions != null && !permissions.IsEmpty())
                {
                    var userPermissions = userAuth.Permissions;
                    foreach (var permission in permissions)
                    {
                        userPermissions.AddIfNotExists(permission);
                    }

                    userAuth.Permissions = userPermissions;
                }

                this.SaveUserAuth(userAuth);
            }
            else
            {
                var now = DateTime.UtcNow;
                var rolesAndPermissions =
                    this.unitOfWork.UserAuthRoles
                        .Where(x => x.UserAuthId == userAuth.Id);

                if (roles != null && !roles.IsEmpty())
                {
                    var roleSet =
                        rolesAndPermissions
                            .Where(x => x.Role != null)
                            .Select(x => x.Role)
                            .ToHashSet();

                    foreach (
                        var role
                        in roles
                            .Where(role => !roleSet.Contains(role)))
                    {
                        this.unitOfWork.Add(
                            new UserAuthRole
                                {
                                    UserAuthId = userAuth.Id,
                                    Role = role,
                                    CreatedDate = now,
                                    ModifiedDate = now
                                });
                    }
                }

                if (permissions != null && !permissions.IsEmpty())
                {
                    var permissionSet =
                        rolesAndPermissions
                            .Where(x => x.Permission != null)
                            .Select(x => x.Permission)
                            .ToHashSet();

                    foreach (
                        var permission
                        in permissions
                            .Where(permission => !permissionSet.Contains(permission)))
                    {
                        this.unitOfWork.Add(
                            new UserAuthRole
                                {
                                    UserAuthId = userAuth.Id,
                                    Permission = permission,
                                    CreatedDate = now,
                                    ModifiedDate = now
                                });
                    }
                }
            }

            this.unitOfWork.SaveChanges();
        }
开发者ID:hhandoko,项目名称:ServiceStack.Authentication.LightSpeed,代码行数:98,代码来源:LightSpeedManageRoles.cs

示例9: Push

		/// <exception cref="NGit.Errors.TransportException"></exception>
		public virtual void Push(ProgressMonitor monitor, IDictionary<string, RemoteRefUpdate
			> refUpdates)
		{
			MarkStartedOperation();
			packNames = null;
			newRefs = new SortedDictionary<string, Ref>(GetRefsMap());
			packedRefUpdates = new AList<RemoteRefUpdate>(refUpdates.Count);
			// Filter the commands and issue all deletes first. This way we
			// can correctly handle a directory being cleared out and a new
			// ref using the directory name being created.
			//
			IList<RemoteRefUpdate> updates = new AList<RemoteRefUpdate>();
			foreach (RemoteRefUpdate u in refUpdates.Values)
			{
				string n = u.GetRemoteName();
				if (!n.StartsWith("refs/") || !Repository.IsValidRefName(n))
				{
					u.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
					u.SetMessage(JGitText.Get().funnyRefname);
					continue;
				}
				if (AnyObjectId.Equals(ObjectId.ZeroId, u.GetNewObjectId()))
				{
					DeleteCommand(u);
				}
				else
				{
					updates.AddItem(u);
				}
			}
			// If we have any updates we need to upload the objects first, to
			// prevent creating refs pointing at non-existent data. Then we
			// can update the refs, and the info-refs file for dumb transports.
			//
			if (!updates.IsEmpty())
			{
				Sendpack(updates, monitor);
			}
			foreach (RemoteRefUpdate u_1 in updates)
			{
				UpdateCommand(u_1);
			}
			// Is this a new repository? If so we should create additional
			// metadata files so it is properly initialized during the push.
			//
			if (!updates.IsEmpty() && IsNewRepository())
			{
				CreateNewRepository(updates);
			}
			RefWriter refWriter = new _RefWriter_177(this, newRefs.Values);
			if (!packedRefUpdates.IsEmpty())
			{
				try
				{
					refWriter.WritePackedRefs();
					foreach (RemoteRefUpdate u_2 in packedRefUpdates)
					{
						u_2.SetStatus(RemoteRefUpdate.Status.OK);
					}
				}
				catch (IOException err)
				{
					foreach (RemoteRefUpdate u_2 in packedRefUpdates)
					{
						u_2.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
						u_2.SetMessage(err.Message);
					}
					throw new TransportException(uri, JGitText.Get().failedUpdatingRefs, err);
				}
			}
			try
			{
				refWriter.WriteInfoRefs();
			}
			catch (IOException err)
			{
				throw new TransportException(uri, JGitText.Get().failedUpdatingRefs, err);
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:80,代码来源:WalkPushConnection.cs

示例10: SetLists

		/// <summary>
		///     タイムラインに受信対象リストを設定します。
		/// </summary>
		/// <param name="lists">受信対象リストのコレクション。すべてのツイートを受信する設定に戻す場合は null。</param>
		public void SetLists(ICollection<List> lists)
		{
			if (lists == null || lists.IsEmpty())
			{
				this.targets = null;
				if (this.Timeline != null)
				{
					this.Timeline.SubscribedLists = null;
				}
			}
			else
			{
				this.targets = lists as List<List> ?? lists.ToList();
				this.targets.ForEach(
					l => Helper.Operation(l.UpdateMembers, "リスト '{0}' のメンバーを取得できませんでした。", l.HasDetails ? l.FullName : "id:" + l.Id));

				if (this.Timeline != null)
				{
					this.Timeline.SubscribedLists = this.targets;
				}
			}

			this.RaisePropertyChanged("IsReceivingAll");
		}
开发者ID:Grabacr07,项目名称:Mukyutter.Old,代码行数:28,代码来源:TimelineBlock.cs


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