Ejemplo n.º 1
0
        public IHosting FromCredentials(Node <OAuthCredentials> root)
        {
            var serviceName = root.Value.Service;

            if (root.Value?.Service == null)
            {
                throw new NullReferenceException("Unexpected service name");
            }
            if (root.IsLeaf)
            {
                if (!collection.IsContainsManager(serviceName))
                {
                    throw new InvalidOperationException($"Unexpected service '{serviceName}'");
                }
                var service = collection.GetManager(serviceName);
                return(service.GetFileHostingFor(root.Value));
            }
            else
            {
                if (!collection.IsContainsMultiHostingManager(serviceName))
                {
                    throw new InvalidOperationException($"Unexpected multihosting manager '{serviceName}'");
                }
                var service = collection.GetMultiHostingManager(serviceName);
                return(service.GetFileHostingFor(root.Nested.Select(FromCredentials).ToArray()));
            }
        }