using System;
using System.Collections.Generic;
using Umbraco.Core.Services;
namespace Umbraco.Core.Sync
{
///
/// A registrar that stores registered server nodes in the database.
///
public sealed class DatabaseServerRegistrar : IServerRegistrar
{
private readonly Lazy _registrationService;
///
/// Gets or sets the registrar options.
///
public DatabaseServerRegistrarOptions Options { get; private set; }
///
/// Initializes a new instance of the class.
///
/// The registration service.
/// Some options.
public DatabaseServerRegistrar(Lazy registrationService, DatabaseServerRegistrarOptions options)
{
if (registrationService == null) throw new ArgumentNullException("registrationService");
if (options == null) throw new ArgumentNullException("options");
Options = options;
_registrationService = registrationService;
}
///
/// Gets the registered servers.
///
public IEnumerable Registrations
{
get { return _registrationService.Value.GetActiveServers(); }
}
///
/// Gets the role of the current server in the application environment.
///
public ServerRole GetCurrentServerRole()
{
var service = _registrationService.Value;
return service.GetCurrentServerRole();
}
///
/// Gets the current umbraco application url.
///
public string GetCurrentServerUmbracoApplicationUrl()
{
// this registrar does not provide the umbraco application url
return null;
}
}
}