public void ModelTest() { var model = new TagModel(new Reflection(new Hashtable())); model.Model["NewValue"] = "abc"; Assert.That(model.Model["NewValue"], Is.EqualTo("abc")); Assert.That(model[VariableScope.Model + ".NewValue"], Is.EqualTo("abc")); }
protected override object InternalEvaluate(TagModel model) { var builder = new StringBuilder(); builder.Append(GetAsUrl(Value, model) ?? String.Empty); builder.Append(ParamsEvaluate(model)); return builder.ToString(); }
public override object InternalEvaluate(TagModel model) { string dateStr = GetAutoValueAsString("Value", model); CultureInfo culture = ParseLocale != null ? new CultureInfo(GetAsString(ParseLocale, model)) : (CultureInfo) model[FormatConstants.LOCALE]; var format = (DateTimeFormatInfo) DateTimeFormatInfo.GetInstance(culture.DateTimeFormat).Clone(); DateTime? result = null; if (!String.IsNullOrEmpty(dateStr)) { if (GetAutoValueAsBool("Exact", model)) { string pattern = GetAsString(Pattern, model) ?? GetPattern(model, format); try { result = DateTime.ParseExact(dateStr, pattern, format); } catch (FormatException) { throw TagException.ParseException(dateStr, "Date").Decorate(Context); } } else { result = DateTime.Parse(dateStr, format); } } return result; }
public string Evaluate(TagModel model) { string locale = GetAsString(Value, model); VariableScope scope = GetAutoValueAs<VariableScope>("Scope", model).Value; model[scope + "." + FormatConstants.LOCALE] = new CultureInfo(locale); return String.Empty; }
public void GlobalResolveTest() { var model = new TagModel(new Reflection(new Hashtable())); model.Global["ResolveNewValue"] = "abc"; Assert.That(model.Global["ResolveNewValue"], Is.EqualTo("abc")); Assert.That(model["ResolveNewValue"], Is.EqualTo("abc")); }
public override void SetUp() { base.SetUp(); var model = new Hashtable(); _model = new TagModel(model); _model.Page[FormatConstants.LOCALE] = CultureInfo.InvariantCulture; }
public string Evaluate(TagModel model) { var builder = new StringBuilder(); IList list = ToList(GetIEnumerable(model)); int start = GetAutoValueAsInt("Begin", model).Value; int end = GetAsInt(End, model) ?? list.Count; int step = GetAutoValueAsInt("Step", model).Value; string var = GetAutoValueAsString("Var", model); string varStatus = GetAutoValueAsString("VarStatus", model); model.PushTagStack(); var status = new ForEachStatus(list.Count, start, end); if (list.Count > 0) { model.Tag[varStatus] = status; for (int i = start; i < end; i += step) { status.Index = i; model.Tag[var] = list[i]; builder.Append(GetAsString(Body, model) ?? String.Empty); } model.Tag[var] = null; model.Tag[varStatus] = null; } model.PopTagStack(); return builder.ToString(); }
public override void SetUp() { base.SetUp(); var model = new Hashtable(); _model = new TagModel(model); _model.Page[FormatConstants.LOCALE] = new CultureInfo("en-US"); }
public XsltParameter EvaluateNested(TagModel model) { string name = GetAsString(Name, model) ?? String.Empty; string nameSpaceUri = GetAsString(NameSpaceUri, model) ?? String.Empty; object value = GetAutoValue("Value", model) ?? String.Empty; return new XsltParameter(name, nameSpaceUri, value); }
public NewTagViewController (WorkspaceModel workspace) { this.model = new TagModel () { Workspace = workspace, }; Title = "NewTagTitle".Tr (); }
public string Evaluate(TagModel model) { string result = GetAutoValueAsString("Value", model); var escapeXml = GetAutoValueAsBool("EscapeXml", model); result = result ?? String.Empty; return escapeXml ? StringUtils.EscapeXml(result) : result; }
public static string Evaluate(ITagWithVariable tag, TagModel model) { object result = tag.InternalEvaluate(model); string var = tag.GetAutoValueAsString("Var", model); string scope = tag.GetAutoValueAsString("Scope", model); model[scope + "." + var] = result; return String.Empty; }
protected override object InternalEvaluate(TagModel model) { var urlBuilder = new StringBuilder(); urlBuilder.Append(GetAsUrl(Url, model)); urlBuilder.Append(ParamsEvaluate(model)); return ReadData(PlaceRequest(urlBuilder)); }
public void CheckParsingOfLocaleDefautScope() { var model = new TagModel(this); var tag = new SetLocale(); tag.Value = new MockAttribute(new Constant("nl-NL")); Assert.That(tag.Evaluate(model), Is.EqualTo(String.Empty)); Assert.That(model.Page[FormatConstants.LOCALE], Is.EqualTo(new CultureInfo("nl-NL"))); }
public override IEnumerable GetIEnumerable(TagModel model) { string items = GetAsString(Items, model) ?? String.Empty; string delims = GetAsString(Delims, model); string[] tokens = items.Split(delims.ToCharArray()); return new ArrayList(tokens); }
public void ModelAbovePageResolveTest() { var model = new TagModel(new Reflection(new Hashtable())); model.Page["NewValue"] = "Page"; Assert.That(model["NewValue"], Is.EqualTo("Page")); model.Model["NewValue"] = "Model"; Assert.That(model["NewValue"], Is.EqualTo("Model")); }
public void TestRequestEncodingNoRepsonseSet() { var tag = new RequestEncoding(); tag.Value = new MockAttribute(new Constant("UTF-8")); var model = new TagModel(this); Assert.That(tag.Evaluate(model), Is.EqualTo(String.Empty)); Assert.That(model.Encoding, Is.EqualTo(Encoding.UTF8)); }
public void DateAutoValueTestTag_Should_Pass_Date() { var _model = new TagModel(new Hashtable() { { "SomeDate", new DateTime(1979,10,2)} }); var tag = new DateAutoValueTestTag(); tag.SomeDateValue = new MockAttribute(new Property("SomeDate")); Assert.That(tag.Evaluate(_model), Is.EqualTo("date=02|10|1979")); }
TagModel GetTagModel (SolutionFolderItem policyParent, Project project, string language, string identifier, string fileName) { var model = new TagModel(); var projectModel = ProjectTagModel ?? Outer.ProjectTagModel; if (projectModel != null) model.InnerModels = new [] { projectModel }; ModifyTags (policyParent, project, language, identifier, fileName, ref model.OverrideTags); return model; }
public string Evaluate(TagModel model) { var baseName = GetAsString(BaseName, model); var prefix = GetAsString(Prefix, model); IResourceBundle bundle = new ResourceBundle(baseName, prefix, BaseName.ResourceLocator); model.PushTagStack(); model.Tag[FormatConstants.BUNDLE] = bundle; return GetAsString(Body, model) ?? string.Empty; }
public void CheckParsingOfLocale() { var model = new TagModel(new Hashtable()); var tag = new SetLocale(); Assert.That(model[FormatConstants.LOCALE], Is.EqualTo(Thread.CurrentThread.CurrentCulture)); tag.Value = new MockAttribute(new Constant("nl-NL")); Assert.That(tag.Evaluate(model), Is.EqualTo(String.Empty)); Assert.That(model[FormatConstants.LOCALE], Is.EqualTo(new CultureInfo("nl-NL"))); }
public void TestSettingOfPrefix() { var model = new TagModel(new Hashtable()); var tag = new Bundle(); tag.BaseName = new MockAttribute(new Constant("FormatTags/test")); tag.Prefix = new MockAttribute(new Constant("pre_")); Assert.That(tag.Evaluate(model), Is.EqualTo(String.Empty)); var bundle = (ResourceBundle) model.SearchInTagScope(FormatConstants.BUNDLE); Assert.That(bundle.Prefix, Is.EqualTo("pre_")); }
public void TestRedirectOnMock() { var url = new Redirect(); var response = new MockResponse(); var model = new TagModel(this, new MockSessionState(), null, response); url.Url = new MockAttribute(new Constant("www.sharptiles.org")); Assert.IsNull(response.LastRedirectUrl); url.Evaluate(model); Assert.That(response.LastRedirectUrl, Is.EqualTo("www.sharptiles.org")); }
public void TestResponseOnMock() { var tag = new RequestEncoding(); var response = new MockResponse(); var model = new TagModel(this, new MockSessionState(), null, response); tag.Value = new MockAttribute(new Constant("UTF-7")); Assert.IsNull(response.ResponseEncoding); tag.Evaluate(model); Assert.That(response.ResponseEncoding, Is.EqualTo(Encoding.UTF7)); }
public override string Evaluate(TagModel model) { var urlBuilder = new StringBuilder(); urlBuilder.Append(GetAsUrl(Url, model)); urlBuilder.Append(ParamsEvaluate(model)); model.Redirect(urlBuilder.ToString()); return ""; }
public void CheckLoadingOfBundle() { var model = new TagModel(new Hashtable()); var tag = new Bundle(); tag.BaseName = new MockAttribute(new Constant("FormatTags/test")); Assert.That(tag.Evaluate(model), Is.EqualTo(String.Empty)); Assert.That(model.SearchInTagScope(FormatConstants.BUNDLE), Is.Not.Null); Assert.That(model.SearchInTagScope(FormatConstants.BUNDLE) is ResourceBundle, Is.True); var bundle = (ResourceBundle) model.SearchInTagScope(FormatConstants.BUNDLE); Assert.That(bundle.BaseName, Is.EqualTo("FormatTags/test")); }
public override string Evaluate(TagModel model) { object result = InternalEvaluate(model); if (Var != null) { string var = GetAsString(Var, model); string scope = GetAutoValueAsString("Scope", model); model[scope + "." + var] = result; return String.Empty; } return result != null ? result.ToString() : String.Empty; }
public void TestGetOfMessageDifferentLocale() { var model = new TagModel(new object()); model.PushTagStack(); model.Tag[FormatConstants.BUNDLE] = new ResourceBundle("FormatTags/compiled", ""); model.PushTagStack(); model.Page[FormatConstants.LOCALE] = new CultureInfo("nl-NL"); var tag = new Message(); tag.Key = new MockAttribute(new Constant("c")); Assert.That(tag.Evaluate(model), Is.EqualTo("nederlandseC")); }
public static string EvaluateOptional(ITagWithVariable tag, TagModel model) { object result = tag.InternalEvaluate(model); if (tag.Var != null) { string var = tag.GetAutoValueAsString("Var", model); string scope = tag.GetAutoValueAsString("Scope", model); model[scope + "." + var] = result; return String.Empty; } return result != null ? result.ToString() : String.Empty; }
public void CheckLoadingOfSetBundle() { var model = new TagModel(new Hashtable()); var tag = new SetBundle(); tag.BaseName = new MockAttribute(new Constant("FormatTags/test")); tag.Var = new MockAttribute(new Constant("myBundle")); Assert.That(tag.Evaluate(model), Is.EqualTo(String.Empty)); Assert.That(model.Page["myBundle"], Is.Not.Null); Assert.That(model.Page["myBundle"] is ResourceBundle, Is.True); var bundle = (ResourceBundle) model.Page["myBundle"]; Assert.That(bundle.BaseName, Is.EqualTo("FormatTags/test")); }
public JsonResult Manage(TagModel model, GridManagingModel manageModel) { if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del) { return(Json(_tagServices.ManageTag(manageModel.Operation, model))); } return(Json(new ResponseModel { Success = false, Message = GetFirstValidationResults(ModelState).Message })); }
TagModel GetTagModel(SolutionFolderItem policyParent, Project project, string language, string identifier, string fileName) { var model = new TagModel(); var projectModel = ProjectTagModel ?? Outer.ProjectTagModel; if (projectModel != null) { model.InnerModels = new [] { projectModel } } ; ModifyTags(policyParent, project, language, identifier, fileName, ref model.OverrideTags); return(model); }
public void SetUp() { tile = new TemplateTile( "test", new FileTemplate("a.htm"), new List <TileAttribute>() ); model = new TagModel(new Hashtable { { "some", new Hashtable { { "a", "b" } } } }); }
public object GetAutoValue(string propertyName, TagModel model) { PropertyInfo property = CollectionUtils.SafeGet(PROPERTY_CACHE, propertyName); var attribute = (ITagAttribute)property.GetValue(this, null); object value = attribute != null?attribute.Evaluate(model) : null; if (value == null) { IDefaultPropertyValue fallBack = CollectionUtils.SafeGet(DEFAULT_CACHE, propertyName); value = fallBack != null?fallBack.GetValue(this, model) : null; } return(value); }
public async Task <bool> Update(Guid id, TagModel model, CancellationToken token = default) { var tag = model.MapToTag(id, _scopeControl.GetUserId()); if (tag.IsInValid()) { _scopeControl.AddNotifications(tag.Notifications); return(false); } _repository.Update(tag); return(await _repository.UnitOfWork.Commit(token)); }
public ActionResult Create(TagModel model, bool continueEditing) { if (ModelState.IsValid) { var tag = model.ToEntity(); _articleService.InsertTag(tag); SuccessNotification("添加成功"); return(continueEditing ? RedirectToAction("Edit", new { id = tag.Id }) : RedirectToAction("List")); } return(View(model)); }
public void CheckLoadingOfBundle() { var model = new TagModel(new Hashtable()); var tag = new Bundle(); tag.BaseName = new MockAttribute(new Constant("FormatTags/test")); Assert.That(tag.Evaluate(model), Is.EqualTo(String.Empty)); Assert.That(model.SearchInTagScope(FormatConstants.BUNDLE), Is.Not.Null); Assert.That(model.SearchInTagScope(FormatConstants.BUNDLE) is ResourceBundle, Is.True); var bundle = (ResourceBundle)model.SearchInTagScope(FormatConstants.BUNDLE); Assert.That(bundle.BaseName, Is.EqualTo("FormatTags/test")); }
public void TestOfParseOfForEachfBodyWithVar() { var model = new Hashtable(); model.Add(VariableScope.Model.ToString(), new Hashtable()); var reflection = new TagModel(model); var list = new ArrayList(new[] { 1, 2, 3, 4, 5, 6 }); reflection["Model.list"] = list; ITag tag = Base().Parse("<c:forEach items=\"${Model.list}\">${Item}</c:forEach>"); Assert.That(tag.Evaluate(reflection), Is.EqualTo("123456")); }
public void CheckStoringOfLocaleInDifferentScope() { var model = new Hashtable(); var tagModel = new TagModel(model); var tag = new SetLocale(); tag.Value = new MockAttribute(new Constant("nl-NL")); tag.Scope = new MockAttribute(new Constant("Model")); Assert.That(tag.Evaluate(tagModel), Is.EqualTo(String.Empty)); Assert.That(tagModel[FormatConstants.LOCALE], Is.EqualTo(new CultureInfo("nl-NL"))); Assert.That(tagModel.Page[FormatConstants.LOCALE], Is.Null); Assert.That(tagModel.Model[FormatConstants.LOCALE], Is.EqualTo(new CultureInfo("nl-NL"))); }
public static Tag ToEntity(this TagModel model) { if (model == null) { return(null); } return(new Tag() { Name = model.Name, DisplayOrder = model.DisplayOrder, CreateDate = model.CreateDate }); }
public void TestXmlIf() { var model = new Hashtable(); var reflection = new TagModel(model); model.Add(VariableScope.Page.ToString(), new Hashtable()); Base().Parse( "<x:parse var='fileAsXml'><VALUES><TRUE>true</TRUE><FALSE>false</FALSE></VALUES></x:parse>").Evaluate( reflection); ITag tag = Base().Parse("<x:if source='fileAsXml' select='//TRUE'>Yeah</x:if>"); Assert.That(tag.Evaluate(reflection), Is.EqualTo("Yeah")); }
public void TestAcquiringOfParamsImportInVariable() { var url = new Import(); string fileUrl = GetUrl("CoreTags/import.txt"); url.Url = new MockAttribute(new Constant(fileUrl)); url.Var = new MockAttribute(new Constant("target")); var model = new TagModel(this); Assert.That(url.Evaluate(model), Is.EqualTo(String.Empty)); Assert.That(model.Page["target"], Is.EqualTo("some text")); }
protected override void RemoveFromDictonary(TagModel tag) { base.RemoveFromDictonary(tag as TagModel); if (_addedTags.Contains(tag)) { _addedTags.Remove(tag as TagTreeViewItemModel); } else { _deletedTags.Add(tag as TagTreeViewItemModel); } }
private void TagDropDown_SelectedIndexChanged(object sender, EventArgs e) { ComboBox tagDropDown = (ComboBox)sender; SelectedTag = (TagModel)tagDropDown.SelectedValue; UpdateProductsForSelectedTag(); SearchTextBox.TextChanged -= new EventHandler(SearchTextBox_TextChanged); SearchTextBox.Text = "Search "; SearchTextBox.ForeColor = Color.Gray; SearchTextBox.TextChanged += new EventHandler(SearchTextBox_TextChanged); }
public async Task <IActionResult> AddNewTag(TagModel tag) { if (ModelState.IsValid) { int id = await _tagRepository.AddNewTag(tag); if (id > 0) { return(RedirectToAction(nameof(AddNewTag), new { isSuccess = true, tagId = id })); } } return(View()); }
public void TestOfParseOfNestedForTokens() { var model = new Hashtable(); model.Add(VariableScope.Model.ToString(), new Hashtable()); var reflection = new TagModel(model); ITag tag = Base().Parse( "<c:forTokens step='2' items=\"1,2,3,4,5,6\" delims=\",\">${Status.Index}.[<c:forTokens step='2' begin='1' items=\"1,2,3,4,5,6\" delims=\",\">${Status.Index}</c:forTokens>]</c:forTokens>"); Assert.That(tag.Evaluate(reflection), Is.EqualTo("0.[135]2.[135]4.[135]")); }
public static TagTreeViewItemModel ConvertTag(TagModel tag) { if (tag.IsBase()) { return(ConvertBaseTag(tag)); } var model = new TagTreeViewItemModel(tag.Id); model.Name = tag.Name; return(model); }
public void Should_User_Function_Defaults_For_Arguments() { var model = new TagModel(this); CreateFactory().Parse("<macro:function name='testA' argument-1='firstName(FIRST)' argument-2='lastName(LAST)'>Hi ${firstName} ${lastName}</macro:function>").Evaluate(model); model.PushTagStack(true); model.Tag["FIRST"] = "John"; model.Tag["LAST"] = "Doe"; var result = CreateFactory().Parse("<macro:call name='testA'/>").Evaluate(model); model.PopTagStack(); Assert.That(result, Is.EqualTo("Hi John Doe")); }
private void TagsListBox_SelectedIndexChanged(object sender, EventArgs e) { TagModel clickedTag = (TagModel)TagsListBox.SelectedValue; if (clickedTag == null) { return; } GlobalConfig.Connection.ToggleProductTagRelation(ClickedProduct, clickedTag); GetDataFromDatabase(); WireUpTags(); }
public void TestOfParseOfForTokensComplexBody() { var model = new Hashtable(); model.Add(VariableScope.Model.ToString(), new Hashtable()); var reflection = new TagModel(model); ITag tag = Base().Parse( "<c:forTokens items=\"1,2,3,4,5,6\" delims=\",\"><c:set value=\"${Item}\" var=\"last\"/></c:forTokens>"); Assert.That(tag.Evaluate(reflection), Is.EqualTo(String.Empty)); Assert.That(reflection["Page.last"], Is.EqualTo("6")); }
public void DeleteTagFromVideo(VideoModel video, TagModel tag) { if (video == null || tag == null) { throw new NullReferenceException(); } string sql = "DELETE FROM video_tags WHERE video_id = @videoId AND tag_id = @tagId"; SQLiteCommand command = new SQLiteCommand(sql, connection); command.Parameters.AddWithValue("@videoId", video.Id); command.Parameters.AddWithValue("@tagId", tag.Id); command.ExecuteNonQuery(); }
public void TestAttributesSetByPropertyPageScope() { var tag = new Remove(); tag.Var = new MockAttribute(new Property("Var")); tag.Scope = new MockAttribute(new Property("SessionScope")); _page.Add("value", "Value"); var reflection = new TagModel(this, new MockSessionState()); tag.Evaluate(reflection); Assert.That(reflection["Page." + Var], Is.Null); }
public JsonResult PredloziTag(TagModel tag) { Predlozeni_TagDTO tg = new Predlozeni_TagDTO(); tg.DatumPostavljanja = DateTime.Now; tg.Ime = tag.Ime; tg.TagIme = tag.TagIme; tg.Opis = tag.Opis; PredlozeniTagovi.Dodaj(tg); return(Json(tag, JsonRequestBehavior.AllowGet)); }
public IEnumerable <ArticleModel> GetByHashtag(string hashtag) { TagModel tag = _tagRepository.GetByHashtag(hashtag); if (tag != null) { IEnumerable <ArticleModel> articles = tag .ArticleTags .Select(t => t.Article); return(articles); } return(null); }
public static Tag ToTag(TagModel tagModel) { if (tagModel == null) { return(null); } return(new Tag { Id = tagModel.Id, Name = tagModel.Name }); }
public override string Evaluate(TagModel model) { object result = InternalEvaluate(model); if (Var != null) { string var = GetAsString(Var, model); string scope = GetAutoValueAsString("Scope", model); model[scope + "." + var] = result; return(String.Empty); } return(result != null?result.ToString() : String.Empty); }
public async Task <IActionResult> Update(int id, [FromBody] TagModel tagModel) { if (tagModel == null || id <= 0) { return(BadRequest()); } tagModel.Id = id; var tag = _mapper.Map <Tag>(tagModel); await _tagsBusiness.UpdateAsync(tag); return(Ok()); }
/// <summary> /// 更新标签 /// </summary> /// <param name="tagModel"></param> /// <returns></returns> public bool UpdateTag(TagModel tagModel) { var tag = _tagRepsitory.GetTagById(tagModel.Id); if (tag == null) { throw new Exception("订单标签不存在"); } else { return(_tagRepsitory.UpdateTag(tagModel)); } }
/// <summary> /// Loads the tags from Gramps XML file asynchronously. /// </summary> /// <returns> /// True if loaded successfully. /// </returns> public async Task LoadTagsAsync() { _iocCommonNotifications.DataLogEntryAdd("Loading Tag data"); { try { // Run query var de = from el in localGrampsXMLdoc.Descendants(ns + "tag") select el; // get Tag fields // Loop through results foreach (XElement pTagElement in de) { TagModel loadTag = new TagModel { // Citation attributes //Id = GetAttribute(pTagElement, "id"), //Change = GetDateTime(pTagElement, "change"), //Priv = SetPrivateObject(GetAttribute(pTagElement, "priv")), //Handle = GetAttribute(pTagElement, "handle"), // Tag fields GColor = GetColour(pTagElement, "color"), GName = GetAttribute(pTagElement, "name"), GPriority = int.Parse(GetAttribute(pTagElement, "priority"), System.Globalization.CultureInfo.CurrentCulture) }; loadTag.LoadBasics(GetBasics(pTagElement)); // Set tag colour loadTag.ModelItemGlyph.SymbolColour = loadTag.GColor; // save the Tag DV.TagDV.TagData.Add(loadTag); } } catch (Exception ex) { _iocCommonNotifications.NotifyException("Error in LoadTagsAsync", ex); throw; } } _iocCommonNotifications.DataLogEntryReplace("Tag load complete"); return; }
void createCommand() { CreateTagWindow window = new CreateTagWindow(); window.Closed += (s, args) => { if (window.DialogResult.Value) { var has = this.Tags.Any(c => { return(window.Tags.Any(cc => cc.Equals(c.Name))); }); if (has) { var result = this.ShowDialog("提示信息", "存在相同标签,是否继续添加", CustomControl.Enums.DialogSettingType.OkAndCancel, CustomControl.Enums.DialogType.Warning); if (result != CustomControl.Enums.DialogResultType.OK) { return; } } var cl = base.GetClCase(base.LocalID); foreach (var t in window.Tags) { var tagID = this.Tags.Count == 0 ? 0 : this.Tags.Max(tt => Convert.ToInt64(tt.ID)); // 创建 TagModel tag = new TagModel() { ID = (tagID + 1).ToString(), Name = t, }; // 更新UI this.Tags.Add(new UITag { ID = tag.ID, Name = tag.Name, }); // 更新缓存 cl.Tags.Add(tag); } base.Serialize(cl, LocalID); } }; window.ShowDialog(); }