コード例 #1
0
        /// <summary>
        /// Notifies the handle that a new response segment
        /// is available
        /// </summary>
        /// <param name="message">The complex ack message</param>
        /// <param name="segment">The response segment</param>
        public override void FeedComplexAck(ComplexAckMessage message, BufferSegment segment)
        {
            _buffers.Add(segment);

            if (!message.MoreFollows)
            {
                try
                {
                    // TODO: Is this the best place to do this? Decoding
                    // large requests could potentially be more time than
                    // we want to spent in the transaction's lock

                    using (var stream = new MultiBufferStream(_buffers))
                    {
                        var tagReader       = new TagReader(stream);
                        var tagReaderStream = new TagReaderStream(tagReader, Value <TAck> .Schema);
                        var ack             = Value <TAck> .Load(tagReaderStream);

                        _source.SetResult(ack);
                    }
                }
                catch (Exception e)
                {
                    _source.SetException(new RejectException(RejectReason.InvalidTag));
                }
            }
        }
コード例 #2
0
ファイル: TestBase.cs プロジェクト: nojan1/NBT.Standard
        protected void WriteTest <T, T2>(Func <Stream, T> createWriter, Func <Stream, T2> createReader)
            where T : TagWriter where T2 : TagReader
        {
            // arrange
            Stream stream = new MemoryStream();

            var expected = CreateComplexData();

            TagWriter target = createWriter(stream);

            // act
            target.WriteStartDocument();
            target.WriteStartTag("Level", TagType.Compound);
            target.WriteTag("longTest", 9223372036854775807);
            target.WriteTag("shortTest", (short)32767);
            target.WriteTag("stringTest", "HELLO WORLD THIS IS A TEST STRING ÅÄÖ!");
            target.WriteTag("floatTest", (float)0.498231471);
            target.WriteTag("intTest", 2147483647);
            target.WriteStartTag("nested compound test", TagType.Compound);
            target.WriteStartTag("ham", TagType.Compound);
            target.WriteTag("name", "Hampus");
            target.WriteTag("value", 0.75F);
            target.WriteEndTag();
            target.WriteStartTag("egg", TagType.Compound);
            target.WriteTag("name", "Eggbert");
            target.WriteTag("value", 0.5F);
            target.WriteEndTag();
            target.WriteEndTag();
            target.WriteStartTag("listTest (long)", TagType.List, TagType.Long, 5);
            target.WriteTag((long)11);
            target.WriteTag((long)12);
            target.WriteTag((long)13);
            target.WriteTag((long)14);
            target.WriteTag((long)15);
            target.WriteEndTag();
            target.WriteStartTag("listTest (compound)", TagType.List, TagType.Compound, 2);
            target.WriteStartTag(TagType.Compound);
            target.WriteTag("name", "Compound tag #0");
            target.WriteTag("created-on", 1264099775885);
            target.WriteEndTag();
            target.WriteStartTag(TagType.Compound);
            target.WriteTag("name", "Compound tag #1");
            target.WriteTag("created-on", 1264099775885);
            target.WriteEndTag();
            target.WriteEndTag();
            target.WriteTag("byteTest", (byte)127);
            target.WriteTag(
                "byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))",
                ComplexData.SampleByteArray);
            target.WriteTag("doubleTest", 0.49312871321823148);
            target.WriteEndTag();
            target.WriteEndDocument();

            // assert
            stream.Seek(0, SeekOrigin.Begin);
            TagReader reader = createReader(stream);
            var       actual = reader.ReadDocument();

            NbtAssert.Equal(expected, actual);
        }
コード例 #3
0
    /// <summary>末尾に文字追加</summary>
    public void addLast(string aText)
    {
        TagReader tReader = new TagReader(aText);

        while (!tReader.isEnd())
        {
            TagReader.Element tElement = tReader.read();
            //1文字
            if (tElement is TagReader.OneChar)
            {
                StringElement tStringElement = StringElement.create(((TagReader.OneChar)tElement).mChar, this);
                addLast(tStringElement);
                continue;
            }
            //開始タグ
            if (tElement is TagReader.StartTag)
            {
                applyStartTag(((TagReader.StartTag)tElement));
                continue;
            }
            //終了タグ
            if (tElement is TagReader.EndTag)
            {
                applyEndTag(((TagReader.EndTag)tElement));
                continue;
            }
            Debug.LogWarning("MyTextBoard : 文字読み込み失敗 次の文字「" + tReader.mNext.ToString() + "」");
        }
        _Text += aText;
    }
コード例 #4
0
ファイル: HtmlDocument.cs プロジェクト: ridomin/waslibs
        private static string AddFragments(TagReader reader, HtmlFragment parentFragment, Stack<string> openTagStack)
        {
            while (reader.Read())
            {
                parentFragment.TryToAddText(HtmlText.Create(reader.Document, reader.PreviousTag, reader.CurrentTag));

                if (reader.CurrentTag.TagType == TagType.Close && openTagStack.Any(t => t.Equals(reader.CurrentTag.Name, StringComparison.CurrentCultureIgnoreCase)))
                {
                    return reader.CurrentTag.Name;
                }

                var node = parentFragment.AddNode(reader.CurrentTag);
                node.Parent = parentFragment;

                if (reader.CurrentTag.TagType == TagType.Open)
                {
                    openTagStack.Push(reader.CurrentTag.Name);

                    var lastClosed = AddFragments(reader, node, openTagStack);
                    if (lastClosed != openTagStack.Pop())
                    {
                        return lastClosed;
                    }
                }
            }
            parentFragment.TryToAddText(HtmlText.Create(reader.Document, reader.CurrentTag, null));
            return null;
        }
コード例 #5
0
        public MusicFileReader(string FilePath)
        {
            int handle = Bass.SampleLoad(FilePath, 0, 0, 1, BassFlags.Float);

            if (Bass.LastError != Errors.OK)
            {
                throw new Exception(Bass.LastError.ToString());
            }

            this.Buf = new float[(long)(Bass.ChannelGetLength(handle, PositionFlags.Bytes) * Const.byte_per_float)];

            Bass.SampleGetData(handle, this.Buf);

            if (Bass.LastError != Errors.OK)
            {
                Console.WriteLine(Bass.LastError.ToString());
            }

            int         channel = Bass.SampleGetChannel(handle);
            ChannelInfo info    = Bass.ChannelGetInfo(channel);

            this.SampleRate     = info.Frequency;
            this.Channels       = info.Channels;
            this.TotalSamples   = Buf.Length / this.Channels;
            this.SamplePosition = 0;

            int tmphandle = Bass.CreateStream(FilePath);

            this.Tags = TagReader.Read(tmphandle);

            Bass.StreamFree(tmphandle);

            Bass.SampleFree(handle);
        }
コード例 #6
0
        private static string AddFragments(TagReader reader, HtmlFragment parentFragment, Stack <string> openTagStack)
        {
            while (reader.Read())
            {
                parentFragment.TryToAddText(HtmlText.Create(reader.Document, reader.PreviousTag, reader.CurrentTag));

                if (reader.CurrentTag.TagType == TagType.Close && openTagStack.Any(t => t.Equals(reader.CurrentTag.Name, StringComparison.CurrentCultureIgnoreCase)))
                {
                    return(reader.CurrentTag.Name);
                }

                var node = parentFragment.AddNode(reader.CurrentTag);
                node.Parent = parentFragment;

                if (reader.CurrentTag.TagType == TagType.Open)
                {
                    openTagStack.Push(reader.CurrentTag.Name);

                    var lastClosed = AddFragments(reader, node, openTagStack);
                    if (lastClosed != openTagStack.Pop())
                    {
                        return(lastClosed);
                    }
                }
            }
            parentFragment.TryToAddText(HtmlText.Create(reader.Document, reader.CurrentTag, null));
            return(null);
        }
コード例 #7
0
    //引数の文字列を表示する
    private void write(string aText)
    {
        TagReader tReader = new TagReader(aText);

        while (!tReader.isEnd())
        {
            TagReader.Element tElement = tReader.read();
            //1文字
            if (tElement is TagReader.OneChar)
            {
                addChar(((TagReader.OneChar)tElement).mChar);
                continue;
            }
            //開始タグ
            if (tElement is TagReader.StartTag)
            {
                applyStartTag(((TagReader.StartTag)tElement));
                continue;
            }
            //終了タグ
            if (tElement is TagReader.EndTag)
            {
                applyEndTag(((TagReader.EndTag)tElement));
                continue;
            }
            Debug.LogWarning("MyTextBoard : 文字読み込み失敗 次の文字「" + tReader.mNext.ToString() + "」");
        }
    }
コード例 #8
0
        public void class_gets_new_sources()
        {
            var reader = new TagReader();

            reader.ReadTags();

            Assert.NotNull(reader.Tags);
        }
コード例 #9
0
ファイル: TagReaderTests.cs プロジェクト: m42/cobalt
        public void GetTagValue_ReturnsCorrectValue_WhenCorrectInput()
        {
            var sutA = TagReader.GetTagValue(GetContent(), "tagA");
            var sutB = TagReader.GetTagValue(GetContent(), "tagB");

            Assert.Equal("Value A", sutA);
            Assert.Equal("Value B", sutB);
        }
コード例 #10
0
 public static string GetTag(this TagReader tagReader, string key)
 {
     if (tagReader.Other.TryGetValue(key, out string value))
     {
         return(value);
     }
     return(string.Empty);
 }
コード例 #11
0
        private void OnDownloadComplete()
        {
            if (Name != null)
            {
                return;
            }

            var tags = TagReader.Read(SourceChannel.Handle);

            Name = $"{tags.Artist} - {tags.Title}";
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: nstrydom2/appule
        static void Main(string[] args)
        {
            TagReader tags = new TagReader(@"E:\Music\KORN - DISCOGRAPHY (1994-13) [CHANNEL NEO]\[1998] Follow The Leader (2 CD)\[CD 1] Follow The Leader\02 - Freak On A Leash.mp3");

            foreach (String tag in tags.tagData.Values)
            {
                Console.WriteLine(tag);
            }

            Console.ReadLine();
        }
コード例 #13
0
        private static Song CreateSongFromTags(string file, TagReader reader)
        {
            var song = new Song(
                reader.Artist?.Trim(),
                reader.Album?.Trim(),
                reader.Title?.Trim(),
                reader.TrackNo,
                file
                );

            return(song);
        }
コード例 #14
0
        private void GetNewDataFromSite()
        {
            var tagReader = new TagReader();

            tagReader.ReadTags();
            List <itemTag> items = new List <itemTag>();

            items = mongoCRUD.returnAllSources <itemTag>("Sources");
            var sources    = GetXRandomItemsFromList(5, items);
            var itemReader = new RssReader();

            itemReader.ReadItemsFromMultipleSources(sources);
        }
コード例 #15
0
        public static bool WriteLyrics(string artist, string title, string lyrics)
        {
            var mDB   = MusicDatabase.Instance;
            var songs = new List <Song>();

            mDB.GetSongsByArtist(artist, ref songs);

            _currentTitle = title;

            var rightSongs = songs.FindAll(RightTitle);

            return(rightSongs.Aggregate(false, (current, song) => (TagReader.WriteLyrics(song.FileName, lyrics) || current)));
        }
コード例 #16
0
 private void Load()
 {
     using (TagReader reader = new TagReader(this.Path)) {
         int tag = reader.ReadTag();
         while (tag != TagEnd && !reader.Eof)
         {
             switch (tag)
             {
             case TagFlags:
             }
             tag = reader.ReadTag();
         }
     }
 }
コード例 #17
0
        public List <string> GetAllTags()
        {
            connectionString = _configuration["ConnectionString"];

            TagReader  tagReader   = new TagReader(connectionString);
            List <Tag> tagsAllData = new List <Tag>();

            tagsAllData = tagReader.ReadAll();

            List <string> tagCategories = new List <string>();

            tagCategories = tagsAllData.Select(tag => tag.Name).ToList();

            return(tagCategories);
        }
コード例 #18
0
        private bool LyricFoundInMusicTag(string artist, string title)
        {
            var song = new Song();

            _mMDb.GetSongByMusicTagInfo(artist, string.Empty, title, true, ref song);

            var tag = TagReader.ReadTag(song.FileName);

            if (tag != null && tag.Lyrics != string.Empty)
            {
                LyricFound = new Object[] { tag.Lyrics, artist, title, "music tag" };
                return(true);
            }
            return(false);
        }
コード例 #19
0
ファイル: NbtDocument.cs プロジェクト: nojan1/NBT.Standard
        private static string GetDocumentName(TagReader reader)
        {
            string result;

            if (reader.IsNbtDocument())
            {
                reader.ReadTagType(); // advance the reader
                result = reader.ReadTagName();
            }
            else
            {
                result = null;
            }

            return(result);
        }
コード例 #20
0
        /// <summary>
        /// Executes all the init statements for the TagReader like:
        /// - start the thread
        /// - start the timer to handle the progress output
        /// </summary>
        private void initTagReaderProcess()
        {
            //register the thread
            tagReaderThread = new Thread(delegate()
            {
                allUsedTags = TagReader.getAllTagReadersFromDirectory(new DirectoryInfo(OpenFolder.SelectedPath), this);
            });
            //Search asynchronous for TagReaders
            tagReaderThread.Start();

            //Timer needed for the progress output
            this.tagReaderTimer          = new System.Windows.Forms.Timer();
            this.tagReaderTimer.Interval = 1000;
            this.tagReaderTimer.Tick    += new EventHandler(checkTagReaderReady);
            this.tagReaderTimer.Start();
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: Rozentor/tdd
        static void Main(string[] args)
        {
            if (!IsInputCorrect(args))
            {
                return;
            }

            var pathToWords   = args[0];
            var pathToPicture = args[1];

            var tagGroups = new TagGroups();

            if (args.Length > 2)
            {
                tagGroups = ReadTagGroups(args[2]);
            }
            else
            {
                tagGroups.AddSizeGroup("Big", new FrequencyGroup(0.9, 1), new Size(80, 150));
                tagGroups.AddSizeGroup("Average", new FrequencyGroup(0.6, 0.9), new Size(60, 100));
                tagGroups.AddSizeGroup("Small", new FrequencyGroup(0, 0.6), new Size(30, 50));
            }


            var settings = DrawSettings.WordsInRectangles;

            if (args.Length > 3)
            {
                settings = (DrawSettings)(int.Parse(args[3]) % 4);
            }

            var spiral     = new Spiral();
            var cloud      = new CircularCloudLayouter(spiral);
            var visualizer = new CloudVisualizer.CloudVisualizer
            {
                Settings = settings
            };

            var cloudItems = new TagReader(tagGroups)
                             .GetTags(pathToWords)
                             .Select(tag => new CloudItem(tag.Word, cloud.PutNextRectangle(tag.Size)))
                             .ToArray();

            var picture = visualizer.CreatePictureWithItems(cloudItems);

            picture.Save(Path.Combine(Directory.GetCurrentDirectory(), $"{pathToPicture}.png"));
        }
コード例 #22
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            var mDB     = MusicDatabase.Instance;
            var counter = 0;

            for (var i = 0; i < _artists.Count; i++)
            {
                if (bw.CancellationPending)
                {
                    return;
                }

                var artist = (string)_artists[i];
                bw.ReportProgress(counter, artist);

                mDB.GetSongsByArtist(artist, ref _songs);

                foreach (var song in _songs)
                {
                    var tag = TagReader.ReadTag(song.FileName);
                    if (tag != null && tag.Lyrics != string.Empty)
                    {
                        var capArtist = LyricUtil.CapatalizeString(tag.Artist);
                        var capTitle  = LyricUtil.CapatalizeString(tag.Title);

                        if (
                            DatabaseUtil.IsSongInLyricsDatabase(MyLyricsUtils.LyricsDB, capArtist, capTitle).Equals(
                                DatabaseUtil.LyricFound))
                        {
                            // If lyric exists in LyricsDb then only import (and overwrite) if it isn't an LRC-file
                            var lyricsText = MyLyricsUtils.LyricsDB[DatabaseUtil.CorrectKeyFormat(capArtist, capTitle)].Lyrics;
                            var lrc        = new SimpleLRC(capArtist, capTitle, lyricsText);
                            if (!lrc.IsValid)
                            {
                                _tags.Add(tag);
                                ++counter;
                            }
                        }
                        else
                        {
                            _tags.Add(tag);
                            ++counter;
                        }
                    }
                }
            }
        }
コード例 #23
0
        /// <summary>
        /// Initialization of the GUI
        /// </summary>
        /// <param name="fileTagReader">The FileTagReader width the data of the file</param>
        public WindowsTagAnalyzerDetails(TagReader fileTagReader, regexGUI rx)
        {
            InitializeComponent();

            regex = rx;

            currentTagReader = fileTagReader;

            string path;

            path = fileTagReader.getAbsoluteFilePath();

            //Fill the labels width the name and the path of the file
            FileName.Text = ExtractFileName(path);
            FilePath.Text = path.Substring(0, path.Length - (ExtractFileName(path).Length));

            this.Visible = true;
        }
コード例 #24
0
        public MusicFileReaderStreaming(string FilePath)
        {
            this.handle = Bass.CreateStream(FilePath, Flags: BassFlags.Float | BassFlags.Decode);

            if (Bass.LastError != Errors.OK)
            {
                throw new Exception(Bass.LastError.ToString());
            }

            ChannelInfo info = Bass.ChannelGetInfo(handle);

            this.SampleRate     = info.Frequency;
            this.Channels       = info.Channels;
            this.TotalSamples   = (long)(Bass.ChannelGetLength(handle, PositionFlags.Bytes) * Const.byte_per_float) / this.Channels;
            this.SamplePosition = 0;

            this.Tags = TagReader.Read(this.handle);
        }
コード例 #25
0
ファイル: DAO.cs プロジェクト: Silberfischen/git-portfolio
        /// <summary>
        /// Saves all the needed infos about the File into the db
        /// </summary>
        /// <param name="tr">A TagReader object which contains all the infos about the File's tags</param>
        public void saveReportParams(TagReader tr)
        {
            //Create query object
            SQLiteCommand query = new SQLiteCommand(conn);

            //Begin transaction
            SQLiteTransaction tx = conn.BeginTransaction();

            //Delete old entries of the file
            query.CommandText = "DELETE FROM Reports WHERE FilePath = '" + tr.getAbsoluteFilePath() + "';";

            //send the delete query to the server
            query.ExecuteNonQuery();

            foreach (KeyValuePair <string, string> kvp in tr.getUsedTags())
            {
                //The query which will be executed
                query.CommandText = "INSERT INTO Reports VALUES(@absolutePath," +
                                    "(SELECT TagID FROM Tags WHERE TagName = @tagName)," +
                                    "@tagValue," +
                                    "@sha512," +
                                    "@sha384," +
                                    "@sha256," +
                                    "@sha1," +
                                    "@md5);";

                //Add parameters to the prepared statement
                query.Parameters.AddWithValue("@absolutePath", tr.getAbsoluteFilePath());
                query.Parameters.AddWithValue("@tagName", kvp.Key);
                query.Parameters.AddWithValue("@tagValue", kvp.Value);

                //Add hashes to the statement
                foreach (KeyValuePair <string, string> hash in tr.getHashes())
                {
                    query.Parameters.AddWithValue("@" + hash.Key, hash.Value);
                }

                //Execute query after query
                query.ExecuteNonQuery();
            }

            //Commit the transaction
            tx.Commit();
        }
コード例 #26
0
        /// <summary>
        /// Adds an array of files to the list
        /// </summary>
        /// <param name="files"></param>
        private void AddFile(TagReader tagReader, string file)
        {
            //read the tag
            var tagInfo = tagReader.ReadTags(file);

            if (tagInfo != null)
            {
                //create playlist entry
                var playlistEntry = new PlayListEntry()
                {
                    TagInfo = tagInfo, FileName = file
                };

                System.Windows.Application.Current.Dispatcher.Invoke(() =>
                {
                    //add to now playing
                    App.SoundEngine.AddToNowPlaying(playlistEntry);
                });
            }
        }
コード例 #27
0
ファイル: Program.cs プロジェクト: nicholasjgravante/tweepics
        static void Main(string[] args)
        {
            PublicOfficialReader  publicOfficialReader = new PublicOfficialReader(Keys.mySqlConnectionString);
            List <PublicOfficial> publicOfficials      = publicOfficialReader.ReadFromDb();

            List <long> userId = publicOfficials.Where(official => official.TwitterId != 0).Select(official => official.TwitterId).ToList();

            Timeline timeline = new Timeline();

            foreach (long id in userId)
            {
                List <Tweet> untaggedTweets = new List <Tweet>();
                untaggedTweets = timeline.GetTimeline(id);

                if (untaggedTweets == null)
                {
                    continue;
                }

                TweetAdder tweetAdder = new TweetAdder(Keys.mySqlConnectionString);
                tweetAdder.AddUntaggedTweets(untaggedTweets);

                Console.WriteLine($"{untaggedTweets.Count} tweets were added.");

                TagReader  tagReader = new TagReader(Keys.mySqlConnectionString);
                List <Tag> tags      = new List <Tag>();
                tags = tagReader.ReadAll();

                TweetTagger        tagger       = new TweetTagger();
                List <TaggedTweet> taggedTweets = new List <TaggedTweet>();
                taggedTweets = tagger.Tag(untaggedTweets, tags);

                tweetAdder.AddTaggedTweets(taggedTweets);

                Console.WriteLine($"{taggedTweets.Count} tweets were tagged.");
                Console.WriteLine("--------------------");
            }

            Console.WriteLine("The program ran to completion.");
            Console.ReadLine();
        }
コード例 #28
0
        /// <summary>
        /// Handles dropping files onto the window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Drop(object sender, DragEventArgs e)
        {
            //check to see what the user dropped on top of us
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                //get the files we have dropped
                string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop);

                //check if we have anything
                if (paths.Length > 0)
                {
                    //filter out files that we don't support
                    //tag reader
                    using (var tagReader = new TagReader())
                    {
                        //add files to the playlist
                        foreach (var path in paths)
                        {
                            if (Directory.Exists(path))
                            {
                                //recursively get all the files in the folder
                                var dirFiles = Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories);

                                foreach (var file in dirFiles)
                                {
                                    //add the file to the playlist
                                    AddFile(tagReader, file);
                                }
                            }
                            else if (File.Exists(path))
                            {
                                //add the file to the playlist
                                AddFile(tagReader, path);
                            }
                        }
                    }
                }
            }
        }
コード例 #29
0
ファイル: TestBase.cs プロジェクト: nojan1/NBT.Standard
        protected void WriteDocumentTest <T, T2>(Func <Stream, T> createWriter, Func <Stream, T2> createReader)
            where T : TagWriter where T2 : TagReader
        {
            // arrange
            Stream stream = new MemoryStream();

            var expected = CreateComplexData();

            TagWriter target = createWriter(stream);

            // act
            target.WriteStartDocument();
            target.WriteTag(expected);
            target.WriteEndDocument();

            // assert
            stream.Seek(0, SeekOrigin.Begin);
            TagReader reader = createReader(stream);
            var       actual = reader.ReadDocument();

            NbtAssert.Equal(expected, actual);
        }
コード例 #30
0
        public static HtmlDocument Load(string document)
        {
            var root = new HtmlDocument();

            if (!string.IsNullOrWhiteSpace(document))
            {
                if (TagReader.Any(document))
                {
                    document = Clean(document);

                    var reader = TagReader.Create(document);
                    AddFragments(reader, root, new Stack <string>());
                }
                else
                {
                    root.TryToAddText(new HtmlText
                    {
                        Content = document
                    });
                }
            }

            return(root);
        }
コード例 #31
0
        private MusicTag GetTrackTag(MusicDatabase dbs, string strFile, bool useID3, string title, string artist)
        {
            MusicTag tag;
            var      song   = new Song();
            var      bFound = dbs.GetSongByFileName(strFile, ref song);

            if (!bFound)
            {
                // Track information already available
                if (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(artist))
                {
                    song.Title  = title;
                    song.Artist = artist;
                    song.Album  = string.Empty;
                    tag         = song.ToMusicTag();
                    return(tag);
                }

                // If allowed, read tag from file
                if (useID3)
                {
                    tag = TagReader.ReadTag(strFile);
                    if (tag != null && !string.IsNullOrEmpty(tag.Title) && !string.IsNullOrEmpty(tag.Artist))
                    {
                        return(tag);
                    }
                }

                // tagreader failed or not using it and no available track information
                song.Title  = Path.GetFileNameWithoutExtension(strFile);
                song.Artist = string.Empty;
                song.Album  = string.Empty;
            }
            tag = song.ToMusicTag();
            return(tag);
        }
コード例 #32
0
ファイル: AXmlParser.cs プロジェクト: Altaxo/Altaxo
		/// <summary>
		/// Incrementaly parse the given text.
		/// You have to hold the write lock.
		/// </summary>
		/// <param name="input">
		/// The full XML text of the new document.
		/// </param>
		/// <param name="changesSinceLastParse">
		/// Changes since last parse.  Null will cause full reparse.
		/// </param>
		public AXmlDocument Parse(string input, IEnumerable<DocumentChangeEventArgs> changesSinceLastParse)
		{
			if (!Lock.IsWriteLockHeld)
				throw new InvalidOperationException("Lock needed!");
			
			// Use changes to invalidate cache
			if (changesSinceLastParse != null) {
				this.TrackedSegments.UpdateOffsetsAndInvalidate(changesSinceLastParse);
			} else {
				this.TrackedSegments.InvalidateAll();
			}
			
			TagReader tagReader = new TagReader(this, input);
			List<AXmlObject> tags = tagReader.ReadAllTags();
			AXmlDocument parsedDocument = new TagMatchingHeuristics(this, input, tags).ReadDocument();
			tagReader.PrintStringCacheStats();
			AXmlParser.Log("Updating main DOM tree...");
			userDocument.UpdateTreeFrom(parsedDocument);
			userDocument.DebugCheckConsistency(true);
			Assert(userDocument.GetSelfAndAllChildren().Count() == parsedDocument.GetSelfAndAllChildren().Count(), "Parsed document and updated document have different number of children");
			return userDocument;
		}