public Label CreateNotificationVisualElement( string text, params string[] additionalTextClasses) { if (uiDocument == null) { return(null); } VisualElement notificationOverlay = uiDocument.rootVisualElement.Q <VisualElement>("notificationOverlay"); if (notificationOverlay == null) { notificationOverlay = notificationOverlayVisualTreeAsset.CloneTree() .Children() .First(); uiDocument.rootVisualElement.Children().First().Add(notificationOverlay); } TemplateContainer templateContainer = notificationVisualTreeAsset.CloneTree(); VisualElement notification = templateContainer.Children().First(); Label notificationLabel = notification.Q <Label>("notificationLabel"); notificationLabel.text = text; if (additionalTextClasses != null) { additionalTextClasses.ForEach(className => notificationLabel.AddToClassList(className)); } notificationOverlay.Add(notification); // Fade out then remove StartCoroutine(FadeOutVisualElement(notification, 2, 1)); return(notificationLabel); }
/// <summary> /// Iterates the specified container. /// </summary> /// <param name="container">The container.</param> public void Iterate(TemplateContainer container) { foreach (TemplateRule rule in this.Rules) { rule.Iterate(container); } }
//---------------------------------------------------------------------------------------------------------------------- private PopupField <T> AddPlayerConfigPopupField <T>(VisualTreeAsset template, VisualElement parent, GUIContent content, List <T> options, Action <MeshSyncPlayerConfig, int> onValueChanged) { TemplateContainer templateInstance = template.CloneTree(); VisualElement fieldContainer = templateInstance.Query <VisualElement>("FieldContainer").First(); PopupField <T> popupField = new PopupField <T>(options, options[0]); popupField.AddToClassList("general-settings-field"); Label label = templateInstance.Query <Label>().First(); label.text = content.text; label.tooltip = content.tooltip; popupField.RegisterValueChangedCallback((ChangeEvent <T> changeEvent) => { MeshSyncPlayerConfig config = popupField.userData as MeshSyncPlayerConfig; if (null == config) { Debug.LogError("[MeshSync] Toggle doesn't have the correct user data"); return; } onValueChanged(config, popupField.index); MeshSyncRuntimeSettings.GetOrCreateSettings().SaveSettings(); }); fieldContainer.Add(popupField); parent.Add(templateInstance); m_playerConfigUIElements.Add(popupField); return(popupField); }
/// <summary> /// Creates any child controls necessary to render the field /// </summary> protected override void CreateChildControls() { base.CreateChildControls(); treeViewSelectedValues = new HiddenField(); treeViewSelectedValues.EnableViewState = true; this.Controls.Add(treeViewSelectedValues); if (this.ControlMode != SPControlMode.Display) { objTreeView = (System.Web.UI.WebControls.TreeView)TemplateContainer.FindControl(GlobalConstants.TREEVIEW_CONTROL_NAME_TREEVIEWTechPerspect); objTreeView.Enabled = true; lblExptnMsg = (Label)TemplateContainer.FindControl("lblExptnMsg"); this.Page.ClientScript.RegisterClientScriptInclude("CheckChild", GlobalConstants.TREEVIEW_JS_PATH); objTreeView.Attributes.Add("onclick", "OnTreeClick(event);"); } else { objTreeView = new System.Web.UI.WebControls.TreeView(); objTreeView.Enabled = true; this.Controls.Add(objTreeView); lblExptnMsg = new Label(); lblExptnMsg.Text = string.Empty;; lblExptnMsg.ForeColor = System.Drawing.Color.Red; this.Controls.Add(lblExptnMsg); } }
/// <summary> /// Executes the specified container. /// </summary> /// <param name="container">The container.</param> public void Execute(TemplateContainer container) { foreach (TemplateAction action in this.Actions) { action.Execute(container); } }
/// <summary> /// 收集相关信息 /// </summary> /// <param name="guid"></param> /// <param name="allowNew">是否需要创建项目</param> /// <returns></returns> public override object[] GetGenerateInfo(string guid, bool allowNew) { //找到项目源 string pid = CdeCmdId.BelongId(guid); Project prjt = TemplateContainer.Resove <Project>(pid); if (prjt == null && allowNew) { string pname = PrjCmdId.FindProjectName(pid); if (pid != "06D57C23-4D51-430D-A8E6-9A19F38390E3") { prjt = CommonContainer.CommonServer.AddClassLibrary(pname); } else { prjt = CommonContainer.CommonServer.AddWebService(pname); } TemplateContainer.Regist(pid, prjt); } string templatePath = Path.Combine(CommonContainer.RootPath, TemplateContainer.Resove <string>(guid)); return(new object[] { guid, pid, prjt, templatePath }); }
protected static int Generate(GenerateOptions options) { System.Console.WriteLine($"Generating file {options.Destination} based on {options.Source}."); //Parse the model var container = new ParserContainer(); container.Initialize(Path.GetExtension(options.Source)); var modelFactory = new ModelFactory(); var collection = modelFactory.Instantiate(options.Source, container); var types = collection.Select(o => o.GetType()).Distinct(); //Render the template foreach (var type in types) { var templateContainer = new TemplateContainer(); templateContainer.Initialize(); var templateFactory = templateContainer.Retrieve(type); var engine = templateFactory.Instantiate(string.Empty, false, options.Template); var objects = collection.Where(o => o.GetType() == type); var text = engine.Execute(objects); File.WriteAllText(options.Destination, text); } return(0); }
private void InitializeLayout() { VisualTreeAsset layout = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/OTGCombatSystem/Editor/CombatSM/MainEditor/CombatSMEditorWindow.uxml"); TemplateContainer treeAsset = layout.CloneTree(); rootVisualElement.Add(treeAsset); }
private static void AddComponentSyncSettingFields(VisualElement parent, GUIContent content, ComponentSyncSettings componentSyncSettings) { VisualTreeAsset template = UIElementsEditorUtility.LoadVisualTreeAsset( Constants.COMPONENT_SYNC_FIELDS_TEMPLATE_PATH); TemplateContainer templateInstance = template.CloneTree(); VisualElement fieldContainer = templateInstance.Query <VisualElement>("FieldContainer").First(); Label label = templateInstance.Query <Label>().First(); label.text = content.text; label.tooltip = content.tooltip; Toggle createToggle = templateInstance.Query <Toggle>("CreateToggle").First(); Assert.IsNotNull(createToggle); createToggle.SetValueWithoutNotify(componentSyncSettings.CanCreate); createToggle.RegisterValueChangedCallback((ChangeEvent <bool> changeEvent) => { componentSyncSettings.CanCreate = changeEvent.newValue; }); Toggle updateToggle = templateInstance.Query <Toggle>("UpdateToggle").First(); Assert.IsNotNull(updateToggle); updateToggle.SetValueWithoutNotify(componentSyncSettings.CanUpdate); updateToggle.RegisterValueChangedCallback((ChangeEvent <bool> changeEvent) => { componentSyncSettings.CanUpdate = changeEvent.newValue; }); parent.Add(fieldContainer); }
public void CreateGUI() { // Each editor window contains a root VisualElement object VisualElement root = rootVisualElement; // Import UXML var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Packages/com.litefeel.renametools/Editor/RenameWindow.uxml"); m_RootTree = visualTree.CloneTree(); root.Add(m_RootTree); m_NameTF = m_RootTree.Q <TextField>("nameTxt"); m_NameTF.isDelayed = true; m_NameTI = m_NameTF.Q(TextField.textInputUssName); m_NameTI.RegisterCallback <KeyUpEvent>(e => { m_TemplateName = m_NameTF.text; UpdateChangeInfo(); }); m_NameTI.RegisterCallback <KeyDownEvent>(e => { if (e.keyCode == KeyCode.KeypadEnter) { m_NameTI.Focus(); DoRename(); } }); m_RootTree.Q <Button>("renameBtn").RegisterCallback <MouseUpEvent>(evt => { m_NameTI.Focus(); DoRename(); }); m_CountTxt = m_RootTree.Q <TextElement>("countTxt"); m_CountTxt.text = "count:0"; }
/// <summary> /// 执行上下文 /// </summary> public void Commit() { while (_rEntityQueue.Count() > 0) { ReferenceEntity queue = _rEntityQueue.Dequeue(); try { Project proj = TemplateContainer.Resove <Project>(queue.ProjectId); List <string> refers = queue.ReferenceCollection; if (refers != null && refers.Count > 0) { refers.ForEach(t => { proj.AddReferByKey(t); }); } } catch (Exception ex) { MsgBoxHelp.ShowError(string.Format(Properties.Resource.ReferError, PrjCmdId.FindProjectName(queue.ProjectId)), ex); } finally { if (HandledOne != null) { HandledOne(this, new EventHandledArg(queue.ProjectId, Count)); } } } }
protected override void CreateChildControls() { Controls.Clear(); Control blockMarkup = Page.LoadControl("~/UserControls/Block.ascx"); _headerPlaceholder = blockMarkup.FindControl("HeaderPlaceholder") as PlaceHolder; _contentPlaceholder = blockMarkup.FindControl("ContentPlaceholder") as PlaceHolder; _headerPlaceholder.Visible = !String.IsNullOrEmpty(_caption); if (_headerPlaceholder.Visible) { Literal caption = new Literal(); caption.Text = _caption; _headerPlaceholder.Controls.Add(caption); } if (_contentTemplate != null) { TemplateContainer container = new TemplateContainer(); _contentTemplate.InstantiateIn(container); _contentPlaceholder.Controls.Add(container); } Controls.Add(blockMarkup); }
/// <summary> /// 通过关键字来添加项目引用 /// </summary> /// <param name="project"></param> /// <param name="referId">项目ID,系统类库或者资源类库</param> public static void AddReferByKey(this Project project, string referId) { try { if (referId.Count() == 36) { Project referProject = TemplateContainer.Resove <Project>(referId); if (referProject != null) { project.AddReferenceFromProject(referProject); return; } } string[] files = Directory.GetFiles(CommonContainer.RootPath, "*.dll"); if (files != null) { Array.ForEach(files, t => { if (t.Contains(referId)) { project.AddReference(t); return; } }); } project.AddReference(referId); } catch (Exception ex) { MsgBoxHelp.ShowError(string.Format(Properties.Resource.ReferError, referId), ex); } }
///############################################################ /// <summary> /// Renders the control to the specified HTML writer. /// </summary> /// <param name="writer">The System.Web.UI.HtmlTextWriter object that recieves the control content.</param> ///############################################################ /// <LastUpdated>March 19, 2010</LastUpdated> protected override void Render(HtmlTextWriter writer) { TemplateContainer oTemplateContainer; //#### .Write out the .GenerateCSS writer.Write("<style>" + g_oInputCollection.GenerateCSS() + "</style>"); //#### If we are to .DisplayErrorMessagesViaJavaScript, .write out the .ValidationJavaScript to manage the g_oInputs if (g_oInputCollection.DisplayErrorMessagesViaJavaScript) { writer.Write(g_oInputCollection.ValidationJavaScript("", "", "", true)); } //#### If the g_oTemplate_Form has been defined by the developer if (g_oTemplate_Form != null) { //#### Set the oTemplateContainer based on the g_oDataSource, assoicate it with the g_oTemplate_Form then .Add the oTemplateContainer into our Controls //! NEEK this is not really a .cnDetail! oTemplateContainer = new TemplateContainer(g_oDataSource, -1, 1, Cn.Web.Renderer.enumPageSections.cnDetail); g_oTemplate_Form.InstantiateIn(oTemplateContainer); Controls.Add(oTemplateContainer); //#### Now pass the call off to the base implementation (which will render the g_oTemplate_Form) base.Render(writer); } }
/// <summary> /// 初始化 /// </summary> protected virtual void Init() { SetSize(); // this.position = ContextRect; UIStyles.Init(); if (!EditorUI.GetVisualTreeAsset(mUXML, out mVisualTree)) { UpdateNotification("编辑器描述文件读取失败"); return; } if (!string.IsNullOrEmpty(mUSS)) { if (!EditorUI.GetStyleSheet(mUSS, out mCommonStyle)) { UpdateNotification("通用样式读取失败"); return; } } mContainer = mVisualTree.CloneTree(); mRoot = rootVisualElement; /** 不能初始化直接add ToolbarMenu后续事件无法添加 * mRoot.Add(mContainer); * if(mCommonStyle != null) * { * mContainer.styleSheets.Add(mCommonStyle); * } */ CustomInit(); }
/// <summary> /// Executes the specified container. /// </summary> /// <param name="container">The container.</param> public void Execute(TemplateContainer container) { string source = JavascriptEvaluator.ReplaceString(this.Source, container); string target = JavascriptEvaluator.ReplaceString(this.Target, container); string actionType = this.ActionType.ToLower(); if (actionType.Equals("createfolder")) { this.CreateFolder(target); } else if (actionType.Equals("deletefolder")) { this.DeleteFolder(target); } else if (actionType.Equals("copyfile")) { this.CopyFile(source, target); } else if (actionType.Equals("copyfileavoid")) { this.CopyFileAvoid(source, target); } else if (actionType.Equals("deletefile")) { this.DeleteFile(target); } else if (actionType.Equals("transform")) { this.Transform(container, source, target); } else if (actionType.Equals("transformavoid")) { this.TransformAvoid(container, source, target); } }
protected override void CreateChildControls() { if (this.Field != null) { // Make sure inherited child controls are completely rendered. base.CreateChildControls(); // Associate child controls in the .ascx file with the // fields allocated by this control. this.ISBNPrefix = (Label)TemplateContainer.FindControl("ISBNPrefix"); this.textBox = (TextBox)TemplateContainer.FindControl("TextField"); this.ISBNValueForDisplay = (Label)TemplateContainer.FindControl("ISBNValueForDisplay"); if (this.ControlMode != SPControlMode.Display) { if (!this.Page.IsPostBack) { if (this.ControlMode == SPControlMode.New) { textBox.Text = "0-000-00000-0"; } // end assign default value in New mode } // end if this is not a postback // Do not reinitialize on a postback. } // end if control mode is not Display else // control mode is Display { // Assign current value from database to the label control ISBNValueForDisplay.Text = (String)this.ItemFieldValue; } // end control mode is Display } // end if there is a non-null underlying ISBNField // Do nothing if the ISBNField is null. }
public void AddTemplate(TemplateContainer template, Vector2I position) { CellOffset[] array = new CellOffset[template.cells.Count]; for (int i = 0; i < template.cells.Count; i++) { array[i] = new CellOffset(template.cells[i].location_x, template.cells[i].location_y); } ClearTemplatesInArea(Grid.XYToCell(position.x, position.y), array); for (int j = 0; j < template.buildings.Count; j++) { buildings.Add((Prefab)template.buildings[j].Clone(position)); } for (int k = 0; k < template.pickupables.Count; k++) { pickupables.Add((Prefab)template.pickupables[k].Clone(position)); } for (int l = 0; l < template.elementalOres.Count; l++) { elementalOres.Add((Prefab)template.elementalOres[l].Clone(position)); } for (int m = 0; m < template.otherEntities.Count; m++) { otherEntities.Add((Prefab)template.otherEntities[m].Clone(position)); } for (int n = 0; n < template.cells.Count; n++) { preventFoWReveal.Add(new KeyValuePair <Vector2I, bool>(new Vector2I(position.x + template.cells[n].location_x, position.y + template.cells[n].location_y), template.cells[n].preventFoWReveal)); } }
/// <summary> /// Transforms the avoid. /// </summary> /// <param name="container">The container.</param> /// <param name="source">The source.</param> /// <param name="target">The target.</param> private void TransformAvoid(TemplateContainer container, string source, string target) { if (!File.Exists(target)) { this.Transform(container, source, target); } }
// ######################## FUNCTIONALITY ######################## // #region FUNCTIONALITY /// <summary> /// Adds a new asset or folder to the list /// </summary> /// <param name="folder"></param> private void AddAsset(bool folder) { // if the specified path is invalid, return string path = ValidatePath( folder ? EditorUtility.OpenFolderPanel("Select a location", Application.dataPath, "") : EditorUtility.OpenFilePanel("Select a location", Application.dataPath, ""), ""); if (path == string.Empty) { return; } // add a new element serializedObject.Update(); SerializedProperty pathsProperty = serializedObject.FindProperty("_paths"); ++pathsProperty.arraySize; SerializedProperty pathProperty = pathsProperty.GetArrayElementAtIndex(pathsProperty.arraySize - 1); pathProperty.stringValue = path; serializedObject.ApplyModifiedProperties(); TemplateContainer assetElement = AddAssetElement(); TextElement assetPathDisplay = assetElement.Q <TextElement>("assetPathDisplay"); assetPathDisplay.text = path; }
protected override void CreateChildControls() { Controls.Clear(); Control articleMarkup = Page.LoadControl("~/Pages/Modulos/Cliente/Reportes/MasterPageV2/design/Article.ascx"); _headerPlaceholder = articleMarkup.FindControl("HeaderPlaceholder") as PlaceHolder; _contentPlaceholder = articleMarkup.FindControl("ContentPlaceholder") as PlaceHolder; _headerPlaceholder.Visible = !String.IsNullOrEmpty(_caption); if (_headerPlaceholder.Visible) { Literal caption = new Literal(); caption.Text = _caption; _headerPlaceholder.Controls.Add(caption); } if (_contentTemplate != null) { TemplateContainer container = new TemplateContainer(); _contentTemplate.InstantiateIn(container); _contentPlaceholder.Controls.Add(container); } Controls.Add(articleMarkup); }
protected override void CreateChildControls() { Controls.Clear(); Control articleMarkup = Page.LoadControl("~/Design/Article.ascx"); _headerPlaceholder = articleMarkup.FindControl("HeaderPlaceholder") as PlaceHolder; _contentPlaceholder = articleMarkup.FindControl("ContentPlaceholder") as PlaceHolder; _headerPlaceholder.Visible = ! String.IsNullOrEmpty(_caption); if (_headerPlaceholder.Visible) { Literal caption = new Literal(); caption.Text = _caption; _headerPlaceholder.Controls.Add(caption); } if (_contentTemplate != null) { TemplateContainer container = new TemplateContainer(); _contentTemplate.InstantiateIn(container); _contentPlaceholder.Controls.Add(container); } Controls.Add(articleMarkup); }
/// <summary> /// Iterates the specified container. /// </summary> /// <param name="container">The container.</param> /// <exception cref="System.ArgumentException">The iterator + this.Iterator + is not a valid container</exception> public void Iterate(TemplateContainer container) { object pathItem = string.IsNullOrEmpty(this.Iterator) ? container : container.GetByPath(this.Iterator); if ((pathItem != null) && (pathItem is TemplateContainer)) { TemplateContainer root = (TemplateContainer)pathItem; if (root.IsList) { string maxIteratorIndex = (root.ArrayValues.Count - 1).ToString(); for (int i = 0; i < root.ArrayValues.Count; i++) { TemplateContainer son = root.ArrayValues[i]; son.AddAttribute("IteratorIndex", i.ToString()); son.AddAttribute("MaxIteratorIndex", maxIteratorIndex); son.AddAttribute("IsIteratorFirst", i == 0); son.AddAttribute("IsIteratorLast", i == root.ArrayValues.Count - 1); this.Execute(son); } } else { this.Execute(root); } } else { throw new ArgumentException("The iterator " + this.Iterator + " is not a valid container"); } }
//---------------------------------------------------------------------------------------------------------------------- public void Setup(VisualElement root) { VisualTreeAsset tab = UIElementsEditorUtility.LoadVisualTreeAsset(Constants.SCENE_CACHE_PLAYER_SETTINGS_TAB_PATH); TemplateContainer tabInstance = tab.CloneTree(); VisualElement content = tabInstance.Query <VisualElement>("Content").First(); m_generatedSCResPathTextField = tabInstance.Query <TextField>("GeneratedSCResPathText").First(); m_generatedSCResPathTextField.RegisterValueChangedCallback((ChangeEvent <string> changeEvent) => { MeshSyncRuntimeSettings settings = MeshSyncRuntimeSettings.GetOrCreateSettings(); settings.SetSceneCacheOutputPath(changeEvent.newValue); settings.SaveSettings(); }); m_outputPathSelectButton = tabInstance.Query <Button>("OutputPathSelectButton").First(); m_outputPathSelectButton.clicked += OnOutputPathSelectButtonClicked; RefreshSettings(); //MeshSyncPlayerConfig MeshSyncPlayerConfigSection section = new MeshSyncPlayerConfigSection(MeshSyncPlayerType.CACHE_PLAYER); section.Setup(content); root.Add(tabInstance); }
//---------------------------------------------------------------------------------------------------------------------- //Support Toggle, FloatField, etc private F AddPlayerConfigField <F, V>(VisualTreeAsset template, VisualElement parent, GUIContent content, Action <MeshSyncPlayerConfig, V> onValueChanged) where F : VisualElement, INotifyValueChanged <V>, new() { TemplateContainer templateInstance = template.CloneTree(); VisualElement fieldContainer = templateInstance.Query <VisualElement>("FieldContainer").First(); // F field = templateInstance.Query<F>().First(); Label label = templateInstance.Query <Label>().First(); label.text = content.text; label.tooltip = content.tooltip; F field = new F(); field.AddToClassList("general-settings-field"); field.RegisterValueChangedCallback((ChangeEvent <V> changeEvent) => { MeshSyncPlayerConfig config = field.userData as MeshSyncPlayerConfig; if (null == config) { Debug.LogError("[MeshSync] Field doesn't have the correct user data"); return; } onValueChanged(config, changeEvent.newValue); MeshSyncRuntimeSettings.GetOrCreateSettings().SaveSettings(); }); fieldContainer.Add(field); parent.Add(templateInstance); m_playerConfigUIElements.Add(field); return(field); }
public void Execute(TemplateContainer container) { foreach (TemplateAction action in this.Actions) { action.Execute(container); } }
/// <summary> /// 初始化页面 /// </summary> public void InitViewer() { // 加载布局文件 _visualAsset = EditorHelper.LoadWindowUXML <DebuggerAssetListViewer>(); if (_visualAsset == null) { return; } _root = _visualAsset.CloneTree(); _root.style.flexGrow = 1f; // 资源列表 _assetListView = _root.Q <ListView>("TopListView"); _assetListView.makeItem = MakeAssetListViewItem; _assetListView.bindItem = BindAssetListViewItem; #if UNITY_2020_1_OR_NEWER _assetListView.onSelectionChange += AssetListView_onSelectionChange; #else _assetListView.onSelectionChanged += AssetListView_onSelectionChange; #endif // 依赖列表 _dependListView = _root.Q <ListView>("BottomListView"); _dependListView.makeItem = MakeDependListViewItem; _dependListView.bindItem = BindDependListViewItem; }
protected override void CreateChildControls() { if (this.Field != null && this.ControlMode != SPControlMode.Display) { if (!this.ChildControlsCreated) { CustomDropDownList field = this.Field as CustomDropDownList; base.CreateChildControls(); /* * MultiLookupPicker = (GroupedItemPicker)TemplateContainer.FindControl("MultiLookupPicker"); * * BuildAvailableItems(ref MultiLookupPicker); * * SelectCandidate = (SPHtmlSelect)TemplateContainer.FindControl("SelectCandidate"); * SelectResult = (SPHtmlSelect)TemplateContainer.FindControl("SelectResult"); * * AddButton = (HtmlButton)TemplateContainer.FindControl("AddButton"); * RemoveButton = (HtmlButton)TemplateContainer.FindControl("RemoveButton"); */ left_box = (ListBox)TemplateContainer.FindControl("LeftBox"); if (left_box.Attributes["done"] == null) { BuildAvailableItems(ref left_box); } right_box = (ListBox)TemplateContainer.FindControl("RightBox"); add_button = (Button)TemplateContainer.FindControl("AddButton"); add_button.Click += new EventHandler(add_button_Click); remove_button = (Button)TemplateContainer.FindControl("RemoveButton"); remove_button.Click += new EventHandler(remove_button_Click); } } }
//draw the parsed information private void DrawChangeLog(List <string> content) { int currentVersionCount = -1; var builder = new StringBuilder(); var firstTitle = true; var regexLine = new Regex("^\\* (.*)$"); var regexBold = new Regex("\\*\\*(.*)\\*\\*"); for (int i = 0; i < content.Count; i++) { string item = content[i]; //if the item is a version if (item.Contains("# [") || item.Contains("## [")) { currentVersionCount++; TemplateContainer newLog = _changeLogTemplate.CloneTree(); newLog.Q <Label>("ChangeLogVersion").text = $"Version {item.Split(new[] { "[" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(new[] { "]" }, StringSplitOptions.RemoveEmptyEntries)[0]}"; rootVisualElement.Q <VisualElement>("ChangelogData").Add(newLog); builder = new StringBuilder(); firstTitle = true; } //if the item is a change title else if (item.Contains("###")) { //only add a space above the title if it isn't the first title if (!firstTitle) { builder.Append("\n"); } #if UNITY_2021_2_OR_NEWER string subTitle = $"<b>{item.Substring(4)}</b>"; #else string subTitle = item.Substring(4); #endif builder.Append(subTitle); builder.Append("\n"); firstTitle = false; } //if the item is a change else { string change = item.Split(new string[] { "([" }, StringSplitOptions.None)[0]; change = regexLine.Replace(change, "- $1\n"); change = regexBold.Replace(change, BoldReplace); builder.Append(change); } rootVisualElement.Q <VisualElement>("ChangelogData").ElementAt(currentVersionCount).Q <Label>("ChangeLogText").text = builder.ToString(); } }
protected override void CreateChildControls() { if(Content != null) { _container = new TemplateContainer(); Content.InstantiateIn(_container); Controls.Add(_container); } }
private void BuildDomains(TemplateContainer node) { foreach (MetaDomain domain in model.Domains) { TemplateContainer arrnode = node.AddArrayValue(domain.Id.ToString()); arrnode.AddFromObject(domain); } }
public static void ShouldBeABleToTellIfATemplateContainerIsAValidTemplateContainerModel() { //Arrange var templateContainer = new TemplateContainer(new Template()); //Act //Assert Assert.IsAssignableFrom<TemplateContainer<DataElement>>(templateContainer); }
public static void ShouldBeAbleToCheckTheEqualityBetweenTheSameTemplateContainer() { //Arrange var templateContainer = new TemplateContainer(new Template()); //Act //Assert Assert.Equal(templateContainer, templateContainer); }
protected virtual void CreateSearchResultSummaryControl() { TemplateContainer.Add( SRSummaryControl = new ASPxLabel() ); SRSummaryControl.ID = Grid.GetSRSummaryControlID(); }
//Evento para la carga del Template para la condiguracion del Grid. void CreateEditAddressTemplate(Object sender, Obout.Grid.GridRuntimeTemplateEventArgs e) { Literal oLiteral = new Literal(); e.Container.Controls.Add(oLiteral); c = e.Container; oLiteral.DataBinding += new EventHandler(DataBindEditAddressTemplate); }
public static void ShouldBeAbleToTellTwoDifferentTemplateContainers() { //Arrange var templateContainer1 = new TemplateContainer(new Template()); var templateContainer2 = new TemplateContainer(new Template()); //Act //Assert Assert.NotEqual(templateContainer1, templateContainer2); }
protected virtual TemplateContainer CreateTemplateContainer(SPField field) { TemplateContainer templateContainer = new TemplateContainer(); //templateContainer.ControlMode = base.ControlMode; PropertyInfo ControlMode = typeof(TemplateContainer).GetProperty("ControlMode", BindingFlags.NonPublic | BindingFlags.Instance); ControlMode.SetValue(templateContainer, base.ControlMode); //templateContainer.FieldName = field.InternalName; PropertyInfo FieldName = typeof(TemplateContainer).GetProperty("FieldName", BindingFlags.NonPublic | BindingFlags.Instance); FieldName.SetValue(templateContainer, field.InternalName); return templateContainer; }
public static void ShouldBeAbleToCheckTheEqualityBetweenTwoTemplateContainersWithTheSameValues() { //Arrange var templateContainer1 = new TemplateContainer(new Template()); var templateContainer2 = new TemplateContainer(new Template()); //Act //Assert Assert.Equal(templateContainer1, templateContainer1); }
public static void ShouldBeABleToCreateANewCollectionWithDefaultProperties() { //Arrange var templateContainer = new TemplateContainer(new Template()); //Act //Assert Assert.NotNull(templateContainer); Assert.NotNull(templateContainer.Template); Assert.Empty(templateContainer.Template.Data); }
/// <summary> /// Runs the script given in variable s, and returns a string result. /// </summary> /// <param name="s">The s.</param> /// <param name="container">The container.</param> /// <returns></returns> public static string ReplaceString(string s, TemplateContainer container) { dynamic result = RunScript(s, container); if (result is string) { return (string)result; } else { return result.ToString(); } }
public void Execute(TemplateContainer container) { string source = LanguageParser.ReplaceString(this.Source, container); string target = LanguageParser.ReplaceString(this.Target, container); string actionType = this.ActionType.ToLower(); if (actionType.Equals("deleteall")) { this.DeleteAll(target); } if (actionType.Equals("createfolder")) { this.CreateFolder(target); } else if (actionType.Equals("deletefolder")) { this.DeleteFolder(target); } else if (actionType.Equals("copyfile")) { this.CopyFile(source, target); } else if (actionType.Equals("copyfileavoid")) { this.CopyFileAvoid(source, target); } else if (actionType.Equals("deletefile")) { this.DeleteFile(target); } else if (actionType.Equals("transform")) { this.Transform(container, source, target); } else if (actionType.Equals("transformavoid")) { this.TransformAvoid(container, source, target); } }
public ASPLTemplateContainer() { this._templateContainer = new TemplateContainer(); }
private string GetLowGuid(ParserToken token, TemplateContainer container) { return GetGuid(token, container).ToLower(); }
private string Camelize2(ParserToken token, TemplateContainer container) { string result = ""; string value = this.EvaluateParameter(container, token.Parameters[0]); for (int i = 0; i < value.Length; i++) { char c = value[i]; if (i == 0) { result = result + char.ToLower(c); } else { result = result + c; } } return result; }
/// <summary> /// Evaluates the string parsing it, and then the value using the template container. /// </summary> /// <param name="str">The string.</param> /// <param name="container">The container.</param> /// <returns></returns> private string Evaluate(string str, TemplateContainer container) { builder.Clear(); ParserToken rootToken = this.Parse(str); this.Visit(container, rootToken); return builder.ToString(); }
protected internal override void CreateChildControls () { Controls.Clear (); TemplateContainer container = new TemplateContainer (); Controls.Add (container); if (Template != null) Template.InstantiateIn (container); }
private string GetGuid(ParserToken token, TemplateContainer container) { string value = this.EvaluateParameter(container, token.Parameters[0]); if (guidMap.ContainsKey(value)) { return guidMap[value]; } else { string guid = Guid.NewGuid().ToString().ToUpper(); guidMap.Add(value, guid); return guid; } }
/// <summary> /// Evaluates a condition. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="container">The container.</param> /// <returns></returns> private bool EvaluateCondition(List<ParserToken> tokens, TemplateContainer container) { List<string> parameters = new List<string>(); foreach (ParserToken token in tokens) { if (token.TokenType == (int)LanguageTokenType.Identifier) { List<string> list = this.ParseConditionToken(token.Content); foreach (string item in list) { object obj = container.GetByPath(item); if (obj != null) { parameters.Add(obj.ToString()); } else { if (this.Functions.ContainsKey(item)) { parameters.Add(this.Functions[item](token, container)); } else { parameters.Add(item); } } } } else if (token.TokenType == (int)LanguageTokenType.Literal) { parameters.Add(token.Content); } } if (parameters.Count == 1) { return ((parameters[0].ToLower() == "true") || (parameters[0] == "1")); } else if (parameters[0] == "!") { return (!((parameters[1].ToLower() == "true") || (parameters[1] == "1"))); } else { if (parameters[1] == "==") { return (parameters[0] == parameters[2]); } else if (parameters[1] == "!=") { return (parameters[0] != parameters[2]); } } return true; }
/// <summary> /// Determines whether the specified token is first. /// </summary> /// <param name="token">The token.</param> /// <param name="container">The container.</param> /// <returns></returns> private string IsFirst(ParserToken token, TemplateContainer container) { return (container.Attributes["Index"].ToString() == "0").ToString(); }
public static void ShouldBeAbleToSerializeToJsonATemplateContainerWithDefaultProperties() { //Arrange var expectedAnswer = "{\"template\":{\"data\":[]}}"; var template = new Template(); var templateContainer = new TemplateContainer(template); //Act //Assert Assert.Equal(expectedAnswer, JsonConvert.SerializeObject(templateContainer)); }
/// <summary> /// Visits the specified token using the container. /// </summary> /// <param name="container">The container.</param> /// <param name="token">The token.</param> private void Visit(TemplateContainer container, ParserToken token) { if (token.TokenType == (int)LanguageTokenType.Root) { foreach (ParserToken nested in token.Sons) { this.Visit(container, nested); } } if (token.TokenType == (int)LanguageTokenType.Text) { this.builder.Append(token.Content); } else if (token.TokenType == (int)LanguageTokenType.TextNoBreak) { int i = token.Content.IndexOf('\n'); if (i > -1) { this.builder.Append(token.Content.Substring(i)); } else { this.builder.Append(token.Content); } } else if (token.TokenType == (int)LanguageTokenType.Identifier) { this.EvaluateIdentifier(container, token); } }
private string Upper(ParserToken token, TemplateContainer container) { string value = this.EvaluateParameter(container, token.Parameters[0]); return value.ToUpper(); }
/// <summary> /// Pascalizes the specified token. /// </summary> /// <param name="token">The token.</param> /// <param name="container">The container.</param> /// <returns></returns> private string Pascalize(ParserToken token, TemplateContainer container) { string value = this.EvaluateParameter(container, token.Parameters[0]); return StringUtil.Pascalize(value); }
/// <summary> /// Determines whether the specified token is last. /// </summary> /// <param name="token">The token.</param> /// <param name="container">The container.</param> /// <returns></returns> private string IsLast(ParserToken token, TemplateContainer container) { return (container.Attributes["Index"] == container.Attributes["MaxIndex"]).ToString(); }
/// <summary> /// Determines whether the specified token has the specified index. /// </summary> /// <param name="token">The token.</param> /// <param name="container">The container.</param> /// <returns></returns> private string IsIndex(ParserToken token, TemplateContainer container) { string value = this.EvaluateParameter(container, token.Parameters[0]); return (container.Attributes["Index"].ToString() == value).ToString(); }
/// <summary> /// Evaluates one parameter, resolving to a string. /// </summary> /// <param name="container">The container.</param> /// <param name="parameter">The parameter.</param> /// <returns></returns> private string EvaluateParameter(TemplateContainer container, ParserToken parameter) { object obj = container.GetByPath(parameter.Content); if (obj != null) { return obj.ToString(); } else { if (this.Functions.ContainsKey(parameter.Content)) { return this.Functions[parameter.Content](parameter, container); } else { return parameter.Content; } } }
/// <summary> /// Evaluates one identifier token. /// </summary> /// <param name="container">The container.</param> /// <param name="token">The token.</param> private void EvaluateIdentifier(TemplateContainer container, ParserToken token) { if (this.Commands.ContainsKey(token.Content)) { LanguageCommandType commandType = this.Commands[token.Content]; switch (commandType) { case LanguageCommandType.Foreach: if (token.Parameters.Count > 0) { object obj = container.GetByPath(token.Parameters[0].Content); if ((obj != null) && (obj is TemplateContainer)) { TemplateContainer sonContainer = (TemplateContainer)obj; if (sonContainer.IsList) { int index = 0; string maxIndex = (sonContainer.ArrayValues.Count - 1).ToString(); foreach (TemplateContainer gransonContainer in sonContainer.ArrayValues) { gransonContainer.AddAttribute("Index", index.ToString()); gransonContainer.AddAttribute("MaxIndex", maxIndex); foreach (ParserToken son in token.Sons) { this.Visit(gransonContainer, son); } index++; } } else { //foreach (ParserToken son in token.Sons) //{ // this.Visit(sonContainer, son); //} } } else if ((obj != null) && (obj is TemplateLink)) { TemplateLink link = obj as TemplateLink; if (link.IsList) { object objcontainer = container.GetByPath(link.Link); if ((objcontainer != null) && (objcontainer is TemplateContainer)) { TemplateContainer sonContainer = (TemplateContainer)objcontainer; if (sonContainer.IsList) { int index = 0; string maxIndex = (link.ListValues.Count - 1).ToString(); foreach (string listValue in link.ListValues) { object foundobj = sonContainer.GetByPath("[" + listValue + "]"); if ((foundobj != null) && (foundobj is TemplateContainer)) { TemplateContainer gransonContainer = foundobj as TemplateContainer; gransonContainer.AddAttribute("Index", index.ToString()); gransonContainer.AddAttribute("MaxIndex", maxIndex); foreach (ParserToken son in token.Sons) { this.Visit(gransonContainer, son); } index++; } } } } } } } break; case LanguageCommandType.If: if (token.Parameters.Count > 0) { if (EvaluateCondition(token.Parameters, container)) { foreach (ParserToken son in token.Sons) { this.Visit(container, son); } } } break; case LanguageCommandType.Else: break; } } else { object obj = container.GetByPath(token.Content); if (obj != null) { builder.Append(obj.ToString()); } else { if (this.Functions.ContainsKey(token.Content)) { builder.Append(this.Functions[token.Content](token, container)); } } } }
private string FirstUpper(ParserToken token, TemplateContainer container) { string value = this.EvaluateParameter(container, token.Parameters[0]); if (string.IsNullOrEmpty(value)) { return value; } return char.ToUpper(value[0]) + value.Substring(1); }