Пример #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);
 }