/// <summary> /// Pop off the top tag off the stack. /// </summary> /// <returns>A <see cref="TagPosition"/> representing the tag on the top of the stack.</returns> public TagPosition Pop() { TagPosition tgpTag = Last.Value; RemoveLast(); return(tgpTag); }
public bool EditTagPosition(Position position) { TagPosition tagPos = TagPositions.FindByCode(position.Tag);//判断是否存在实时数据 if (tagPos == null) { TagPosition tagPosition = new TagPosition(position); if (TagPositions.Add(tagPosition))//添加新的实时数据 { return(true); } else { ErrorMessage = Position.ErrorMessage; return(false); } } else { tagPos.Edit(position); if (TagPositions.Edit(tagPos))//修改实时数据 { return(true); } else { ErrorMessage = Position.ErrorMessage; return(false); } } }
public SimpleTagInfo(Tag tag, TagPosition tagPosition) : base(tag, tagPosition, 0) { if (tag == Tag.Hyperlink) { throw new ArgumentException($"Tag should be simple. {tag} is not a simple tag."); } }
private List <TagPosition> EditTagPositionList(List <Position> positions) { //1.获取列表 List <TagPosition> tagPosList = TagPositions.ToList(); List <TagPosition> changedTagPosList = new List <TagPosition>(); //2.修改数据 for (int i = 0; i < positions.Count; i++) { Position position = positions[i]; if (position == null) { continue; //位置信息可能有null } TagPosition tagPos = tagPosList.Find(item => item.Tag == position.Tag); if (tagPos == null) { continue; } tagPos.Edit(position); if (!changedTagPosList.Contains(tagPos)) { changedTagPosList.Add(tagPos); } } return(changedTagPosList); }
public void IfStoppedAtTag_ReturnCorrectStoppedAt(string markdown, Tag tag, TagPosition tagPosition, int tagPart) { var stoppedAt = ParseUntilGetStoppedAt(markdown, tag, new TagType(tagPosition, tagPart)); stoppedAt.Tag.Should().Be(tag); stoppedAt.TagPosition.Should().Be(tagPosition); }
public void IfFinished_ReturnNoneStoppedAt(string markdown, Tag tag, TagPosition tagPosition, int tagPart) { var stoppedAt = ParseUntilGetStoppedAt(markdown, tag, new TagType(tagPosition, tagPart)); stoppedAt.Tag.Should().Be(Tag.None); stoppedAt.TagPosition.Should().Be(TagPosition.None); }
public InjectCodeConfigRecord(string hostRegex, string pathRegex, string injectionCodeFile, string tag, TagPosition position) { this.HostnameStr = hostRegex; this.PathStr = pathRegex; this.InjectionCodeFile = injectionCodeFile; this.Tag = tag; this.Position = position; this.TagRegex = $@"(<\s*{tag}[^>]*>)"; this.InjectionCodeFileContent = File.ReadAllText(injectionCodeFile); }
private string SendPos(TagPosition tagPos) { var dbPos = tagPos.ToDbModel(); Position pos = new Position(); pos.SetProperty(dbPos); return(SendPos(pos)); }
public TagPosition GetPositon(string personId) { var query = from r in db.LocationCardToPersonnels.DbSet join tag in db.LocationCards.DbSet on r.LocationCardId equals tag.Id join pos in db.LocationCardPositions.DbSet on tag.Code equals pos.Id where r.PersonnelId + "" == personId select pos; TagPosition tagPos = query.FirstOrDefault().ToTModel(); return(tagPos); }
private void MenuSetNormal_OnClick(object sender, RoutedEventArgs e) { SetFlag("0:0:0:0:0", 380); TagPosition pos = DataGrid1.SelectedItem as TagPosition; if (pos == null) { return; } offlinePos.Remove(pos.Tag); }
internal static void AreTagPositionsSame(TagPosition expectedTagPosition, TagPosition actualTagPosition) { if (expectedTagPosition == null && actualTagPosition == null) { return; } Assert.IsTrue((expectedTagPosition == null) == (actualTagPosition == null), "One TagPosition is null but the other isn't"); Assert.AreEqual(expectedTagPosition.EndPosition, actualTagPosition.EndPosition); Assert.AreEqual(expectedTagPosition.StartEndPosition, actualTagPosition.StartEndPosition); Assert.AreEqual(expectedTagPosition.StartPosition, actualTagPosition.StartPosition); }
public PersonShape(AreaCanvas canvas, int id, string name, TagPosition pos, double scale, double size = 2) { Id = id; Name = name; _canvas = canvas; Pos = pos; _scale = scale; _size = size; PosX = Pos.X; PosY = Pos.Z; }
public void AtSpecifiedPosition_FindNextTag(string markdown, int position, Tag expectedTag, TagPosition expectedPosition, int expectedPart) { var markdownEnumerable = new StringMarkdownEnumerable(markdown); markdownEnumerable.SkipCharacters(position); var expectedTagInfo = TagInfo.Create(expectedTag, new TagType(expectedPosition, expectedPart)); var returnedTagInfo = markdownEnumerable.GetNextTag(new[] { expectedTagInfo }); returnedTagInfo.Should().Be(expectedTagInfo); }
private void MenuRefreshOnTheSpotOne_OnClick(object sender, RoutedEventArgs e) { TagPosition position = DataGrid1.SelectedItem as TagPosition; if (position == null) { return; } position.DateTime = DateTime.Now; position.Time = DateTime.Now.ToStamp(); Modify(position); RefreshData(); }
private void MenuSetOffline_OnClick(object sender, RoutedEventArgs e) { TagPosition pos = DataGrid1.SelectedItem as TagPosition; if (pos == null) { return; } //SetFlag("0:0:0:0:1"); if (!offlinePos.Contains(pos.Tag)) { offlinePos.Add(pos.Tag); } }
public void TestSlices() { EntityRegistry registry = new EntityRegistry(5000); TagPosition sliceTagPosition = new TagPosition(); registry.SetupSlice(ref sliceTagPosition); ParentedPosition sliceParentedPosition = new ParentedPosition(); registry.SetupSlice(ref sliceParentedPosition); UnparentedPosition sliceUnparentedPosition = new UnparentedPosition(); registry.SetupSlice(ref sliceUnparentedPosition); List <Entity> entities = new List <Entity>(registry.Capacity); for (int i = 0; i < registry.Capacity; ++i) { Entity entity = registry.Create(); entities.Add(entity); registry.AddComponent(entity, new PositionComponent(i, i)); } Assert.AreEqual(0, sliceTagPosition.Positions.Count); Assert.AreEqual(0, sliceParentedPosition.Positions.Count); Assert.AreEqual((int)registry.Capacity, sliceUnparentedPosition.Positions.Count); for (int i = 0; i < registry.Capacity; i += 2) { Entity entity = entities[i]; registry.AddComponent(entity, new ParentedComponent(entities[i + 1])); } Assert.AreEqual(0, sliceTagPosition.Positions.Count); Assert.AreEqual(2500, sliceParentedPosition.Positions.Count); Assert.AreEqual(2500, sliceUnparentedPosition.Positions.Count); foreach (Entity entity in entities) { registry.Destroy(entity); } entities.Clear(); Assert.AreEqual(0, sliceTagPosition.Positions.Count); Assert.AreEqual(0, sliceParentedPosition.Positions.Count); Assert.AreEqual(0, sliceUnparentedPosition.Positions.Count); }
private void SetFlag(string flag, int power = 0) { TagPosition pos = DataGrid1.SelectedItem as TagPosition; if (pos == null) { return; } pos.Flag = flag; if (power > 0) { pos.Power = power; } Modify(pos); RefreshData(); }
public TagPosition GetPositon(string personId) { try { var query = from r in db.LocationCardToPersonnels.DbSet join tag in db.LocationCards.DbSet on r.LocationCardId equals tag.Id join pos in db.LocationCardPositions.DbSet on tag.Code equals pos.Id where r.PersonnelId + "" == personId select pos; TagPosition tagPos = query.FirstOrDefault().ToTModel(); return(tagPos); } catch (System.Exception ex) { Log.Error(tag, "GetPositon", ex.ToString()); return(null); } }
/// <summary> /// Factory method for creating test Tags /// </summary> /// <returns>The test tag.</returns> /// <param name="tagName">Tag name.</param> /// <param name="searchText">Search text.</param> /// <param name="startTagStartPosition">Start tag start position.</param> /// <param name="startTagStartEndPosition">Start tag start end position.</param> /// <param name="startTagEndPosition">Start tag end position.</param> /// <param name="endTagStartPosition">End tag start position.</param> /// <param name="endTagStartEndPosition">End tag start end position.</param> /// <param name="endTagEndPosition">End tag end position.</param> /// <param name="content">Content.</param> /// <param name="properties">Properties.</param> internal static Tag CreateTestTag( string tagName, string searchText, int startTagStartPosition, int startTagStartEndPosition, int startTagEndPosition, int?endTagStartPosition = null, int?endTagStartEndPosition = null, int?endTagEndPosition = null, string content = null, Dictionary <string, string> properties = null ) { TagPosition startTagPosition = new TagPosition() { StartPosition = startTagStartPosition, StartEndPosition = startTagStartEndPosition, EndPosition = startTagEndPosition }; // Create an end tag, if needed TagPosition endTagPosition = null; if (endTagStartPosition.HasValue && endTagStartEndPosition.HasValue && endTagEndPosition.HasValue) { endTagPosition = new TagPosition() { StartPosition = endTagStartPosition.Value, StartEndPosition = endTagStartEndPosition.Value, EndPosition = endTagEndPosition.Value }; } return(new Tag() { Contents = content, HasContent = content != null, Name = tagName, Properties = properties == null ? new Dictionary <string, string>() : properties, SearchText = searchText, StartTagPosition = startTagPosition, EndTagPosition = endTagPosition }); }
private static bool AreGoodPositionsForTag(TagPosition tagPosition, string markdown, int positionBefore, int positionAfter) { if (tagPosition == TagPosition.None) { return(false); } if (tagPosition == TagPosition.Opening) { var correctAtPositionBefore = IsPositionOutOfRange(markdown, positionBefore) || char.IsWhiteSpace(markdown, positionBefore); var correctAtPositionAfter = IsPositionOutOfRange(markdown, positionAfter) || !char.IsWhiteSpace(markdown, positionAfter); return(correctAtPositionBefore && correctAtPositionAfter); } if (tagPosition == TagPosition.Closing) { return(AreGoodPositionsForTag(TagPosition.Opening, markdown, positionAfter, positionBefore)); } throw new ArgumentException($"Unknown tag type:{tagPosition}"); }
public TagPositionTrans PostArcho(TagPositionTrans recv) { int total = recv.total; List <TagPosition> data = recv.data; foreach (TagPosition item in data) { TagPosition item2 = TagPositionList.Find(p => p.Tag == item.Tag); if (item2 != null) { TagPositionList.Remove(item2); item2 = item; } TagPositionList.Add(item); } TagPositionTrans send = new TagPositionTrans(); send.total = total; send.msg = "ok"; return(send); }
public void AddTagPositionsByTags(List <Tag> tags) { List <TagPosition> tagPosList = TagPositions.ToList();//事先取出全部到内存中,比每次都到数据库中查询快很多。 100个从6.4s->1.8s,1.8s中主要是第一次查询的一些初始工作 List <TagPosition> newPosList = new List <TagPosition>(); foreach (Tag tag in tags) { //TagPosition tagPos = TagPositions.FindByCode(tag.Code);//100个要2s TagPosition tagPos = tagPosList.Find(i => i.Tag == tag.Code);//判断是否存在实时数据 if (tagPos == null) { TagPosition tagPosition = new TagPosition(tag.Code); newPosList.Add(tagPosition); } } //TagPositions.Db.BulkInsert(newPosList);//插件Z.EntityFramework.Extensions功能 //TagPositions.Db.BulkSaveChanges(); foreach (TagPosition tp in newPosList) { TagPositions.Add(tp); } }
protected TagInfo(Tag tag, TagPosition tagPosition, int tagPart) { Tag = tag; TagType = new TagType(tagPosition, tagPart); }
public void ParseUntilEnd(string markdown, Tag tag, TagPosition tagPosition, int tagPart) { var markdownEnumerable = ParseUntil(markdown, tag, new TagType(tagPosition, tagPart)); markdownEnumerable.IsFinished().Should().BeTrue(); }
public void ParseUntilMeetTag(string markdown, Tag tag, TagPosition tagPosition, int tagPart, char symbolAfterTag) { var markdownEnumerable = ParseUntil(markdown, tag, new TagType(tagPosition, tagPart)); markdownEnumerable.GetNextChar().Should().Be(symbolAfterTag); }
public static TagInfo Create(Tag tag, TagPosition tagPosition, int tagPart) { return(Create(tag, new TagType(tagPosition, tagPart))); }
private void InitTagPositions() { Log.InfoStart("InitTagPositions"); Tag tag1 = new Tag() { Name = "标签1", Code = "0002" }; Tag tag2 = new Tag() { Name = "标签2", Code = "0003" }; Tag tag3 = new Tag() { Name = "标签3", Code = "0004" }; Tag tag4 = new Tag() { Name = "标签4", Code = "0005" }; Tag tag5 = new Tag() { Name = "标签5", Code = "0006" }; Tag tag6 = new Tag() { Name = "标签6", Code = "0007" }; Tag tag7 = new Tag() { Name = "标签7", Code = "0008" }; Tag tag8 = new Tag() { Name = "标签8", Code = "0009" }; List <Tag> tags = new List <Tag>() { tag1, tag2, tag3, tag4, tag5, tag6, tag7, tag8 }; Tags.AddRange(tags); //TagPosition tagposition1 = new TagPosition() { Tag = "0002", X = -50, Y = -50, Z = -50, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; //TagPosition tagposition2 = new TagPosition() { Tag = "0003", X = -50, Y = -50, Z = -50, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; TagPosition tagposition1 = new TagPosition() { Tag = "0002", X = 2293.5, Y = 2, Z = 1715.5F, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; TagPosition tagposition2 = new TagPosition() { Tag = "0003", X = 2294.5, Y = 2, Z = 1715.5f, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; TagPosition tagposition3 = new TagPosition() { Tag = "0004", X = 2295.5, Y = 2, Z = 1715.5F, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; TagPosition tagposition4 = new TagPosition() { Tag = "0005", X = 2296.5, Y = 2, Z = 1715.5f, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; TagPosition tagposition5 = new TagPosition() { Tag = "0006", X = 2297.5, Y = 2, Z = 1715.5F, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; TagPosition tagposition6 = new TagPosition() { Tag = "0007", X = 2298.5, Y = 2, Z = 1715.5F, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; TagPosition tagposition7 = new TagPosition() { Tag = "0008", X = 2299.5, Y = 2, Z = 1715.5f, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; TagPosition tagposition8 = new TagPosition() { Tag = "0009", X = 2300.5, Y = 2, Z = 1715.5F, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; List <TagPosition> tagpositions = new List <TagPosition>() { tagposition1, tagposition2, tagposition3, tagposition4, tagposition5, tagposition6, tagposition7, tagposition8 }; TagPositions.AddRange(tagpositions); Position position1 = new Position() { Tag = "002", X = -50, Y = -50, Z = -50, Time = 1527754678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position2 = new Position() { Tag = "002", X = 0, Y = 0, Z = 0, Time = 1527756478, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position3 = new Position() { Tag = "002", X = 50, Y = 50, Z = 50, Time = 1527758278, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position4 = new Position() { Tag = "002", X = 100, Y = 100, Z = 100, Time = 1527760078, Power = 0, Number = 0, Flag = "0:0:0:0:1" }; Position position5 = new Position() { Tag = "002", X = 150, Y = 150, Z = 150, Time = 1527761878, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position6 = new Position() { Tag = "002", X = 200, Y = 200, Z = 200, Time = 1527763678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position7 = new Position() { Tag = "002", X = 250, Y = 250, Z = 250, Time = 1527765478, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position8 = new Position() { Tag = "002", X = 300, Y = 300, Z = 300, Time = 1527767278, Power = 0, Number = 0, Flag = "0:0:0:0:1" }; Position position9 = new Position() { Tag = "002", X = 350, Y = 350, Z = 350, Time = 1527769078, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position10 = new Position() { Tag = "002", X = 400, Y = 400, Z = 400, Time = 1527770878, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position11 = new Position() { Tag = "002", X = 500, Y = 500, Z = 450, Time = 1527772678, Power = 0, Number = 0, Flag = "0:0:0:0:1" }; Position position12 = new Position() { Tag = "002", X = 600, Y = 600, Z = 500, Time = 1527774478, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position13 = new Position() { Tag = "002", X = 700, Y = 700, Z = 550, Time = 1527776278, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position14 = new Position() { Tag = "002", X = 800, Y = 800, Z = 600, Time = 1527778078, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position15 = new Position() { Tag = "002", X = 900, Y = 900, Z = 650, Time = 1527779878, Power = 0, Number = 0, Flag = "0:0:0:0:1" }; Position position16 = new Position() { Tag = "002", X = 1100, Y = 1100, Z = 700, Time = 1527781678, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position17 = new Position() { Tag = "002", X = 1200, Y = 1200, Z = 750, Time = 1527783478, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position18 = new Position() { Tag = "002", X = 1300, Y = 1300, Z = 800, Time = 1527785278, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position19 = new Position() { Tag = "002", X = 1400, Y = 1400, Z = 850, Time = 1527787078, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; Position position20 = new Position() { Tag = "002", X = 1500, Y = 1500, Z = 900, Time = 1527788878, Power = 0, Number = 0, Flag = "0:0:0:0:0" }; List <Position> positions = new List <Position>() { position1, position2, position3, position4, position5, position6, position7, position8, position9, position10, position11, position12, position13, position14, position15, position16, position17, position18, position19, position20 }; Position.AddRange(positions); Log.InfoEnd("InitTagPositions"); }
public HyperlinkTagInfo(TagPosition tagPosition, int tagPart) : base(Tag.Hyperlink, tagPosition, tagPart) { }
public HeaderTagInfo(TagPosition tagPosition, int level = -1) : base(Tag.Header, tagPosition, 0) { HeaderLevel = level; }
private void Modify(TagPosition pos) { //PosService service = new PosService(); //service.Put(pos); SendPos(pos); }