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


C# Contracts.ToString方法代码示例

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


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

示例1: CreateNewGroup

 /// <summary>
 /// Create a new WCS group for given user role
 /// </summary>
 /// <param name="role">WCS user role</param>
 /// <param name="desc">Group description</param>
 internal static DirectoryEntry CreateNewGroup(Contracts.WCSSecurityRole role)
 {
     // Note: No additional try/catch block needed here as it is being invoked
     // from inside a try/catch block.
     DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
     DirectoryEntry newGroup = AD.Children.Add(role.ToString(), "group");
     newGroup.Invoke("Put", new object[] { "Description", "WCS group" });
     newGroup.CommitChanges();
     return newGroup;
 }
开发者ID:silupher,项目名称:ChassisManager,代码行数:15,代码来源:ChassisManagerUtil.cs

示例2: AddChassisControllerUser

        /// <summary>
        /// Method to add chassis controller user
        /// </summary>
        /// <param name="userName">User name</param>
        /// <param name="passwordString">password</param>
        /// <returns>Response indicating if add user was success/failure</returns>
        public Contracts.ChassisResponse AddChassisControllerUser(string userName, string passwordString, Contracts.WCSSecurityRole role)
        {
            Contracts.ChassisResponse response = new Contracts.ChassisResponse();
            response.completionCode = Contracts.CompletionCode.Unknown;
            response.statusDescription = String.Empty;

            Tracer.WriteUserLog("Invoked AddChassisControllerUser(UserName: {0}, role: {1})", userName, role.ToString());
            try
            {
                // password never expires flag.
                int neverExpire = 0x10000;

                // Check if security role is valid
                if (!Enum.IsDefined(typeof(WCSSecurityRole), role))
                {
                    Tracer.WriteError("AddChassisControllerUser: Invalid security role " + role.ToString());
                    response.completionCode = Contracts.CompletionCode.ParameterOutOfRange;
                    response.statusDescription = "Input security role is invalid";
                    return response;
                }

                // Return BadRequest if any data is missing.
                if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(passwordString))
                {
                    Tracer.WriteError("AddChassisControllerUser: Invalid input parameters.");
                    response.completionCode = Contracts.CompletionCode.ParameterOutOfRange;
                    response.statusDescription = "Username or Password is null or empty";
                    return response;
                }

                userName = userName.Trim();
                passwordString = passwordString.Trim();

                if (userName == null || passwordString == null)
                {
                    Tracer.WriteError("AddChassisControllerUser: Invalid input parameters.");

                    response.completionCode = Contracts.CompletionCode.ParameterOutOfRange;
                    response.statusDescription = "Username or Password is null or empty";
                    return response;
                }

                DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
                DirectoryEntry NewUser = AD.Children.Add(userName, "user");

                // create account
                NewUser.Invoke("SetPassword", new object[] { passwordString });
                NewUser.Invoke("Put", new object[] { "Description", "WcsCli chassis manager request" });
                NewUser.CommitChanges();

                // update properteis for password to never expire.
                int userProperties = (int)NewUser.Properties["userFlags"].Value;
                NewUser.Properties["userFlags"].Value = userProperties | neverExpire;
                NewUser.CommitChanges();

                DirectoryEntry grp;
                // Find group, if not exists, create
                grp = ChassisManagerUtil.FindGroupIfNotExistsCreate(role);

                if (grp != null)
                {
                    grp.Invoke("Add", new object[] { NewUser.Path.ToString() });

                    Tracer.WriteInfo("AddChassisControllerUser: User Account Created Successfully");
                    response.completionCode = Contracts.CompletionCode.Success;
                }
                else
                {
                    Tracer.WriteInfo("AddChassisControllerUser: Failed to create account, failed to add user to group");
                    response.completionCode = Contracts.CompletionCode.Failure;
                    response.statusDescription = String.Format("AddChassisControllerUser: Failed to create account, failed to add user to group");
                }

                return response;
            }
            catch (Exception ex)
            {
                Tracer.WriteError("AddChassisControllerUser: failed with exception: " + ex);

                // check if password did not meet the requirements, display appropriate message to user.
                if (ex.ToString().Contains("0x800708C5") || ex.ToString().Contains("password does not meet"))
                {
                    response.completionCode = Contracts.CompletionCode.UserPasswordDoesNotMeetRequirement;
                    response.statusDescription = "User password does not meet requirement";
                }
                else if (ex.ToString().Contains("0x800708B0"))
                {
                    response.completionCode = Contracts.CompletionCode.UserAccountExists;
                    response.statusDescription = "User account already exists";
                }
                else
                {
                    response.completionCode = Contracts.CompletionCode.Failure;
                    response.statusDescription = String.Format("AddChassisControllerUser failed. Unknown Error.");
//.........这里部分代码省略.........
开发者ID:rockyshek,项目名称:ocs-source-code-and-operations-toolkit-for-open-cloudserver,代码行数:101,代码来源:ChassisManager.cs

示例3: Keywords

        /// <summary>
        /// Gets the root keyword for the given <see cref="P:taxonomyUri" />
        /// </summary>
        /// <param name="taxonomyUri">Taxonomy <see cref="T:TcmCDService.Tridion.TcmUri" /></param>
        /// <param name="taxonomyFilter"><see cref="T:TcmCDService.Contracts.TaxonomyFilter" /> to apply.</param>
        /// <returns>
        ///   <see cref="T:TcmCDService.Contracts.Keyword" />
        /// </returns>
        public Contracts.Keyword Keywords(String taxonomyUri, Contracts.TaxonomyFilter taxonomyFilter, Contracts.TaxonomyFormatter taxonomyFormatter)
        {
            Logger.Debug("Keywords: taxonomyUri \"{0}\", taxonomyFilter \"{1}\".", taxonomyUri, taxonomyFilter != null ? "<Object>" : String.Empty);

            return Cache.Get<Contracts.Keyword>(
                String.Format("Keywords-{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}",
                taxonomyUri,
                taxonomyFilter != null ? taxonomyFilter.DepthFilteringDirection.ToString() : String.Empty,
                taxonomyFilter != null ? taxonomyFilter.DepthFilteringLevel.ToString() : String.Empty,
                taxonomyFilter != null ? taxonomyFilter.FilterAbstract.ToString() : String.Empty,
                taxonomyFilter != null ? taxonomyFilter.FilterConcrete.ToString() : String.Empty,
                taxonomyFilter != null ? taxonomyFilter.FilterHasChildren.ToString() : String.Empty,
                taxonomyFilter != null ? taxonomyFilter.FilterNavigable.ToString() : String.Empty,
                taxonomyFormatter.ToString()),
                () =>
                {
                    using (Keyword keyword = ContentDelivery.Taxonomies.KeywordCache.GetKeywords(taxonomyUri, taxonomyFilter, taxonomyFormatter))
                    {
                        return keyword.ToContract();
                    }
                },
                CacheRegion.Taxonomy | CacheRegion.TanonomyKeywordCount | CacheRegion.TanonomyKeywordRelations,
                taxonomyUri);
        }
开发者ID:TcmExtensions,项目名称:TcmCDService,代码行数:32,代码来源:Service.cs


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