public CompositeRootControllerBase()
        {
            RootConfiguration = GetConfiguration();
            var config = CompositeRootHttpServerConfiguration.Create(RootConfiguration);

            CompositeRootConfiguration = config.ServerRootConfigurations.RootConfigurations.Values.First();
        }
 protected CompositeRoot(CompositeRootConfiguration configuration, params IService[] services)
 {
     Id            = Guid.NewGuid().ToString();
     Configuration = configuration;
     _services     = new Collection <IService>(services.ToList());
     SetCompositeRoots();
 }
        public static IEnumerable <CompositeRootCommandResponse> SendRequest(CompositeRootConfiguration configuration, string command, IEnumerable <FileInfo> files, string sessionToken)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var commandPath = new Uri("file:///" + command);
            var formFields  = GetFormFields(commandPath);

            var returnedBytes = CompositeRootHttpServerTesterConnection.SendMultipartFormDataRequest(
                configuration.Endpoint + sessionToken + commandPath.AbsolutePath,
                files.Select(f => f.FullName).ToArray(),
                formFields, out string responseContentType, out string responseContentEncoding);

            try
            {
                return(JsonConvert.DeserializeObject <CompositeRootCommandResponse[]>(Encoding.UTF8.GetString(returnedBytes)) as IEnumerable <CompositeRootCommandResponse>);
            }
            catch
            {
                return(new CompositeRootCommandResponse[]
                {
                    new CompositeRootCommandResponse
                    {
                        Success = true,
                        ReturnValue = returnedBytes,
                        ReturnValueContentType = responseContentType,
                        ReturnValueContentEncoding = responseContentEncoding
                    }
                });
            }
        }
        protected CompositeRoot(CompositeRootConfiguration configuration)
        {
            Id            = Guid.NewGuid().ToString();
            Configuration = configuration;
            var assemblies = GetServiceAssemblyNames().Select(ca => Assembly.Load(ca.FullName));

            InitializeServices(assemblies);
        }
Example #5
0
        internal CompositeRoot CreateCompositeRoot(CompositeRootConfiguration configuration, EventHandler eventHandler, IEnumerable <Assembly> serviceAssemblies)
        {
            var compositeRoot = CompositeRoot.Create(configuration, eventHandler, serviceAssemblies);

            compositeRoot.ActiveCompositeRoots = this;
            compositeRoots.Add(configuration.Id.ToString(), compositeRoot);
            return(compositeRoot);
        }
        public CompositeRootHttpServerTesterConnection LogOnUser(CompositeRootConfiguration configuration, string parameters)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return(CreateCompositeRootHttpServerTesterConnection(configuration, CreateLogOnWebRequest(configuration, parameters)));
        }
        public static IEnumerable <CompositeRootCommandResponse> SendRequest(CompositeRootConfiguration configuration, IEnumerable <CompositeRootCommandRequest> commands, string sessionToken)
        {
            if (commands == null)
            {
                throw new ArgumentNullException(nameof(commands));
            }

            return(GetCommandResponses(CreateRequest(configuration, sessionToken), commands));
        }
        public static HttpWebRequest CreateLogOnWebRequest(CompositeRootConfiguration configuration, string parameters)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return((HttpWebRequest)WebRequest.Create((new Uri(configuration.Endpoint + nameof(CompositeRootAuthenticator.LogOn) + "?" + parameters))));
        }
        public static HttpWebRequest CreateRequest(CompositeRootConfiguration configuration, string sessionToken)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return((HttpWebRequest)WebRequest.Create(new Uri(configuration.Endpoint + sessionToken)));
        }
Example #10
0
        public static void Setup(TestContext testContext)
        {
            _tester = new CompositeRootHttpServerTester(JsonConvert.DeserializeObject <RootHttpServerConfiguration>(File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "BlogServerMonitorConfig.json"))));
            _tester.Initialize();

            _blogServerMonitorConfiguration = _tester.Configuration.ServerRootConfigurations.RootConfigurations.Values.First();
            _blogServerHttpServerConfig     = CompositeRootHttpServerConfiguration.Create(JsonConvert.DeserializeObject <RootHttpServerConfiguration>(File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "BlogServerConfig.json"))));
            _blogServerConfig = _blogServerHttpServerConfig.ServerRootConfigurations.RootConfigurations.Values.First();
        }
        public static CompositeRoot Create(CompositeRootConfiguration configuration, EventHandler eventHandler, IEnumerable <IService> services)
        {
            var compositeRoot = services == null ? (CompositeRoot)Activator.CreateInstance(configuration.CompositeRootType, _constructorBindingFlags, null, new object[] { configuration }, CultureInfo.InvariantCulture) :
                                (CompositeRoot)Activator.CreateInstance(configuration.CompositeRootType, _constructorBindingFlags, null, new object[] { configuration, services }, CultureInfo.InvariantCulture);

            compositeRoot.Authenticator = Activator.CreateInstance(configuration.CompositeRootAuthenticatorType) as CompositeRootAuthenticator;
            compositeRoot.Configuration = configuration;
            compositeRoot.EventAdded   += eventHandler;

            return(compositeRoot);
        }
 protected override void OnAfterExecuteCommandRequests(HttpListenerContext httpListenerContext, CompositeRootConfiguration compositeRootConfiguration, object returnValue, IEnumerable <CompositeRootCommandResponse> commandResponses, string sessionToken)
 {
     base.OnAfterExecuteCommandRequests(httpListenerContext, compositeRootConfiguration, returnValue, commandResponses, sessionToken);
 }
Example #13
0
 protected override void OnAfterConfiguration(CompositeRootConfiguration configuration)
 {
     Console.WriteLine(configuration.Endpoint + " - " + configuration.EndpointPublicDirectory);
     base.OnAfterConfiguration(configuration);
 }
 protected override void OnAfterLogOn(HttpListenerContext httpListenerContext, CompositeRootConfiguration compositeRootConfiguration, string requestParameters, IEnumerable <CompositeUploadedFile> uploadedFiles, CompositeRootAuthenticatorResponse authenticatorResponse)
 {
     base.OnAfterLogOn(httpListenerContext, compositeRootConfiguration, requestParameters, uploadedFiles, authenticatorResponse);
 }
Example #15
0
 public ChatRoot(CompositeRootConfiguration configuration) : base(configuration)
 {
 }
 protected override RequestProcessingAction OnBeforeWriteResponse(HttpListenerContext httpListenerContext, CompositeRootConfiguration compositeRootConfiguration, object value, string sessionToken)
 {
     return(base.OnBeforeWriteResponse(httpListenerContext, compositeRootConfiguration, value, sessionToken));
 }
 public static CompositeRoot Create(CompositeRootConfiguration configuration)
 {
     return(Create(configuration, null, (IEnumerable <Assembly>)null));
 }
 public BlogServerMonitorCompositeRoot(CompositeRootConfiguration configuration, params IService[] services) : base(configuration, services)
 {
     Initialize();
 }
 public BlogApplicationCompositeRoot(CompositeRootConfiguration configuration) : base(configuration)
 {
     Initialize();
 }
 protected override void OnAfterWriteResponse(HttpListenerContext httpListenerContext, CompositeRootConfiguration compositeRootConfiguration, object value, string sessionToken)
 {
     base.OnAfterWriteResponse(httpListenerContext, compositeRootConfiguration, value, sessionToken);
 }
 protected override void OnConfigurationError(CompositeRootConfiguration configuration, string errorMessage)
 {
     base.OnConfigurationError(configuration, errorMessage);
 }
 protected CompositeRoot(CompositeRootConfiguration configuration, IEnumerable <Assembly> serviceAssemblies)
 {
     Id            = Guid.NewGuid().ToString();
     Configuration = configuration;
     InitializeServices(serviceAssemblies);
 }
 protected override void OnWriteResponse(HttpListenerContext httpListenerContext, CompositeRootConfiguration compositeRootConfiguration, object value, BinaryWriter writer, byte[] content, string sessionToken)
 {
     base.OnWriteResponse(httpListenerContext, compositeRootConfiguration, value, writer, content, sessionToken);
 }
 protected override void OnWriteHomeFile(HttpListenerContext httpListenerContext, CompositeRootConfiguration compositeRootConfiguration, Stream responseStream, byte[] content)
 {
     base.OnWriteHomeFile(httpListenerContext, compositeRootConfiguration, responseStream, content);
 }
 public static IEnumerable <CompositeRootCommandResponse> SendRequest(CompositeRootConfiguration configuration, string command, string sessionToken)
 {
     return(SendRequest(configuration, new CompositeRootCommandRequest[] { CompositeRootCommandRequest.Create(1, command) }, sessionToken));
 }
 protected override RequestProcessingAction OnBeforeLogOn(HttpListenerContext httpListenerContext, CompositeRootConfiguration compositeRootConfiguration, string requestParameters, IEnumerable <CompositeUploadedFile> uploadedFiles)
 {
     return(base.OnBeforeLogOn(httpListenerContext, compositeRootConfiguration, requestParameters, uploadedFiles));
 }
 public BlogServerMonitorCompositeRoot(CompositeRootConfiguration configuration) : base(configuration)
 {
     Initialize();
 }
        private CompositeRootHttpServerTesterConnection CreateCompositeRootHttpServerTesterConnection(CompositeRootConfiguration configuration, WebRequest request)
        {
            var response = JsonConvert.DeserializeObject <CompositeRootAuthenticatorResponse>(Encoding.UTF8.GetString(CompositeRootHttpServerTesterConnection.SendRequest(request, out _, out _)));

            var sessionToken = response.SessionToken;
            CompositeRootHttpServerTesterConnection compositeRootHttpServerTesterConnection = null;

            try
            {
                compositeRootHttpServerTesterConnection = new CompositeRootHttpServerTesterConnection(configuration.Endpoint, sessionToken);
                if (!_connections.TryAdd(sessionToken, compositeRootHttpServerTesterConnection))
                {
                    return(null);
                }
            }
            catch
            {
                compositeRootHttpServerTesterConnection?.Dispose();
                throw;
            }

            return(compositeRootHttpServerTesterConnection);
        }
 public BlogServerMonitorCompositeRoot(CompositeRootConfiguration configuration, IEnumerable <Assembly> serviceAssemblies) : base(configuration, serviceAssemblies)
 {
     Initialize();
 }
 protected override string OnGetSessionTokenFromRequest(HttpListenerContext httpListenerContext, CompositeRootConfiguration compositeRootConfiguration)
 {
     return(base.OnGetSessionTokenFromRequest(httpListenerContext, compositeRootConfiguration));
 }