Exemplo n.º 1
0
        /// <summary>
        /// Adds a file to this folder and returns it. If the file already exists, it is returned.
        /// </summary>
        /// <param name="folderName"></param>
        /// <returns></returns>
        internal FileWalker GetFileOrCreateIfNotExists(string fileName, object userState, bool raiseExceptionIfFileAlreadyExists = false)
        {
            if (!_fileNameToFile.ContainsKey(fileName))
            {
                FileWalker file = new FileWalker(fileName, Path.Combine(_fullPath, fileName), userState);
                _fileNameToFile.Add(fileName, file);
                return(file);
            }
            else
            {
                if (raiseExceptionIfFileAlreadyExists)
                {
                    throw new Exception(string.Format("A file with the name '{0}' already exists.", fileName));
                }

                return(_fileNameToFile[fileName]);
            }
        }
Exemplo n.º 2
0
 public ProjectItemWrapper(Microsoft.Build.Evaluation.ProjectItem projectItemLoadedWithMsBuild, FileWalker fileWalker)
 {
     _projectItemInCaseOfProjectLoadedWithMsBuild = projectItemLoadedWithMsBuild;
     _fileWalkerInCaseOfProjectLoadedWithMsBuild  = fileWalker;
 }