/// <summary>
        /// Translates the specified from.
        /// </summary>
        /// <param name="from">From.</param>
        /// <returns></returns>
        public CustomRenderers Translate(string from)
        {
            TraceService.WriteLine("CustomRenderers::Translate " + from);

            CustomRenderers customRenderers = new CustomRenderers();

            try
            {
                XDocument doc = XDocument.Load(@from);

                if (doc.Root != null)
                {
                    TraceService.WriteDebugLine(doc.Root.Value);

                    customRenderers.HelpLink = this.GetHelpLink(doc.Root);
                    customRenderers.Groups   = this.GetGroups(doc.Root);
                }
            }
            catch (Exception exception)
            {
                TraceService.WriteError(exception);
            }

            return(customRenderers);
        }
Esempio n. 2
0
        /// <summary>
        /// Setups the event handlers.
        /// </summary>
        internal void SetupEventHandlers()
        {
            TraceService.WriteLine("NugetService::SetupEventHandlers");

            this.documentEvents = this.visualStudioService.DTEService.GetDocumentEvents();
            this.documentEvents.DocumentOpened += this.DocumentEventsDocumentOpened;
        }
Esempio n. 3
0
        /// <summary>
        /// Executes the post nuget commands.
        /// </summary>
        internal void ExecutePostNugetCommands()
        {
            TraceService.WriteLine("NugetService::ExecutePostNugetCommands");

            IEnumerable <StudioCommand> postNugetCommands = this.cachingService.PostNugetCommands;

            if (postNugetCommands != null)
            {
                foreach (StudioCommand postNugetCommand in postNugetCommands)
                {
                    TraceService.WriteLine("Platform=" + postNugetCommand.PlatForm);
                    TraceService.WriteLine("CommandType=" + postNugetCommand.CommandType);
                    TraceService.WriteLine("Platform=" + postNugetCommand.PlatForm);
                    TraceService.WriteLine("Name=" + postNugetCommand.Name);

                    IProjectService projectService = this.visualStudioService.GetProjectServiceBySuffix(postNugetCommand.PlatForm);

                    if (projectService != null)
                    {
                        switch (postNugetCommand.CommandType)
                        {
                        case "RemoveFolder":
                            projectService.RemoveFolder(postNugetCommand.Name);
                            break;

                        case "RemoveFile":
                            projectService.RemoveFolderItem(postNugetCommand.Name);
                            break;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Removes the folder.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="folderName">Name of the folder.</param>
        public static ProjectItem RemoveFolder(
            this Project instance,
            string folderName)
        {
            TraceService.WriteLine("ProjectExtensions::RemoveFolder project=" + instance.Name);

            ProjectItem removedProjectItem = null;

            IEnumerable <ProjectItem> projectItems = instance.GetProjectItems();

            if (projectItems != null)
            {
                foreach (ProjectItem projectItem in projectItems)
                {
                    if (projectItem.Kind == VSConstants.VsProjectItemKindPhysicalFolder)
                    {
                        if (projectItem.Name.ToLower() == folderName.ToLower())
                        {
                            removedProjectItem = projectItem;
                            projectItem.Remove();
                            break;
                        }
                    }
                }
            }

            return(removedProjectItem);
        }
Esempio n. 5
0
        /// <summary>
        /// Adds the command bar.
        /// </summary>
        /// <param name="commandName">Name of the command.</param>
        /// <returns>The command bar.</returns>
        public CommandBar AddCommandBar(string commandName)
        {
            TraceService.WriteLine("CommandManager::AddCommandBar commandName=" + commandName);

            Commands2       commands       = (Commands2)this.VSInstance.ApplicationObject.Commands;
            CommandBarPopup toolsMenuPopUp = this.VSInstance.ApplicationObject.GetToolsMenuPopUp();

            CommandBar commandBar = null;

            for (int i = 1; i <= toolsMenuPopUp.CommandBar.Controls.Count; i++)
            {
                if (toolsMenuPopUp.CommandBar.Controls[i].Caption == commandName)
                {
                    TraceService.WriteLine("CommandManager::AddCommandBar commandFound in collection");
                    CommandBarPopup commandBarPopup = (CommandBarPopup)toolsMenuPopUp.CommandBar.Controls[i];

                    commandBar = commandBarPopup.CommandBar;
                    break;
                }
            }

            if (commandBar == null)
            {
                TraceService.WriteLine("CommandManager::AddCommandBar creating command");
                return((CommandBar)commands.AddCommandBar(commandName, vsCommandBarType.vsCommandBarTypeMenu, toolsMenuPopUp.CommandBar));
            }

            return(commandBar);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseController" /> class.
        /// </summary>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="settingsService">The settings service.</param>
        /// <param name="messageBoxService">The message box service.</param>
        /// <param name="resolverService">The resolver service.</param>
        /// <param name="readMeService">The read me service.</param>
        protected BaseController(
            IVisualStudioService visualStudioService,
            ISettingsService settingsService,
            IMessageBoxService messageBoxService,
            IResolverService resolverService,
            IReadMeService readMeService)
        {
            //// init the tracing service first!
            TraceService.Initialize(
                settingsService.LogToTrace,
                false, //// log to console.
                settingsService.LogToFile,
                settingsService.ExtendedLogging,
                settingsService.LogFilePath,
                settingsService.DisplayErrors,
                settingsService.ErrorFilePath);

            TraceService.WriteLine("BaseController::Constructor");

            this.VisualStudioService = visualStudioService;
            this.SettingsService     = settingsService;
            this.MessageBoxService   = messageBoxService;
            this.ResolverService     = resolverService;
            this.ReadMeService       = readMeService;
        }
Esempio n. 7
0
        /// <summary>
        /// Queries the status.
        /// </summary>
        /// <param name="commandName">ProjectName of the command.</param>
        /// <param name="neededText">The needed text.</param>
        /// <param name="status">The status option.</param>
        /// <param name="commandText">The command text.</param>
        public void QueryStatus(
            string commandName,
            vsCommandStatusTextWanted neededText,
            ref vsCommandStatus status,
            ref object commandText)
        {
            try
            {
                if (neededText != vsCommandStatusTextWanted.vsCommandStatusTextWantedNone)
                {
                    return;
                }

                if (this.commandInfos.Any(vsCommandInfo => vsCommandInfo.Command.Name == commandName))
                {
                    status = vsCommandStatus.vsCommandStatusSupported |
                             vsCommandStatus.vsCommandStatusEnabled;
                }
            }
            catch (Exception exception)
            {
                string message = string.Format("commandName={0} exceptionMessage={1}", commandName, exception.Message);
                TraceService.WriteLine("CommandManager::QueryStatus " + message);
            }
        }
        /// <summary>
        /// Gets the first class.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns>The first class.</returns>
        public static CodeClass GetFirstClass(this ProjectItem instance)
        {
            TraceService.WriteLine("ProjectItemExtensions::GetFirstClass file=" + instance.Name);

            IEnumerable <CodeClass> codeClasses = instance.FileCodeModel.CodeElements.OfType <CodeClass>();

            if (!codeClasses.Any())
            {
                CodeNamespace codeNamespace = instance.GetFirstNameSpace();

                if (codeNamespace != null)
                {
                    foreach (CodeElement codeElement in codeNamespace.Children)
                    {
                        if (codeElement.Kind == vsCMElement.vsCMElementClass)
                        {
                            return(codeElement as CodeClass);
                        }
                    }
                }
                else
                {
                    TraceService.WriteError("ProjectItemExtensions::GetFirstClass cannot find namespace");
                }
            }
            else
            {
                return(codeClasses.FirstOrDefault());
            }

            return(null);
        }
Esempio n. 9
0
        /// <summary>
        /// Inits this instance.
        /// </summary>
        internal void Init()
        {
            TraceService.WriteLine("BuildOptionsViewModel::Init");

            this.SelectedWindowsPhoneVersion = this.settingsService.WindowsPhoneBuildVersion;

            this.TestingFrameworks = this.testingServiceFactory.FrameWorks;
            this.MockingFrameworks = this.mockingServiceFactory.FrameWorks;

            this.SelectedTestingFramework = this.testingServiceFactory.CurrentFrameWork;
            this.SelectedMockingFramework = this.mockingServiceFactory.CurrentFrameWork;

            this.UsePreReleaseMvvmCrossNugetPackages    = this.settingsService.UsePreReleaseMvvmCrossNugetPackages;
            this.UsePreReleaseXamarinFormsNugetPackages = this.settingsService.UsePreReleaseXamarinFormsNugetPackages;
            this.UsePreReleaseNinjaCoderNugetPackages   = this.settingsService.UsePreReleaseNinjaNugetPackages;

            if (this.usePreReleaseMvvmCrossNugetPackages ||
                this.usePreReleaseNinjaCoderNugetPackages ||
                this.usePreReleaseXamarinFormsNugetPackages)
            {
                this.ExpandPreReleaseOptions = true;
            }

            this.CreatePlatformTestProjects = this.settingsService.CreatePlatformTestProjects;
            this.UseXamarinTestCloud        = this.settingsService.UseXamarinTestCloud;
            this.UseXamarinInsights         = this.settingsService.UseXamarinInsights;
            this.UseStyleCop = this.settingsService.UseStyleCop;
        }
Esempio n. 10
0
        /// <summary>
        /// Replaces the text.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="findText">The find text.</param>
        /// <param name="replaceText">The replace text.</param>
        /// <param name="saveFiles">if set to <c>true</c> [save files].</param>
        /// <returns>True or false.</returns>
        public static bool ReplaceText(
            this DTE2 instance,
            string findText,
            string replaceText,
            bool saveFiles)
        {
            TraceService.WriteLine("DTEExtensions::ReplaceText from '" + findText + "' to '" + replaceText + "'");

            bool replaced = true;

            Find2 find2 = (Find2)instance.Find;

            vsFindResult findResults = find2.FindReplace(
                vsFindAction.vsFindActionReplaceAll,
                findText,
                (int)vsFindOptions.vsFindOptionsFromStart,
                replaceText,
                vsFindTarget.vsFindTargetSolution,
                string.Empty,
                string.Empty,
                vsFindResultsLocation.vsFindResultsNone);

            if (findResults == vsFindResult.vsFindResultNotFound)
            {
                replaced = false;
                TraceService.WriteError("Unable to replace text from:-" + findText + " to:- " + replaceText);
            }

            if (saveFiles)
            {
                instance.SaveAll();
            }

            return(replaced);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectsController" /> class.
        /// </summary>
        /// <param name="projectsService">The projects service.</param>
        /// <param name="nugetService">The nuget service.</param>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="settingsService">The settings service.</param>
        /// <param name="messageBoxService">The message box service.</param>
        /// <param name="resolverService">The resolver service.</param>
        /// <param name="viewModelViewsService">The view model views service.</param>
        /// <param name="readMeService">The read me service.</param>
        /// <param name="projectFactory">The project factory.</param>
        /// <param name="applicationService">The application service.</param>
        /// <param name="cachingService">The caching service.</param>
        public ProjectsController(
            IProjectsService projectsService,
            INugetService nugetService,
            IVisualStudioService visualStudioService,
            ISettingsService settingsService,
            IMessageBoxService messageBoxService,
            IResolverService resolverService,
            IViewModelViewsService viewModelViewsService,
            IReadMeService readMeService,
            IProjectFactory projectFactory,
            IApplicationService applicationService,
            ICachingService cachingService)
            : base(visualStudioService, settingsService, messageBoxService, resolverService, readMeService)
        {
            TraceService.WriteLine("ProjectsController::Constructor");

            this.projectsService       = projectsService;
            this.nugetService          = nugetService;
            this.viewModelViewsService = viewModelViewsService;
            this.projectFactory        = projectFactory;
            this.applicationService    = applicationService;
            this.cachingService        = cachingService;

            this.commands                = string.Empty;
            this.postNugetCommands       = new List <StudioCommand>();
            this.postNugetFileOperations = new List <FileOperation>();

            this.messages = new List <string>();
        }
        /// <summary>
        /// Gets the folder project items.
        /// </summary>
        /// <param name="instance">The instance.</param>
        public static IEnumerable <ProjectItem> GetFolderProjectItems(this Project instance)
        {
            TraceService.WriteLine("ProjectExtensions::GetFolderProjectItems");

            return(instance.ProjectItems.Cast <ProjectItem>()
                   .Where(x => x.Kind == VSConstants.VsProjectItemKindPhysicalFolder));
        }
Esempio n. 13
0
        /// <summary>
        /// Implements the mock variable.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="name">The name.</param>
        /// <param name="type">The type.</param>
        /// <returns>The code variable.</returns>
        public static CodeVariable ImplementMockVariable(
            this CodeClass instance,
            string name,
            string type)
        {
            TraceService.WriteLine("CodeClassExtensions::ImplementMockVariable file=" + instance.Name);

            CodeVariable codeVariable = instance.AddVariable(name, type, 0, vsCMAccess.vsCMAccessPrivate, 0);

            string typeDescriptor = name.Substring(4, 1).ToUpper() + name.Substring(5);

            codeVariable.DocComment = "<doc><summary>\r\nMock " + typeDescriptor + ".\r\n</summary></doc>";


            EditPoint startPoint = codeVariable.StartPoint.CreateEditPoint();
            EditPoint endPoint   = codeVariable.EndPoint.CreateEditPoint();

            string text    = startPoint.GetText(endPoint);
            string newText = text.Replace(type, "Mock<" + type + ">");

            startPoint.ReplaceText(endPoint, newText, 0);

            // get the new endpoint before inserting new line.
            endPoint = codeVariable.EndPoint.CreateEditPoint();
            endPoint.InsertNewLine();

            return(codeVariable);
        }
Esempio n. 14
0
        /// <summary>
        /// Implements the variable.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="name">The name.</param>
        /// <param name="type">The type.</param>
        /// <param name="isReadOnly">if set to <c>true</c> [is read only].</param>
        /// <returns>The Code Variable. </returns>
        public static CodeVariable ImplementVariable(
            this CodeClass instance,
            string name,
            string type,
            bool isReadOnly)
        {
            TraceService.WriteLine("CodeClassExtensions::ImplementVariable name=" + name + " type=" + type);

            CodeVariable codeVariable = instance.AddVariable(name, type, 0, vsCMAccess.vsCMAccessPrivate, 0);

            codeVariable.DocComment = "<doc><summary>\r\nBacking field for " + name + ".\r\n</summary></doc>";
            codeVariable.GetEndPoint().CreateEditPoint().InsertNewLine();

            if (isReadOnly)
            {
                CodeVariable2 codeVariable2 = codeVariable as CodeVariable2;

                if (codeVariable2 != null)
                {
                    codeVariable2.ConstKind = vsCMConstKind.vsCMConstKindReadOnly;
                }
            }

            return(codeVariable);
        }
Esempio n. 15
0
        /// <summary>
        /// Gets the MVVM cross tests commands.
        /// </summary>
        /// <returns>A list of Nuget commands.</returns>
        public IEnumerable <string> GetMvvmCrossTestsCommands()
        {
            TraceService.WriteLine("NugetCommandsService::GetMvvmCrossTestsCommands");

            string testingFrameworkNugetPackage = ScorchioMvvmCrossMsTestTests;

            switch (this.settingsService.TestingFramework)
            {
            case TestingConstants.NUnit.Name:
                testingFrameworkNugetPackage = ScorchioMvvmCrossNUnitTests;
                break;

            case TestingConstants.XUnit.Name:
                testingFrameworkNugetPackage = ScorchioMvvmCrossXUnitTests;
                break;
            }

            List <string> commands = new List <string>
            {
                this.GetMvvmCrossCommand(MvvmCrossCore),
                this.GetMvvmCrossCommand(MvvmCrossTests),
                this.GetNinjaCommand(testingFrameworkNugetPackage, false),
            };

            IEnumerable <string> testCommands = this.GetTestCommands();

            commands.AddRange(testCommands);

            return(commands);
        }
        /// <summary>
        /// Processes the specified form.
        /// </summary>
        /// <param name="effectViewModel">The effect view model.</param>
        internal void Process(EffectViewModel effectViewModel)
        {
            TraceService.WriteLine("EffectsController::Process");

            this.VisualStudioService.WriteStatusBarMessage(NinjaMessages.NinjaIsRunning);

            try
            {
                TraceService.WriteLine("EffectsController::Process GetTextTemplates");

                IEnumerable <TextTemplateInfo> textTemplates = this.effectFactory.GetTextTemplates(
                    effectViewModel.RequestedName,
                    this.SettingsService.EffectDirectory);

                IEnumerable <string> messages = this.textTemplatingService.AddTextTemplates(
                    NinjaMessages.AddingEffect,
                    textTemplates);

                //// show the readme.
                this.ShowReadMe("Add Xamarin Forms Effect", messages);
            }
            catch (Exception exception)
            {
                TraceService.WriteError("Cannot create effect exception=" + exception.Message);
            }
        }
        /// <summary>
        /// Projects the item added.
        /// </summary>
        /// <param name="projectItemService">The project item service.</param>
        internal void ProjectItemAdded(IProjectItemService projectItemService)
        {
            TraceService.WriteLine("BaseController::ProjectItemAdded");

            bool saveFile = false;

            if (projectItemService.IsCSharpFile())
            {
                if (this.SettingsService.RemoveDefaultComments)
                {
                    projectItemService.RemoveComments();
                    saveFile = true;
                }

                if (this.SettingsService.RemoveDefaultFileHeaders)
                {
                    projectItemService.RemoveHeader();
                    saveFile = true;
                }
            }

            if (saveFile)
            {
                this.VisualStudioService.DTEService.SaveAll();
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Gets the constructors.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns>The constructors.</returns>
        public static IEnumerable <CodeFunction> GetConstructors(this CodeClass instance)
        {
            TraceService.WriteLine("CodeClassExtensions::GetConstructors file=" + instance.Name);

            return(instance.Members.OfType <CodeFunction>()
                   .Where(x => x.FunctionKind == vsCMFunction.vsCMFunctionConstructor));
        }
Esempio n. 19
0
        /// <summary>
        /// Gets the projects.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns>The projects.</returns>
        public static IEnumerable <Project> GetProjects(this Solution2 instance)
        {
            TraceService.WriteLine("SolutionExtensions::GetProjects");

            List <Project> projects = instance.Projects.Cast <Project>().ToList();

            List <Project> allProjects = new List <Project>(projects);

            foreach (Project project in projects)
            {
                IEnumerable <ProjectItem> projectItems = project.GetProjectItems();

                if (projectItems != null)
                {
                    foreach (ProjectItem projectItem in projectItems)
                    {
                        if (projectItem.Kind == VSConstants.VsProjectItemKindSolutionItems)
                        {
                            if (projectItem.SubProject != null)
                            {
                                allProjects.Add(projectItem.SubProject);
                            }
                        }
                    }
                }
            }

            return(allProjects);
        }
Esempio n. 20
0
        /// <summary>
        /// Implements the mock variable.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="name">The name.</param>
        /// <param name="type">The type.</param>
        /// <param name="mockVariableDeclaration">The mock variable declaration.</param>
        /// <returns>The code variable.</returns>
        public static CodeVariable ImplementMockVariable(
            this CodeClass instance,
            string name,
            string type,
            string mockVariableDeclaration)
        {
            TraceService.WriteLine("CodeClassExtensions::ImplementMockVariable file=" + instance.Name);

            CodeVariable codeVariable = instance.AddVariable(name, type, 0, vsCMAccess.vsCMAccessPrivate, 0);

            string typeDescriptor = name.Substring(4, 1).ToUpper() + name.Substring(5);

            codeVariable.DocComment = "<doc><summary>\r\nMock " + typeDescriptor + ".\r\n</summary></doc>";

            EditPoint startPoint = codeVariable.StartPoint.CreateEditPoint();
            EditPoint endPoint   = codeVariable.EndPoint.CreateEditPoint();

            //// if we are Moq then we change the variable declaration.
            if (string.IsNullOrEmpty(mockVariableDeclaration) == false)
            {
                string substitution = mockVariableDeclaration.Replace("%TYPE%", type);

                string text    = startPoint.GetText(endPoint);
                string newText = text.Replace("private " + type, "private " + substitution);
                startPoint.ReplaceText(endPoint, newText, 0);
            }

            // get the new endpoint before inserting new line.
            endPoint = codeVariable.EndPoint.CreateEditPoint();
            endPoint.InsertNewLine();

            return(codeVariable);
        }
Esempio n. 21
0
        /// <summary>
        /// Deletes the command.
        /// </summary>
        /// <param name="commandName">Name of the command.</param>
        protected void DeleteCommand(string commandName)
        {
            TraceService.WriteLine("CommandManager::DeleteCommand commandName=" + commandName);

            try
            {
                Commands2       commands       = (Commands2)this.VsInstance.ApplicationObject.Commands;
                CommandBarPopup toolsMenuPopUp = this.VsInstance.ApplicationObject.GetToolsMenuPopUp();

                CommandBar commandBar = null;

                for (int i = 1; i <= toolsMenuPopUp.CommandBar.Controls.Count; i++)
                {
                    if (toolsMenuPopUp.CommandBar.Controls[i].Caption == commandName)
                    {
                        TraceService.WriteLine("CommandManager::DeleteCommand commandFound in collection commandName=" + commandName);
                        CommandBarPopup commandBarPopup = (CommandBarPopup)toolsMenuPopUp.CommandBar.Controls[i];

                        commandBar = commandBarPopup.CommandBar;
                        break;
                    }
                }

                if (commandBar != null)
                {
                    TraceService.WriteLine("Command found and will be deleted ommandName=" + commandName);
                    commandBar.Delete();
                }
            }
            catch (Exception exception)
            {
                TraceService.WriteError("exception=" + exception.Message);
                TraceService.WriteError("stackTrace=" + exception.StackTrace);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PluginsViewModel" /> class.
        /// </summary>
        /// <param name="settingsService">The settings service.</param>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="pluginFactory">The plugin factory.</param>
        public PluginsViewModel(
            ISettingsService settingsService,
            IVisualStudioService visualStudioService,
            IPluginFactory pluginFactory)
            : base(settingsService)
        {
            TraceService.WriteLine("PluginsViewModel::Constructor Start");

            this.settingsService     = settingsService;
            this.visualStudioService = visualStudioService;

            Plugins allPlugins = pluginFactory.GetPlugins(this.settingsService.MvvmCrossPluginsUri);

            this.corePlugins      = this.GetPlugins(allPlugins, false);
            this.communityPlugins = this.GetPlugins(allPlugins, true);

            if (this.corePlugins.Any() == false &&
                this.communityPlugins.Any())
            {
                this.CommunityPluginsSelected = true;
            }
            else
            {
                this.CorePluginsSelected = true;
            }

            TraceService.WriteLine("PluginsViewModel::Constructor End");
        }
        /// <summary>
        /// Gets the project item.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <returns>The project item.</returns>
        public static ProjectItem GetProjectItem(
            this Project instance,
            string fileName)
        {
            TraceService.WriteLine("ProjectExtensions::GetProjectItem project=" + instance.Name + " fileName=" + fileName);

            ProjectItem projectItem = instance.GetCSharpProjectItems().FirstOrDefault(x => x.Name.StartsWith(fileName));

            //// try all the sub-folders!
            if (projectItem == null)
            {
                IEnumerable <ProjectItem> projectItems = instance.GetProjectItems();

                foreach (ProjectItem item in projectItems)
                {
                    if (item.Name.StartsWith(fileName))
                    {
                        return(item);
                    }

                    IEnumerable <ProjectItem> subProjectItems = item.GetSubProjectItems();

                    foreach (ProjectItem subItem in subProjectItems.Where(subItem => subItem.Name.StartsWith(fileName)))
                    {
                        return(subItem);
                    }
                }
            }

            return(projectItem);
        }
        /// <summary>
        /// Processes the command.
        /// </summary>
        /// <param name="fileOperation">The file operation.</param>
        public void ProcessCommand(FileOperation fileOperation)
        {
            TraceService.WriteLine("FileOperationService::ProcessCommand");

            TraceService.WriteDebugLine("Platform=" + fileOperation.PlatForm);
            TraceService.WriteDebugLine("CommandType=" + fileOperation.CommandType);
            TraceService.WriteDebugLine("Directory=" + fileOperation.Directory);
            TraceService.WriteDebugLine("File=" + fileOperation.File);
            TraceService.WriteDebugLine("From=" + fileOperation.From);
            TraceService.WriteDebugLine("To=" + fileOperation.To);

            IProjectService projectService = this.visualStudioService.GetProjectServiceBySuffix(fileOperation.PlatForm);

            if (projectService != null)
            {
                IEnumerable <IProjectItemService> fileItemServices = this.GetFileItems(fileOperation, projectService);

                foreach (IProjectItemService projectItemService in fileItemServices)
                {
                    if (fileOperation.CommandType == "ReplaceText")
                    {
                        this.ReplaceText(fileOperation, projectService, projectItemService);
                    }
                    else if (fileOperation.CommandType == "Properties")
                    {
                        this.UpdateProperty(fileOperation, projectItemService);
                    }
                }
            }
            else
            {
                TraceService.WriteLine("Platform " + fileOperation.PlatForm + " not found");
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Execs the specified command name.
        /// </summary>
        /// <param name="commandName">ProjectName of the command.</param>
        /// <param name="executeOption">The execute option.</param>
        /// <param name="variantIn">The variant in.</param>
        /// <param name="variantOut">The variant out.</param>
        /// <param name="handled">if set to <c>true</c> [handled].</param>
        public void Exec(
            string commandName,
            vsCommandExecOption executeOption,
            ref object variantIn,
            ref object variantOut,
            ref bool handled)
        {
            TraceService.WriteLine("CommandManager::Exec commandName=" + commandName);

            if (executeOption != vsCommandExecOption.vsCommandExecOptionDoDefault)
            {
                return;
            }

            foreach (VSCommandInfo vsCommandInfo in this.commandInfos
                     .Where(vsCommandInfo => vsCommandInfo.Command.Name == commandName))
            {
                if (vsCommandInfo.Action != null)
                {
                    vsCommandInfo.Action();
                }

                handled = true;
                break;
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Translates the specified from.
        /// </summary>
        /// <param name="from">Translate Source.</param>
        /// <returns>A Commands List.</returns>
        public CommandsList Translate(string @from)
        {
            TraceService.WriteLine("CommandsList::Translate " + @from);

            try
            {
                XDocument doc = XDocument.Load(from);

                if (doc.Root != null)
                {
                    TraceService.WriteDebugLine(doc.Root.Value);

                    return(new CommandsList
                    {
                        Commands = this.commandsTranslator.Translate(doc.Root),
                        FileOperations = this.fileOperationsTranslator.Translate(doc.Root)
                    });
                }

                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Completed the nuget updates.
        /// </summary>
        internal void NugetCompleted()
        {
            TraceService.WriteLine("NugetService::NugetCompleted");

            if (this.documentEvents != null)
            {
                this.RemoveEventHandlers();
            }

            this.ExecutePostNugetCommands();
            this.ExecutePostNugetFileOperations();

            this.visualStudioService.DTEService.CollapseSolution();

            if (this.ResumeReSharper)
            {
                try
                {
                    //// this could fail - so catch exception.
                    this.visualStudioService.DTEService.ExecuteCommand(Settings.ResumeReSharperCommand);
                }
                catch (Exception exception)
                {
                    TraceService.WriteError("Error Resuming ReSharper exception=" + exception.Message);
                }
            }
        }
        /// <summary>
        /// Shows the not MVVM cross solution message.
        /// </summary>
        protected void ShowNotMvvmCrossSolutionMessage()
        {
            string message = @"This solution is not a MvvmCross solution.";

            TraceService.WriteLine(message);
            MessageBox.Show(message, Settings.ApplicationName);
        }
Esempio n. 29
0
 /// <summary>
 /// Gets the init nuget messages.
 /// </summary>
 /// <returns>
 /// The messages.
 /// </returns>
 public IEnumerable <string> GetInitNugetMessages()
 {
     TraceService.WriteLine("NugetService::InitNugetMessages");
     return(new List <string> {
         string.Empty
     });
 }
Esempio n. 30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServicesController" /> class.
        /// </summary>
        /// <param name="servicesService">The services service.</param>
        public ServicesController(IServicesService servicesService)
            : base(new VisualStudioService(), new ReadMeService(), new SettingsService())
        {
            TraceService.WriteLine("ServicesController::Constructor");

            this.servicesService = servicesService;
        }