public static TermsOfUseFrame Get(TagLib.Id3v2.Tag tag, string language, bool create) { IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.USER).GetEnumerator(); try { while (enumerator.MoveNext()) { Frame current = enumerator.Current; TermsOfUseFrame frame2 = current as TermsOfUseFrame; if ((frame2 != null) && ((language == null) || (language == frame2.Language))) { return frame2; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } if (!create) { return null; } TermsOfUseFrame frame3 = new TermsOfUseFrame(language); tag.AddFrame(frame3); return frame3; }
public static bool SaveXmpSidecar(this TagLib.Image.File file, TagLib.File.IFileAbstraction resource) { var xmp_tag = file.GetTag (TagLib.TagTypes.XMP, false) as XmpTag; if (xmp_tag == null) { // TODO: Delete File return true; } var xmp = xmp_tag.Render (); try { using (var stream = resource.WriteStream) { stream.SetLength (0); using (var writer = new StreamWriter (stream)) { writer.Write (xmp); } resource.CloseStream (stream); } } catch (Exception e) { Log.DebugFormat ("Sidecar cannot be saved: {0}", resource.Name); Log.DebugException (e); return false; } return true; }
public static TermsOfUseFrame GetPreferred(TagLib.Id3v2.Tag tag, string language) { TermsOfUseFrame frame = null; IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.USER).GetEnumerator(); try { while (enumerator.MoveNext()) { Frame current = enumerator.Current; TermsOfUseFrame frame3 = current as TermsOfUseFrame; if (frame3 != null) { if (frame3.Language == language) { return frame3; } if (frame == null) { frame = frame3; } } } } finally { if (enumerator == null) { } enumerator.Dispose(); } return frame; }
/// <summary> /// Parses the XMP file identified by resource and replaces the XMP /// tag of file by the parsed data. /// </summary> public static bool ParseXmpSidecar(this TagLib.Image.File file, TagLib.File.IFileAbstraction resource) { string xmp; try { using (var stream = resource.ReadStream) { using (var reader = new StreamReader (stream)) { xmp = reader.ReadToEnd (); } } } catch (Exception e) { Log.DebugFormat ("Sidecar cannot be read for file {0}", file.Name); Log.DebugException (e); return false; } XmpTag tag = null; try { tag = new XmpTag (xmp, file); } catch (Exception e) { Log.DebugFormat ("Metadata of Sidecar cannot be parsed for file {0}", file.Name); Log.DebugException (e); return false; } var xmp_tag = file.GetTag (TagLib.TagTypes.XMP, true) as XmpTag; xmp_tag.ReplaceFrom (tag); return true; }
private static TagLib BuildTagLib() { var tagLib = new TagLib(); tagLib.Register(new Html()); return(tagLib); }
public void ErrorFileShouldSaveParseContext() { var lib = new TagLib(); lib.Register(new Tags.Tiles()); lib.Register(new Sharp()); var factory = new FileLocatorFactory().CloneForTagLib(lib) as FileLocatorFactory; try { new TilesSet(); var tile = new TemplateTile( "test", factory.Handle("errorinfile.htm", true), null ); } catch (TemplateExceptionWithContext TEWC) { Assert.That(TEWC.Context, Is.Not.Null); Assert.That(TEWC.Context.LineNumber, Is.EqualTo(2)); string fullPath = Path.GetFullPath("errorinfile.htm"); TagException tagException = TagException.UnbalancedCloseingTag(new ForEach() { Group = new Core() }, new If() { Group = new Core() }).Decorate(TEWC.Context); Assert.That(TEWC.Message, Is.EqualTo(TemplateExceptionWithContext.ErrorInTemplate(fullPath, tagException).Message)); } }
public static void OverwriteSequenceNumbers(TagLib.Ogg.File file, long position, IDictionary<uint, int> shiftTable) { if (file == null) { throw new ArgumentNullException("file"); } if (shiftTable == null) { throw new ArgumentNullException("shiftTable"); } bool flag = true; IEnumerator<KeyValuePair<uint, int>> enumerator = shiftTable.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair<uint, int> current = enumerator.Current; if (current.Value != 0) { flag = false; goto Label_0065; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } Label_0065: if (flag) { return; } while (position < (file.Length - 0x1bL)) { PageHeader header = new PageHeader(file, position); int length = (int) (header.Size + header.DataSize); if (shiftTable.ContainsKey(header.StreamSerialNumber) && (shiftTable[header.StreamSerialNumber] != 0)) { file.Seek(position); ByteVector vector = file.ReadBlock(length); ByteVector data = ByteVector.FromUInt(header.PageSequenceNumber + ((uint) ((long) shiftTable[header.StreamSerialNumber])), false); for (int i = 0x12; i < 0x16; i++) { vector[i] = data[i - 0x12]; } for (int j = 0x16; j < 0x1a; j++) { vector[j] = 0; } data.Add(ByteVector.FromUInt(vector.Checksum, false)); file.Seek(position + 0x12L); file.WriteBlock(data); } position += length; } }
public static AttachedPictureFrame Get(TagLib.Id3v2.Tag tag, string description, PictureType type, bool create) { AttachedPictureFrame frame; IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.APIC).GetEnumerator(); try { while (enumerator.MoveNext()) { Frame current = enumerator.Current; frame = current as AttachedPictureFrame; if (((frame != null) && ((description == null) || (frame.Description == description))) && ((type == PictureType.Other) || (frame.Type == type))) { return frame; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } if (!create) { return null; } frame = new AttachedPictureFrame { Description = description, Type = type }; tag.AddFrame(frame); return frame; }
/// <summary> /// Constructs and initializes a new instance of <see /// cref="AviHeaderList" /> by reading the contents of a raw /// RIFF list from a specified position in a <see /// cref="TagLib.File"/>. /// </summary> /// <param name="file"> /// A <see cref="TagLib.File" /> object containing the file /// from which the contents of the new instance is to be /// read. /// </param> /// <param name="position"> /// A <see cref="long" /> value specify at what position to /// read the list. /// </param> /// <param name="length"> /// A <see cref="int" /> value specifying the number of bytes /// to read. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="file" /> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="position" /> is less than zero or greater /// than the size of the file. /// </exception> /// <exception cref="CorruptFileException"> /// The list does not contain an AVI header or the AVI header /// is the wrong length. /// </exception> public AviHeaderList (TagLib.File file, long position, int length) { if (file == null) throw new ArgumentNullException ("file"); if (length < 0) throw new ArgumentOutOfRangeException ( "length"); if (position < 0 || position > file.Length - length) throw new ArgumentOutOfRangeException ( "position"); List list = new List (file, position, length); if (!list.ContainsKey ("avih")) throw new CorruptFileException ( "Avi header not found."); ByteVector header_data = list ["avih"][0]; if (header_data.Count != 0x38) throw new CorruptFileException ( "Invalid header length."); header = new AviHeader (header_data, 0); foreach (ByteVector list_data in list ["LIST"]) if (list_data.StartsWith ("strl")) codecs.Add (AviStream .ParseStreamList (list_data) .Codec); }
public TagLib.Tag AddTag(TagTypes type, TagLib.Tag copy) { TagLib.Tag target = null; if (type == (TagTypes.None | TagTypes.Id3v1)) { target = new TagLib.Id3v1.Tag(); } else if (type == (TagTypes.None | TagTypes.Id3v2)) { TagLib.Id3v2.Tag tag2; target = new TagLib.Id3v2.Tag { Version = 4, Flags = (byte) (tag2.Flags | HeaderFlags.FooterPresent) }; } else if (type == (TagTypes.None | TagTypes.Ape)) { target = new TagLib.Ape.Tag(); } if (target != null) { if (copy != null) { copy.CopyTo(target, true); } if (type == (TagTypes.None | TagTypes.Id3v1)) { base.AddTag(target); return target; } base.InsertTag(0, target); } return target; }
public static string[] GetMiscTag(TagLib.File file, string name) { //TagLib.Mpeg4.AppleTag apple = (TagLib.Mpeg4.AppleTag)file.GetTag(TagLib.TagTypes.Apple); //TagLib.Id3v2.Tag id3v2 = (TagLib.Id3v2.Tag)file.GetTag(TagLib.TagTypes.Id3v2); TagLib.Ogg.XiphComment xiph = (TagLib.Ogg.XiphComment)file.GetTag(TagLib.TagTypes.Xiph); TagLib.Ape.Tag ape = (TagLib.Ape.Tag)file.GetTag(TagLib.TagTypes.Ape); //if (apple != null) //{ // string[] text = apple.GetText(name); // if (text.Length != 0) // return text; //} //if (id3v2 != null) // foreach (TagLib.Id3v2.Frame f in id3v2.GetFrames()) // if (f is TagLib.Id3v2.TextInformationFrame && ((TagLib.Id3v2.TextInformationFrame)f).Text != null) // return ((TagLib.Id3v2.TextInformationFrame)f).Text; if (xiph != null) { string[] l = xiph.GetField(name); if (l != null && l.Length != 0) return l; } if (ape != null) { TagLib.Ape.Item item = ape.GetItem(name); if (item != null) return item.ToStringArray(); } return null; }
public Song(TagLib.File file, string path) { tagFile = file; Path = path; int temp = path.LastIndexOf('\\'); FileName = path.Substring(temp+1, path.Length - temp - 1); }
/// <summary> /// Constructs and initializes a new instance of <see /// cref="AppleAdditionalInfoBox" /> with a provided header /// and handler by reading the contents from a specified /// file. /// </summary> /// <param name="header"> /// A <see cref="BoxHeader" /> object containing the header /// to use for the new instance. /// </param> /// <param name="file"> /// A <see cref="TagLib.File" /> object to read the contents /// of the box from. /// </param> /// <param name="handler"> /// A <see cref="IsoHandlerBox" /> object containing the /// handler that applies to the new instance. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="file" /> is <see langword="null" />. /// </exception> public AppleAdditionalInfoBox(BoxHeader header, TagLib.File file, IsoHandlerBox handler) : base(header, file, handler) { // We do not care what is in this custom data section // see: https://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap2/qtff2.html Data = file.ReadBlock(DataSize > 0 ? DataSize : 0); ; }
public HeaderExtensionObject(TagLib.Asf.File file, long position) : base(file, position) { this.children = new List<TagLib.Asf.Object>(); if (!base.Guid.Equals(TagLib.Asf.Guid.AsfHeaderExtensionObject)) { throw new CorruptFileException("Object GUID incorrect."); } if (file.ReadGuid() != TagLib.Asf.Guid.AsfReserved1) { throw new CorruptFileException("Reserved1 GUID expected."); } if (file.ReadWord() != 6) { throw new CorruptFileException("Invalid reserved WORD. Expected '6'."); } uint num = file.ReadDWord(); position += 0x2eL; while (num > 0) { TagLib.Asf.Object item = file.ReadObject(position); position += (long) item.OriginalSize; num -= (uint) item.OriginalSize; this.children.Add(item); } }
public static RelativeVolumeFrame Get(TagLib.Id3v2.Tag tag, string identification, bool create) { RelativeVolumeFrame frame; IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.RVA2).GetEnumerator(); try { while (enumerator.MoveNext()) { Frame current = enumerator.Current; frame = current as RelativeVolumeFrame; if ((frame != null) && (frame.Identification == identification)) { return frame; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } if (!create) { return null; } frame = new RelativeVolumeFrame(identification); tag.AddFrame(frame); return frame; }
public ContentDescriptionObject(TagLib.Asf.File file, long position) : base(file, position) { this.title = string.Empty; this.author = string.Empty; this.copyright = string.Empty; this.description = string.Empty; this.rating = string.Empty; if (base.Guid != TagLib.Asf.Guid.AsfContentDescriptionObject) { throw new CorruptFileException("Object GUID incorrect."); } if (base.OriginalSize < 0x22L) { throw new CorruptFileException("Object size too small."); } ushort length = file.ReadWord(); ushort num2 = file.ReadWord(); ushort num3 = file.ReadWord(); ushort num4 = file.ReadWord(); ushort num5 = file.ReadWord(); this.title = file.ReadUnicode(length); this.author = file.ReadUnicode(num2); this.copyright = file.ReadUnicode(num3); this.description = file.ReadUnicode(num4); this.rating = file.ReadUnicode(num5); }
protected void Application_Start() { RegisterRoutes(RouteTable.Routes); ViewEngines.Engines.Clear(); TagLib.Register(new Tiles()); ViewEngines.Engines.Add((IViewEngine) new org.SharpTiles.Connectors.NstlViewEngine().Init()); }
public void CreateShouldAssembleFileTileWithCorrectPath() { var lib = new TagLib(); lib.Register(new Tags.Tiles()); lib.Register(new Sharp()); var locatorFactory = new FileLocatorFactory().CloneForTagLib(lib) as FileLocatorFactory; var factory = new TilesFactory(new MockConfiguration("x", DateTime.Now) { Factory = locatorFactory }); var entry = new MockTileEntry { Name = "name", Path = "a.htm", Extends = null }; var tile = new TemplateTileCreator().Create(entry, factory); Assert.That(tile, Is.Not.Null); Assert.That(tile.GetType(), Is.EqualTo(typeof(TemplateTile))); Assert.That(tile.Name, Is.EqualTo("name")); var templateTile = (TemplateTile)tile; var fileTemplate = (FileTemplate)templateTile.Template; Assert.That(fileTemplate.Path.EndsWith("a.htm")); }
public static UnsynchronisedLyricsFrame Get(TagLib.Id3v2.Tag tag, string description, string language, bool create) { UnsynchronisedLyricsFrame frame; IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.USLT).GetEnumerator(); try { while (enumerator.MoveNext()) { Frame current = enumerator.Current; frame = current as UnsynchronisedLyricsFrame; if (((frame != null) && (frame.Description == description)) && ((language == null) || (language == frame.Language))) { return frame; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } if (!create) { return null; } frame = new UnsynchronisedLyricsFrame(description, language); tag.AddFrame(frame); return frame; }
public static void getAvatarImg(ref TagLib.File tagFile, ref JsonPoco.Track song) { //download user profile avatar image string avatarFilepath = Path.GetTempFileName(); string highResAvatar_url = song.user.avatar_url.Replace("large.jpg", "t500x500.jpg"); for (int attempts = 0; attempts < 5; attempts++) { try { using (WebClient web = new WebClient()) { web.DownloadFile(highResAvatar_url, avatarFilepath); } TagLib.Picture artwork = new TagLib.Picture(avatarFilepath); artwork.Type = TagLib.PictureType.FrontCover; tagFile.Tag.Pictures = new[] { artwork }; break; } catch (Exception e) { Debug.WriteLine(e); } System.Threading.Thread.Sleep(50); // Pause 50ms before new attempt } if (avatarFilepath != null && File.Exists(avatarFilepath)) { File.Delete(avatarFilepath); } }
protected void Read(TagLib.File file) { if (file == null) return; try { file.Mode = FileAccessMode.Read; } catch (TagLibException) { return; } file.Seek(tagOffset); header.SetData(file.ReadBlock((int)Id3v2Header.Size)); // if the tag size is 0, then this is an invalid tag (tags must contain // at least one frame) if (header.TagSize == 0) return; Parse(file.ReadBlock((int)header.TagSize)); }
public static GeneralEncapsulatedObjectFrame Get(TagLib.Id3v2.Tag tag, string description, bool create) { GeneralEncapsulatedObjectFrame frame; IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.GEOB).GetEnumerator(); try { while (enumerator.MoveNext()) { Frame current = enumerator.Current; frame = current as GeneralEncapsulatedObjectFrame; if ((frame != null) && (frame.Description == description)) { return frame; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } if (!create) { return null; } frame = new GeneralEncapsulatedObjectFrame { Description = description }; tag.AddFrame(frame); return frame; }
public void SetUp() { _lib = new TagLib(); _lib.Register(new Tags.Tiles()); _lib.Register(new Sharp()); _factory = new FileLocatorFactory().CloneForTagLib(_lib) as FileLocatorFactory; new TilesSet(); _map = new TilesMap(); _data = new Hashtable(); _model = new TagModel(_data); _nestedAttributes = new AttributeSet( "nested", new TileAttribute("aAttribute", new StringTile("aAttributeValue")) ); _map.AddTile(new TemplateTile("fileWithAttributes", _factory.Handle("filewithtileattributes.htm", true), _nestedAttributes)); _attributes = new AttributeSet( "main", new TileAttribute("simple", new StringTile("simpleValue")), new TileAttribute("file", new TemplateTile(null, _factory.Handle("a.htm", true), null)), new TileAttribute("fileWithVars", new TemplateTile(null, _factory.Handle("b.htm", true), null)), new TileAttribute("fileWithTilesAttributes", new TileReference("fileWithAttributes", _map)) ); _model.Decorate().With(_attributes); _data["simpleAsProperty"] = "simple"; _data["some"] = new Hashtable { { "a", "AA" } }; }
public static MusicCdIdentifierFrame Get(TagLib.Id3v2.Tag tag, bool create) { MusicCdIdentifierFrame frame; IEnumerator<Frame> enumerator = tag.GetEnumerator(); try { while (enumerator.MoveNext()) { Frame current = enumerator.Current; frame = current as MusicCdIdentifierFrame; if (frame != null) { return frame; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } if (!create) { return null; } frame = new MusicCdIdentifierFrame(); tag.AddFrame(frame); return frame; }
public void SetUp() { _lib = new TagLib(); _lib.Register(new Tags.Tiles()); _lib.Register(new Sharp()); _locatorFactory = new FileLocatorFactory().CloneForTagLib(_lib) as FileLocatorFactory; }
public Tag(TagLib.NonContainer.File file) { this.start_tag = new TagLib.NonContainer.StartTag(file); this.end_tag = new TagLib.NonContainer.EndTag(file); base.AddTag(this.start_tag); base.AddTag(this.end_tag); }
public static UniqueFileIdentifierFrame Get(TagLib.Id3v2.Tag tag, string owner, bool create) { UniqueFileIdentifierFrame frame; IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.UFID).GetEnumerator(); try { while (enumerator.MoveNext()) { Frame current = enumerator.Current; frame = current as UniqueFileIdentifierFrame; if ((frame != null) && (frame.Owner == owner)) { return frame; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } if (!create) { return null; } frame = new UniqueFileIdentifierFrame(owner, null); tag.AddFrame(frame); return frame; }
public static SynchronisedLyricsFrame Get(TagLib.Id3v2.Tag tag, string description, string language, SynchedTextType type, bool create) { IEnumerator<Frame> enumerator = tag.GetEnumerator(); try { while (enumerator.MoveNext()) { Frame current = enumerator.Current; SynchronisedLyricsFrame frame2 = current as SynchronisedLyricsFrame; if (((frame2 != null) && ((frame2.Description == description) && ((language == null) || (language == frame2.Language)))) && (type == frame2.Type)) { return frame2; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } if (!create) { return null; } SynchronisedLyricsFrame frame3 = new SynchronisedLyricsFrame(description, language, type); tag.AddFrame(frame3); return frame3; }
private static TagLibParserFactory CreateFactory() { ITagLib lib = new TagLib(); lib.Register(new Sharp()); return(new TagLibParserFactory(new TagLibForParsing(lib), new ExpressionLib(), new FileLocatorFactory(), null)); }
public void CheckPassThroughOfContentParsed() { var lib = new TagLib().Register(new Sharp()); ITag tag = new TagLibParserFactory(new TagLibForParsing(lib), new ExpressionLib(), new FileLocatorFactory(), null).Parse("<sharp:marker id='id'>body</sharp:marker>"); Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo("body")); }
public static PopularimeterFrame Get(TagLib.Id3v2.Tag tag, string user, bool create) { PopularimeterFrame frame; IEnumerator<Frame> enumerator = tag.GetEnumerator(); try { while (enumerator.MoveNext()) { Frame current = enumerator.Current; frame = current as PopularimeterFrame; if ((frame != null) && frame.user.Equals(user)) { return frame; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } if (!create) { return null; } frame = new PopularimeterFrame(user); tag.AddFrame(frame); return frame; }
private static TagLibParserFactory CreateFactory() { var lib = new TagLib(); lib.Register(new Macro()); return(new TagLibParserFactory(new TagLibForParsing(lib), new ExpressionLib(new MacroFunctionLib()), new FileLocatorFactory(), null)); }
static void AddSongToDirectory(TagLib.File file) { file.Save(); string fileName = file.Name.Split('\\').Last(); string currentPosition = file.Name; string destination = directoryName + @"\" + file.Tag.Performers[0] + @"\" + file.Tag.Performers[0] + " - " + fileName; System.IO.File.Move(currentPosition, destination); }
public UnknownBox(BoxHeader header, TagLib.File file, IsoHandlerBox handler) : base(header, handler) { if (file == null) { throw new ArgumentNullException("file"); } this.data = base.LoadData(file); }
public AppleItemListBox(BoxHeader header, TagLib.File file, IsoHandlerBox handler) : base(header, handler) { if (file == null) { throw new ArgumentNullException("file"); } this.children = base.LoadChildren(file); }
public Picture(string filePath, int index, TagLib.IPicture picture) { _description = picture.Description; _filePath = filePath; _index = index; _mimeType = picture.MimeType; _type = picture.Type; }
private AudioHeader(uint flags, long streamLength, TagLib.Mpeg.XingHeader xingHeader, TagLib.Mpeg.VBRIHeader vbriHeader) { this.flags = flags; this.stream_length = streamLength; this.xing_header = xingHeader; this.vbri_header = vbriHeader; this.duration = TimeSpan.Zero; }
public void Overwrite(TagLib.Mpeg4.File file, long sizeDifference, long after) { if (file == null) { throw new ArgumentNullException("file"); } file.Insert(this.Render(sizeDifference, after), base.Header.Position, (long) this.Size); }
protected ListTag (TagLib.File file, long position, int length) { if (file == null) throw new System.ArgumentNullException ("file"); file.Seek (position); fields = new List (file.ReadBlock (length)); }
public DocumentationGenerator() { _lib = new TagLib(); _lib.Register(new Sharp()); _subject = _lib; _all = true; _fragment = false; // FunctionLib.Register(new MathFunctionLib()); _specials = new List <Func <ITag, TagDocumentation, bool> >(); }
protected void Application_Start() { RegisterRoutes(RouteTable.Routes); ViewEngines.Engines.Clear(); FunctionLib.Register(new MathLib()); TagLib.Register(new MyTagLib()); var engine = new TilesViewEngine(); ViewEngines.Engines.Add(engine.Init()); engine.LoadResourceBundle("CustomTaglibsTagsAndFunctions.Views.default"); }
public Formatter SwitchToMode(TagLibMode mode) { if (_templateParsed != null) { throw new InvalidOperationException("SwitchToMode can only be called before calling Parse!"); } var lib = new TagLib(mode, _lib.ToArray()); _lib = lib; return(this); }
public void SetUp() { _lib = new TagLib(); _lib.Register(new Tags.Tiles()); _lib.Register(new Sharp()); _locatorFactory = new FileLocatorFactory().CloneForTagLib(_lib) as FileLocatorFactory; var config = new MockConfiguration() { Factory = _locatorFactory }; _factory = new TilesFactory(config); }
public DocumentModel(TagLib subject, bool all, ResourceBundle bundle, IList <Func <ITag, TagDocumentation, bool> > specials = null) { _expressionlib = new ExpressionLib(); _tagDictionary = new Dictionary <int, TagDocumentation>(); _subject = subject; _all = all; _specials = specials ?? new List <Func <ITag, TagDocumentation, bool> >(); _additionalResources = new Dictionary <string, string>(); _resouceKey = new ResourceKeyStack(bundle); GatherExpressions(); GatherFunctions(); GatherGroups(); }
public void GenerateDocumentationForTagLib() { var lib = new TagLib(); lib.Register(new TestGroup()); //When var model = new DocumentationGenerator().For(lib).BuildModel(); var result = JsonConvert.SerializeObject(model, Formatting.Indented); // Then File.WriteAllText("c:/Temp/TagLib.json", result); Assert.That(result, Is.Not.Null); }
static TemplateField() { TagLib = new TagLib(); TilesConfigurationSection config = TilesConfigurationSection.Get(); var prefix = TemplateFieldPrefixHelper.BuildPrefix(HostingEnvironment.ApplicationPhysicalPath, config.FilePrefix); RefreshJob.REFRESH_INTERVAL = config.RefreshIntervalSeconds; _configuration = new TileXmlConfigurator( TagLib, config.ConfigFilePath, prefix ); TILES = new TilesSet(_configuration); }
public void GetView_Should_Update_Locator_Correct() { //Given var lib = new TagLib(); lib.Register(new Html()); lib.Register(new Tiles.Tags.Tiles()); var factory = new FileLocatorFactory("Views").CloneForTagLib(lib); var cache = new NstlCache { Factory = factory }; var view = cache.GetView("Home/Index.htm"); Assert.That(view, Is.Not.Null); var model = new TagModel(new Dictionary <string, string> { { "Message", "Test" } }); Assert.That(view.Render(model).Contains("VIEWS")); //Then }
public void CreateShouldAssembleFileTileWithCorrectExtendsAndPath() { var lib = new TagLib(); lib.Register(new Tags.Tiles()); lib.Register(new Sharp()); var locatorFactory = new FileLocatorFactory().CloneForTagLib(lib) as FileLocatorFactory; var factory = new TilesFactory(new MockConfiguration("a", DateTime.Now) { Factory = locatorFactory }); var entry = new MockTileEntry { Name = "name", Path = "b.htm", Extends = "definition" }; ITile tile = new TemplateOverridingDefinitionTileCreator().Create(entry, factory); Assert.That(tile, Is.Not.Null); Assert.That(tile.GetType(), Is.EqualTo(typeof(TemplateOveridingDefinitionTile))); Assert.That(tile.Name, Is.EqualTo("name")); var definition = (TemplateOveridingDefinitionTile)tile; var tileTemplate = (FileTemplate)definition.Template; Assert.That(tileTemplate.Path.EndsWith("b.htm")); Assert.That(definition.Extends, Is.Not.Null); Assert.That(definition.Extends.GetType(), Is.EqualTo(typeof(TileReference))); var reference = (TileReference)definition.Extends; Assert.That(reference.Name, Is.EqualTo("definition")); }
public DocumentationGenerator For(TagLib subject) { _subject = subject; return(this); }
public void Push(params ITagGroup[] extension) { var dish = new TagLib(Mode, extension); _stack.Push(dish); }
public void SetUp() { _lib = new TagLib(); // _lib.Register(new Tiles.Tags.Tiles()); // _lib.Register(new Sharp()); }