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);
        }
Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 5
0
 public static PhysicalResource FromId(SonosIdentifier identifier)
 {
     return identifier.IsDirectory 
         ? (PhysicalResource) new Container(identifier) 
         : new MusicFile(identifier);
 }
Esempio n. 6
0
 protected PhysicalResource(SonosIdentifier identifier)
 {
     Identifier = identifier;
 }
Esempio n. 7
0
 public static PhysicalResource FromId(SonosIdentifier identifier)
 {
     return(identifier.IsDirectory
         ? (PhysicalResource) new Container(identifier)
         : new MusicFile(identifier));
 }
Esempio n. 8
0
 protected PhysicalResource(SonosIdentifier identifier)
 {
     Identifier = identifier;
 }
Esempio n. 9
0
        public void CreatedWithAPath_IsDirectoryIsAccurate(string path, bool isDirectory)
        {
            var si = new SonosIdentifier {Path = path};

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