Exemplo n.º 1
0
        public ResourceOptions GetOptions()
        {
            var options = new ResourceOptions();

            CopyToOptions(options);
            return(options);
        }
Exemplo n.º 2
0
 public void ResourceInstantiation ()
 {
     var options = new ResourceOptions ();
     SetResourceOptions (options);
     var resource = new Resource (new Uri ("http://0"), options);
     AssertResource (resource, options);
     AssertResource (resource, resource.GetOptions ());
 }
Exemplo n.º 3
0
 static void AssertResource (Resource resource, ResourceOptions options)
 {
     Assert.AreEqual (resource.Size, options.Size);
     Assert.AreEqual (resource.Duration, options.Duration);
     Assert.AreEqual (resource.BitRate, options.BitRate);
     Assert.AreEqual (resource.SampleFrequency, options.SampleFrequency);
     Assert.AreEqual (resource.BitsPerSample, options.BitsPerSample);
     Assert.AreEqual (resource.NrAudioChannels, options.NrAudioChannels);
     Assert.AreEqual (resource.Resolution, options.Resolution);
     Assert.AreEqual (resource.ColorDepth, options.ColorDepth);
     Assert.AreEqual (resource.ProtocolInfo, options.ProtocolInfo);
     Assert.AreEqual (resource.Protection, options.Protection);
     Assert.AreEqual (resource.ImportUri, options.ImportUri);
 }
Exemplo n.º 4
0
 static void SetResourceOptions (ResourceOptions options)
 {
     options.Size = 0;
     options.Duration = new TimeSpan (0, 0, 1);
     options.BitRate = 2;
     options.SampleFrequency = 3;
     options.BitsPerSample = 4;
     options.NrAudioChannels = 5;
     options.Resolution = new Resolution (6, 7);
     options.ColorDepth = 8;
     options.ProtocolInfo = new ProtocolInfo ("foo");
     options.Protection = "9";
     options.ImportUri = new Uri ("http://10");
 }
Exemplo n.º 5
0
        protected void CopyToOptions(ResourceOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            options.Size            = Size;
            options.Duration        = Duration;
            options.BitRate         = BitRate;
            options.SampleFrequency = SampleFrequency;
            options.BitsPerSample   = BitsPerSample;
            options.NrAudioChannels = NrAudioChannels;
            options.Resolution      = Resolution;
            options.ColorDepth      = ColorDepth;
            options.ProtocolInfo    = ProtocolInfo;
            options.Protection      = Protection;
            options.ImportUri       = ImportUri;
        }
Exemplo n.º 6
0
        public Resource(Uri uri, ResourceOptions options)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }
            else if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            Uri             = uri;
            Size            = options.Size;
            Duration        = options.Duration;
            BitRate         = options.BitRate;
            SampleFrequency = options.SampleFrequency;
            BitsPerSample   = options.BitsPerSample;
            NrAudioChannels = options.NrAudioChannels;
            Resolution      = options.Resolution;
            ColorDepth      = options.ColorDepth;
            ProtocolInfo    = options.ProtocolInfo;
            Protection      = options.Protection;
            ImportUri       = options.ImportUri;
        }
Exemplo n.º 7
0
 static void SetObjectOptions (ObjectOptions options)
 {
     options.Title = "1";
     options.Creator = "2";
     options.WriteStatus = WriteStatus.Protected;
     options.IsRestricted = true;
     var resource_options = new ResourceOptions ();
     SetResourceOptions (resource_options);
     options.Resources = new[] { new Resource (new Uri ("http://0"), resource_options) };
 }
Exemplo n.º 8
0
        UpnpPhoto GetPhoto (FSpotPhoto photo, Container parent)
        {
            UpnpPhoto upnp_photo = null;
            if (!photos_cache.ContainsKey (photo.Id)) {
                var resource_options = new ResourceOptions {
                    ProtocolInfo = new ProtocolInfo (Protocols.HttpGet, MimeTypeHelper.GetMimeType(photo.DefaultVersion.Uri))
                };

                var resource_uri = new Uri (string.Format ("{0}object?id={1}", prefix, upnp_photo.Id));

                var photo_options = new PhotoOptions {
                    Title = photo.Name,
                    Rating = photo.Rating.ToString(),
                    Description = photo.Description,
                    Resources = new [] { new Resource (resource_uri, resource_options) }
                };

                upnp_photo = new UpnpPhoto ((id++).ToString (), parent.Id, photo_options);

                photos_cache.Add (photo.Id, upnp_photo);
            } else {
                upnp_photo = photos_cache [photo.Id];
            }

            return upnp_photo;
        }