public static byte[] GetXCTagData(string value) { var tagUtils = new TagUtils(); tagUtils.AddStringTag("XC", value); return(tagUtils.ToBytes()); }
private void OnTriggerEnter(Collider other) { if (TagUtils.IsPlayer(other)) { EventManager.ReachPortal(); } }
private static void AssertResults ( string folderPath, string filter, params string[] expectedResults) { // Reset the testing directory before comparing, in case a previous test // changed it Utils.ResetTestFolder(); // Get the actual results string fullPath = Utils.GetTestFolder(folderPath); TagFilter tagFilter = new TagFilter(filter); var actualResults = TagUtils.GetMatchingFiles(fullPath, tagFilter); // Convert them to their file names so we can compare them as strings var actualResultsPaths = actualResults.Select(f => f.Name); // Sort them before comparing them, because we don't care about order. actualResultsPaths = actualResultsPaths.OrderBy(s => s).ToArray(); expectedResults = expectedResults.OrderBy(s => s).ToArray(); // Compare them to the expected results bool matches = actualResultsPaths.SequenceEqual(expectedResults); Assert.IsTrue(matches); }
private static void TestFilenameToTagProcessorSimple() { string undoFilename = VirtualDrive.VirtualFileName( @"TestFilenameToTagProcessor\TestFilenameToTagProcessorUndoFile.txt"); string filename = VirtualDrive.VirtualFileName( @"TestFilenameToTagProcessor\My Artist - 03 - My Title.mp3"); string pattern = "Artist - TrackNumber - Title"; VirtualDrive.Store(filename, TestTags.mpegDummy); FilenameToTagProcessor processor = new FilenameToTagProcessor(); processor.ProcessMessage(new FilenameToTagProcessor.Message(pattern)); using (UndoFileWriter undoFileWriter = new UndoFileWriter(undoFilename)) { processor.UndoFile = undoFileWriter; processor.Process(new FileInfo(filename)); } TagEditor editor = new TagEditor(TagUtils.ReadTag(new FileInfo(filename))); UnitTest.Test(editor.Artist == "My Artist"); UnitTest.Test(editor.TrackNumber == "03"); UnitTest.Test(editor.Title == "My Title"); UndoFilePlayer.Undo(undoFilename); UnitTest.Test(Object.ReferenceEquals(TagUtils.ReadTag(new FileInfo(filename)), null)); }
public override void Undo() { FileInfo f = new FileInfo(FileName); bool hasV1InFile = TagUtils.HasTagV1(f); bool hasV2InFile = TagUtils.HasTagV2(f); bool hasV1ToWrite = TagUtils.HasTagV1(OldTag0); bool hasV2ToWrite = TagUtils.HasTagV2(OldTag1); if (hasV1InFile && hasV2ToWrite || hasV2InFile && hasV1ToWrite || Object.ReferenceEquals(OldTag0, null) && Object.ReferenceEquals(OldTag1, null)) { TagUtils.StripTags(f, 0, 0); } if (!Object.ReferenceEquals(OldTag0, null)) { TagUtils.WriteTag(OldTag0, f); } if (!Object.ReferenceEquals(OldTag1, null)) { TagUtils.WriteTag(OldTag1, f); } }
private void OnTriggerExit(Collider other) { if (TagUtils.IsPlayer(other)) { _isDamaging = false; } }
public override void Process(object obj) { FileInfo file = obj as FileInfo; try { Logger.WriteLine(Tokens.Info, file.FullName); if (TagUtils.HasTagV1(file)) { Logger.Write(Tokens.Info, TagUtils.ReadTagV1(file)); } if (TagUtils.HasTagV2(file)) { Logger.Write(Tokens.Info, TagUtils.ReadTagV2(file)); } } catch (VersionInvariant e) { throw e; } catch (Exception e) { Logger.WriteLine(Tokens.Info, e.Message); } }
virtual public void TestSiblingAvailableMinus1() { parent.AddChild(sibling1); parent.AddChild(sibling2); parent.AddChild(sibling3); Assert.AreEqual(sibling1, TagUtils.GetInstance().GetSibling(sibling2, -1)); }
private BamAlignment CreateAlignment(string name, int position, string cigar, string bases, int nm = -1, uint mapq = 1) { var alignment = new BamAlignment(); alignment.Name = name; alignment.Position = position; alignment.RefID = 1; alignment.MapQuality = mapq; alignment.CigarData = new CigarAlignment(cigar); alignment.Bases = bases; alignment.Qualities = new byte[alignment.Bases.Length]; alignment.Qualities = Enumerable.Repeat((byte)30, alignment.Bases.Length).ToArray(); // Generates quality scores of 30 alignment.SetIsProperPair(true); var tagUtils = new TagUtils(); if (nm >= 0) { tagUtils.AddIntTag("NM", nm); } alignment.TagData = tagUtils.ToBytes(); return(alignment); }
public override void Do() { FileInfo f = new FileInfo(FileName); bool hasV1InFile = TagUtils.HasTagV1(f); bool hasV2InFile = TagUtils.HasTagV2(f); bool hasV1ToWrite = TagUtils.HasTagV1(NewTag); bool hasV2ToWrite = TagUtils.HasTagV2(NewTag); if (hasV1InFile) { OldTag0 = TagUtils.ReadTagV1Raw(f); } if (hasV2InFile) { OldTag1 = TagUtils.ReadTagV2Raw(f); } if (hasV1InFile && hasV2ToWrite || hasV2InFile && hasV1ToWrite) { TagUtils.StripTags(f, 0, 0); } TagUtils.WriteTag(NewTag, f); }
public static void ProcessCommand(SerializedCommand command) { byte[] tag = System.Convert.FromBase64String(command.Data[1].ToString()); FileInfo fileInfo = new FileInfo(command.Data[0]); TagUtils.WriteTag(tag, fileInfo); }
public void Load(string fileName) { Tag tag = TagUtils.ReadTag(new FileInfo(fileName)); int bitrate = -1; if (!Object.ReferenceEquals(tag, null)) { try { int tagSize = TagUtils.TagSizeV2(new FileInfo(fileName)); using (Stream stream = VirtualDrive.OpenInStream(fileName)) { stream.Seek(tagSize, SeekOrigin.Begin); bitrate = ID3MediaFileHeader.MP3Header.ReadBitrate( stream, VirtualDrive.FileLength(fileName)); } } catch (Exception) { bitrate = -1; } } Init(fileName, tag, bitrate); }
private static void CheckReadIndexToExpandedIndex(string inputXDtag, string inputCigarString, string sequence, int[] readIndexes, int[] expectedExpandedIndexes) { var tagUtils = new TagUtils(); tagUtils.AddStringTag("XD", inputXDtag); var alignment = new BamAlignment { Bases = sequence, Position = 100, MatePosition = 500, Name = "test", CigarData = new CigarAlignment(inputCigarString), MapQuality = 10, TagData = tagUtils.ToBytes(), Qualities = new[] { (byte)10, (byte)20, (byte)30 } }; var read = new Read("chr7", alignment); var directionMap = read.SequencedBaseDirectionMap; var observedExpandedIndexes = read.SequencedIndexesToExpandedIndexes(readIndexes); for (int i = 0; i < readIndexes.Length; i++) { var observedExpandedIndex = observedExpandedIndexes[i]; var expectedExpandedIndex = expectedExpandedIndexes[i]; Assert.Equal(expectedExpandedIndex, observedExpandedIndex); } ; }
private static void CheckSequencedBaseDirectionMap(string inputXDtag, string inputCigarString, string sequence, DirectionType[] expectedDirectionMap) { var tagUtils = new TagUtils(); tagUtils.AddStringTag("XD", inputXDtag); var alignment = new BamAlignment { Bases = sequence, Position = 100, MatePosition = 500, Name = "test", CigarData = new CigarAlignment(inputCigarString), MapQuality = 10, TagData = tagUtils.ToBytes(), Qualities = new[] { (byte)10, (byte)20, (byte)30 } }; var read = new Read("chr7", alignment); var directionMap = read.SequencedBaseDirectionMap; Assert.Equal(expectedDirectionMap, directionMap); var directTestMap = Read.CreateSequencedBaseDirectionMap(read.CigarDirections.Expand().ToArray(), read.CigarData); Assert.Equal(expectedDirectionMap, directTestMap); }
static void InitTagTagUtils() { if (LayerMask.NameToLayer(HLOD.HLODLayerStr) == -1) { TagUtils.AddLayer(HLOD.HLODLayerStr); Tools.lockedLayers |= 1 << LayerMask.NameToLayer(HLOD.HLODLayerStr); } }
// Checks Tags from Resource in Azure with information from db. // Makes sure they are equal. async Task CheckAndUpdateTags(CloudResource resource) { try { var serviceForResource = AzureResourceServiceResolver.GetServiceWithTags(_serviceProvider, resource.ResourceType); if (serviceForResource == null) { LogMonitoringError(resource, SepesEventId.MONITORING_NO_TAG_SERVICE, $"Could not resolve tag service for resource type: {resource.ResourceType}", critical: true); } else { // Read info used to create tags from resourceGroup in DB // These tags should be checked with the ones in Azure. var tagsFromDb = TagUtils.TagStringToDictionary(resource.Tags); var tagsFromAzure = await serviceForResource.GetTagsAsync(resource.ResourceGroupName, resource.ResourceName); if (tagsFromDb != null && tagsFromDb.Count > 0 && tagsFromAzure == null) { _logger.LogWarning(SepesEventId.MONITORING_NO_TAGS, $"No tags found for resource {resource.Id}!"); return; } // Check against tags from resource in Azure. // If different => update Tags and report difference to Study Owner? foreach (var tag in tagsFromAzure) { //Do not check CreatedByMachine-tag, as this will be different from original. if (!tag.Key.Equals("CreatedByMachine")) { if (!tagsFromDb.TryGetValue(tag.Key, out string dbValue)) { // If Tag exists in Azure but not in tags generated from DB-data, report. // Means that user has added tags themselves in Azure. LogMonitoringError(resource, SepesEventId.MONITORING_MANUALLY_ADDED_TAGS, $"Tag {tag.Key} : {tag.Value} has been added after resource creation!"); } else { // If Tag exists in Azure and Db but has different value in Azure if (!tag.Value.Equals(dbValue)) { LogMonitoringError(resource, SepesEventId.MONITORING_INCORRECT_TAGS, $"Tag {tag.Key} : {tag.Value} does not match value from Sepes : {dbValue}"); //Update tag in Azure to match DB-information. await serviceForResource.UpdateTagAsync(resource.ResourceGroupName, resource.ResourceName, new KeyValuePair <string, string>(tag.Key, dbValue)); _logger.LogWarning($"Updated Tag: {tag.Key} from value: {tag.Value} => {dbValue}"); } } } } } } catch (Exception ex) { LogMonitoringError(resource, SepesEventId.MONITORING_CRITICAL, $"Tag check/update failed", ex); } }
protected Pool InitPool(T tagEnum) { var pool = GameObject .FindGameObjectWithTag(TagUtils.GetTagNameByEnum(tagEnum)) .GetComponent <Pool>(); pool.Init(); return(pool); }
public static BamAlignment StitchifyBamAlignment(ReadPair pair, Read read, char read1dir, char read2dir) { var alignment = new BamAlignment(read.BamAlignment); alignment.SetIsFirstMate(false); alignment.SetIsProperPair(false); var tagUtils = new TagUtils(); if (read.StitchedCigar != null) { alignment.CigarData = read.StitchedCigar; } if (read.CigarDirections != null) { tagUtils.AddStringTag("XD", read.CigarDirections.ToString()); } // if the original reads had UMIs and were collapsed, they will have XU(Z), XV(i), XW(i) // these need to be copied to correctly populate some fields in the called variants if (pair.Read1.TagData != null && pair.Read1.TagData.Length > 0) { var xu = pair.Read1.GetStringTag("XU"); if (xu != null) { tagUtils.AddStringTag("XU", xu); } var xv = pair.Read1.GetIntTag("XV"); if (xv.HasValue) { tagUtils.AddIntTag("XV", xv.Value); } var xw = pair.Read1.GetIntTag("XW"); if (xw.HasValue) { tagUtils.AddIntTag("XW", xw.Value); } } var xr = string.Format("{0}{1}", read1dir, read2dir); tagUtils.AddStringTag("XR", xr); var tagData = tagUtils.ToBytes(); var existingTags = alignment.TagData; if (existingTags == null) { alignment.TagData = tagData; } else { alignment.AppendTagData(tagData); } return(alignment); }
void CheckWeaponCollider(Collider other) { if (TagUtils.GetTagType(other.tag) == TagType.Monster) { // other.transform.SendMessage("BeHitAndDamaged", ""); //与附加碰撞器边界框最近的点。 // Vector3 pos=other.ClosestPointOnBounds(transform.position); } }
public override void Process(object obj) { FileInfo file = obj as FileInfo; if (TagUtils.HasTagV2(file)) { TagVersionProcessor converter = new TagVersionProcessor(ID3.Version.v2_0); converter.Process(TagUtils.ReadTagV2(file)); } }
private void OnTriggerEnter(Collider other) { if (TagUtils.IsEnemy(other)) { triggered = true; this.other = other; var enemy = other.gameObject.GetComponent <EnemyController>(); _fpsController.AttackManager.AddTarget(enemy.Id); } }
private void ProcessFileForAdd(string fileName, HashSet <string> filenamesCaseInsensitive) { if (filenamesCaseInsensitive.Contains(fileName)) { return; } try { ID3.Tag tag = ID3.TagUtils.ReadTag(new FileInfo(fileName)); if (!Object.ReferenceEquals(tag, null)) { ID3.TagEditor editor = new ID3.TagEditor(tag); int bitrate = -1; if (!Object.ReferenceEquals(tag, null)) { try { int tagSize = TagUtils.TagSizeV2(new FileInfo(fileName)); using (Stream stream = VirtualDrive.OpenInStream(fileName)) { stream.Seek(tagSize, SeekOrigin.Begin); bitrate = ID3MediaFileHeader.MP3Header.ReadBitrate( stream, VirtualDrive.FileLength(fileName)); } } catch (Exception) { bitrate = -1; } } var track = new Tracks(); track.ID = Guid.NewGuid(); track.Artist = ShrinkText(editor.Artist, 64); track.Title = ShrinkText(editor.Title, 64); track.Album = ShrinkText(editor.Album, 64); track.Filename = ShrinkText(fileName, 1024); track.ReleaseYear = ShrinkText(editor.ReleaseYear, 10); track.TrackNumber = ShrinkText(editor.TrackNumber, 10); track.PartOfSet = ShrinkText(editor.PartOfSet, 10); track.ContentType = ShrinkText(editor.ContentType, 64); track.FullText = ShrinkText(track.Artist + track.Title + track.Album + track.ContentType, 256); track.Bitrate = ShrinkText(bitrate.ToString(), 10); databaseChanger.AddTrack(track); } } catch (Exception) { } }
// Update is called once per frame void Update() { if ((wasTagged && wasBlockResolved) || (GameState.Singleton.CurrentState != State.Running)) { return; } // Check for if the object has been clicked on. // XXX (kasiu): Assigns points for the tag select, but does not check if it matches gold standard. if (!wasTagged) { foreach (Triple <double, string, string> ct in GameState.Singleton.clickTrace) { if (ct.Second == transform.name) { wasTagged = true; this.click = ct; GameState.Singleton.score += baseScore; //Debug.Log("OH GOODNESS! OUR SCORE CHANGED!"); break; } } // Check to see if it's been blocked (and dock points). // NOTE (kasiu): This really doesn't need to be isolated: refactor back into above loop if (wasTagged) { foreach (Triple <double, string, string> pt in GameState.Singleton.partnerTrace) { if (wasAssignmentBeaten(pt, click)) { // We've been blocked BOO HISS. wasBlockResolved = true; GameState.Singleton.score -= blockPenalty; string str = "-" + blockPenalty + " points!\n" + "(SELECTED SECOND)"; GUIUtils.SpawnFloatingText(TagUtils.GetPositionOfChildTag(this.gameObject, click.Third), str, Color.black, 2.0f); Debug.Log(str); } } } } else // Tagged, but block hasn't been resolved. { foreach (Triple <double, string, string> pt in GameState.Singleton.partnerTrace) { if (wasAssignmentBeaten(click, pt) && GameState.Singleton.TimeUsed >= pt.First) { wasBlockResolved = true; GameState.Singleton.score += blockPenalty; string str = "+" + blockPenalty + " points!\n" + "(SELECTED FIRST)"; GUIUtils.SpawnFloatingText(TagUtils.GetPositionOfChildTag(this.gameObject, click.Third), str, Color.black, 2.0f); Debug.Log(str); } } } }
public void Add(string fileName) { Tag tag = TagUtils.ReadTag(new FileInfo(fileName)); if (tag == null) { tag = new Tag(ID3.Preferences.PreferredVersion); } Add(fileName, tag, -1); }
private void CheckHasTag(AlbumData album, FileInfo file) { if (TagUtils.HasTag(file)) { album.Result = ParseResult.Fine; } else { album.Result = ParseResult.NoTagAtAll; } }
public static GameObject GetChildrenWithTag <T>(GameObject gameObject, T tag) { foreach (Transform child in gameObject.transform) { if (TagUtils.CompareGameObjectTag(child.gameObject, tag)) { return(child.gameObject); } } return(null); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } var siteId = AuthRequest.GetQueryInt("siteId"); _tag = AuthRequest.GetQueryString("tag"); if (AuthRequest.IsQueryExists("remove")) { var channelId = AuthRequest.GetQueryInt("channelId"); var contentId = AuthRequest.GetQueryInt("contentId"); var channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId); var contentInfo = ContentManager.GetContentInfo(SiteInfo, channelInfo, contentId); var tagList = TranslateUtils.StringCollectionToStringList(contentInfo.Tags, ' '); if (tagList.Contains(_tag)) { tagList.Remove(_tag); } contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagList, " "); DataProvider.ContentDao.Update(SiteInfo, channelInfo, contentInfo); TagUtils.RemoveTags(SiteId, contentId); AuthRequest.AddSiteLog(SiteId, "移除内容", $"内容:{contentInfo.Title}"); SuccessMessage("移除成功"); AddWaitAndRedirectScript(PageUrl); } SpContents.ControlToPaginate = RptContents; RptContents.ItemDataBound += RptContents_ItemDataBound; SpContents.ItemsPerPage = SiteInfo.Additional.PageSize; SpContents.SelectCommand = DataProvider.ContentDao.GetSqlStringByContentTag(SiteInfo.TableName, _tag, siteId); SpContents.SortField = ContentAttribute.AddDate; SpContents.SortMode = SortMode.DESC; if (IsPostBack) { return; } VerifySitePermissions(ConfigManager.SitePermissions.ConfigGroups); LtlContentTag.Text = "标签:" + _tag; SpContents.DataBind(); }
private static GH_Structure <GH_String> GetTagStrings(IEnumerable <StbBeam> beams, StbSections sections) { var ghSecStrings = new GH_Structure <GH_String>(); foreach (var item in beams.Select((beam, index) => new { beam, index })) { string secId = item.beam.id_section; var ghPath = new GH_Path(0, item.index); StbGirderKind_structure kindStruct = item.beam.kind_structure; switch (kindStruct) { case StbGirderKind_structure.RC: StbSecBeam_RC secRc = sections.StbSecBeam_RC.First(i => i.id == secId); foreach (object figureObj in secRc.StbSecFigureBeam_RC.Items) { ghSecStrings.AppendRange(TagUtils.GetBeamRcSection(figureObj, secRc.strength_concrete), ghPath); } break; case StbGirderKind_structure.S: StbSecBeam_S secS = sections.StbSecBeam_S.First(i => i.id == secId); foreach (object figureObj in secS.StbSecSteelFigureBeam_S.Items) { ghSecStrings.AppendRange(TagUtils.GetBeamSSection(figureObj), ghPath); } break; case StbGirderKind_structure.SRC: StbSecBeam_SRC secSrc = sections.StbSecBeam_SRC.First(i => i.id == secId); foreach (object figureObj in secSrc.StbSecFigureBeam_SRC.Items) { ghSecStrings.AppendRange(TagUtils.GetBeamRcSection(figureObj, secSrc.strength_concrete), ghPath); } foreach (object figureObj in secSrc.StbSecSteelFigureBeam_SRC.Items) { ghSecStrings.AppendRange(TagUtils.GetBeamSSection(figureObj), ghPath); } break; case StbGirderKind_structure.UNDEFINED: break; default: throw new ArgumentOutOfRangeException(); } } return(ghSecStrings); }
// Events private async void goButton_Click(object sender, RoutedEventArgs e) { string tag = deleteTextbox.Text; // Disable the controls while we wait IsEnabled = false; progressBar.Visibility = Visibility.Visible; // Replace the tags asynchronously await Task.Run(() => TagUtils.DeleteTag(directory, tag)); // Close this window Close(); }
public void TestTagValueStateChanges() { SetupParser(); tagFile.SetupDefaultConfiguration(0); var unixTimestamp = TagUtils.GetCurrentUnixTimestampMillis(); var timeStamp = "TME" + unixTimestamp.ToString(); var rs = Convert.ToChar(TagConstants.RS).ToString(); var hdr = rs + timeStamp + rs + "HDR1" + rs + "GPM3" + rs + "DESDesign A" + rs + "LAT0.631930995750444" + rs + "LON-2.007479992025198" + rs + "HGT542" + rs + "MIDTestTagFileChange" + rs + "UTM0" + rs + "HDG90" + rs + "SER1551J025SW" + rs + "MTPCOM" + rs + "BOG0" + rs + "MPM0" + rs + "CST1" + rs + "FLG4" + rs + "TMP900" + rs + "TCC600" + rs + "DIR1" + rs + "TTS200" + rs + "TPC5" + rs + "TMD200" + rs + "TMN90" + rs + "TMX143"; tagFile.ParseText(hdr); // first change record unixTimestamp += 100; timeStamp = "TME" + unixTimestamp.ToString(); var rec = rs + timeStamp + rs + "HDR0" + rs + "LEB2745" + rs + "LNB1163.5" + rs + "LHB542" + rs + "REB2745" + rs + "RNB1163" + rs + "RHB542" + rs + "BOG1" + rs + "HDG90" + rs + "CCV600" + rs + "MDP210"; tagFile.ParseText(rec); // no change unixTimestamp += 100; timeStamp = "TME" + unixTimestamp.ToString(); rec = rs + timeStamp + rs + "HDR0" + rs + "LEB2745" + rs + "LNB1163.5" + rs + "LHB542" + rs + "REB2745" + rs + "RNB1163" + rs + "RHB542" + rs + "BOG1" + rs + "HDG90" + rs + "CCV600" + rs + "MDP210"; tagFile.ParseText(rec); // full change 2nd epoch unixTimestamp += 100; timeStamp = "TME" + unixTimestamp.ToString(); rec = rs + timeStamp + rs + "HDR0" + rs + "LEB2746" + rs + "LNB1163.6" + rs + "LHB543" + rs + "REB2746" + rs + "RNB1164" + rs + "RHB543" + rs + "BOG0" + rs + "HDG91" + rs + "CCV601" + rs + "MDP211"; tagFile.ParseText(rec); // no change unixTimestamp += 100; timeStamp = "TME" + unixTimestamp.ToString(); rec = rs + timeStamp + rs + "HDR0" + rs + "LEB2746" + rs + "LNB1163.6" + rs + "LHB543" + rs + "REB2746" + rs + "RNB1164" + rs + "RHB543" + rs + "BOG0" + rs + "HDG91" + rs + "CCV601" + rs + "MDP211"; tagFile.ParseText(rec); // small height change 3rd record unixTimestamp += 100; timeStamp = "TME" + unixTimestamp.ToString(); rec = rs + timeStamp + rs + "HDR0" + rs + "LHB544" + rs + "RHB544"; tagFile.ParseText(rec); // small CMV and BOG change 4 the record unixTimestamp += 100; timeStamp = "TME" + unixTimestamp.ToString(); rec = rs + timeStamp + rs + "HDR0" + rs + "CCV602" + rs + "BOG1"; tagFile.ParseText(rec); tagFile.Parser.EpochCount.Should().Be(4, "Epoch count expected to be 4"); }