Exemplo n.º 1
0
        protected override Task <PersistedConfiguration> RemoteCollectAsync(IRemoteOperationCollectionContext context)
        {
            this.LogDebug($"Collecting status of {this.Template.GetDisplayPath()}...");

            var config = new RegistryKeyConfiguration
            {
                Hive = this.Template.Hive,
                Key  = this.Template.Key
            };

            using (var baseKey = RegistryKey.OpenBaseKey(this.Template.Hive, RegistryView.Default))
                using (var key = baseKey.OpenSubKey(this.Template.Key))
                {
                    if (key == null)
                    {
                        config.Exists = false;
                    }
                    else
                    {
                        config.Exists       = true;
                        config.DefaultValue = key.GetValue(null)?.ToString();
                    }
                }

            return(Task.FromResult <PersistedConfiguration>(config));
        }
Exemplo n.º 2
0
        protected override Task <PersistedConfiguration> RemoteCollectAsync(IRemoteOperationCollectionContext context)
        {
            var config = new RegistryValueConfiguration
            {
                Hive      = this.Template.Hive,
                Key       = this.Template.Key,
                ValueName = this.Template.ValueName
            };

            using (var baseKey = RegistryKey.OpenBaseKey(this.Template.Hive, RegistryView.Default))
                using (var key = baseKey.OpenSubKey(this.Template.Key))
                {
                    if (key == null)
                    {
                        config.Exists = false;
                    }
                    else
                    {
                        var value = key.GetValue(this.Template.ValueName, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                        if (value == null)
                        {
                            config.Exists = false;
                        }
                        else
                        {
                            config.Exists    = true;
                            config.ValueKind = key.GetValueKind(this.Template.ValueName);
                            config.Value     = ReadRegistyValue(value, config.ValueKind);
                        }
                    }
                }

            return(Task.FromResult <PersistedConfiguration>(config));
        }
        protected override Task <PersistedConfiguration> RemoteCollectAsync(IRemoteOperationCollectionContext context)
        {
            this.LogDebug($"Looking for Site \"{this.Template.Name}\"...");
            using (var manager = new ServerManager())
            {
                var site = manager.Sites[this.Template.Name];
                if (site == null)
                {
                    this.LogInformation($"Site \"{this.Template.Name}\" does not exist.");
                    return(Task.FromResult <PersistedConfiguration>(new IisSiteConfiguration {
                        Name = this.Template.Name, Exists = false
                    }));
                }

                return(Task.FromResult <PersistedConfiguration>(IisSiteConfiguration.FromMwaSite(this, site, this.Template)));
            }
        }
        protected override Task <PersistedConfiguration> RemoteCollectAsync(IRemoteOperationCollectionContext context)
        {
            if (this.Template == null)
            {
                throw new InvalidOperationException("Template is not set.");
            }

            this.LogDebug($"Looking for Virtual Directory \"{this.Template.FullPath}\"...");

            lock (lockbox)
                using (var manager = new ServerManager())
                {
                    var uninclused = new IisVirtualDirectoryConfiguration
                    {
                        Exists          = false,
                        Path            = this.Template.Path,
                        SiteName        = this.Template.SiteName,
                        ApplicationPath = this.Template.ApplicationPath
                    };

                    var site = manager.Sites[this.Template.SiteName];
                    if (site == null)
                    {
                        this.LogInformation($"Site \"{this.Template.SiteName}\" does not exist.");
                        return(Complete(uninclused));
                    }
                    var app = site.Applications[this.Template.ApplicationPath];
                    if (app == null)
                    {
                        this.LogInformation($"Application \"{this.Template.ApplicationPath}\" does not exist.");
                        return(Complete(uninclused));
                    }
                    var vdir = app.VirtualDirectories[this.Template.Path];
                    if (vdir == null)
                    {
                        this.LogInformation($"Virtual Directory \"{this.Template.Path}\" does not exist.");
                        return(Complete(uninclused));
                    }

                    return(Complete(IisVirtualDirectoryConfiguration.FromMwaVirtualDirectory(this, this.Template.SiteName, vdir, this.Template)));
                }
        }
Exemplo n.º 5
0
        protected override Task <PersistedConfiguration> RemoteCollectAsync(IRemoteOperationCollectionContext context)
        {
            this.LogDebug($"Looking for Application Pool \"{this.Template.Name}\"...");

            lock (syncLock)
            {
                using (var manager = new ServerManager())
                {
                    var pool = manager.ApplicationPools[this.Template.Name];
                    if (pool == null)
                    {
                        this.LogInformation($"Application Pool \"{this.Template.Name}\" does not exist.");
                        return(Task.FromResult <PersistedConfiguration>(new IisAppPoolConfiguration {
                            Exists = false, Name = this.Template.Name
                        }));
                    }

                    return(Task.FromResult <PersistedConfiguration>(IisAppPoolConfiguration.FromMwaApplicationPool(this, pool, this.Template)));
                }
            }
        }
Exemplo n.º 6
0
 protected override Task <PersistedConfiguration> RemoteCollectAsync(IRemoteOperationCollectionContext context)
 {
     this.LogDebug($"Looking for service \"{this.Template.Name}\"...");
     return(Complete(WindowsServiceConfiguration.FromService(this.Template.Name)));
 }