Beispiel #1
0
        public void Execute(IResponseWriter writer, string[] arguments)
        {
            if (arguments.Length < 2)
            {
                writer.Write("error|Invalid number of arguments. " +
                             "Usage: new {template name} {item name} {template arguments}");
                return;
            }

            var className = getFileName(arguments[1]);
            var location  = getLocation(arguments[1]);

            if (!_project.Read(location, _getTypesProviderByLocation))
            {
                return;
            }

            var template = _pickTemplate(arguments[0], _project.Type);

            if (template == null)
            {
                writer.Write("error|No template with the name {0} exists.", arguments[0]);
                return;
            }
            var ns = getNamespace(location, _project.Fullpath, _project.DefaultNamespace);

            template.Run(location, className, ns, _project.Fullpath, _project.Type, getArguments(arguments));
            if (template.File == null)
            {
                return;
            }

            _project.AppendFile(template.File);
            _project.Write();

            writer.Write("comment|Created class {0}.{1}", ns, className);
            writer.Write("comment|Full path {0}", template.File.Fullpath);

            gotoFile(writer, template.File.Fullpath, template.Line, template.Column, location);
        }
        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);
        }
        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);
        }