Пример #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
        private static void ShowService(OpticalDiscService service)
        {
            Console.WriteLine();
            Console.WriteLine("Service: " + service.DisplayName);
            Console.WriteLine("  Safe Name: " + Uri.EscapeDataString(service.DisplayName) + "  (for URLs, copy+paste)");
            Console.WriteLine();

            bool foundDisk = false;
            foreach (var disk in service.AdvertisedDiscs)
            {
                foundDisk = true;
                Console.WriteLine("  Disk: " + disk.VolumeLabel);
                Console.WriteLine("    Name: " + disk.Name);
                Console.WriteLine("    Type: " + disk.VolumeType);
                Console.WriteLine("     Url: " + Uri.EscapeUriString("ods://local/" + service.DisplayName + "/" + disk.VolumeLabel));
            }

            if (!foundDisk)
            {
                Console.WriteLine("  [No disks found - try specifying host to connect for full list]");
            }
        }