Example #1
0
 /// <summary>
 /// Compares this instance to another
 /// </summary>
 /// <param name="other">another <see cref="MimeMediaType"/> instance</param>
 protected bool Equals(MimeMediaType other)
 {
     if (other == null)
     {
         return(false);
     }
     return(Equals(_contentType, other._contentType) && Equals(_subType, other._subType));
 }
Example #2
0
        public void Equals()
        {
            MimeMediaType mt = MimeMediaType.Parse("text/html");

            Assert.AreEqual(MimeMediaType.Text.Html, mt);
            Assert.AreEqual(MimeMediaType.Parse("text/html"), mt);

            Assert.AreNotEqual(MimeMediaType.Parse("text/xml"), mt);
        }
Example #3
0
        public void GetHashcode()
        {
            MimeMediaType mt = MimeMediaType.Parse("text/html");

            Assert.AreEqual(MimeMediaType.Text.Html.GetHashCode(), mt.GetHashCode());
            Assert.AreEqual(MimeMediaType.Parse("text/html").GetHashCode(), mt.GetHashCode());

            Assert.AreNotEqual(MimeMediaType.Parse("text/xml").GetHashCode(), mt.GetHashCode());
        }
        public void CreateInstance()
        {
            Assert.AreEqual( MimeMediaType.Application.Octet, new MimeMediaType() );
            MimeMediaType mt = new MimeMediaType("ApPlicatioN");
            Assert.AreEqual("application", mt.ContentType);
            Assert.AreEqual("*", mt.SubType);

            Assert.AreEqual("*", new MimeMediaType("ApPlicatioN", null).SubType);
            Assert.AreEqual("*", new MimeMediaType("ApPlicatioN", "").SubType);
            Assert.AreEqual("bla", new MimeMediaType("ApPlicatioN", "bla").SubType);
        }
Example #5
0
        public void CreateInstance()
        {
            Assert.AreEqual(MimeMediaType.Application.Octet, new MimeMediaType());
            MimeMediaType mt = new MimeMediaType("ApPlicatioN");

            Assert.AreEqual("application", mt.ContentType);
            Assert.AreEqual("*", mt.SubType);

            Assert.AreEqual("*", new MimeMediaType("ApPlicatioN", null).SubType);
            Assert.AreEqual("*", new MimeMediaType("ApPlicatioN", "").SubType);
            Assert.AreEqual("bla", new MimeMediaType("ApPlicatioN", "bla").SubType);
        }
Example #6
0
        public void Parse()
        {
            MimeMediaType mt = MimeMediaType.Parse("text/html");

            Assert.AreEqual("text", mt.ContentType);
            Assert.AreEqual("html", mt.SubType);

            try { mt = MimeMediaType.Parse(null); Assert.Fail(); }
            catch (ArgumentNullException) { /* ok */ }
            try { mt = MimeMediaType.Parse(""); Assert.Fail(); }
            catch (ArgumentException) { /* ok */ }
            try { mt = MimeMediaType.Parse("aasdfaDF"); Assert.Fail(); }
            catch (ArgumentException) { /* ok */ }
            try { mt = MimeMediaType.Parse("*"); Assert.Fail(); }
            catch (ArgumentException) { /* ok */ }
        }
Example #7
0
 /// <summary>
 /// Registers script file that should be referenced within the <c>head</c> HTML element.
 /// </summary>
 /// <param name="key">Script key.</param>
 /// <param name="type">Script language MIME type.</param>
 /// <param name="fileName">Script file name.</param>
 public void RegisterHeadScriptFile( string key, MimeMediaType type, string fileName )
 {
     headScripts[key] = new ScriptFile( type, fileName );
 }
Example #8
0
 /// <summary>
 /// Registers script block that should be rendered within the <c>head</c> HTML element.
 /// </summary>
 /// <param name="key">Script key.</param>
 /// <param name="type">Script language MIME type.</param>
 /// <param name="script">Script text.</param>
 public void RegisterHeadScriptBlock( string key, MimeMediaType type, string script )
 {
     headScripts[key] = new ScriptBlock( type, script );
 }
Example #9
0
 /// <summary>
 /// Registers script block that should be rendered within the <c>head</c> HTML element.
 /// </summary>
 /// <param name="key">Script key.</param>
 /// <param name="mimeType">The scripting language's MIME type.</param>
 /// <param name="element">Element ID of the event source.</param>
 /// <param name="eventName">Name of the event to handle.</param>
 /// <param name="script">Script text.</param>
 public void RegisterHeadScriptEvent( string key, MimeMediaType mimeType, string element, string eventName, string script )
 {
     headScripts[key] = new ScriptEvent( mimeType, element, eventName, script );
 }
 /// <summary>
 /// Initialize a new <see cref="ScriptFile"/> instance.
 /// </summary>
 /// <param name="type">the script language's <see cref="MimeMediaType"/></param>
 /// <param name="fileName">the (virtual) path to the script</param>
 public ScriptFile(MimeMediaType type, string fileName)
     : base(type)
 {
     this.fileName = fileName;
 }
Example #11
0
 /// <summary>
 /// Initialize a new script object of the specified type
 /// </summary>
 /// <param name="type">a <see cref="MimeMediaType"/></param>
 public Script(MimeMediaType type)
 {
     this.Type = type;
 }
Example #12
0
 /// <summary>
 /// Initialize a new <see cref="ScriptEvent"/> instance.
 /// </summary>
 /// <param name="type">the script language's <see cref="MimeMediaType"/></param>
 /// <param name="element">Element ID of the event source.</param>
 /// <param name="eventName">Name of the event to handle.</param>
 /// <param name="script">Script text.</param>
 public ScriptEvent(MimeMediaType type, string element, string eventName, string script)
     : base(type, script)
 {
     this.element   = element;
     this.eventName = eventName;
 }
Example #13
0
 /// <summary>
 /// Initialize a new <see cref="ScriptFile"/> instance.
 /// </summary>
 /// <param name="type">the script language's <see cref="MimeMediaType"/></param>
 /// <param name="fileName">the (virtual) path to the script</param>
 public ScriptFile(MimeMediaType type, string fileName)
     : base(type)
 {
     this.fileName = fileName;
 }
Example #14
0
 /// <summary>
 /// Initialize a new script block instance.
 /// </summary>
 /// <param name="type">the script language's <see cref="MimeMediaType"/></param>
 /// <param name="script">the script body</param>
 public ScriptBlock(MimeMediaType type, string script) : base(type)
 {
     this.script = script;
 }
 /// <summary>
 /// Initialize a new script object of the specified type
 /// </summary>
 /// <param name="type">a <see cref="MimeMediaType"/></param>
 public Script(MimeMediaType type)
 {
     this.Type = type;
 }
 /// <summary>
 /// Initialize a new <see cref="ScriptEvent"/> instance.
 /// </summary>
 /// <param name="type">the script language's <see cref="MimeMediaType"/></param>
 /// <param name="element">Element ID of the event source.</param>
 /// <param name="eventName">Name of the event to handle.</param>
 /// <param name="script">Script text.</param>
 public ScriptEvent(MimeMediaType type, string element, string eventName, string script)
     : base(type, script)
 {
     this.element = element;
     this.eventName = eventName;
 }
Example #17
0
 /// <summary>
 /// Compares this instance to another
 /// </summary>
 /// <param name="other">another <see cref="MimeMediaType"/> instance</param>
 protected bool Equals(MimeMediaType other)
 {
     if (other == null) return false;
     return Equals(_contentType, other._contentType) && Equals(_subType, other._subType);
 }
 /// <summary>
 /// Initialize a new script block instance.
 /// </summary>
 /// <param name="type">the script language's <see cref="MimeMediaType"/></param>
 /// <param name="script">the script body</param>
 public ScriptBlock(MimeMediaType type, string script) : base(type)
 {
     this.script = script;
 }