public override Func <IFubuFile, RazorTemplate> CreateBuilder(SettingsCollection settings) { var razorSettings = settings.Get <RazorEngineSettings>(); var namespaces = settings.Get <CommonViewNamespaces>(); var factory = new TemplateFactoryCache(namespaces, razorSettings, new TemplateCompiler(), new RazorTemplateGenerator()); return(file => new RazorTemplate(file, factory)); }
private void AddRibbonBarCommands(SettingsCollection ribbonbar, XElement root) { logger.WriteLine("building ribbon groups"); var group = root.Descendants(ns + "group") .FirstOrDefault(e => e.Attribute("id")?.Value == "ribOneMoreGroup"); if (group == null) { return; } var editCommands = ribbonbar.Get <bool>("editCommands"); var formulaCommands = ribbonbar.Get <bool>("formulaCommands"); if (editCommands || formulaCommands) { group.Add(new XElement(ns + "separator", new XAttribute("id", "omRibbonExtensions"))); if (editCommands) { var showLabels = !ribbonbar.Get <bool>("editIconsOnly"); group.Add(MakeNoSpellCheckButton(showLabels)); group.Add(MakeRibbonButton( "barPasteRtfButton", "PasteSpecialDialog", "PasteRtfCmd", showLabels)); group.Add(MakeRibbonButton( "barReplaceButton", "ReplaceDialog", "SearchAndReplaceCmd", showLabels)); } if (formulaCommands) { var showLabels = !ribbonbar.Get <bool>("formulaIconsOnly"); group.Add(MakeRibbonButton( "barAddFormulaButton", "TableFormulaDialog", "AddFormulaCmd", showLabels)); group.Add(MakeRibbonButton( "barHighlightFormulaButton", "PivotTableListFormulas", "HighlightFormulaCmd", showLabels)); group.Add(MakeRibbonButton( "barRecalculateFormulaButton", "CalculateSheet", "RecalculateFormulaCmd", showLabels)); } } }
private void AddContextMenuCommands( SettingsCollection ccommands, XElement root, XElement menu) { foreach (var key in ccommands.Keys) { if (!ccommands.Get <bool>(key)) { continue; } var element = root.Descendants() .FirstOrDefault(e => e.Attribute("id")?.Value == key); if (element != null) { // deep clone item but must change id and remove getEnabled... var item = new XElement(element); // cleanup the item itself XAttribute id = item.Attribute("id"); if (id != null && id.Value.StartsWith("rib")) { id.Value = $"ctx{id.Value.Substring(3)}"; } var enabled = item.Attribute("getEnabled"); if (enabled != null) { enabled.Remove(); } // cleanup all children below the item foreach (var node in item.Descendants() .Where(e => e.Attributes().Any(a => a.Name == "id"))) { id = node.Attribute("id"); if (id != null && id.Value.StartsWith("rib")) { id.Value = $"ct2{id.Value.Substring(3)}"; } enabled = node.Attribute("getEnabled"); if (enabled != null) { enabled.Remove(); } } item.Add(new XAttribute("insertBeforeMso", "Cut")); menu.Add(item); } } }
public IEnumerable<BehaviorChain> BuildChains(SettingsCollection settings) { var sources = _sources.Any() ? _sources : new IActionSource[] {new EndpointActionSource()}; var actions = sources.SelectMany(x => x.FindActions(_applicationAssembly)).ToArray() .Distinct(); var urlPolicies = settings.Get<UrlPolicies>(); return actions.Select(x => x.BuildChain(urlPolicies)).ToArray(); }
public void pulls_value_from_config() { // look at FubuMVC.Tests.dll.config AppSettingsProvider.GetValueFor<DiagnosticsSettings>(x => x.TraceLevel) .ShouldBe(TraceLevel.None.ToString()); var collection = new SettingsCollection(); collection.Get<DiagnosticsSettings>() .TraceLevel.ShouldBe(TraceLevel.None); }
public void pulls_value_from_config() { // look at FubuMVC.Tests.dll.config AppSettingsProvider.GetValueFor <DiagnosticsSettings>(x => x.TraceLevel) .ShouldBe(TraceLevel.None.ToString()); var collection = new SettingsCollection(); collection.Get <DiagnosticsSettings>() .TraceLevel.ShouldBe(TraceLevel.None); }
/// <summary> /// Returns a key value from settings /// </summary> /// <param name="key">The key of the seting value to get.</param> /// <returns>Returns a value of settings key by specified name.</returns> /// <exception cref="ArgumentException">If key does not exist.</exception> public static object GetValue(string key) { TestInstance(); if (Contains(key)) { return(settings.Get(key)); } throw new KeyNotFoundException(string.Format(CultureInfo.InvariantCulture, "Key named \"{0}\" does not exist in configuration. Following providers are configured:{1}", key, Environment.NewLine + providersContext)); }
private void AddContextMenuSearchers( SettingsCollection ccommands, XElement menu) { logger.WriteLine("building context menu search engines"); engines = ccommands.Get <XElement>("engines"); if (engines == null || !engines.HasElements) { return; } var elements = engines.Elements("engine"); var count = elements.Count(); XElement content = null; if (count == 1) { content = MakeSearchButton(elements.First(), 0); } else if (count > 1) { content = new XElement(ns + "menu", new XAttribute("id", "ctxSearchMenu"), new XAttribute("label", "Search"), new XAttribute("imageMso", "WebPagePreview"), new XAttribute("insertBeforeMso", "Cut") ); var id = 0; foreach (var engine in engines.Elements("engine")) { content.Add(MakeSearchButton(engine, id++)); } } if (content != null) { menu.Add(content); } }
private void AddContextMenuCommands( SettingsCollection ccommands, XElement root, XElement menu) { logger.WriteLine("building context menu"); foreach (var key in ccommands.Keys) { if (!ccommands.Get <bool>(key)) { continue; } var element = root.Descendants() .FirstOrDefault(e => e.Attribute("id")?.Value == key); if (element == null) { logger.WriteLine($"cannot add {key} command to context menu, element not found"); continue; } // deep clone item but must change id and remove getEnabled... var item = new XElement(element); // cleanup the item itself var id = item.Attribute("id"); if (id == null) { logger.WriteLine($"cannot add {key} command to context menu, id not found"); continue; } // special case to avoid collisions between Edit\Colorize and Colorize if (id.Value == "ribEditMenu" && ccommands.Keys.Contains("ribColorizeMenu")) { var sub = item.Elements() .FirstOrDefault(e => e.Attribute("id")?.Value == "ribColorizeMenu"); if (sub != null) { // allows top level context menu Colorize submenu // but removes the context menu Edit\Colorize submenu sub.Remove(); } } if (id.Value.StartsWith("rib")) { id.Value = $"ctx{id.Value.Substring(3)}"; } var enabled = item.Attribute("getEnabled"); if (enabled != null) { enabled.Remove(); } // cleanup all children below the item foreach (var node in item.Descendants() .Where(e => e.Attributes().Any(a => a.Name == "id"))) { id = node.Attribute("id"); if (id != null && id.Value.StartsWith("rib")) { id.Value = $"ct2{id.Value.Substring(3)}"; } enabled = node.Attribute("getEnabled"); if (enabled != null) { enabled.Remove(); } } item.Add(new XAttribute("insertBeforeMso", "Cut")); menu.Add(item); } }
public void pull_defaults_from_the_parent_if_it_exists_if_it_is_missing_in_child() { theParent.Replace(new FakeSettings()); theSettings.Get <FakeSettings>().ShouldBeTheSameAs(theParent.Get <FakeSettings>()); }
public void get_can_happily_create_the_default() { theSettings.Get <FakeSettings>().ShouldEqual(new FakeSettings()); }
public override FileSet FindMatching(SettingsCollection settings) { return(settings.Get <RazorEngineSettings>().Search); }
public override Func <IFubuFile, SparkTemplate> CreateBuilder(SettingsCollection settings, IFubuApplicationFiles files) { return(file => new SparkTemplate(files, file, _engine, settings.Get <SparkEngineSettings>())); }
private void AddContextMenuCommands( SettingsCollection ccommands, XElement root, XElement menu) { logger.WriteLine("building context menu"); foreach (var key in ccommands.Keys) { if (!ccommands.Get <bool>(key)) { continue; } // special case to hide Proofing menu if language set is only 1 if (key == "ribProofingMenu") { var langs = Office.GetEditingLanguages(); if (langs == null || langs.Length < 2) { continue; } } var element = root.Descendants() .FirstOrDefault(e => e.Attribute("id")?.Value == key); if (element == null) { logger.WriteLine($"cannot add {key} command to context menu, element not found"); continue; } // deep clone item but must change id and remove getEnabled... var item = new XElement(element); // cleanup the item itself var id = item.Attribute("id"); if (id == null) { logger.WriteLine($"cannot add {key} command to context menu, id not found"); continue; } // special case to avoid collisions between a top menu and its submenu, such as // Edit/Colorize and Colorize both chosen; in this case the submenu, Colorize, // will be placed as an item in the context menu but removed from the copy of // Edit menu in the context menu... if (id.Value == "ribEditMenu") { if (ccommands.Keys.Contains("ribColorizeMenu")) { item.Elements().Where(e => e.Attribute("id")?.Value == "ribColorizeMenu").Remove(); } if (ccommands.Keys.Contains("ribProofingMenu")) { item.Elements().Where(e => e.Attribute("id")?.Value == "ribProofingMenu").Remove(); } } if (id.Value.StartsWith("rib")) { id.Value = $"ctx{id.Value.Substring(3)}"; } var enabled = item.Attribute("getEnabled"); if (enabled != null) { enabled.Remove(); } // cleanup all children below the item foreach (var node in item.Descendants() .Where(e => e.Attributes().Any(a => a.Name == "id"))) { id = node.Attribute("id"); if (id != null && id.Value.StartsWith("rib")) { id.Value = $"ct2{id.Value.Substring(3)}"; } enabled = node.Attribute("getEnabled"); if (enabled != null) { enabled.Remove(); } } item.Add(new XAttribute("insertBeforeMso", "Cut")); menu.Add(item); } }