/// <summary> /// Initializes a new instance of the <see cref="StyleItem"/> class. /// </summary> public StyleItem(Style style, FrameworkElement source, string name, string location, StyleScope scope) { Style = style; Name = name; Location = location; Scope = scope; // Setters foreach (Setter setter in style.Setters) { if(setter.Property.Name == "OverridesDefaultStyle" && setter.Value.ToString().ToLower() == "true") { OverridesDefaultStyle = true; } _setterItems.Add(new SetterItem(setter, source)); } // Triggers foreach (var trigger in style.Triggers) { _triggerItems.Add(TriggerItemFactory.GetTriggerItem(trigger, source, TriggerSource.Style )); } // Ressources foreach (var resource in ResourceHelper.GetResourcesRecursively<object>(style.Resources)) { _resourceItems.Add(ResourceItemFactory.CreateResourceItem(resource.Key, resource.Owner, source, ResourceScope.Style)); } GlobalIndex = StyleHelper.GetGlobalIndex(style); }
/// <summary> /// Initializes a new instance of the <see cref="StyleItem"/> class. /// </summary> public StyleItem(Style style, FrameworkElement source, string name, string location, StyleScope scope) { Style = style; Name = name; Location = location; Scope = scope; // Setters foreach (Setter setter in style.Setters) { if (setter.Property.Name == "OverridesDefaultStyle" && setter.Value.ToString().ToLower() == "true") { OverridesDefaultStyle = true; } _setterItems.Add(new SetterItem(setter, source)); } // Triggers foreach (var trigger in style.Triggers) { _triggerItems.Add(TriggerItemFactory.GetTriggerItem(trigger, source, TriggerSource.Style)); } // Ressources foreach (var resource in ResourceHelper.GetResourcesRecursively <object>(style.Resources)) { _resourceItems.Add(ResourceItemFactory.CreateResourceItem(resource.Key, resource.Owner, source, ResourceScope.Style)); } GlobalIndex = StyleHelper.GetGlobalIndex(style); }
IStoryThread EnchantExecute(IEnumerable <HarloweEnchantment> enchantments, Func <IStoryThread> fragment) { foreach (HarloweEnchantment enchantment in enchantments) { bool isHookRef = enchantment.ReferenceType == HarloweEnchantReferenceType.Hook; int index = isHookRef && enchantment.Command != HarloweEnchantCommand.Append ? enchantment.HookGroup.Index + 1 : -1; if (enchantment.Affected.Count > 0) { if (index == -1) { index = enchantment.Command == HarloweEnchantCommand.Append ? enchantment.Affected.Last().Index + 1 : enchantment.Affected[0].Index; } // Remove affected outputs to be replaced if (enchantment.Command == HarloweEnchantCommand.Replace) { for (int i = 0; i < enchantment.Affected.Count; i++) { OutputRemove(enchantment.Affected[i]); } } } this.InsertStack.Push(index); _activeEnchantments.Push(enchantment); StyleScope scope = isHookRef ? scope = styleScope(enchantment.HookGroup) : null; using (scope) { // Execute the enchantment thread yield return(this.fragment(fragment)); } _activeEnchantments.Pop(); // Reset the index this.InsertStack.Pop(); } }