예제 #1
0
 private void HttpServer_HttpConnectionReceived(object sender, HttpConnectionEventArgs e)
 {
     if (_started &&
         ((e.Context.Request.Url.IsAbsoluteUri && StringComparer.InvariantCultureIgnoreCase.Compare(e.Context.Request.Url.AbsolutePath, ApplicationPrefix.AbsolutePath) == 0) ||
          StringComparer.InvariantCultureIgnoreCase.Compare(e.Context.Request.Url.OriginalString, ApplicationPrefix.AbsolutePath) == 0))
     {
         OnHmeApplicationRequestReceived(e.Context);
     }
     else if (_started &&
              ((e.Context.Request.Url.IsAbsoluteUri && e.Context.Request.Url.AbsolutePath.StartsWith(ApplicationPrefix.AbsolutePath, StringComparison.InvariantCultureIgnoreCase)) ||
               e.Context.Request.Url.OriginalString.StartsWith(ApplicationPrefix.AbsolutePath, StringComparison.InvariantCultureIgnoreCase)))
     {
         if (StringComparer.InvariantCultureIgnoreCase.Compare(e.Context.Request.Url.LocalPath, iconUri) == 0)
         {
             HmeApplicationIconRequestedArgs iconArgs = new HmeApplicationIconRequestedArgs {
                 BaseUri = BuildBaseUri(e.Context)
             };
             OnHmeApplicationIconRequested(iconArgs);
             e.Context.Response.ContentType     = iconArgs.ContentType;
             e.Context.Response.ContentLength64 = iconArgs.Icon.LongLength;
             e.Context.Response.OutputStream.Write(iconArgs.Icon, 0, iconArgs.Icon.Length);
             //e.Context.Response.Close();
         }
         else
         {
             OnNonApplicationRequestReceived(e);
         }
     }
 }
예제 #2
0
 protected override void OnHmeApplicationIconRequested(HmeApplicationIconRequestedArgs e)
 {
     object[] attributes = typeof(ApplicationT).GetCustomAttributes(typeof(ApplicationIconAttribute), true);
     if (attributes.Length != 0)
     {
         e.Icon        = ((ApplicationIconAttribute)attributes[0]).Icon;
         e.ContentType = "image/png";
     }
     base.OnHmeApplicationIconRequested(e);
 }
예제 #3
0
        protected virtual void OnHmeApplicationIconRequested(HmeApplicationIconRequestedArgs e)
        {
            EventHandler <HmeApplicationIconRequestedArgs> handler = ApplicationIconRequested;

            if (handler != null)
            {
                handler(this, e);
            }
            if (e.Icon == null)
            {
                // provide default icon
                e.Icon        = Properties.Resources.iconpng;
                e.ContentType = "image/png";
            }
        }