/// <summary> /// Creates a new <see cref="Controller"/> instance. /// </summary> /// <param name="tagController">The tag controller used by the created controller.</param> /// <param name="controllerTag">The tag, the new controller is dependend on.</param> /// <param name="userDefinedInterfaces">User defined interfaces</param> /// <param name="tagListener">A tag listener instance</param> /// <returns>A new <see cref="Controller"/> instance.</returns> public Controller Create( ITagController tagController, IControllerTag controllerTag, IList <string> userDefinedInterfaces, ITagListener tagListener) { var controller = Create(tagController, controllerTag, tagListener); if (userDefinedInterfaces != null) { tagListener.AddUdtHandler <Command>(CmdList.PlcArrayDataType()); foreach (var userDefinedInterface in userDefinedInterfaces.Where(value => !string.IsNullOrWhiteSpace(value))) { var path = TagName.SpecificInterface(parent: null).AppendTagName(userDefinedInterface); var userDefinedInterfaceTags = ChildTagsFromPath(controllerTag, path); controller.AddUserDefinedInterface(path, userDefinedInterfaceTags); // create the commands foreach (var userDefinedInterfaceTag in userDefinedInterfaceTags) { var commands = CreateCommands(controllerTag, controller, userDefinedInterfaceTag, tagListener); controller.UpdateUserDefinedCommands(userDefinedInterfaceTag.NestedName, commands.ToList()); } } } return(controller); }
public override int GetHashCode() { unchecked { return(((TagName != null ? TagName.GetHashCode() : 0) * 397) ^ Count); } }
public ContentResult AddTag([Bind(Exclude = "Id")] TagName tag) { string json; if (ModelState.IsValid) { var id = repo.AddTag(tag); json = JsonConvert.SerializeObject(new { id = id, success = true, message = "Tag added successfully." }); } else { json = JsonConvert.SerializeObject(new { id = 0, success = false, message = "Failed to add the tag." }); } return(Content(json, "application/json")); }
public override int GetHashCode() { if (fHashCode == 0) { fHashCode = 19 * TagID + 7; fHashCode ^= 11 * EntityID + 11; fHashCode ^= 17 * EntityType + 21; if (!String.IsNullOrEmpty(TagName)) { fHashCode ^= TagName.GetHashCode(); } if (!String.IsNullOrEmpty(TagColor)) { fHashCode ^= TagColor.GetHashCode(); } if (!String.IsNullOrEmpty(TagTextColor)) { fHashCode ^= TagTextColor.GetHashCode(); } if (!String.IsNullOrEmpty(EntityName)) { fHashCode ^= EntityName.GetHashCode(); } } return(fHashCode); }
/// <summary> /// 构造TLV结构 /// </summary> /// <param name="_tag">标签</param> /// <param name="_format">类型</param> /// <param name="_len">长度</param> /// <param name="_tag_buf">值</param> public TagStruct(TagName _tag, TagFormat _format, uint _len, string _tag_buf) { tag = _tag; format = _format; len = _len; tag_buf = _tag_buf; }
private async void squareBoard_MouseClick(object i_Sender, MouseEventArgs i_Events) { if (this.m_IsChooseSolider == true) { removeBorderFromSoliderThatHaveBeenChosen(); PictureBox currentSquare = i_Sender as PictureBox; TagName currentPositionOfCurrentSolider = currentSquare.Tag as TagName; this.m_CurrentMove.ToSquare = new Square(currentPositionOfCurrentSolider.Name[1], currentPositionOfCurrentSolider.Name[0]); CheckerboardController.Instance.nextTurn(m_CurrentMove); if (CheckerboardController.Instance.GameStatus != eGameStatus.ContinueGame) { await Task.Delay(2000); gameStatusChangeMessage(CheckerboardController.Instance.GameStatus); } else { while (CheckerboardController.Instance.CurrentPlayer.TypeOfPlayer == eTypeOfPlayer.Computer && CheckerboardController.Instance.GameStatus == eGameStatus.ContinueGame) { await Task.Delay(3000); CheckerboardController.Instance.nextTurn(null); if (CheckerboardController.Instance.GameStatus != eGameStatus.ContinueGame) { await Task.Delay(3000); gameStatusChangeMessage(CheckerboardController.Instance.GameStatus); break; } } } } }
public async Task <Errorable <Tag> > GetTagByName(TagName tagName) { var eid = await getTagIDByName(tagName).ConfigureAwait(continueOnCapturedContext: false); if (eid.HasErrors) { return(eid.Errors); } var etg = await getTag(eid.Value).ConfigureAwait(continueOnCapturedContext: false); if (etg.HasErrors) { return(etg.Errors); } Tag tg = etg.Value; // Check that the retrieved TagName matches what we asked for: if (tg.Name != tagName) { return(new TagNameDoesNotMatchExpectedError(tg.Name, tagName)); } return(etg); }
public ContentResult EditTag(TagName tag) { string json; if (ModelState.IsValid) { repo.EditTag(tag); json = JsonConvert.SerializeObject(new { id = tag.Id, success = true, message = "Changes saved successfully." }); } else { json = JsonConvert.SerializeObject(new { id = 0, success = false, message = "Failed to save the changes." }); } return(Content(json, "application/json")); }
public async Task <IActionResult> Delete(int?id, TagName Tag) { if (id == null) { return(NotFound()); } if (id != Tag.Id) { return(NotFound()); } var tag = _db.TagName.Find(id); if (tag == null) { return(NotFound()); } if (ModelState.IsValid) { _db.Remove(tag); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(Tag)); }
public string Post(TagName tn) { try { string query = @" insert into dbo.tblTagName (TagName) values ('" + tn.tagName + @"') "; DataTable dt = new DataTable(); using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["Tags"].ConnectionString)) using (var cmd = new SqlCommand(query, con)) using (var da = new SqlDataAdapter(cmd)) { cmd.CommandType = CommandType.Text; da.Fill(dt); } return("Added Successfully."); } catch (Exception) { return("Added Failed."); } }
public bool IsSafeAttribute(string tagName, Element el, NSoup.Nodes.Attribute attr) { TagName tag = TagName.ValueOf(tagName); AttributeKey key = AttributeKey.ValueOf(attr.Key); if (_attributes.ContainsKey(tag)) { if (_attributes[tag].Contains(key)) { if (_protocols.ContainsKey(tag)) { Dictionary <AttributeKey, HashSet <Protocol> > attrProts = _protocols[tag]; // ok if not defined protocol; otherwise test return(!attrProts.ContainsKey(key) || TestValidProtocol(el, attr, attrProts[key])); } else { // attribute found, no protocols defined, so OK return(true); } } } // no attributes defined for tag, try :all tag return(!tagName.Equals(":all") && IsSafeAttribute(":all", el, attr)); }
// ==================================================================== // // PRIVATE/PROTECTED METHODS // // ==================================================================== private void CheckTag() { if (TagName.EndsWith("/")) { TagName = TagName.Substring(0, TagName.Length - 1); } TagNameNS = TagName; ElementInfo = HtmlElementInfo.GetElementInfo(TagNameNS); int pos = TagName.IndexOf(':'); if (pos != -1) { Namespace = TagName.Substring(0, pos); TagName = TagName.Substring(pos + 1); } if (ElementInfo == null) { if (Namespace == null) { AddWarning("Unknown tag: " + TagName); } } else { if (Parent != null) { if (!ElementInfo.IsValidParent(Parent.TagName)) { AddWarning("Invalid parent for " + TagName + " (parent: " + Parent.TagName + ")"); } } } }
/// <summary> /// 构造TLV结构 /// </summary> /// <param name="tag">标签</param> /// <param name="len">长度</param> /// <param name="val">值</param> public TLV_Structure(TagName tag, uint len, byte[] val) { this.m_Tag = tag; this.m_uiValueLen = len; this.m_bValueBuffer = new byte[this.m_uiValueLen]; this.init(len, val); }
/// <summary>Adds the given type as an available widget type.</summary> public static void Add(Type type) { if (widgetTypes == null) { // widgetTypes the set now: widgetTypes = new Dictionary <string, Type>(); } // Get the name attribute from it (don't inherit): #if NETFX_CORE TagName tagName = type.GetTypeInfo().GetCustomAttribute(typeof(TagName), false) as TagName; #else TagName tagName = Attribute.GetCustomAttribute(type, typeof(TagName), false) as TagName; #endif if (tagName == null) { // Nope! return; } string tag = tagName.Tags; if (!string.IsNullOrEmpty(tag)) { // Add now: widgetTypes[tag] = type; } }
public YamlNodeEvent(YamlNodeEventType type, AnchorName anchor, TagName tag, string value) { Type = type; Anchor = anchor; Tag = tag; Value = value; }
protected override void Render(TagHelperContext context, TagHelperOutput output) { output.SetTagName("button"); output.AddCssClass("btn"); if (TagName.Equals("button", StringComparison.OrdinalIgnoreCase)) { output.AddCssClass(ButtonColor.Default); } else { output.AddCssClass(context.TagName); } if (IsBlock) { output.AddCssClass("btn-block"); } // Type RenderType(context, output); // Disabled & ReadOnly RenderVisability(context, output); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TagName.Focus(); } }
public TextTagsState SwitchTag(TagName name) { var bitArray = new BitArray(mask); bitArray[tagsNumbers[name]] = !mask[tagsNumbers[name]]; return(new TextTagsState(bitArray, Text, Start, End)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TagName.Focus(); //string userid = Convert.ToString(Session["UserID"]); //if (Session["RoleID"] != null && !String.IsNullOrEmpty(Session["RoleID"].ToString()) && (Session["RoleID"].ToString() == "1" || Session["RoleID"].ToString() == "2")) //{ // //ClassifyPanel.Visible = true; // using (SqlConnection conn = new DB().GetConnection()) // { // string sql = "select * from UserTags where UserID = @UserID order by ID desc"; // SqlCommand cmd = new SqlCommand(sql, conn); // cmd.Parameters.AddWithValue("@UserID", userid); // conn.Open(); // SqlDataReader rd = cmd.ExecuteReader(); // TagsList.DataSource = rd; // TagsList.DataTextField = "TagName"; // TagsList.DataValueField = "ID"; // TagsList.DataBind(); // rd.Close(); // } //} //else //{ // ClassifyPanel.Visible = false; //} } }
public async Task <IActionResult> Edit(int id, [Bind("Id,TagNames")] TagName tagName) { if (id != tagName.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tagName); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagNameExists(tagName.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tagName)); }
private bool IsClosedTag(TagName tag, TextTagsState state) { return(IsItLooksLikeTag(tag, state) && state.Start > 0 && state.Text[state.Start - 1] != ' ' && IsNotPrevSymbolUnderlining(state) && !char.IsDigit(state.Text[state.Start - 1])); }
/// <summary> /// Initializes a new instance of the <see cref="Scalar"/> class. /// </summary> /// <param name="anchor">The anchor.</param> /// <param name="tag">The tag.</param> /// <param name="value">The value.</param> /// <param name="style">The style.</param> /// <param name="isPlainImplicit">.</param> /// <param name="isQuotedImplicit">.</param> /// <param name="start">The start position of the event.</param> /// <param name="end">The end position of the event.</param> public Scalar(AnchorName anchor, TagName tag, string value, ScalarStyle style, bool isPlainImplicit, bool isQuotedImplicit, Mark start, Mark end) : base(anchor, tag, start, end) { this.Value = value; this.Style = style; this.IsPlainImplicit = isPlainImplicit; this.IsQuotedImplicit = isQuotedImplicit; }
/// <summary> /// Edit an existing tag. /// </summary> /// <param name="tag"></param> public void EditTag(TagName tag) { using (var tran = _sess.BeginTransaction()) { _sess.SaveOrUpdate(tag); tran.Commit(); } }
public TagStruct(TagName _tag, TagFormat _format, uint _len, byte[] _tag_buf) { tag = _tag; format = _format; len = _len; this.tag_buf = new byte[len]; tag_buf = _tag_buf; }
public void FindFirstTag_InBeginingAndOutOfTags(TagName expectedTagName, int expectedX, int expectedY) { var md = Tags.GetMd(expectedTagName); var text = string.Format("{0}t{0}t", md); var state = new TextTagsState(text, 0, text.Length - 1); tagsFinder.GetFirstTagOnSegment(state).Should().Be(new TagSegment(expectedTagName, expectedX, expectedY)); }
public HtmlTag(string tag) : this() { tag = tag.Substring(1, tag.Length - 2); var spaceIndex = tag.IndexOf(" "); //Extract tag name if (spaceIndex < 0) { TagName = tag; } else { TagName = tag.Substring(0, spaceIndex); } //Check if is end tag if (TagName.StartsWith("/")) { IsClosing = true; TagName = TagName.Substring(1); } TagName = TagName.ToLower(); //Extract attributes var atts = Parser.Match(Parser.HmlTagAttributes, tag); foreach (Match att in atts) { //Extract attribute and value var chunks = att.Value.Split('='); if (chunks.Length == 1) { if (!Attributes.ContainsKey(chunks[0])) { Attributes.Add(chunks[0].ToLower(), string.Empty); } } else if (chunks.Length == 2) { var attname = chunks[0].Trim(); var attvalue = chunks[1].Trim(); if (attvalue.StartsWith("\"") && attvalue.EndsWith("\"") && attvalue.Length > 2) { attvalue = attvalue.Substring(1, attvalue.Length - 2); } if (!Attributes.ContainsKey(attname)) { Attributes.Add(attname, attvalue); } } } }
/// <summary> /// Add a new tag. /// </summary> /// <param name="tag"></param> /// <returns></returns> public int AddTag(TagName tag) { using (var tran = _sess.BeginTransaction()) { _sess.Save(tag); tran.Commit(); return(tag.Id); } }
public static void InitNewTag(TagName name, string md, string openHtml, string closeHtml) { MdToTagName[md] = name; OpenTagToTagName[openHtml] = name; CloseTagToTagName[closeHtml] = name; TagNameToMd[name] = md; TagNameToOpenHtml[name] = openHtml; TagNameToCloseHtml[name] = closeHtml; }
public Tag(TagName t) { //parinte = new Tag(TagName.html); internalTagName = t; attributes = new Dictionary <string, string>(); children = new List <Element>(); isSelfClosing = false; internalInnerText = ""; }
/// <summary> /// Resets the alarm manager of the module this controller is in. /// </summary> public void ResetModuleAlarms() { var resetAlarmsTag = new Tag( TagName.AlarmManager(parent: null).AlarmCommand(), TagName.Global(), "INT"); _tagController.WriteTag(resetAlarmsTag, (short)StandardAlarmCommands.ResetAll); }
public async Task<Errorable<Tuple<Tag, CommitTree>>> GetCommitTreeByTagName(TagName tagName, int depth = 10) { // TODO: implement a single query to handle this var etg = await tgrepo.GetTagByName(tagName); if (etg.HasErrors) return etg.Errors; Tag tg = etg.Value; var ecmtr = await db.ExecuteListQueryAsync(new QueryCommitsRecursively(tg.CommitID, depth)); if (ecmtr.HasErrors) return ecmtr.Errors; CommitTree cmtr = ecmtr.Value; return new Tuple<Tag, CommitTree>(tg, cmtr); }
public static MvcHtmlString TagLink(this HtmlHelper help, TagName tag) { return help.ActionLink(tag.Name, "Tag", "Blognew", new { tag = tag.UrlName }, new { title = string.Format("See All Posts in {0}", tag.Name) }); }
public async Task<Errorable<Tuple<Tag, CommitTree>>> GetCommitTreeByTagName(TagName tagName, int depth = 10) { var etg = await tgrepo.GetTagByName(tagName).ConfigureAwait(continueOnCapturedContext: false); if (etg.HasErrors) return etg.Errors; Tag tg = etg.Value; var eall = await getCommitsRecursively(tg.CommitID, 1, depth).ConfigureAwait(continueOnCapturedContext: false); if (eall.HasErrors) return eall.Errors; var all = eall.Value; // Return them (all[0] is the root): return new Tuple<Tag, CommitTree>( tg, new CommitTree(all[0].ID, new ImmutableContainer<CommitID, ICommit>(cm => cm.ID, all)) ); }
public Task<Errorable<Tuple<Tag, Commit>>> GetCommitByTagName(TagName tagName) { return db.ExecuteSingleQueryAsync(new QueryCommitByTagName(tagName)); }
public async Task<Errorable<TagID>> DeleteTagByName(TagName tagName) { var eid = await getTagIDByName(tagName).ConfigureAwait(continueOnCapturedContext: false); if (eid.HasErrors) return eid.Errors; var etg = await getTag(eid.Value).ConfigureAwait(continueOnCapturedContext: false); if (etg.HasErrors) return etg.Errors; Tag tg = etg.Value; deleteTag(tg); return eid.Value; }
public async Task<Errorable<Tag>> GetTagByName(TagName tagName) { var eid = await getTagIDByName(tagName).ConfigureAwait(continueOnCapturedContext: false); if (eid.HasErrors) return eid.Errors; var etg = await getTag(eid.Value).ConfigureAwait(continueOnCapturedContext: false); if (etg.HasErrors) return etg.Errors; Tag tg = etg.Value; // Check that the retrieved TagName matches what we asked for: if (tg.Name != tagName) return new TagNameDoesNotMatchExpectedError(tg.Name, tagName); return etg; }
private async Task<Errorable<TagID>> getTagIDByName(TagName tagName) { FileInfo fiTracker = system.getTagPathByTagName(tagName); Debug.Assert(fiTracker != null); if (!fiTracker.Exists) return new TagNameDoesNotExistError(tagName); byte[] buf; int nr = 0; using (var fs = new FileStream(fiTracker.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, 16384, true)) { // TODO: implement an async buffered Stream: buf = new byte[16384]; nr = await fs.ReadAsync(buf, 0, 16384).ConfigureAwait(continueOnCapturedContext: false); if (nr >= 16384) { // My, what a large tag you have! throw new NotSupportedException(); } } // Parse the TagID: using (var ms = new MemoryStream(buf, 0, nr, false)) using (var sr = new StreamReader(ms, Encoding.UTF8)) { string line = sr.ReadLine(); if (line == null) return new TagNameDoesNotExistError(tagName); return TagID.TryParse(line); } }
public TagNameDoesNotExistError(TagName tagName) : base("A tag with tag name '{0}' does not exist", tagName) { }
public Builder( TagName pName ,CommitID pCommitID ,string pTagger ,DateTimeOffset pDateTagged ,string pMessage ) { this.Name = pName; this.CommitID = pCommitID; this.Tagger = pTagger; this.DateTagged = pDateTagged; this.Message = pMessage; }
public TagNameAlreadyExistsError(TagName tagName) : base("A tag with tag name '{0}' already exists", tagName) { }
public async Task<Errorable<Tuple<Tag, Commit>>> GetCommitByTagName(TagName tagName) { var etg = await tgrepo.GetTagByName(tagName).ConfigureAwait(continueOnCapturedContext: false); if (etg.HasErrors) return null; Tag tg = etg.Value; var ecm = await getCommit(tg.CommitID).ConfigureAwait(continueOnCapturedContext: false); if (ecm.HasErrors) return ecm.Errors; Commit cm = ecm.Value; return new Tuple<Tag, Commit>(tg, cm); }
public TagNameDoesNotMatchExpectedError(TagName retrievedName, TagName expectedName) : base("Retrieved tag name '{0}' does not match expected tag name '{1}'", retrievedName, expectedName) { }
internal FileInfo getTagPathByTagName(TagName tagName) { if (tagName == null) throw new ArgumentNullException("tagName"); DirectoryInfo tagDir = getTagsDirectory(); string[] parts = new string[1] { tagDir.FullName }.Concat(tagName.Parts).ToArray(tagName.Parts.Count + 1); string path = System.IO.Path.Combine(parts); return new FileInfo(path); }
public ContentResult EditTag(TagName tag) { string json; if (ModelState.IsValid) { repo.EditTag(tag); json = JsonConvert.SerializeObject(new { id = tag.Id, success = true, message = "Changes saved successfully." }); } else { json = JsonConvert.SerializeObject(new { id = 0, success = false, message = "Failed to save the changes." }); } return Content(json, "application/json"); }
private void PushElementName (string name, string local, string prefix) { if (elementNames.Length == elementNameStackPos) { TagName [] newArray = new TagName [elementNames.Length * 2]; Array.Copy (elementNames, 0, newArray, 0, elementNameStackPos); elementNames = newArray; } elementNames [elementNameStackPos++] = new TagName (name, local, prefix); }
public static MvcHtmlString FakeTextArea(this HtmlHelper helper, TagName tag, string id, object value, int rows, IDictionary<string, object> htmlAttributes) { string output; TagBuilder tagBuilder; value = value ?? String.Empty; tagBuilder = new TagBuilder(EnumExtensions.ToPrettyLowerString(tag)); tagBuilder.MergeAttribute("id", id); //htmlAttributes.Add("height", (rows * 13) + "px"); tagBuilder.MergeAttributes(htmlAttributes); tagBuilder.AddCssClass("faketextarea"); tagBuilder.InnerHtml = value.ToString(); output = tagBuilder.ToString(TagRenderMode.Normal); return MvcHtmlString.Create(output); }