Microsoft.WindowsAzure.Commands.Utilities.Common.CommonUtilities.GetRoleName C# (CSharp) Method

GetRoleName() public static method

Gets role name for the current pathif exists.
public static GetRoleName ( string rootPath, string currentPath ) : string
rootPath string
currentPath string
return string
        public static string GetRoleName(string rootPath, string currentPath)
        {
            bool found = false;
            string roleName = null;

            if (!(rootPath.Length >= currentPath.Length))
            {
                string difference = currentPath.Replace(rootPath, string.Empty);
                roleName = difference.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries).GetValue(0).ToString();
                CloudServiceProject service = new CloudServiceProject(rootPath, null);
                found = service.Components.RoleExists(roleName);
            }

            if (!found)
            {
                throw new ArgumentException(string.Format(Resources.CannotFindRole, currentPath));
            }

            return roleName;
        }