예제 #1
0
        public void Execute(IResponseWriter writer, string[] arguments)
        {
            if (arguments.Length != 2)
            {
                writer.Write("error|The handler needs the full path to the reference. " +
                             "Usage: dereference {assembly/project} {project to remove reference from}");
                return;
            }

            var   fullpath = getFile(arguments[0]);
            IFile file;

            if (new VSProjectFile().SupportsExtension(fullpath))
            {
                file = new VSProjectFile().New(fullpath);
            }
            else
            {
                file = new AssemblyFile().New(fullpath);
            }
            var projectFile = getFile(arguments[1]);

            if (!File.Exists(projectFile))
            {
                writer.Write("error|The project to remove this reference for does not exist. " +
                             "Usage: dereference {assembly/project} {project to remove reference from}");
                return;
            }

            if (!_project.Read(projectFile, _getTypesProviderByLocation))
            {
                return;
            }
            _project.Dereference(file);
            _project.Write();

            writer.Write("comment|Rereferenced {0} from {1}", file, projectFile);
        }
예제 #2
0
        public void Execute(IResponseWriter writer, string[] arguments)
        {
            if (arguments.Length != 2)
            {
                writer.Write("error|The handler needs the full path to the reference. " +
                             "Usage: reference {assembly/project} {project to add reference to");
                return;
            }

            var   fullpath = getFile(arguments[0]);
            IFile file;

            if (new VSProjectFile().SupportsExtension(fullpath))
            {
                file = new VSProjectFile().New(fullpath);
            }
            else
            {
                file = new AssemblyFile().New(fullpath);
            }
            var projectFile = getFile(arguments[1]);

            if (!File.Exists(projectFile))
            {
                writer.Write("error|The project to add this reference to does not exist. " +
                             "Usage: reference {assembly/project} {project to add reference to");
                return;
            }

            if (!_project.Read(projectFile, _provider))
            {
                return;
            }
            _project.Reference(file);
            _project.Write();

            writer.Write("comment|Added reference {0} to {1}", file, projectFile);
        }