Exemplo n.º 1
0
        protected override void RunStartedCore(Dictionary <string, string> replacementsDictionary)
        {
            ContextDiscovery discovery = new ContextDiscovery(_dte);

            discovery.DiscoverCore(out ProjectItemOrProject projectItemorProject);
            SourceText text           = SourceCodeGenerator.GenerateXamlPropertyRuleSourceText(RootName);
            string     codeBehindText = XamlPropertyRuleGenerator.GenerateCodeBehindContent(RootName, RootNamespace);
            string     filePath       = null;
            string     codeBehindPath = null;

            if (projectItemorProject.IsProject)
            {
                string directory = Path.GetDirectoryName(projectItemorProject.Project.FullName);
                filePath       = Path.Combine(directory, $"{RootName}.xaml");
                codeBehindPath = Path.Combine(directory, $"{RootName}.xaml.cs");
            }
            else
            {
                filePath       = Path.Combine(projectItemorProject.ProjectItem.FileNames[0], $"{RootName}.xaml");
                codeBehindPath = Path.Combine(projectItemorProject.ProjectItem.FileNames[0], $"{RootName}.xaml.cs");
            }

            File.WriteAllText(codeBehindPath, codeBehindText);
            File.WriteAllText(filePath, text.ToString(), Encoding.ASCII);

            ProjectItem projectItem = projectItemorProject.ProjectItem.ProjectItems.AddFromFile(filePath);

            SetXamlPropertyRuleBuildProperties(projectItem);
        }
        protected override void RunStartedCore(Dictionary <string, string> replacementsDictionary)
        {
            string           name          = replacementsDictionary["$rootname$"];
            string           rootnamespace = replacementsDictionary["$rootnamespace$"];
            ContextDiscovery discovery     = new ContextDiscovery(_dte);

            discovery.DiscoverCore(out ProjectItemOrProject projectItemorProject);
            CodeAnalysis.Text.SourceText text = SourceCodeGenerator.GenerateAsyncCommandGroupHandlerSourceText(rootnamespace, name);
            string filePath = null;

            if (projectItemorProject.IsProject)
            {
                filePath = Path.Combine(Path.GetDirectoryName(projectItemorProject.Project.FullName), $"{name}.cs");
            }
            else
            {
                filePath = Path.Combine(projectItemorProject.ProjectItem.FileNames[0], $"{name}.cs");
            }

            File.WriteAllText(filePath, text.ToString(), Encoding.ASCII);

            ProjectItem projectItem = projectItemorProject.ProjectItem.ProjectItems.AddFromFile(filePath);

            Service.Open(projectItem);
        }
        protected override void RunStartedCore(Dictionary <string, string> replacementsDictionary)
        {
            ContextDiscovery discovery = new ContextDiscovery(_dte);

            discovery.DiscoverCore(out ProjectItemOrProject projectItemorProject);
            CodeAnalysis.Text.SourceText text = SourceCodeGenerator.GenerateGlobalPropeertiesProviderSourceText(RootNamespace, RootName);
            string filePath = null;

            if (projectItemorProject.IsProject)
            {
                filePath = Path.Combine(Path.GetDirectoryName(projectItemorProject.Project.FullName), $"{RootName}.cs");
            }
            else
            {
                filePath = Path.Combine(projectItemorProject.ProjectItem.FileNames[0], $"{RootName}.cs");
            }

            File.WriteAllText(filePath, text.ToString(), Encoding.ASCII);

            ProjectItem projectItem = projectItemorProject.ProjectItem.ProjectItems.AddFromFile(filePath);
        }