예제 #1
0
        public ContainerInfo (Container container, IList<UpnpObject> children)
        {
            if (container == null) {
                throw new ArgumentNullException ("container");
            } else if (children == null) {
                throw new ArgumentNullException ("children");
            }

            Container = container;
            Children = children;
        }
예제 #2
0
        public Container Build (Action<ContainerInfo> consumer,
                                string title,
                                string id,
                                string parentId,
                                IList<Object> children)
        {
            if (consumer == null) {
                throw new ArgumentNullException ("consumer");
            } else if (children == null) {
                throw new ArgumentNullException ("children");
            }

            var container = new Container (id, parentId, new ContainerOptions {
                Title = title,
                ChildCount = children.Count
            });

            consumer (new ContainerInfo (container, children));

            return container;
        }
예제 #3
0
 static void AssertContainer (Container container, ContainerOptions options)
 {
     AssertObject (container, options);
     Assert.AreEqual (container.ChildCount, options.ChildCount);
     Assert.AreEqual (container.IsSearchable, options.IsSearchable);
     Assert.IsTrue (container.SearchClasses.IsReadOnly);
     Assert.IsTrue (container.CreateClasses.IsReadOnly);
     CollectionAssert.AreEqual (container.SearchClasses, options.SearchClasses);
     CollectionAssert.AreEqual (container.CreateClasses, options.CreateClasses);
 }
예제 #4
0
 public void ContainerInstantiation ()
 {
     var options = new ContainerOptions ();
     SetContainerOptions (options);
     var container = new Container ("-1", "-1", options);
     AssertContainer (container, options);
     AssertContainer (container, container.GetOptions ());
 }
예제 #5
0
        Container GetContainer (Tag tag, Container parent)
        {
            Container container = null;
            if (!tags_cache.ContainsKey (tag.Id)) {
                var album_options = new AlbumOptions { Title = tag.Name, Description = "Tag" };
                var photo_album = new PhotoAlbum ((id++).ToString (), parent.Id, album_options);
                tags_cache.Add (tag.Id, photo_album);
                container = photo_album;
            } else
            {
                container = tags_cache [tag.Id];
            }

            return container;
        }
예제 #6
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;
        }