private void PaintHeaderControlRightPortion(ListView listView) { bool hasColumns = listView.View == View.Details && listView.HeaderStyle != ColumnHeaderStyle.None && listView.Columns.Count > 0; if (hasColumns) { int columnsWidth = listView.Columns.Cast <ColumnHeader>().Sum(header => header.Width); int x = columnsWidth; int width = listView.Width - columnsWidth; Rectangle rect = new Rectangle(x, 0, width, listView.TopItem?.Bounds.Top ?? 0); IntPtr headerControl = GetHeaderControl(listView); IntPtr hdc = User32.GetDC(headerControl); IRuleset ruleset = GetColumnHeaderRuleset(listView.Columns[0]); using (Graphics graphics = Graphics.FromHdc(hdc)) styleRenderer.PaintBackground(graphics, rect, ruleset); User32.ReleaseDC(headerControl, hdc); } }
private void PaintSubItem(Graphics graphics, ListViewItem item, ListViewItem.ListViewSubItem subItem) { ListView listView = item.ListView; ColumnHeader columnHeader = listView.Columns[item.SubItems.IndexOf(subItem)]; Rectangle bounds = subItem.Bounds; UserNode node = new UserNode(bounds, listView.PointToClient(Cursor.Position)); node.SetClass("ListViewItem"); node.AddClass("Item"); node.SetParent(new ControlNode(listView)); if (item.Selected) { node.AddState(NodeStates.Checked); } int textPadding = 4; IRuleset ruleset = styleSheet.GetRuleset(node); Rectangle itemRect = new Rectangle(bounds.X, bounds.Y, columnHeader.Width, bounds.Height); Rectangle textRect = new Rectangle(itemRect.X + textPadding, itemRect.Y, itemRect.Width - textPadding * 2, itemRect.Height); TextFormatFlags textFormatFlags = TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis | TextFormatFlags.NoPrefix; styleRenderer.PaintText(graphics, textRect, ruleset, subItem.Text, subItem.Font, textFormatFlags); styleRenderer.PaintBorder(graphics, itemRect, ruleset); }
private IRuleset SetNonDefaultCellColors(IRuleset ruleset, DataGridView dataGridView, DataGridViewCellPaintingEventArgs e) { IRuleset result = new Ruleset(ruleset); DataGridViewCellStyle cellStyle = DataGridViewUtilities.GetDefaultCellStyle(dataGridView, e.RowIndex, e.ColumnIndex); bool isSelected = e.State.HasFlag(DataGridViewElementStates.Selected); if (!isSelected && e.CellStyle.ForeColor != cellStyle.ForeColor) { result.AddProperty(Property.Create(PropertyType.Color, e.CellStyle.ForeColor)); } else if (isSelected && e.CellStyle.SelectionForeColor != cellStyle.SelectionForeColor) { result.AddProperty(Property.Create(PropertyType.Color, e.CellStyle.SelectionForeColor)); } if (!isSelected && e.CellStyle.BackColor != cellStyle.BackColor) { result.AddProperty(Property.Create(PropertyType.BackgroundColor, e.CellStyle.BackColor)); } else if (isSelected && e.CellStyle.SelectionBackColor != cellStyle.SelectionBackColor) { result.AddProperty(Property.Create(PropertyType.BackgroundColor, e.CellStyle.SelectionBackColor)); } return(result); }
private void PaintItem(Graphics graphics, ListViewItem item) { Rectangle bounds = item.Bounds; UserNode node = new UserNode(bounds, item.ListView.PointToClient(Cursor.Position)); node.AddClass("ListViewItem"); node.AddClass("Item"); node.SetParent(new ControlNode(item.ListView)); if (item.Index % 2 == 0) { node.AddClass("Even"); } else { node.AddClass("Odd"); } if (item.Selected) { node.AddState(NodeStates.Checked); } IRuleset ruleset = styleSheet.GetRuleset(node); Rectangle rect = new Rectangle(bounds.X, bounds.Y, bounds.Width, bounds.Height); styleRenderer.PaintBackground(graphics, rect, ruleset); styleRenderer.PaintBorder(graphics, rect, ruleset); }
private IRuleset GetRuleset(INode node, bool inherit, bool useCache) { IRuleset result = null; // Only use the cache if inheriting styles is enabled. // This is because the value of "inherit" isn't part of the node's key, so if we inherit later, we'll get the non-inherited ruleset from the cache. // This could be fixed by having the value of "inherit" factor into the node's key in some way. if (useCache && inherit) { result = GetRulesetFromCache(node, inherit); } else { result = new Ruleset(); if (inherit && node.Parent != null) { result.InheritProperties(GetRuleset(node.Parent, inherit)); } foreach (IRuleset ruleset in rulesets.Where(r => r.Selector.IsMatch(node))) { result.AddProperties(ruleset); } } return(result); }
// Public members public override void PaintControl(GroupBox control, ControlPaintArgs e) { IRuleset ruleset = e.StyleSheet.GetRuleset(control); IRuleset textBackgroundRuleset = new Ruleset(); textBackgroundRuleset.AddProperty(ruleset.BackgroundColor); SizeF textSize = e.Graphics.MeasureString(control.Text, control.Font); Rectangle clientRect = control.ClientRectangle; Rectangle backgroundRect = new Rectangle(clientRect.X, clientRect.Y + (int)textSize.Height / 2, clientRect.Width, clientRect.Height - (int)textSize.Height / 2); Rectangle textRect = new Rectangle(clientRect.X + 6, clientRect.Y, (int)textSize.Width, (int)textSize.Height); Rectangle textBackgroundRect = new Rectangle(textRect.X, backgroundRect.Y, textRect.Width, textRect.Height - (int)textSize.Height / 2); e.Clear(); e.StyleRenderer.PaintBackground(e.Graphics, backgroundRect, ruleset); e.StyleRenderer.PaintBorder(e.Graphics, backgroundRect, ruleset); e.StyleRenderer.PaintBackground(e.Graphics, textBackgroundRect, textBackgroundRuleset); e.StyleRenderer.PaintBorder(e.Graphics, textBackgroundRect, textBackgroundRuleset); e.StyleRenderer.PaintText(e.Graphics, textRect, ruleset, control.Text, control.Font, TextFormatFlags.Top); }
public override void PaintControl(RichTextBox control, ControlPaintArgs args) { INode controlNode = new ControlNode(control); IRuleset ruleset = args.StyleSheet.GetRuleset(controlNode); RenderUtilities.ApplyColorProperties(control, ruleset); Rectangle clientRect = control.ClientRectangle; Rectangle borderRect = new Rectangle(clientRect.X - 3, clientRect.Y - 3, clientRect.Width + 6, clientRect.Height + 6); ScrollBars visibleScrollbars = ControlUtilities.GetVisibleScrollBars(control); if (visibleScrollbars.HasFlag(ScrollBars.Vertical)) { borderRect = new Rectangle(borderRect.X, borderRect.Y, borderRect.Width + SystemInformation.VerticalScrollBarWidth, borderRect.Height); } if (visibleScrollbars.HasFlag(ScrollBars.Horizontal)) { borderRect = new Rectangle(borderRect.X, borderRect.Y, borderRect.Width, borderRect.Height + SystemInformation.HorizontalScrollBarHeight); } args.PaintBackground(borderRect); args.PaintBorder(borderRect); }
protected virtual void PaintNodeContent(TreeView control, TreeNode node, int visibleIndex, ControlPaintArgs args) { UserNode treeNodeNode = new UserNode(string.Empty, new[] { "Node", "TreeViewNode" }); treeNodeNode.SetParent(new ControlNode(control)); if (node.IsSelected) { treeNodeNode.AddState(NodeStates.Checked); } if (visibleIndex % 2 == 0) { treeNodeNode.AddClass("Even"); } else { treeNodeNode.AddClass("Odd"); } IRuleset treeNodeRuleset = args.StyleSheet.GetRuleset(treeNodeNode); Rectangle nodeRect = node.Bounds; Rectangle backgroundRect = new Rectangle(nodeRect.X + 2, nodeRect.Y + 1, nodeRect.Width, nodeRect.Height - 1); Rectangle textRect = new Rectangle(nodeRect.X + 1, nodeRect.Y + 3, nodeRect.Width - 1, nodeRect.Height - 3); if (control.FullRowSelect) { backgroundRect = new Rectangle(0, backgroundRect.Y, control.Width, backgroundRect.Height); } args.StyleRenderer.PaintBackground(args.Graphics, backgroundRect, treeNodeRuleset); args.StyleRenderer.PaintText(args.Graphics, textRect, treeNodeRuleset, node.Text, control.Font, TextFormatFlags.Default | TextFormatFlags.VerticalCenter); args.StyleRenderer.PaintBorder(args.Graphics, backgroundRect, treeNodeRuleset); }
public Story(string name, IRuleset <IStory, IStoryHandler> handlerProvider) { try { Ensure.ArgumentNotEmpty(name, "name"); Ensure.ArgumentNotNull(handlerProvider, "handlerProvider"); this.HandlerProvider = handlerProvider; this.stopWatch = new Stopwatch(); this.log = new StoryLog(this); this.data = new StoryData(this); if (this.Parent == null) { this.Name = name; } else { this.Name = this.Parent.Name + "/" + name; } } catch { base.Detach(); throw; } }
/// <summary> /// Renders the PlantUML code based on a given VTL 2.0 ruleset. /// </summary> /// <param name="ruleset">The VTL 2.0 ruleset.</param> /// <param name="name">The name of PlantUML object to render.</param> /// <returns>The PlantUML code.</returns> private string RenderRuleset(IRuleset ruleset, string name) { StringBuilder sb = new StringBuilder(); string size = $"<size:{(int)(this._fontSize * 0.9)}>"; string objectName = ruleset.RulesetText; sb.AppendLine(); sb.AppendLine($"object \"{this.ReplaceQuotationMarks(objectName)}\" as {name} #Bisque{"{"}"); sb.AppendLine($" {size}Name = '{ruleset.Name}'"); sb.AppendLine("}"); IEnumerable <IRuleExpression> exprs = ruleset.RulesCollection; string ruleName = "rule"; for (int i = 0; i < exprs.Count(); i++) { sb.Append(this.RenderExpression(exprs.ToArray()[i], $"{name}_{ruleName}{i + 1}")); } for (int i = 0; i < exprs.Count(); i++) { sb.AppendLine($"{name} {this._conf.LineConnection} {name}_{ruleName}{i + 1}"); } if (ruleset.Structure != null && this._conf.ShowDataStructure) { sb.AppendLine(); sb.Append(RenderDataStructureObject(ruleset.Structure, $"{name}_ds", name, string.Empty)); } return(sb.ToString()); }
// Private members private void PaintDropDownArrow(ComboBox control, ControlPaintArgs e) { INode controlNode = new ControlNode(control); UserNode dropDownArrowNode = new UserNode(string.Empty, new[] { "DropDownArrow" }); dropDownArrowNode.SetParent(controlNode); dropDownArrowNode.SetStates(controlNode.States); IRuleset ruleset = e.StyleSheet.GetRuleset(dropDownArrowNode); // Create the arrow rectangle to match the bounds of the default control. Rectangle clientRect = control.ClientRectangle; Rectangle arrowRect = new Rectangle(clientRect.Right - 12, clientRect.Y + 9, 7, 6); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; using (Pen pen = new Pen(ruleset.Color?.Value ?? SystemColors.ControlText)) { pen.Width = 2.0f; pen.Alignment = PenAlignment.Center; pen.StartCap = LineCap.Flat; pen.EndCap = LineCap.Flat; PointF bottomMidpoint = new PointF(arrowRect.Left + arrowRect.Width / 2.0f, arrowRect.Bottom - 1); e.Graphics.DrawLine(pen, new PointF(arrowRect.Left, arrowRect.Top), bottomMidpoint); e.Graphics.DrawLine(pen, new PointF(arrowRect.Right, arrowRect.Top), bottomMidpoint); } }
public void TestPropertyWithLeadingWhitespaceBeforeValue() { string styleSheetStr = "class { border-width: 10px; }"; IStyleSheet styleSheet = StyleSheet.Parse(styleSheetStr); IRuleset ruleset = styleSheet.GetRuleset(new UserNode("class", Enumerable.Empty <string>())); Assert.AreEqual(10.0, ruleset.GetProperty(PropertyType.BorderWidth).Value); }
public void FillBoardState(IRuleset ruleset) { if (Parent == null) { throw new InvalidOperationException("Only call this on a child node."); } FillBoardStateInternal(new GameBoard(Parent.BoardState), new GroupState(Parent.GroupState, ruleset.RulesetInfo), ruleset); }
public void FillBoardStateOfRoot(GameBoardSize boardSize, IRuleset ruleset) { if (Parent != null) { throw new InvalidOperationException("Only call this on a root."); } FillBoardStateInternal(new GameBoard(boardSize), new GroupState(ruleset.RulesetInfo), ruleset); }
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) { IRuleset ruleset = GetToolStripItemRuleset(e.ToolStrip, e.Item); Rectangle backgroundRect = new Rectangle(2, 0, e.Item.Width - 3, e.Item.Height); styleRenderer.PaintBackground(e.Graphics, backgroundRect, ruleset); styleRenderer.PaintBorder(e.Graphics, backgroundRect, ruleset); }
// Protected members protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) { IRuleset ruleset = styleSheet.GetRuleset(e.ToolStrip); Rectangle clientRect = e.ToolStrip.ClientRectangle; styleRenderer.PaintBackground(e.Graphics, clientRect, ruleset); styleRenderer.PaintBorder(e.Graphics, clientRect, ruleset); }
public static Borders GetBorders(this IRuleset ruleset) { Border top = new Border(ruleset.BorderTopWidth?.Value ?? 0, ruleset.BorderTopStyle?.Value ?? BorderStyle.Solid, ruleset.BorderTopColor?.Value ?? default); Border right = new Border(ruleset.BorderRightWidth?.Value ?? 0, ruleset.BorderRightStyle?.Value ?? BorderStyle.Solid, ruleset.BorderRightColor?.Value ?? default); Border bottom = new Border(ruleset.BorderBottomWidth?.Value ?? 0, ruleset.BorderBottomStyle?.Value ?? BorderStyle.Solid, ruleset.BorderBottomColor?.Value ?? default); Border left = new Border(ruleset.BorderLeftWidth?.Value ?? 0, ruleset.BorderLeftStyle?.Value ?? BorderStyle.Solid, ruleset.BorderLeftColor?.Value ?? default); return(new Borders(top, right, bottom, left)); }
public static BorderRadius GetBorderRadii(this IRuleset ruleset) { double topLeft = ruleset.BorderTopLeftRadius?.Value ?? 0; double topRight = ruleset.BorderTopRightRadius?.Value ?? 0; double bottomRight = ruleset.BorderBottomRightRadius?.Value ?? 0; double bottomLeft = ruleset.BorderBottomLeftRadius?.Value ?? 0; return(new BorderRadius(topLeft, topRight, bottomRight, bottomLeft)); }
protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) { // This method is called when rendering the border around the ToolStripDropDown. IRuleset ruleset = GetToolStripDropDownRuleset(e.ToolStrip); styleRenderer.PaintBackground(e.Graphics, e.ToolStrip.ClientRectangle, ruleset); styleRenderer.PaintBorder(e.Graphics, e.ToolStrip.ClientRectangle, ruleset); }
/// <summary> /// Creates a game tree with a given ruleset /// </summary> public GameTree(IRuleset ruleset, GameBoardSize boardSize) { Ruleset = ruleset; BoardSize = boardSize; GameTreeRoot = new GameTreeNode(); GameTreeRoot.BoardState = new GameBoard(boardSize); GameTreeRoot.GroupState = new GroupState(ruleset.RulesetInfo); LastNode = GameTreeRoot; }
private void PaintGenericControl(ControlPaintArgs e) { IRuleset ruleset = e.StyleSheet.GetRuleset(new ControlNode(e.Control)); RenderUtilities.ApplyColorProperties(e.Control, ruleset); e.PaintBackground(); e.PaintBorder(); }
public static IRuleset GetRuleset(this IStyleSheet styleSheet, INode node, IRuleset parentRuleset) { IRuleset ruleset = new Ruleset(); ruleset.InheritProperties(parentRuleset); ruleset.AddProperties(styleSheet.GetRuleset(node)); return(ruleset); }
public void Draw(object sender, DrawToolTipEventArgs e) { INode node = new UserNode(string.Empty, new[] { "ToolTip" }); IRuleset ruleset = styleSheet.GetRuleset(node); styleRenderer.PaintBackground(e.Graphics, e.Bounds, ruleset); styleRenderer.PaintText(e.Graphics, e.Bounds, ruleset, e.ToolTipText, e.Font, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); styleRenderer.PaintBorder(e.Graphics, e.Bounds, ruleset); }
public Board(IRuleset ruleset = null) { for (int i = 1; i <= 6; i++) { Dice.Add(new Dice()); } ScoreTracker = new ScoreTracker(ruleset ?? new DefaultRuleset()); }
private void ReadStream(Stream stream) { using (IStyleSheetLexer lexer = new StyleSheetLexer(stream)) { IRuleset currentRuleset = null; string currentPropertyName = string.Empty; while (!lexer.EndOfStream) { IStyleSheetLexerToken token = lexer.Peek(); switch (token.Type) { case StyleSheetLexerTokenType.DeclarationEnd: rulesets.Add(currentRuleset); break; case StyleSheetLexerTokenType.PropertyName: currentPropertyName = token.Value; break; case StyleSheetLexerTokenType.Value: case StyleSheetLexerTokenType.Function: { StyleObject[] propertyValues = ReadPropertyValues(lexer); IProperty property = null; try { property = Property.Create(currentPropertyName, propertyValues); } catch (Exception ex) { if (!options.IgnoreInvalidProperties) { throw ex; } } if (property != null) { currentRuleset.AddProperty(property); } } continue; case StyleSheetLexerTokenType.Tag: case StyleSheetLexerTokenType.Class: case StyleSheetLexerTokenType.Id: currentRuleset = new Ruleset(ReadSelector(lexer)); continue; } // Consume the current token. lexer.Read(out _); } } }
private void PaintLines(TreeView control, TreeNodeCollection nodes, ControlPaintArgs args) { const int buttonWidth = 9; if (control.ShowLines && control.Nodes.Count > 0) { if (control.ShowRootLines || nodes[0].Level != 0) { UserNode lineNode = new UserNode(string.Empty, new[] { "Lines" }); lineNode.SetParent(new ControlNode(control)); IRuleset lineRuleset = args.StyleSheet.GetRuleset(lineNode); Color lineColor = lineRuleset.Color?.Value ?? Color.Black; using (Pen linePen = new Pen(lineColor)) { linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; // Draw a line from the first node down to the last node. TreeNode firstNode = nodes[0]; TreeNode lastNode = nodes[nodes.Count - 1]; int x1 = firstNode.Bounds.X - 8; int x2 = x1; int y1 = firstNode.Bounds.Y + (firstNode.Nodes.Count > 0 ? buttonWidth - 1 : 2); int y2 = lastNode.Bounds.Y + (firstNode.Nodes.Count > 0 ? buttonWidth - 1 : 13); args.Graphics.DrawLine(linePen, new Point(x1, y1), new Point(x2, y2)); // Draw horizontal lines connecting the vertical line to each of the nodes. foreach (TreeNode childNode in nodes) { x1 = firstNode.Bounds.X - buttonWidth + 1; x2 = childNode.Bounds.X + 2; y1 = childNode.Bounds.Y + 12; y2 = y1; args.Graphics.DrawLine(linePen, new Point(x1, y1), new Point(x2, y2)); } } } // Draw lines for the child nodes. foreach (TreeNode node in nodes) { if (node.IsExpanded) { PaintLines(control, node.Nodes, args); } } } }
public AnalyzeOnlyViewModel(IGameSettings gameSettings, IQuestsManager questsManager, IDialogService dialogService) { _dialogService = dialogService; var analyzeBundle = Mvx.Resolve <NavigationBundle>(); LibraryItem = analyzeBundle.LibraryItem; GameTree = analyzeBundle.GameTree; GameInfo = analyzeBundle.GameInfo; BlackPortrait = new PlayerPortraitViewModel(analyzeBundle.GameInfo.Black); WhitePortrait = new PlayerPortraitViewModel(analyzeBundle.GameInfo.White); _ruleset = new ChineseRuleset(analyzeBundle.GameInfo.BoardSize); // Register tool services ToolServices = new GameToolServices(Localizer, dialogService, _ruleset, analyzeBundle.GameTree); ToolServices.NodeChanged += (s, node) => { AnalyzeToolsViewModel.OnNodeChanged(); RefreshBoard(node); GameTreeViewModel.SelectedGameTreeNode = node; GameTreeViewModel.RaiseGameTreeChanged(); }; ToolServices.PassSoundShouldBePlayed += ToolServices_PassSoundShouldBePlayed; ToolServices.StoneCapturesShouldBePlayed += ToolServices_StoneCapturesShouldBePlayed; ToolServices.StonePlacementShouldBePlayed += ToolServices_StonePlacementShouldBePlayed; Tool = null; BoardViewModel = new BoardViewModel(analyzeBundle.GameInfo.BoardSize); BoardViewModel.BoardTapped += (s, e) => OnBoardTapped(e); BoardViewModel.GameTreeNode = GameTree.GameTreeRoot; BoardViewModel.IsMarkupDrawingEnabled = true; BoardViewModel.IsShadowDrawingEnabled = true; // Initialize analyze mode and register tools BoardViewModel.ToolServices = ToolServices; ToolServices.Node = GameTree.GameTreeRoot; AnalyzeToolsViewModel = new AnalyzeToolsViewModel(ToolServices); AnalyzeToolsViewModel.CanGoBackToLiveGame = false; RegisterAnalyzeTools(); Tool = AnalyzeToolsViewModel.StonePlacementTool; AnalyzeToolsViewModel.SelectedTool = Tool; // Set up Timeline GameTreeViewModel = new GameTreeViewModel(GameTree); GameTreeViewModel.GameTreeSelectionChanged += (s, e) => { ToolServices.Node = e; RefreshBoard(e); AnalyzeToolsViewModel.OnNodeChanged(); }; GameTreeViewModel.SelectedGameTreeNode = GameTree.GameTreeRoot; }
public void CheckBlocks(List <Block> blocksList, IRuleset ruleset) { foreach (Block blockToCheck in blocksList) { blockToCheck.checkNeighbours(); } foreach (Block blockToCheck in blocksList) { blockToCheck.ToggleAlive(ruleset.CheckAlive(blockToCheck)); } }
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) { IRuleset ruleset = GetToolStripSeparatorRuleset(e.ToolStrip); Rectangle separatorRect = e.Vertical ? new Rectangle(e.Item.Width / 2, 4, 1, e.Item.Height - 8) : new Rectangle(0, e.Item.Height / 2, e.Item.Width, 1); styleRenderer.PaintBackground(e.Graphics, separatorRect, ruleset); styleRenderer.PaintBorder(e.Graphics, separatorRect, ruleset); }
private void PaintProgress(ProgressBar control, ControlPaintArgs args) { double progress = (double)control.Value / control.Maximum; IRuleset progressRuleset = GetProgressRuleset(control, args); Rectangle clientRect = control.ClientRectangle; Rectangle progressRect = new Rectangle(clientRect.X, clientRect.Y, (int)Math.Floor(clientRect.Width * progress), clientRect.Height); args.StyleRenderer.PaintBackground(args.Graphics, progressRect, progressRuleset); args.StyleRenderer.PaintBorder(args.Graphics, progressRect, progressRuleset); }
private void OnFileChanged(string fileContent) { var story = new Story("FileBasedStoryRulesetProvider.OnFileChanged", this.ruleset, notInContext: true); story.Start(); try { // Create a new instance of the C# compiler var compiler = new CSharpCodeProvider(); // Create some parameters for the compiler var parms = new CompilerParameters() { GenerateExecutable = false, GenerateInMemory = true, TreatWarningsAsErrors = false }; // Load assemblies from current domain foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { try { parms.ReferencedAssemblies.Add(assembly.Location); foreach (AssemblyName assemblyName in assembly.GetReferencedAssemblies()) { parms.ReferencedAssemblies.Add(Assembly.Load(assemblyName).Location); } } catch { } } // Try to compile the string into an assembly var results = compiler.CompileAssemblyFromSource(parms, fileContent); // Create ruleset if (results.Errors.Count == 0) { try { var rulesetType = results.CompiledAssembly.DefinedTypes.FirstOrDefault(definedType => definedType.GetInterfaces().Any(i => i == typeof(IRuleset<IStory, IStoryHandler>))); if (rulesetType != null) { var args = this.rulesetConstructorArgsProvider(); var newRuleset = results.CompiledAssembly.CreateInstance(rulesetType.FullName, false, BindingFlags.CreateInstance | BindingFlags.Instance | BindingFlags.Public, null, args, null, null) as IRuleset<IStory, IStoryHandler>; this.ruleset = newRuleset; story.Log.Info("Ruleset updated to {0}", rulesetType.Name); } else { Storytelling.Warn("Missing IRuleset<IStory, IStoryHandler>"); } } catch (Exception ex) { story.Log.Error(ex.ToString()); } } else { foreach (var error in results.Errors) { story.Log.Warn(error.ToString()); } } } finally { story.Stop(); } }
public StoryWorker(IStoryTransport storyTransport, IRuleset<IStory, IStoryHandler> handlerProvider) { this.storyTransport = storyTransport; this.handlerProvider = handlerProvider; }
public BasicStoryFactory(IRuleset<IStory, IStoryHandler> ruleset) { this.ruleset = ruleset; }
public BasicStoryRulesetProvider(IRuleset<IStory, IStoryHandler> ruleset) { this.ruleset = ruleset; }