Ejemplo n.º 1
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             StopService();
             var fw = new FirewallHelper();
             var path = Assembly.GetExecutingAssembly().Location;
             fw.closeFirewall(path,_portNumber);
         }
     }
     //dispose unmanaged resources
     disposed = true;
 }
Ejemplo n.º 2
0
        public async Task<bool> RequestFirewallRule()
        {
            var fwManager = new FirewallHelper();
            string title = "";
            Assembly currentAssem = typeof(ServiceRunner).Assembly;
            object[] attribs = currentAssem.GetCustomAttributes(typeof(AssemblyTitleAttribute), true);
            if (attribs.Length > 0)
            {
                title = ((AssemblyTitleAttribute)attribs[0]).Title;
            }


            var path = Assembly.GetExecutingAssembly().Location;
            return await fwManager.openFirewall(title, path, _portNumber);
        }