Exemple #1
0
 /// <summary>
 /// Create a new instance of the shared context.
 /// </summary>
 /// <param name="configuration">A configuration that may be overridden by the individual interactions. This may be null.</param>
 public Context(IConsumerConfiguration configuration)
 {
     if (_instance != null)
     {
         throw new InvalidOperationException("Dispose the old context before creating a new.");
     }
     _instance      = this;
     _configuration = configuration;
     lock (_lockToken)
     {
         if (_servers == null)
         {
             _servers = new WebServerContainer(configuration, false);
         }
     }
 }
Exemple #2
0
        internal static async Task <IVerifyAndClosable> RegisterListener(IPactInteractionDefinition pact, IConsumerConfiguration config)
        {
            var servers = _servers;

            if (servers == null)
            {
                lock (_lockToken)
                {
                    if (_servers == null)
                    {
                        _servers = new WebServerContainer(config, true);
                    }
                    servers = _servers;
                }
            }
            return(new HandlerWrapper(await servers.RegisterListener(pact, config), success => _instance?.ClosePact(pact, success)));
        }