• 大小: 19.36MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-07
  • 语言: 其他
  • 标签: Owin  WebApi  Odata  

资源简介

控制台程序采用自宿主方式提供您webApi服务和Odata服务。本例子采用两种方式做实现,一个是console控制程序自身采用Owin方式将Odata服务自宿主在自身。另一种方式是Console控制体程序采用Owin方式加载webApi网站dll方式。同时控制台程序实现了windows服务的注册和删除功能。

资源截图

代码片段和文件信息

using System;
using System.Linq;
using System.ServiceProcess;
using DebuggableOwinService1.framework;

namespace DebuggableOwinService1
{
    static class Program
    {
        // The main entry point for the windows service application.
        static void Main(string[] args)
        {
            try
            {
                // If install was a command line flag then run the installer at runtime.
                if (args.Contains(“-install“ StringComparer.InvariantCultureIgnoreCase))
                {
                    WindowsServiceInstaller.RuntimeInstall();
                }

                // If uninstall was a command line flag run uninstaller at runtime.
                else if (args.Contains(“-uninstall“ StringComparer.InvariantCultureIgnoreCase))
                {
                    WindowsServiceInstaller.RuntimeUnInstall();
                }

                // Otherwise fire up the service as either console or windows service based on UserInteractive property.
                else
                {
                    var implementation = new ServiceImplementation();

                    // If started from console file explorer etc run as console app.
                    if (Environment.UserInteractive)
                    {
                        ConsoleHarness.Run(args implementation);
                    }

                    // Otherwise run as a windows service
                    else
                    {
                        Servicebase.Run(new WindowsServiceHarness(implementation));
                    }
                }
            }

            catch (Exception ex)
            {
                ConsoleHarness.WriteToConsole(ConsoleColor.Red “An exception occurred in Main(): {0}“ ex);
            }
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2140  2018-04-03 09:57  DebuggableOwinService1\App.config

     文件      66224  2013-08-16 10:43  DebuggableOwinService1\bin\Debug\de\Microsoft.Data.Edm.resources.dll

     文件     282800  2013-08-16 10:55  DebuggableOwinService1\bin\Debug\de\Microsoft.Data.OData.resources.dll

     文件      17584  2013-08-16 10:57  DebuggableOwinService1\bin\Debug\de\System.Spatial.resources.dll

     文件      25088  2018-04-03 10:48  DebuggableOwinService1\bin\Debug\DebuggableOwinService1.exe

     文件       2140  2018-04-03 09:57  DebuggableOwinService1\bin\Debug\DebuggableOwinService1.exe.config

     文件      58880  2018-04-03 10:48  DebuggableOwinService1\bin\Debug\DebuggableOwinService1.pdb

     文件      65712  2013-08-16 10:43  DebuggableOwinService1\bin\Debug\es\Microsoft.Data.Edm.resources.dll

     文件     278192  2013-08-16 10:55  DebuggableOwinService1\bin\Debug\es\Microsoft.Data.OData.resources.dll

     文件      17584  2013-08-16 10:57  DebuggableOwinService1\bin\Debug\es\System.Spatial.resources.dll

     文件      67248  2013-08-16 10:43  DebuggableOwinService1\bin\Debug\fr\Microsoft.Data.Edm.resources.dll

     文件     292016  2013-08-16 10:55  DebuggableOwinService1\bin\Debug\fr\Microsoft.Data.OData.resources.dll

     文件      18096  2013-08-16 10:57  DebuggableOwinService1\bin\Debug\fr\System.Spatial.resources.dll

     文件      65712  2013-08-16 10:43  DebuggableOwinService1\bin\Debug\it\Microsoft.Data.Edm.resources.dll

     文件     276656  2013-08-16 10:55  DebuggableOwinService1\bin\Debug\it\Microsoft.Data.OData.resources.dll

     文件      17584  2013-08-16 10:57  DebuggableOwinService1\bin\Debug\it\System.Spatial.resources.dll

     文件      71856  2013-08-16 10:43  DebuggableOwinService1\bin\Debug\ja\Microsoft.Data.Edm.resources.dll

     文件     315056  2013-08-16 10:55  DebuggableOwinService1\bin\Debug\ja\Microsoft.Data.OData.resources.dll

     文件      18608  2013-08-16 10:57  DebuggableOwinService1\bin\Debug\ja\System.Spatial.resources.dll

     文件      66736  2013-08-16 10:43  DebuggableOwinService1\bin\Debug\ko\Microsoft.Data.Edm.resources.dll

     文件     282288  2013-08-16 10:55  DebuggableOwinService1\bin\Debug\ko\Microsoft.Data.OData.resources.dll

     文件      18096  2013-08-16 10:57  DebuggableOwinService1\bin\Debug\ko\System.Spatial.resources.dll

     文件     659120  2013-08-16 10:43  DebuggableOwinService1\bin\Debug\Microsoft.Data.Edm.dll

     文件     654503  2013-08-16 10:43  DebuggableOwinService1\bin\Debug\Microsoft.Data.Edm.xml

     文件    1518256  2013-08-16 10:55  DebuggableOwinService1\bin\Debug\Microsoft.Data.OData.dll

     文件    3702833  2013-08-16 10:55  DebuggableOwinService1\bin\Debug\Microsoft.Data.OData.xml

     文件     101032  2015-02-13 13:16  DebuggableOwinService1\bin\Debug\Microsoft.Owin.dll

     文件      88232  2015-02-13 13:16  DebuggableOwinService1\bin\Debug\Microsoft.Owin.Host.HttpListener.dll

     文件       8129  2015-02-13 13:16  DebuggableOwinService1\bin\Debug\Microsoft.Owin.Host.HttpListener.xml

     文件      64680  2015-02-13 13:16  DebuggableOwinService1\bin\Debug\Microsoft.Owin.Hosting.dll

............此处省略379个文件信息

评论

共有 条评论