YAXLib.StringUtils.DivideLocationOneStep C# (CSharp) Method

DivideLocationOneStep() public static method

Divides the location string one step, to form a shorter location string.
public static DivideLocationOneStep ( string location, string &newLocation, string &newElem ) : bool
location string The location string to divide.
newLocation string The new location string which is one level shorter.
newElem string The element name removed from the end of location string.
return bool
        public static bool DivideLocationOneStep(string location, out string newLocation, out string newElem)
        {
            newLocation = location;
            newElem = null;

            int slashIdx = location.LastIndexOf('/');
            if (slashIdx < 0) // no slashes found
            {
                if (IsLocationAllGeneric(location))
                {
                    return false;
                }
                else
                {
                    newElem = location;
                    newLocation = ".";
                    return true;
                }
            }
            else // some slashes found
            {
                string preSlash = location.Substring(0, slashIdx);
                string postSlash = location.Substring(slashIdx + 1);

                if (IsLocationAllGeneric(postSlash))
                {
                    return false;
                }
                else
                {
                    newLocation = preSlash;
                    newElem = postSlash;
                    return true;
                }
            }
        }