public static NodeInfo AddNode(ICommonStructureService commonStructureService, string elementPath, string projectName, eStructureType nodeType)
        {
            NodeInfo retVal;
            string rootNodePath = "\\" + projectName + "\\" + nodeType.ToString();

            if (CheckIfPathAlreadyExists(commonStructureService, elementPath, rootNodePath))
            {
                return null;
            }

            int backSlashIndex = GetBackSlashIndex(elementPath);
            string newpathname = GetNewPathName(elementPath, backSlashIndex);
            string path = GetActualNodePath(elementPath, backSlashIndex);
            string pathRoot = rootNodePath + path;
            NodeInfo previousPath = GetPreviousPath(commonStructureService, pathRoot);

            if (previousPath == null)
            {
                // call this method to create the parent paths.
                previousPath = AddNode(commonStructureService, path, projectName, nodeType);
            }

            string newPathUri = commonStructureService.CreateNode(newpathname, previousPath.Uri);
            return commonStructureService.GetNode(newPathUri);
        }
예제 #2
0
        public static NodeInfo AddNode(ICommonStructureService commonStructureService, string elementPath, string projectName, eStructureType nodeType)
        {
            NodeInfo retVal;
            string   rootNodePath = "\\" + projectName + "\\" + nodeType.ToString();

            if (CheckIfPathAlreadyExists(commonStructureService, elementPath, rootNodePath))
            {
                return(null);
            }

            int      backSlashIndex = GetBackSlashIndex(elementPath);
            string   newpathname    = GetNewPathName(elementPath, backSlashIndex);
            string   path           = GetActualNodePath(elementPath, backSlashIndex);
            string   pathRoot       = rootNodePath + path;
            NodeInfo previousPath   = GetPreviousPath(commonStructureService, pathRoot);

            if (previousPath == null)
            {
                // call this method to create the parent paths.
                previousPath = AddNode(commonStructureService, path, projectName, nodeType);
            }

            string newPathUri = commonStructureService.CreateNode(newpathname, previousPath.Uri);

            return(commonStructureService.GetNode(newPathUri));
        }