/// <summary> /// Makes grid from attribute /// </summary> /// <param name="t">Entity for reflection</param> /// <param name="mode">Template render mode</param> /// <returns>Grid class</returns> public Grid Reflect(Type t, TemplateMode mode) { var attribute = (GridPropertiesAttribute)t.GetCustomAttribute(typeof(GridPropertiesAttribute)); if (attribute != null) { var grid = new Grid(attribute); var rows = new List<GridRow>(); foreach (var property in t.GetProperties()) { var rowAttribute = (RowDisplayAttribute)property.GetCustomAttribute(typeof(RowDisplayAttribute)); if (rowAttribute != null) { if (mode == TemplateMode.ExtendedDisplay || !rowAttribute.ExtendedView) { if (mode == TemplateMode.Edit && rowAttribute.ColumnEditType == GridColumnTypes.DropDown) { rows.Add(new GridRow(t.GetProperty(rowAttribute.DropdownPropertyName), rowAttribute, mode)); } else { rows.Add(new GridRow(property, rowAttribute, mode)); } } } } grid.Rows = rows.ToList(); return grid; } return null; }
public ScenarioFindReplaceResultsForm(FindReplaceScriptEditor find_replaceScriptEditor) { InitializeComponent(); this.find_replaceScriptEditor = find_replaceScriptEditor; this.SelectRecordCondition = find_replaceScriptEditor.SelectRecordCondition; this.SelectFieldCondition = find_replaceScriptEditor.SelectFieldCondition; this.SelectSubfieldCondition = find_replaceScriptEditor.SelectSubfieldCondition; this.FindTextStr = find_replaceScriptEditor.FindTextString; this.ReplaceTextStr = find_replaceScriptEditor.ReplaceTextString; workMode = (WorkMode)find_replaceScriptEditor.activeTabIndex; templateMode = (TemplateMode)find_replaceScriptEditor.cmbTemplateType.SelectedIndex; applyActions = new StringCollection(); applyActions.Add("ПОДТВЕРДИТЬ"); applyActions.Add("ОТМЕНИТЬ"); applyActionsToAll = new StringCollection(); applyActionsToAll.Add("ПОДТВЕРДИТЬ ВСЕ"); applyActionsToAll.Add("ОТМЕНИТЬ ВСЕ"); ScriptEngine = new EcmaScriptComponent(); RemObjectUtils.ExposeAssembly(ScriptEngine, typeof(ManagedClient.ManagedClient64).Assembly); ScriptEngine.Globals.SetVariable("client", find_replaceScriptEditor.client); ScriptEngine.Globals.SetVariable("curDatabase", find_replaceScriptEditor.curDatabase); }
public TemplateService(TemplateMode mode) { switch (mode) { case TemplateMode.Standard: Initialize("<%=", "<%", "%>"); break; case TemplateMode.HtmlEscaped: Initialize("<%=", "<%", "%>"); break; default: break; } }
/// <summary> /// Render grid /// </summary> /// <param name="t">Grid to render</param> /// <param name="entities">Entities for render</param> /// <param name="mode">Template render mode</param> /// <param name="sorting">Grid sorting</param> /// <returns>Rendered grid as string</returns> public string Render(Type t, PagingCollection<object> entities, TemplateMode mode, GridSorting sorting) { var grid = this.reflector.Reflect(t, mode); if (sorting != null) { grid.Sorting = sorting; } grid.Rows = grid.Rows.OrderBy(r => r.Order).ToList(); var headerRender = this.RenderHeader(grid); var bodyRender = this.RenderBody(grid, entities.CurrentPageCollection.ToList()); return string.Format("<div class=\"enable-grid-hor-overflow\"><table class=\"table table-bordered entity-grid dataTable\">{0}{1}</table></div>{2}", headerRender, bodyRender, this.RenderPaginanation(entities)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is TemplateMode) { TemplateMode templateMode = (TemplateMode)value; if (templateMode == TemplateMode.FileNameBased) { return("Visible"); } return("Collapsed"); } throw new ArgumentException("Value to convert is not a TemplateMode."); }
private IList <ReferencedFile> GetReferencedFiles( HashSet <string> discoveredPaths, IFrameworkDefinition definition, string textToParse, string currentFilePath, ChutzpahTestSettingsFile chutzpahTestSettings) { var referencedFiles = new List <ReferencedFile>(); Regex regex = RegexPatterns.JsReferencePathRegex; foreach (Match match in regex.Matches(textToParse)) { if (!ShouldIncludeReference(match)) { continue; } string referencePath = match.Groups["Path"].Value; ProcessFilePathAsReference( discoveredPaths, definition, currentFilePath, chutzpahTestSettings, referencePath, referencedFiles, new ReferencePathSettings()); } foreach (Match match in RegexPatterns.JsTemplatePathRegex.Matches(textToParse)) { string referencePath = null, templateId = null, templateType = null; TemplateMode templateMode = TemplateMode.Raw; for (var i = 0; i < match.Groups["PropName"].Captures.Count; i++) { var propName = match.Groups["PropName"].Captures[i].Value.ToLowerInvariant(); var propValue = match.Groups["PropValue"].Captures[i].Value; switch (propName) { case "path": referencePath = propValue; break; case "id": templateId = propValue; break; case "type": templateType = propValue; break; case "mode": if (propValue.Equals("script", StringComparison.OrdinalIgnoreCase)) { templateMode = TemplateMode.Script; } break; default: break; } } referencePath = AdjustPathIfRooted(chutzpahTestSettings, referencePath); string relativeReferencePath = Path.Combine(Path.GetDirectoryName(currentFilePath), referencePath); string absoluteFilePath = fileProbe.FindFilePath(relativeReferencePath); if (referencedFiles.All(r => r.Path != absoluteFilePath)) { ChutzpahTracer.TraceInformation("Added html template '{0}' to referenced files", absoluteFilePath); referencedFiles.Add(new ReferencedFile { Path = absoluteFilePath, IsLocal = false, IncludeInTestHarness = true, TemplateOptions = new TemplateOptions { Mode = templateMode, Id = templateId, Type = templateType } }); } } return(referencedFiles); }
/// <summary> /// Initializes a new instance of the <see cref="GridRow"/> class. /// </summary> /// <param name="targetProperty">property to render in row</param> /// <param name="attribute">Property attribute</param> /// <param name="mode">Template mode</param> public GridRow(PropertyInfo targetProperty, RowDisplayAttribute attribute, TemplateMode mode) { this.RowProperty = targetProperty; this.ColumnName = attribute.ColumnName; this.IsKey = attribute.IsKey; this.ColumnType = mode == TemplateMode.Edit ? attribute.ColumnEditType : attribute.ColumnDisplayType; this.ColumnWidth = attribute.ColumnWidth; this.IsHidden = attribute.IsHidden; this.IsSortable = attribute.IsSortable; this.NonBordered = attribute.NonBordered; this.ColumnStringFormat = attribute.ColumnStringFormat; this.Order = attribute.Order; this.DataField = attribute.DataField; this.ModelField = attribute.ModelField; switch (this.ColumnType) { case GridColumnTypes.Base: { this.RenderTemplate = new BaseTemplate(this.RowProperty, this.ColumnStringFormat); break; } case GridColumnTypes.Input: { this.RenderTemplate = new InputTemplate(this.RowProperty, this.ColumnStringFormat); break; } case GridColumnTypes.PercentInput: { this.RenderTemplate = new PercentInputTemplate(this.RowProperty, this.ColumnStringFormat); break; } case GridColumnTypes.Boolean: { this.RenderTemplate = new BooleanTemplate(this.RowProperty, this.ColumnStringFormat); break; } case GridColumnTypes.CheckBox: { this.RenderTemplate = new CheckBoxTemplate(this.RowProperty, this.ColumnStringFormat); break; } case GridColumnTypes.Date: { this.RenderTemplate = new DateTemplate(this.RowProperty, this.ColumnStringFormat); break; } case GridColumnTypes.Calendar: { this.RenderTemplate = new CalendarTemplate(this.RowProperty, this.ColumnStringFormat); break; } case GridColumnTypes.DropDown: { this.RenderTemplate = new DropDownTemplate(this.RowProperty, this.ColumnStringFormat); break; } case GridColumnTypes.Link: { this.RenderTemplate = new LinkTemplate(this.RowProperty, this.ColumnStringFormat); break; } case GridColumnTypes.None: { this.RenderTemplate = new EmptyTemplate(this.RowProperty, this.ColumnStringFormat); break; } } }
public Context(TemplateMode mode, string spaces) { this.mode = mode; this.spaces = spaces; }
public Context(TemplateMode mode, string spaces) { this.mode = mode; this.spaces = spaces; }