예제 #1
0
        public override void Connect(Uri uri, string username, string password)
        {
            string domain = uri.Host;
            string[] pathParts = Uri.UnescapeDataString(uri.AbsolutePath).Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            string instance = pathParts[0];
            string volName = pathParts[1];

            _odsClient = new OpticalDiscServiceClient();
            foreach (var service in _odsClient.LookupServices(domain))
            {
                if (service.DisplayName == instance)
                {
                    _service = service;
                    _service.Connect(Environment.UserName, Environment.MachineName, 30);

                    foreach (var disk in _service.AdvertisedDiscs)
                    {
                        if (disk.VolumeLabel == volName)
                        {
                            _disk = disk.Name;
                        }
                    }
                }
            }

            if (_disk == null)
            {
                throw new FileNotFoundException("No such disk", uri.ToString());
            }
        }
예제 #2
0
        public override void Connect(Uri uri, string username, string password)
        {
            string domain = uri.Host;

            string[] pathParts = Uri.UnescapeDataString(uri.AbsolutePath).Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            string   instance  = pathParts[0];
            string   volName   = pathParts[1];

            _odsClient = new OpticalDiscServiceClient();
            foreach (OpticalDiscService service in _odsClient.LookupServices(domain))
            {
                if (service.DisplayName == instance)
                {
                    _service = service;
                    _service.Connect(Environment.UserName, Environment.MachineName, 30);

                    foreach (DiscInfo disk in _service.AdvertisedDiscs)
                    {
                        if (disk.VolumeLabel == volName)
                        {
                            _disk = disk.Name;
                        }
                    }
                }
            }

            if (_disk == null)
            {
                throw new FileNotFoundException("No such disk", uri.ToString());
            }
        }
예제 #3
0
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (_odsClient != null)
         {
             _odsClient.Dispose();
             _odsClient = null;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
예제 #4
0
        protected override void DoRun()
        {
            OpticalDiscServiceClient odsClient = new OpticalDiscServiceClient();

            if (_host.IsPresent)
            {
                bool found = false;

                foreach (var service in odsClient.LookupServices())
                {
                    if (_host.Value == service.DisplayName || _host.Value == Uri.EscapeDataString(service.DisplayName))
                    {
                        found = true;

                        Console.WriteLine("Connecting to " + service.DisplayName + " - the owner may need to accept...");
                        service.Connect(Environment.UserName, Environment.MachineName, 30);

                        ShowService(service);

                        break;
                    }
                }

                if (!found)
                {
                    Console.WriteLine("Host not found");
                }
            }
            else
            {
                foreach (var service in odsClient.LookupServices())
                {
                    ShowService(service);
                    Console.WriteLine();
                }
            }
        }
예제 #5
0
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (_odsClient != null)
         {
             _odsClient.Dispose();
             _odsClient = null;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }