Пример #1
0
        public override void Configure(Container container)
        {
            _configured = true;
             // Feature disableFeatures = Feature.Jsv | Feature.Soap;
            SetConfig(new EndpointHostConfig {
                // EnableFeatures = Feature.All.Remove(disableFeatures), //all formats except of JSV and SOAP
                DebugMode = true, //Show StackTraces in service responses during development
                WriteErrorsToResponse = false, //Disable exception handling
                DefaultContentType = ContentType.Json, //Change default content type
                AllowJsonpRequests = true, //Enable JSONP requests
                ServiceName = "RestService",
            });
            LogManager.LogFactory = new DebugLogFactory();

            using (dynamic ps = new DynamicPowershell(SharedRunspacePool)) {
                foreach (var commandName in _commands) {
                    PSObject command = ps.ResolveCommand(commandName);

                    if (command != null) {
                        var cmdletInfo = (command.ImmediateBaseObject as CmdletInfo);
                        if (cmdletInfo != null) {
                            Routes.Add(cmdletInfo.ImplementingType, "/"+commandName+"/", "GET");
                        }
                    }
                }
            }
        }