Exemplo n.º 1
0
        /// <summary>
        /// Instantiates a new <see cref="IHastlayer"/> implementation.
        /// </summary>
        /// <remarks>
        /// Point of this factory is that it returns an interface type instead of the implementation and can throw
        /// exceptions.
        /// </remarks>
        /// <param name="configuration">Configuration for Hastlayer.</param>
        /// <returns>A newly created <see cref="IHastlayer"/> implementation.</returns>
        public static async Task <IHastlayer> Create(IHastlayerConfiguration configuration)
        {
            Argument.ThrowIfNull(configuration, nameof(configuration));
            Argument.ThrowIfNull(configuration.Extensions, nameof(configuration.Extensions));

            var hastlayer = new Hastlayer(configuration);
            // It's easier to eagerly load the host than to lazily create it, because the latter would also need
            // synchronization to allow concurrent access to this type's instance methods.
            await hastlayer.LoadHost();

            return(hastlayer);
        }
Exemplo n.º 2
0
 // Private so the static factory should be used.
 private Hastlayer(IHastlayerConfiguration configuration)
 {
     _configuration = configuration;
 }
 public HastlayerConfiguration(IHastlayerConfiguration previousConfiguration)
 {
     Extensions = previousConfiguration.Extensions;
     Flavor     = previousConfiguration.Flavor;
 }