예제 #1
0
        public static TeamFoundationIdentity ParseUserIdentity(string argumentName, TfsTeamProjectCollection collection, object argumentUser)
        {
            TeamFoundationIdentity userIdentity = null;

            if (argumentUser != null)
            {
                if (argumentUser is PSObject)
                {
                    argumentUser = (argumentUser as PSObject).BaseObject;
                }

                if (argumentUser is string)
                {
                    string userEmail = argumentUser as string;
                    userIdentity = collection.GetUserIdentityByEmail(userEmail);

                    if (userIdentity == null)
                    {
                        throw new PSArgumentException(string.Format("Field \"{0}\": No user is found through email: {1}.", argumentName, userEmail));
                    }
                }
                else if (argumentUser is TeamFoundationIdentity)
                {
                    userIdentity = argumentUser as TeamFoundationIdentity;
                }
                else
                {
                    throw new PSArgumentException("Field \"Assigned To\": the argument type is not supported. We only support user email and TeamFoundationIdentity.");
                }
            }

            return(userIdentity);
        }