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


C# EmailAddress.ToString方法代码示例

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


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

示例1: CheckAccess

        /// <summary>
        /// Checks the access an account has with an organization..
        /// </summary>
        /// <param name="name">The organization name.</param>
        /// <param name="accountId">The account identifier.</param>
        /// <param name="allowAdmin">if set to <c>true</c> allow admin.</param>
        /// <param name="allowWrite">if set to <c>true</c> allow write.</param>
        /// <param name="allowRead">if set to <c>true</c> allow read.</param>
        public void CheckAccess(
            DomainLabel name,
            EmailAddress accountId,
            out bool allowAdmin,
            out bool allowWrite,
            out bool allowRead)
        {
            allowAdmin = false;
            allowWrite = false;
            allowRead = false;

            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (accountId == null)
            {
                throw new ArgumentNullException("accountId");
            }

            CloudTable orgMemberTable = this.GetOrganizationMembershipTable();
            TableOperation getOrgMember = TableOperation.Retrieve<OrganizationMembershipEntity>(
                name.ToString(),
                accountId.ToString());
            TableResult result = orgMemberTable.Execute(getOrgMember);
            OrganizationMembershipEntity entity = result.Result as OrganizationMembershipEntity;
            if (entity != null)
            {
                allowRead = true;
                allowWrite = entity.AllowWrite;
                allowAdmin = entity.AllowAdmin;
            }
        }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:42,代码来源:OrganizationStore.cs

示例2: AcceptRecipient

        public bool AcceptRecipient(SMTPContext context, EmailAddress recipient)
        {
            bool match = recipient.Username.ToLower() == "text";

            ServiceLocator.Current.Log.WarningIf(!match, "Received mail not to [email protected] Instead, " + recipient.ToString());

            return match;
        }
开发者ID:WestonThayer,项目名称:aVoicePush,代码行数:8,代码来源:SmtpHandler.cs

示例3: SendActivationEmail

 /// <summary>
 /// Sends activation email.
 /// </summary>
 /// <param name="accountId">the account to activate.</param>
 /// <param name="activationUrl">the activation url.</param>
 public void SendActivationEmail(EmailAddress accountId, Uri activationUrl)
 {
     using (MailMessage message = new MailMessage(this.info.From, accountId.ToString()))
     {
         message.Subject = "Account Activation Notification";
         message.Body = activationUrl.ToString();
         this.SendMailMessage(message);
     }
 }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:14,代码来源:EmailClient.cs

示例4: AuthorizeApplication

        /// <summary>
        /// Authorizes the application.
        /// </summary>
        /// <param name="accountId">The account identifier.</param>
        /// <param name="applicationName">Name of the application.</param>
        public void AuthorizeApplication(EmailAddress accountId, DomainLabel applicationName)
        {
            if (accountId == null)
            {
                throw new ArgumentNullException("accountId");
            }

            if (applicationName == null)
            {
                throw new ArgumentNullException("applicationName");
            }

            CloudTable authorizeTable = this.GetAuthorizedApplicationsTable();
            AuthorizedApplicationEntity entity = new AuthorizedApplicationEntity(
                accountId.ToString(),
                applicationName.ToString());

            TableOperation op = TableOperation.InsertOrMerge(entity);
            authorizeTable.Execute(op);
        }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:25,代码来源:ApplicationStore.cs

示例5: ToStringReturnsValue

        public void ToStringReturnsValue()
        {
            var email = new EmailAddress("[email protected]");

            Assert.Equal("[email protected]", email.ToString());
        }
开发者ID:EnvironmentAgency,项目名称:prsd-iws,代码行数:6,代码来源:EmailAddressTests.cs

示例6: EmailAddress_Unit_ToString_Optimal

        public void EmailAddress_Unit_ToString_Optimal()
        {
            String localPart = "Chad.Greer";
            String domain = "ParivedaSolutions.com";
            EmailAddress target = new EmailAddress(localPart, domain);
            String expected = localPart + "@" + domain;

            String actual = target.ToString();
            Assert.AreEqual(expected, actual);
        }
开发者ID:cegreer,项目名称:Common,代码行数:10,代码来源:EmailAddressTests.cs

示例7: ComputeBytes

 /// <summary>
 /// Computes the body of the token from the account id.
 /// </summary>
 /// <param name="accountId">The account id.</param>
 /// <returns>The token body.</returns>
 private static byte[] ComputeBytes(EmailAddress accountId)
 {
     byte[] encodedAccountId = Encoding.UTF8.GetBytes(accountId.ToString());
     byte[] raw = new byte[encodedAccountId.Length + 1];
     Array.Copy(encodedAccountId, raw, encodedAccountId.Length);
     raw[encodedAccountId.Length] = 0;
     return raw;
 }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:13,代码来源:ActivationCode.cs

示例8: CreateApplication

        /// <summary>
        /// Creates an application.
        /// </summary>
        /// <param name="name">The name of the application.</param>
        /// <param name="friendlyName">The friendly name of the application.</param>
        /// <param name="organizationName">The organization that owns the application.</param>
        /// <param name="clientId">the client id.</param>
        /// <param name="clientSecret">the client secret.</param>
        /// <param name="homePageUrl">The home page URL.</param>
        /// <param name="authorizationCallbackUrl">The authorization callback URL.</param>
        /// <param name="accountId">The user creating the application.</param>
        /// <remarks>
        /// This call assumes the user has been already authorized to create the application.
        /// </remarks>
        public void CreateApplication(
            DomainLabel name,
            string friendlyName,
            DomainLabel organizationName,
            string clientId,
            string clientSecret,
            Uri homePageUrl,
            Uri authorizationCallbackUrl,
            EmailAddress accountId)
        {
            if (!ValidateApplicationName(name))
            {
                throw new ArgumentOutOfRangeException("name");
            }

            if (string.IsNullOrWhiteSpace(friendlyName))
            {
                throw new ArgumentOutOfRangeException("friendlyName");
            }

            if (organizationName == null)
            {
                throw new ArgumentNullException("organizationName");
            }

            if (accountId == null)
            {
                throw new ArgumentNullException("accountId");
            }

            if (string.IsNullOrWhiteSpace(clientId))
            {
                throw new ArgumentOutOfRangeException("clientId");
            }

            if (string.IsNullOrWhiteSpace(clientSecret))
            {
                throw new ArgumentOutOfRangeException("clientSecret");
            }

            if (homePageUrl == null)
            {
                throw new ArgumentNullException("homePageUrl");
            }

            if (authorizationCallbackUrl == null)
            {
                throw new ArgumentNullException("authorizationCallbackUrl");
            }

            CloudTable appTable = this.GetApplicationTable();
            CloudTable appByClientIdTable = this.GetApplicationNameByClientIdTable();
            CloudTable orgAppsTable = this.GetOrganizationApplicationsTable();
            if (FindExistingApplication(appTable, name.ToString()) != null)
            {
                throw new InvalidOperationException("Application already exists.");
            }

            ApplicationEntity appEntity = new ApplicationEntity(name.ToString())
            {
                FriendlyName = friendlyName,
                OrganizationId = organizationName.ToString(),
                ClientId = clientId,
                ClientSecret = clientSecret,
                CreatedByAccountId = accountId.ToString(),
                CreatedTime = DateTime.UtcNow,
                HomePageUrl = homePageUrl.ToString(),
                AuthorizationCallbackUrl = authorizationCallbackUrl.ToString()
            };

            appEntity.LastModifiedByAccountId = appEntity.CreatedByAccountId;
            appEntity.LastModifiedTime = appEntity.CreatedTime;

            OrganizationApplicationEntity orgAppEntity = new OrganizationApplicationEntity(
                organizationName.ToString(),
                name.ToString());

            ApplicationNameByClientIdEntity appByClientIdEntity = new ApplicationNameByClientIdEntity(
                clientId)
                {
                    ApplicationName = name.ToString()
                };

            TableOperation insertAppByClientId = TableOperation.InsertOrMerge(appByClientIdEntity);
            appByClientIdTable.Execute(insertAppByClientId);

//.........这里部分代码省略.........
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:101,代码来源:ApplicationStore.cs

示例9: IsApplicationAuthorized

        /// <summary>
        /// Determines whether is application authorized by the specified account identifier.
        /// </summary>
        /// <param name="accountId">The account identifier.</param>
        /// <param name="applicationName">Name of the application.</param>
        /// <returns>Whether the user has authorized the application.</returns>
        public bool IsApplicationAuthorized(EmailAddress accountId, DomainLabel applicationName)
        {
            if (accountId == null)
            {
                throw new ArgumentNullException("accountId");
            }

            if (applicationName == null)
            {
                throw new ArgumentNullException("applicationName");
            }

            CloudTable authorizeTable = this.GetAuthorizedApplicationsTable();
            TableOperation op = TableOperation.Retrieve<AuthorizedApplicationEntity>(
                accountId.ToString(),
                applicationName.ToString());
            TableResult result = authorizeTable.Execute(op);
            return (result.Result as AuthorizedApplicationEntity) != null;
        }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:25,代码来源:ApplicationStore.cs

示例10: GetAuthorizedApplications

        /// <summary>
        /// Gets the authorized applications.
        /// </summary>
        /// <param name="accountId">The account identifier.</param>
        /// <returns>a list of applications authorized by the user.</returns>
        public IEnumerable<AuthorizedApplicationInfo> GetAuthorizedApplications(EmailAddress accountId)
        {
            if (accountId == null)
            {
                throw new ArgumentNullException("accountId");
            }

            CloudTable appTable = this.GetApplicationTable();
            CloudTable authorizeTable = this.GetAuthorizedApplicationsTable();
            TableQuery<AuthorizedApplicationEntity> appsQuery =
                new TableQuery<AuthorizedApplicationEntity>().Where(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, accountId.ToString()));
            List<string> appNames = new List<string>();
            foreach (AuthorizedApplicationEntity entity in authorizeTable.ExecuteQuery(appsQuery))
            {
                appNames.Add(entity.RowKey);
            }

            List<AuthorizedApplicationInfo> results = new List<AuthorizedApplicationInfo>();
            foreach (string appName in appNames)
            {
                TableOperation getApp = TableOperation.Retrieve<ApplicationEntity>(appName, string.Empty);
                TableResult getAppResult = appTable.Execute(getApp);
                ApplicationEntity app = getAppResult.Result as ApplicationEntity;
                if (app != null)
                {
                    results.Add(new AuthorizedApplicationInfo
                    {
                        Name = DomainLabel.Parse(app.PartitionKey),
                        FriendlyName = app.FriendlyName,
                        OrganizationName = DomainLabel.Parse(app.OrganizationId),
                        HomePageUrl = new Uri(app.HomePageUrl)
                    });
                }
            }

            return results;
        }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:43,代码来源:ApplicationStore.cs

示例11: ComputeBytes

        /// <summary>
        /// Computes the bytes.
        /// </summary>
        /// <param name="accountId">The account identifier.</param>
        /// <param name="applicationName">Name of the application.</param>
        /// <param name="expires">The expires.</param>
        /// <returns>the body of the token.</returns>
        private static byte[] ComputeBytes(
            EmailAddress accountId, 
            DomainLabel applicationName, 
            DateTime expires)
        {
            byte[] encodedAccountId = Encoding.UTF8.GetBytes(accountId.ToString());
            byte[] encodedAppName = Encoding.UTF8.GetBytes(applicationName.ToString());
            byte[] raw = new byte[encodedAccountId.Length + encodedAppName.Length + 2 + SizeOfLong];
            Array.Copy(encodedAccountId, 0, raw, 0, encodedAccountId.Length);
            raw[encodedAccountId.Length] = 0;
            Array.Copy(encodedAppName, 0, raw, encodedAccountId.Length + 1, encodedAppName.Length);
            raw[encodedAccountId.Length + encodedAppName.Length + 1] = 0;
            long expiresBinary = expires.ToBinary();
            for (int i = 0; i < SizeOfLong; i++)
            {
                byte value = unchecked((byte)(expiresBinary >> (8 * i)));
                raw[encodedAccountId.Length + encodedAppName.Length + 2 + i] = value;
            }

            return raw;
        }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:28,代码来源:OAuth2Code.cs

示例12: GetAccountMemberships

        /// <summary>
        /// Gets organization info the account is a member of.
        /// </summary>
        /// <param name="accountId">the account to lookup.</param>
        /// <returns>list of membership info for each organization the member is in.</returns>
        public IEnumerable<AccountMembershipInfo> GetAccountMemberships(
            EmailAddress accountId)
        {
            string accountIdString = accountId.ToString();
            CloudTable accountMemberTable = this.GetAccountMembershipTable();
            TableQuery<AccountMembershipEntity> accountMemberQuery =
                new TableQuery<AccountMembershipEntity>().Where(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, accountIdString));
            List<string> orgNames = new List<string>();
            foreach (AccountMembershipEntity accountMember in accountMemberTable.ExecuteQuery(accountMemberQuery))
            {
                orgNames.Add(accountMember.RowKey);
            }

            CloudTable orgTable = this.GetOrganizationTable();
            CloudTable orgMemberTable = this.GetOrganizationMembershipTable();
            List<AccountMembershipInfo> results = new List<AccountMembershipInfo>();
            foreach (string orgName in orgNames)
            {
                TableOperation getOrgMemberOperation = TableOperation.Retrieve<OrganizationMembershipEntity>(
                    orgName,
                    accountIdString);
                TableResult orgMemberResult = orgMemberTable.Execute(getOrgMemberOperation);
                OrganizationMembershipEntity orgMember = orgMemberResult.Result as OrganizationMembershipEntity;
                if (orgMember == null)
                {
                    continue;
                }

                TableOperation getOrgOperataion = TableOperation.Retrieve<OrganizationEntity>(
                    orgName,
                    string.Empty);
                TableResult orgResult = orgTable.Execute(getOrgOperataion);
                OrganizationEntity org = orgResult.Result as OrganizationEntity;
                if (org == null)
                {
                    continue;
                }

                AccountMembershipInfo info = new AccountMembershipInfo()
                {
                    OrganizationName = DomainLabel.Parse(orgMember.PartitionKey),
                    OrganizationFriendlyName = org.FriendlyName,
                    AllowAdmin = orgMember.AllowAdmin,
                    AllowWrite = orgMember.AllowWrite
                };

                results.Add(info);
            }

            return results;
        }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:57,代码来源:OrganizationStore.cs

示例13: CreateOrganization

        /// <summary>
        /// Creates a new organization.
        /// </summary>
        /// <param name="name">The name of the organization.</param>
        /// <param name="friendlyName">the friendly name.</param>
        /// <param name="accountId">the account creating the organization who will be an admin.</param>
        public void CreateOrganization(
            DomainLabel name,
            string friendlyName,
            EmailAddress accountId)
        {
            if (!ValidateOrganizationName(name))
            {
                throw new ArgumentOutOfRangeException("name");
            }

            if (string.IsNullOrWhiteSpace(friendlyName))
            {
                throw new ArgumentOutOfRangeException("friendlyName");
            }

            if (accountId == null)
            {
                throw new ArgumentNullException("accountId");
            }

            CloudTable orgTable = this.GetOrganizationTable();
            CloudTable orgMemberTable = this.GetOrganizationMembershipTable();
            CloudTable accountMemberTable = this.GetAccountMembershipTable();
            OrganizationEntity existing = FindExistingOrganization(orgTable, name.ToString());
            if (existing != null)
            {
                throw new InvalidOperationException("Organization already exists.");
            }

            AccountMembershipEntity accountMember = new AccountMembershipEntity()
            {
                PartitionKey = accountId.ToString(),
                RowKey = name.ToString()
            };

            OrganizationMembershipEntity orgMember = new OrganizationMembershipEntity()
            {
                PartitionKey = name.ToString(),
                RowKey = accountId.ToString(),
                AllowAdmin = true,
                AllowWrite = true
            };

            OrganizationEntity org = new OrganizationEntity()
            {
                PartitionKey = name.ToString(),
                RowKey = string.Empty,
                FriendlyName = friendlyName,
                CreatedByAccountId = accountId.ToString(),
                CreatedTime = DateTime.UtcNow
            };

            org.LastModifiedByAccountId = org.CreatedByAccountId;
            org.LastModifiedTime = org.CreatedTime;

            TableOperation insertAccountMember = TableOperation.InsertOrReplace(accountMember);
            TableOperation insertOrgMember = TableOperation.InsertOrReplace(orgMember);
            TableOperation insertOrg = TableOperation.InsertOrReplace(org);
            accountMemberTable.Execute(insertAccountMember);
            orgMemberTable.Execute(insertOrgMember);
            orgTable.Execute(insertOrg);
        }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:68,代码来源:OrganizationStore.cs

示例14: GetAccountInfo

        /// <summary>
        /// Gets account info.
        /// </summary>
        /// <param name="accountId">The account to look up.</param>
        /// <returns>info about the account.</returns>
        public AccountInfo GetAccountInfo(EmailAddress accountId)
        {
            CloudTable loginTable = this.GetLoginTable();
            CloudTable accountTable = this.GetAccountTable();
            LoginEntity login = FindExistingLogin(loginTable, accountId);
            if (login == null)
            {
                return null;
            }

            AccountEntity account = FindExistingAccount(accountTable, accountId);
            if (account == null)
            {
                return null;
            }

            return new AccountInfo
            {
                AccountId = accountId,
                ActivatedTime = account.ActivatedTime,
                CreatedTime = account.CreatedTime,
                LastLogin = login.LastLogin,
                Name = !string.IsNullOrEmpty(account.Name) ? account.Name : accountId.ToString(),
                GivenName = account.GivenName,
                FamilyName = account.FamilyName,
                MiddleName = account.MiddleName
            };
        }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:33,代码来源:AccountStore.cs


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