예제 #1
0
        public void FromId_IdIsForAPath_ReturnsAContainer()
        {
            var id = new SonosIdentifier {Path = "\\abc\\def"};

            var resource = PhysicalResource.FromId(id);

            Assert.That(resource, Is.TypeOf<Container>());
            Assert.That(resource.DisplayName, Is.EqualTo("def"));
        }
        public SonosIdentifier FromPath(string path)
        {
            if (_pathToGuid.ContainsKey(path))
            {
                return(_pathToGuid[path]);
            }

            var identifier = new SonosIdentifier
            {
                Id   = Guid.NewGuid().ToString(),
                Path = path
            };

            _pathToGuid.TryAdd(path, identifier);
            return(identifier);
        }
예제 #3
0
        public SonosIdentifier IdFor(string path)
        {
            if (_hashCache.ContainsKey(path))
            {
                return _hashCache[path];
            }

            var identifier = new SonosIdentifier
            {
                Id = _idGen.IdentifierFor(path),
                Path = path
            };

            _hashCache.TryAdd(path, identifier);
            return identifier;
        }
예제 #4
0
        public SonosIdentifier IdFor(string path)
        {
            if (_hashCache.ContainsKey(path))
            {
                return(_hashCache[path]);
            }

            var identifier = new SonosIdentifier
            {
                Id   = _idGen.IdentifierFor(path),
                Path = path
            };

            _hashCache.TryAdd(path, identifier);
            return(identifier);
        }
예제 #5
0
 public static PhysicalResource FromId(SonosIdentifier identifier)
 {
     return identifier.IsDirectory 
         ? (PhysicalResource) new Container(identifier) 
         : new MusicFile(identifier);
 }
예제 #6
0
 protected PhysicalResource(SonosIdentifier identifier)
 {
     Identifier = identifier;
 }
예제 #7
0
 public static PhysicalResource FromId(SonosIdentifier identifier)
 {
     return(identifier.IsDirectory
         ? (PhysicalResource) new Container(identifier)
         : new MusicFile(identifier));
 }
예제 #8
0
 protected PhysicalResource(SonosIdentifier identifier)
 {
     Identifier = identifier;
 }
예제 #9
0
        public void CreatedWithAPath_IsDirectoryIsAccurate(string path, bool isDirectory)
        {
            var si = new SonosIdentifier {Path = path};

            Assert.That(si.IsDirectory, Is.EqualTo(isDirectory));
        }
예제 #10
0
 public ResourceCollection(SonosIdentifier identifier)
 {
     Identifier = identifier;
 }
예제 #11
0
 public ResourceCollection(SonosIdentifier identifier, IEnumerable <IRepresentAResource> enumerable)
     : this(identifier)
 {
     AddRange(enumerable);
 }