Exemplo n.º 1
0
 public DefineFontNameTag(FlashReader reader, TagRecord header) :
     base(reader, header)
 {
     FontId        = reader.ReadUInt16();
     FontName      = reader.ReadNullTerminatedString();
     FontCopyright = reader.ReadNullTerminatedString();
 }
Exemplo n.º 2
0
 private static TagEntry CreateTagEntry(TagRecord tagRecord)
 {
     return(new TagEntry {
         Tag = tagRecord,
         IsChecked = false,
     });
 }
Exemplo n.º 3
0
    public override void Read(
        TagRecord _Tag
        , BinaryReader _GAFFileReader
        , ref GAFAnimationData _SharedData
        , ref GAFTimelineData _CurrentTimeline)
    {
        uint count = _GAFFileReader.ReadUInt32();

        for (uint i = 0; i < count; ++i)
        {
            string id = GAFReader.ReadString(_GAFFileReader);

            ushort start = _GAFFileReader.ReadUInt16();
            ushort end   = _GAFFileReader.ReadUInt16();

            var data = new GAFSequenceData(id, (uint)start, (uint)end);
            if (_CurrentTimeline == null)
            {
                _SharedData.rootTimeline.sequences.Add(data);
            }
            else
            {
                _CurrentTimeline.sequences.Add(data);
            }
        }
    }
Exemplo n.º 4
0
        // ---------------------------------------------------------------------------

        public bool ReadFromFile(String FileName)
        {
            TagRecord TagData = new TagRecord();

            // Reset and load tag data from file to variable
            ResetData();
            bool result = ReadTag(FileName, ref TagData);

            // Process data if loaded and tag header OK
            if ((result) && Utils.StringEqualsArr("TAG", TagData.Header))
            {
                FExists    = true;
                FVersionID = GetTagVersion(TagData);
                // Fill properties with tag data
                FTitle  = Utils.BuildStringCStyle(TagData.Title);
                FArtist = Utils.BuildStringCStyle(TagData.Artist).TrimEnd();
                FAlbum  = Utils.BuildStringCStyle(TagData.Album).TrimEnd();
                FYear   = Utils.BuildStringCStyle(TagData.Year).TrimEnd();
                if (TAG_VERSION_1_0 == FVersionID)
                {
                    FComment = Utils.BuildStringCStyle(TagData.Comment).TrimEnd();
                }
                else
                {
                    char[] newComment = new char[28];
                    Array.Copy(TagData.Comment, 0, newComment, 0, 28);
                    FComment = Utils.BuildStringCStyle(newComment).TrimEnd();
                    FTrack   = (byte)TagData.Comment[29];
                }
                FGenreID = TagData.Genre;
            }
            return(result);
        }
Exemplo n.º 5
0
        private static void SetWatchlistValues(Video originai, Video updated = null)
        {
            DateTime runTime = DateTime.Now;


            var watchListTag = TagRecord.Create(originai.Id.HasValue ? originai.Id.Value : -1, TagType.WatchList);


            if (updated == null)
            {
                originai.Created = originai.Updated = runTime;
                originai.AddTag(watchListTag);
            }
            else
            {
                originai.Updated = runTime;

                originai.AddTag(watchListTag);

                if (updated.Tags != null)
                {
                    foreach (var t in updated.Tags.Values)
                    {
                        originai.AddTag(t);
                    }
                }
            }
        }
Exemplo n.º 6
0
        // ---------------------------------------------------------------------------

        public bool SaveToFile(String FileName)
        {
            TagRecord TagData = new TagRecord();

            // Prepare tag record
            TagData.Reset();

            TagData.Header[0] = 'T';
            TagData.Header[1] = 'A';
            TagData.Header[2] = 'G';

            Array.Copy(FTitle.ToCharArray(), TagData.Title, 30);
            Array.Copy(FArtist.ToCharArray(), TagData.Artist, 30);
            Array.Copy(FAlbum.ToCharArray(), TagData.Album, 30);
            Array.Copy(FYear.ToCharArray(), TagData.Year, 4);
            Array.Copy(FComment.ToCharArray(), TagData.Comment, 30);

            if (FTrack > 0)
            {
                TagData.Comment[28] = '\0';
                TagData.Comment[29] = (char)FTrack;
            }
            TagData.Genre = FGenreID;

            // Delete old tag and write new tag
            return((RemoveFromFile(FileName)) && (SaveTag(FileName, TagData)));
        }
Exemplo n.º 7
0
 public override void Read(
     TagRecord _Tag
     , BinaryReader _GAFFileReader
     , ref GAFAnimationData _SharedData
     , ref GAFTimelineData _CurrentTimeline)
 {
 }
Exemplo n.º 8
0
        // ---------------------------------------------------------------------------

        bool SaveTag(String FileName, TagRecord TagData)
        {
            bool result = true;

            try
            {
                // Allow write-access and open file
                FileStream   fs         = new FileStream(FileName, FileMode.Open, FileAccess.Write);
                BinaryWriter TargetFile = new BinaryWriter(fs);

                // Write tag
                fs.Seek(fs.Length, SeekOrigin.Begin);

                TargetFile.Write(TagData.Header);
                TargetFile.Write(TagData.Title);
                TargetFile.Write(TagData.Artist);
                TargetFile.Write(TagData.Album);
                TargetFile.Write(TagData.Year);
                TargetFile.Write(TagData.Comment);
                TargetFile.Write(TagData.Genre);

                TargetFile.Close();
                fs.Close();
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.StackTrace);
                result = false;
            }
            return(result);
        }
Exemplo n.º 9
0
        protected virtual FlashTag ReadTag(FlashReader reader, TagRecord header)
        {
            FlashTag tag = null;

            switch (header.TagType)
            {
            default:
                tag = new UnknownTag(Reader, header);
                break;

            case FlashTagType.DoABC:
                tag = new DoABCTag(Reader, header);
                _abcFiles.Add(((DoABCTag)tag).ABC);
                break;

            case FlashTagType.DefineBitsLossless2:
                tag = new DefineBitsLossless2Tag(Reader, header);
                break;

            case FlashTagType.DefineBinaryData:
                tag = new DefineBinaryDataTag(Reader, header);
                break;
            }

            var character = (tag as ICharacter);

            if (character != null)
            {
                // Add ICharacter tag to the global dictionary.
                Dictionary.Characters[
                    character.CharacterId] = character;
            }
            return(tag);
        }
Exemplo n.º 10
0
 public static CourseTagRecordEditor AddTag(this CourseRecord course, TagRecord record)
 {
     if (record.Category.ToUpper() != TagCategory.Course.ToString().ToUpper())
     {
         throw new ArgumentException("");
     }
     return(new CourseTagRecordEditor(course, record));
 }
Exemplo n.º 11
0
 public static StudentTagRecordEditor AddTag(this StudentRecord student, TagRecord record)
 {
     if (record.Category.ToUpper() != TagCategory.Student.ToString().ToUpper())
     {
         throw new ArgumentException("");
     }
     return(new StudentTagRecordEditor(student, record));
 }
Exemplo n.º 12
0
 private void loadItems()
 {
     foreach (int addr in RecordAddresses())
     {
         var r = new TagRecord(M, addr);
         records.Add(r.Key, r);
     }
 }
Exemplo n.º 13
0
 public static TeacherTagRecordEditor AddTag(this TeacherRecord teacher, TagRecord record)
 {
     if (record.Category.ToUpper() != TagCategory.Teacher.ToString().ToUpper())
     {
         throw new ArgumentException("");
     }
     return(new TeacherTagRecordEditor(teacher, record));
 }
Exemplo n.º 14
0
        private SitemapEntry ToSitemapEntry(TagRecord tag)
        {
            var url   = _urlHelper.Action("Search", "Home", new { Area = "Orchard.Tags", TagName = tag.TagName });
            var entry = CreateEntry(tag, url, changeFrequency: ChangeFrequency.Daily);

            entry.Context = tag.Id.ToString();
            return(entry);
        }
Exemplo n.º 15
0
 private void loadItems()
 {
     foreach (int addr in RecordAddresses())
     {
         var r = new TagRecord(M, addr);
         records.Add(r.Key, r);
     }
 }
Exemplo n.º 16
0
 public static ClassTagRecordEditor AddTag(this ClassRecord cla, TagRecord record)
 {
     if (record.Category.ToUpper() != TagCategory.Class.ToString().ToUpper())
     {
         throw new ArgumentException("");
     }
     return(new ClassTagRecordEditor(cla, record));
 }
Exemplo n.º 17
0
 private void loadItems()
 {
     foreach (var addr in RecordAdresses())
     {
         TagRecord r = new TagRecord(m, addr);
         records.Add(r.Key, r);
     }
 }
Exemplo n.º 18
0
 private void loadItems()
 {
     foreach (var addr in RecordAdresses())
     {
         TagRecord r = new TagRecord(m, addr);
         records.Add(r.Key, r);
     }
 }
Exemplo n.º 19
0
        public DefineBinaryDataTag(FlashReader reader, TagRecord header)
            : base(reader, header)
        {
            CharacterId = reader.ReadUInt16();
            reader.ReadUInt32();

            BinaryData = reader.ReadBytes(header.Body.Length - 6);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PdbType"/> class.
 /// </summary>
 /// <param name="pdb">The PDB file reader.</param>
 /// <param name="typeIndex">Type index.</param>
 /// <param name="tagRecord">The tag record.</param>
 /// <param name="modifierOptions">The modifier options.</param>
 /// <param name="size">The type size in bytes.</param>
 internal PdbUserDefinedType(PdbFileReader pdb, TypeIndex typeIndex, TagRecord tagRecord, ModifierOptions modifierOptions, ulong size)
     : base(pdb, typeIndex, modifierOptions, tagRecord.Name.String, size)
 {
     TagRecord               = tagRecord;
     fieldsCache             = SimpleCache.CreateWithContext(this, CallEnumerateFields);
     staticFieldsCache       = SimpleCache.CreateWithContext(this, CallEnumerateStaticFields);
     baseClassesCache        = SimpleCache.CreateWithContext(this, CallEnumerateBaseClasses);
     virtualBaseClassesCache = SimpleCache.CreateWithContext(this, CallEnumerateVirtualBaseClasses);
 }
Exemplo n.º 21
0
    public override void Read(
        TagRecord _Tag
        , BinaryReader _GAFFileReader
        , ref GAFAnimationData _SharedData
        , ref GAFTimelineData _RootTimeline)
    {
        uint    id          = _GAFFileReader.ReadUInt32();
        uint    framesCount = _GAFFileReader.ReadUInt32();
        Rect    frameSize   = GAFReader.ReadRect(_GAFFileReader);
        Vector2 pivot       = GAFReader.ReadVector2(_GAFFileReader);
        byte    hasLinkage  = _GAFFileReader.ReadByte();
        string  linkageName = string.Empty;

        if (hasLinkage == 1)
        {
            linkageName = GAFReader.ReadString(_GAFFileReader);
        }

        var timeline = new GAFTimelineData(id, linkageName, framesCount, frameSize, pivot);

        _SharedData.timelines.Add((int)id, timeline);

        var tagReaders = GetTagsDictionary();

        while (_GAFFileReader.BaseStream.Position < _Tag.expectedStreamPosition)
        {
            TagRecord record;
            try
            {
                record = GAFReader.OpenTag(_GAFFileReader);
            }
            catch (System.Exception _exception)
            {
                throw new GAFException("GAF! GAFReader::Read - Failed to open tag! Stream position - " + _GAFFileReader.BaseStream.Position.ToString() + "\nException - " + _exception);
            }

            if (record.type != TagBase.TagType.TagInvalid &&
                tagReaders.ContainsKey(record.type))
            {
                try
                {
                    tagReaders[record.type].Read(record, _GAFFileReader, ref _SharedData, ref timeline);
                }
                catch (System.Exception _exception)
                {
                    throw new GAFException("GAF! GAFReader::Read - Failed to read tag - " + record.type.ToString() + "\n Exception - " + _exception.ToString(), record);
                }

                GAFReader.CheckTag(record, _GAFFileReader);
            }
            else
            {
                GAFReader.CloseTag(record, _GAFFileReader);
            }
        }
    }
Exemplo n.º 22
0
        public SetBackgroundColorTag(FlashReader reader, TagRecord header) :
            base(reader, header)
        {
            byte red   = reader.ReadByte();
            byte green = reader.ReadByte();
            byte blue  = reader.ReadByte();

            BackgroundColor =
                Color.FromArgb(red, green, blue);
        }
Exemplo n.º 23
0
 internal TagRecordEditor(TagRecord record)
 {
     Tag      = record;
     Remove   = false;
     ID       = record.ID;
     Prefix   = record.Prefix;
     Name     = record.Name;
     Category = record.Category;
     Color    = record.Color;
 }
Exemplo n.º 24
0
 private static IEnumerable <TypeRecord> GetFields(PdbFile pdb, TagRecord record)
 {
     foreach (TypeRecord field in EnumerateFieldList(pdb, record.FieldList))
     {
         if (field is DataMemberRecord || field is StaticDataMemberRecord staticDataMember)
         {
             yield return(field);
         }
     }
 }
Exemplo n.º 25
0
 private void loadItems()
 {
     foreach (var addr in RecordAddresses())
     {
         var r = new TagRecord(M, addr);
         if (!Records.ContainsKey(r.Key))
         {
             Records.Add(r.Key, r);
         }
     }
 }
Exemplo n.º 26
0
 public static void CheckTag(TagRecord _Record, BinaryReader _Reader)
 {
     if (_Reader.BaseStream.Position != _Record.expectedStreamPosition)
     {
         GAFUtils.Error(
             "GAFReader::CloseTag - " +
             "Tag " + _Record.type.ToString() + " " +
             "hasn't been correctly read, tag length is not respected. " +
             "Expected " + _Record.expectedStreamPosition + " " +
             "but actually " + _Reader.BaseStream.Position + " !");
     }
 }
Exemplo n.º 27
0
        public DoABCTag(FlashReader reader, TagRecord header)
            : base(reader, header)
        {
            Flags = reader.ReadUInt32();
            Name  = reader.ReadNullTerminatedString();

            int nameLength = (Encoding.UTF8.GetByteCount(Name) + 1);

            byte[] abcData = reader.ReadBytes(header.Body.Length - (nameLength + 4));

            ABC = new ABCFile(abcData);
        }
        /// <summary>
        /// This method groups the results into batches and send
        /// </summary>
        /// <param name="documents"></param>
        private void GroupDocumentsAndSend(List <BulkDocumentInfoBEO> documents)
        {
            documents = GatherFamiliesAndDuplicates(documents);

            // Construct the record object for the successive worker, with the boot param
            var bulkTagRecord = new BulkTagRecord
            {
                BinderId     = _mBootObject.BinderId,
                CollectionId = _mBootObject.TagDetails.CollectionId,
                MatterId     = _mBootObject.TagDetails.MatterId,
                DatasetId    = _mBootObject.TagDetails.DatasetId,
                ReviewSetId  = _mBootObject.DocumentListDetails.SearchContext.ReviewSetId,
                NumberOfOriginalDocuments = _mTotalDocumentCount,
                CreatedByUserGuid         = _mBootObject.JobScheduleCreatedBy
            };

            // Fill the tag details in record object
            var tagRecord = new TagRecord
            {
                Id                 = _mBootObject.TagDetails.Id,
                ParentId           = _mBootObject.TagDetails.ParentTagId,
                Name               = _mBootObject.TagDetails.Name,
                TagDisplayName     = _mBootObject.TagDetails.TagDisplayName,
                IsOperationTagging = _mBootObject.IsOperationTagging,
                IsTagAllDuplicates = _mBootObject.IsTagAllDuplicates,
                IsTagAllFamily     = _mBootObject.IsTagAllFamily
            };

            tagRecord.TagBehaviors.AddRange(_mBootObject.TagDetails.TagBehaviors);

            bulkTagRecord.SearchContext = _mSearchContext;
            bulkTagRecord.TagDetails    = tagRecord;

            // Determine # of batches for documents to be sent
            var documentsCopy = new List <BulkDocumentInfoBEO>(documents);
            var noOfBatches   = (documentsCopy.Count % _mWindowSize == 0)
                ? (documents.Count / _mWindowSize)
                : (documents.Count / _mWindowSize) + 1;

            bulkTagRecord.NumberOfBatches = noOfBatches;

            Tracer.Info(string.Format("Total batch of document(s) determined : {0}", noOfBatches));
            var processedDocCount = 0;

            for (var i = 0; i < noOfBatches; i++)
            {
                // Group documents and send it to next worker
                bulkTagRecord.Documents = documentsCopy.Skip(processedDocCount).Take(_mWindowSize).ToList();
                processedDocCount      += _mWindowSize;
                Send(bulkTagRecord);
            }
        }
Exemplo n.º 29
0
        // ---------------------------------------------------------------------------

        byte GetTagVersion(TagRecord TagData)
        {
            byte result = TAG_VERSION_1_0;

            // Terms for ID3v1.1
            if ((('\0' == TagData.Comment[28]) && ('\0' != TagData.Comment[29])) ||
                ((32 == (byte)TagData.Comment[28]) && (32 != (byte)TagData.Comment[29])))
            {
                result = TAG_VERSION_1_1;
            }

            return(result);
        }
Exemplo n.º 30
0
        public TagRecord CreateTag(string tagName)
        {
            var result = _tagRepository.Get(x => x.TagName == tagName);

            if (result == null)
            {
                result = new TagRecord {
                    TagName = tagName
                };
                _tagRepository.Create(result);
            }
            return(result);
        }
Exemplo n.º 31
0
        // ---------------------------------------------------------------------------

        public bool RemoveFromFile(String FileName)
        {
            TagRecord TagData = new TagRecord();
            bool      result;

            // Find tag
            result = ReadTag(FileName, ref TagData);
            // Delete tag if loaded and tag header OK
            if ((result) && Utils.StringEqualsArr("TAG", TagData.Header))
            {
                result = RemoveTag(FileName);
            }
            return(result);
        }
Exemplo n.º 32
0
        private RefreshResults RefreshRecentlyAdded()
        {
            var list = Browser.GetRecentlyAddedVideos();

            List <Video> added      = new List <Video>();
            List <Video> duplicates = new List <Video>();
            List <Video> failedIds  = new List <Video>();

            DateTime runTime = DateTime.Now;


            foreach (Video v in list)
            {
                var existing = DataStore.GetExistingVideo(v.Type, v.AmazonId, v.Title);

                if (existing == null)
                {
                    v.Created = v.Updated = runTime;
                    v.AddTag(TagRecord.Create(-1, TagType.New));

                    if ((from i in added
                         where i.AmazonId == v.AmazonId || i.Title == v.Title
                         select i).FirstOrDefault() == null)
                    {
                        try
                        {
                            DataStore.InsertVideo(v);
                            added.Add(v);
                        }
                        catch (Exception e)
                        {
                            failedIds.Add(v);
                        }
                    }
                    else
                    {
                        duplicates.Add(v);
                    }
                }
                else
                {
                    existing.Updated = runTime;
                    DataStore.UpdateVideo(existing);
                }
            }

            RefreshResults result = new RefreshResults(added, failedIds);

            return(result);
        }
Exemplo n.º 33
0
		// ********************* Auxiliary functions & voids ********************

		bool ReadTag(String FileName, ref TagRecord TagData)
		{
			bool result;
			FileStream fs = null;
			BinaryReader SourceFile = null;


			try
			{
				result = true;
				// Set read-access and open file
				fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
				SourceFile = new BinaryReader(fs);
			
				// Read tag
				fs.Seek(-128, SeekOrigin.End);
			
				// ID3v1 tags are C-String(null-terminated)-based tags
				// they are not unicode-encoded, hence the use of ReadTrueChars
				TagData.Header = Utils.ReadTrueChars(SourceFile,3);
				TagData.Title = Utils.ReadTrueChars(SourceFile,30);
				TagData.Artist = Utils.ReadTrueChars(SourceFile,30);
				TagData.Album = Utils.ReadTrueChars(SourceFile,30);
				TagData.Year = Utils.ReadTrueChars(SourceFile,4);
				TagData.Comment = Utils.ReadTrueChars(SourceFile,30);
				TagData.Genre = SourceFile.ReadByte();
			} 
			catch (Exception e)
			{
				System.Console.WriteLine(e.Message);
				System.Console.WriteLine(e.StackTrace);
				result = false;
			}

			if (SourceFile != null) SourceFile.Close();
			if (fs != null) fs.Close();

			return result;
		}
Exemplo n.º 34
0
		// ---------------------------------------------------------------------------

		bool SaveTag(String FileName, TagRecord TagData)
		{	
			bool result = true;

			try
			{		
				// Allow write-access and open file
				FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Write);
				BinaryWriter TargetFile = new BinaryWriter(fs);

				// Write tag
				fs.Seek(fs.Length, SeekOrigin.Begin);
			
				TargetFile.Write(TagData.Header);
				TargetFile.Write(TagData.Title);
				TargetFile.Write(TagData.Artist);
				TargetFile.Write(TagData.Album);
				TargetFile.Write(TagData.Year);
				TargetFile.Write(TagData.Comment);
				TargetFile.Write(TagData.Genre);			
			
				TargetFile.Close();
				fs.Close();
			} 
			catch (Exception e)
			{			
				System.Console.WriteLine(e.StackTrace);
				result = false;
			}
			return result;
		}
Exemplo n.º 35
0
		// ---------------------------------------------------------------------------

		byte GetTagVersion(TagRecord TagData)
		{
			byte result = TAG_VERSION_1_0;
			// Terms for ID3v1.1
			if ( (('\0' == TagData.Comment[28]) && ('\0' != TagData.Comment[29])) ||
				((32 == (byte)TagData.Comment[28]) && (32 != (byte)TagData.Comment[29])) )
				result = TAG_VERSION_1_1;

			return result;
		}
Exemplo n.º 36
0
		// ---------------------------------------------------------------------------

		public bool ReadFromFile(String FileName)
		{
			TagRecord TagData = new TagRecord();
	
			// Reset and load tag data from file to variable
			ResetData();
			bool result = ReadTag(FileName, ref TagData);
			// Process data if loaded and tag header OK
			if ((result) && Utils.StringEqualsArr("TAG",TagData.Header))
			{
				FExists = true;
				FVersionID = GetTagVersion(TagData);
				// Fill properties with tag data
				FTitle = Utils.BuildStringCStyle(TagData.Title);
				FArtist = Utils.BuildStringCStyle(TagData.Artist).TrimEnd();
				FAlbum = Utils.BuildStringCStyle(TagData.Album).TrimEnd();
				FYear = Utils.BuildStringCStyle(TagData.Year).TrimEnd();
				if (TAG_VERSION_1_0 == FVersionID)
				{
					FComment = Utils.BuildStringCStyle(TagData.Comment).TrimEnd();
				}
				else
				{
					char[] newComment = new char[28];
					Array.Copy(TagData.Comment,0,newComment,0,28);
					FComment = Utils.BuildStringCStyle(newComment).TrimEnd();
					FTrack = (byte)TagData.Comment[29];
				}
				FGenreID = TagData.Genre;
			}
			return result;
		}
Exemplo n.º 37
0
		// ---------------------------------------------------------------------------

		public bool RemoveFromFile(String FileName)
		{
			TagRecord TagData = new TagRecord();
			bool result;
	
			// Find tag
			result = ReadTag(FileName, ref TagData);
			// Delete tag if loaded and tag header OK
			if ( (result) && Utils.StringEqualsArr("TAG",TagData.Header) ) result = RemoveTag(FileName);
			return result;
		}
Exemplo n.º 38
0
		// ---------------------------------------------------------------------------

		public bool SaveToFile(String FileName)
		{
			TagRecord TagData = new TagRecord();
	
			// Prepare tag record
			TagData.Reset();

			TagData.Header[0] = 'T';
			TagData.Header[1] = 'A';
			TagData.Header[2] = 'G';
		
			Array.Copy(FTitle.ToCharArray(), TagData.Title, 30);
			Array.Copy(FArtist.ToCharArray(), TagData.Artist, 30);
			Array.Copy(FAlbum.ToCharArray(), TagData.Album, 30);
			Array.Copy(FYear.ToCharArray(), TagData.Year, 4);
			Array.Copy(FComment.ToCharArray(), TagData.Comment, 30);

			if (FTrack > 0)
			{
				TagData.Comment[28] = '\0';
				TagData.Comment[29] = (char)FTrack;
			}
			TagData.Genre = FGenreID;
	
			// Delete old tag and write new tag
			return ( (RemoveFromFile(FileName)) && (SaveTag(FileName, TagData)) );
		}