public static IEnumerable <ReplacementItem> FindMatchedItems(this IEnumerable <ReplacementGroup> groups, Dictionary <string, string> replacementsDictionary) { foreach (var group in groups.Where(r => replacementsDictionary.MatchesCondition(r.Condition))) { foreach (var item in group.Replacements.Where(r => replacementsDictionary.MatchesCondition(r.Condition))) { yield return(item); } } }
public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var doc = Helpers.LoadWizardXml(replacementsDictionary); var ns = Helpers.WizardNamespace; var model = new OptionsPageModel(doc.Root.Elements(ns + "Options").FirstOrDefault()); var view = new OptionsPageView(model); var dialog = new BaseDialog { Content = view, Title = model.Title }; if (dialog.ShowModal(Helpers.MainWindow)) { foreach (var option in model.Options) { var selected = option.Selected; if (selected != null) { foreach (var replacement in selected.Replacements) { if (replacementsDictionary.MatchesCondition(replacement.Condition)) { replacementsDictionary[replacement.Name] = replacement.Content; } } } } } else { throw new WizardBackoutException(); } }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { dte = automationObject as EnvDTE.DTE; defaultDestinationFolder = replacementsDictionary["$destinationdirectory$"]; basePath = Path.GetDirectoryName((string)customParams[0]); safeProjectName = replacementsDictionary["$safeprojectname$"]; var doc = Helpers.LoadWizardXml(replacementsDictionary); var ns = Helpers.WizardNamespace; foreach (var element in doc.Root.Elements(ns + "Projects").Elements(ns + "Project")) { var definition = new ProjectDefinition(element, replacementsDictionary); if (replacementsDictionary.MatchesCondition(definition.Condition)) { definitions.Add(definition); } } cachedGlobals = null; Globals.Clear(); foreach (var replacement in replacementsDictionary) { Globals[replacement.Key] = replacement.Value; } }
public override void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var doc = Helpers.LoadWizardXml(replacementsDictionary); var ns = Helpers.WizardNamespace; var model = new OptionsPageModel(doc.Root.Elements(ns + "Options").FirstOrDefault()); var view = new OptionsPageView(model); var dialog = new BaseDialog { Content = view, Title = model.Title }; if (dialog.ShowModal(Helpers.MainWindow)) { foreach (var option in model.Options) { var selected = option.Selected; if (selected != null) { foreach (var replacement in selected.Replacements) { if (replacementsDictionary.MatchesCondition(replacement.Condition)) { replacementsDictionary[replacement.Name] = replacement.Content; } } } } } else throw new WizardBackoutException(); }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var doc = Helpers.LoadWizardXml(replacementsDictionary); var ns = Helpers.WizardNamespace; skipFiles = SkipGroup.LoadXml(doc.Root.Elements(ns + "SkipFiles").FirstOrDefault()) .Where(r => replacementsDictionary.MatchesCondition(r.Condition)) .ToList(); }
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { dte = automationObject as EnvDTE.DTE; defaultDestinationFolder = replacementsDictionary["$destinationdirectory$"]; basePath = Path.GetDirectoryName((string)customParams[0]); safeProjectName = replacementsDictionary["$safeprojectname$"]; var doc = Helpers.LoadWizardXml(replacementsDictionary); var ns = Helpers.WizardNamespace; foreach (var element in doc.Root.Elements(ns + "Projects").Elements(ns + "Project")) { var definition = new ProjectDefinition(element, replacementsDictionary); if (replacementsDictionary.MatchesCondition(definition.Condition)) definitions.Add(definition); } }
IEnumerable <ReferenceInfo> GetRequiredReferences(Dictionary <string, string> replacementsDictionary) { var wizardData = "<root>" + replacementsDictionary["$wizarddata$"] + "</root>"; var doc = new XmlDocument(); doc.LoadXml(wizardData); var nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("vs", "http://schemas.microsoft.com/developer/vstemplate/2005"); var references = doc.SelectSingleNode("//vs:RequiredReferences", nsmgr) as XmlElement; Quiet = string.Equals(references.GetAttribute("Quiet"), "true", StringComparison.OrdinalIgnoreCase); var requiredReferences = references.SelectNodes("vs:Reference", nsmgr) .OfType <XmlElement>() .Select(r => new ReferenceInfo(r)) .Where(r => replacementsDictionary.MatchesCondition(r.Condition)); return(requiredReferences); }
IEnumerable<ReferenceInfo> GetRequiredReferences(Dictionary<string, string> replacementsDictionary) { var wizardData = "<root>" + replacementsDictionary["$wizarddata$"] + "</root>"; var doc = new XmlDocument(); doc.LoadXml(wizardData); var nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("vs", "http://schemas.microsoft.com/developer/vstemplate/2005"); var references = doc.SelectSingleNode("//vs:RequiredReferences", nsmgr) as XmlElement; Quiet = string.Equals(references.GetAttribute("Quiet"), "true", StringComparison.OrdinalIgnoreCase); var requiredReferences = references.SelectNodes("vs:Reference", nsmgr) .OfType<XmlElement>() .Select(r => new ReferenceInfo(r)) .Where(r => replacementsDictionary.MatchesCondition(r.Condition)); return requiredReferences; }
public static IEnumerable<ReplacementItem> FindMatchedItems(this IEnumerable<ReplacementGroup> groups, Dictionary<string, string> replacementsDictionary) { foreach (var group in groups.Where(r => replacementsDictionary.MatchesCondition(r.Condition))) { foreach (var item in group.Replacements.Where(r => replacementsDictionary.MatchesCondition(r.Condition))) { yield return item; } } }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var doc = Helpers.LoadWizardXml(replacementsDictionary); var ns = Helpers.WizardNamespace; var replacementGroups = ReplacementGroup.LoadXml(doc.Root.Elements(ns + "Replacements").FirstOrDefault()); foreach (var replacementGroup in replacementGroups) { if (replacementsDictionary.MatchesCondition(replacementGroup.Condition)) { foreach (var replacement in replacementGroup.Replacements) { if (replacementsDictionary.MatchesCondition(replacement.Condition)) { replacementsDictionary[replacement.Name] = replacement.Content; } } } } var references = new List <ProjectReference>(); foreach (var element in doc.Root.Elements(ns + "ProjectReferences").Elements(ns + "ProjectReference")) { references.Add(new ProjectReference(element, replacementsDictionary)); } const string ProjectImportsKey = "$ProjectImports$"; const string ProjectReferencesKey = "$ProjectReferences$"; if (!replacementsDictionary.ContainsKey(ProjectImportsKey)) { replacementsDictionary[ProjectImportsKey] = string.Empty; } if (!replacementsDictionary.ContainsKey(ProjectReferencesKey)) { replacementsDictionary[ProjectReferencesKey] = string.Empty; } if (references.Count > 0) { var isSharedLib = replacementsDictionary.GetParameter("UseSAL").ToBool(); var projectReferences = new StringBuilder(); if (isSharedLib) { const string def = @" <Import Project=""{0}.projitems"" Label=""Shared"" Condition=""Exists('{0}.projitems')"" />"; foreach (var reference in references) { projectReferences.AppendFormat(def, reference.Reference, reference.Guid, reference.Name, reference.Extension); } replacementsDictionary[ProjectImportsKey] += projectReferences.ToString(); } else { const string def = @" <ProjectReference Include=""{0}.{3}""> <Project>{{{1}}}</Project> <Name>{2}</Name> </ProjectReference>"; foreach (var reference in references) { projectReferences.AppendFormat(def, reference.Reference, reference.Guid, reference.Name, reference.Extension); } replacementsDictionary[ProjectReferencesKey] += string.Format(@" <ItemGroup>{0} </ItemGroup>", projectReferences); } } }
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var doc = Helpers.LoadWizardXml(replacementsDictionary); var ns = Helpers.WizardNamespace; skipFiles = SkipGroup.LoadXml(doc.Root.Elements(ns + "SkipFiles").FirstOrDefault()) .Where(r => replacementsDictionary.MatchesCondition(r.Condition)) .ToList(); }
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var doc = Helpers.LoadWizardXml(replacementsDictionary); var ns = Helpers.WizardNamespace; var replacementGroups = ReplacementGroup.LoadXml(doc.Root.Elements(ns + "Replacements").FirstOrDefault()); foreach (var replacementGroup in replacementGroups) { if (replacementsDictionary.MatchesCondition(replacementGroup.Condition)) { foreach (var replacement in replacementGroup.Replacements) { if (replacementsDictionary.MatchesCondition(replacement.Condition)) replacementsDictionary[replacement.Name] = replacement.Content; } } } var references = new List<ProjectReference>(); foreach (var element in doc.Root.Elements(ns + "ProjectReferences").Elements(ns + "ProjectReference")) { references.Add(new ProjectReference(element, replacementsDictionary)); } const string ProjectImportsKey = "$ProjectImports$"; const string ProjectReferencesKey = "$ProjectReferences$"; if (!replacementsDictionary.ContainsKey(ProjectImportsKey)) replacementsDictionary[ProjectImportsKey] = string.Empty; if (!replacementsDictionary.ContainsKey(ProjectReferencesKey)) replacementsDictionary[ProjectReferencesKey] = string.Empty; if (references.Count > 0) { var isSharedLib = replacementsDictionary.GetParameter("UseSAL").ToBool(); var projectReferences = new StringBuilder(); if (isSharedLib) { const string def = @" <Import Project=""{0}.projitems"" Label=""Shared"" Condition=""Exists('{0}.projitems')"" />"; foreach (var reference in references) { projectReferences.AppendFormat(def, reference.Reference, reference.Guid, reference.Name, reference.Extension); } replacementsDictionary[ProjectImportsKey] += projectReferences.ToString(); } else { const string def = @" <ProjectReference Include=""{0}.{3}""> <Project>{{{1}}}</Project> <Name>{2}</Name> </ProjectReference>"; foreach (var reference in references) { projectReferences.AppendFormat(def, reference.Reference, reference.Guid, reference.Name, reference.Extension); } replacementsDictionary[ProjectReferencesKey] += string.Format(@" <ItemGroup>{0} </ItemGroup>", projectReferences); } } }