Exemplo n.º 1
0
 private static void CreateNegotiationContext(INancyModule module, NancyContext context)
 {
     // TODO - not sure if this should be here or not, but it'll do for now :)
     context.NegotiationContext = new NegotiationContext
                                      {
                                          ModuleName = module.GetModuleName(),
                                          ModulePath = module.ModulePath,
                                      };
 }
Exemplo n.º 2
0
 private static void CreateNegotiationContext(INancyModule module, NancyContext context)
 {
     // TODO - not sure if this should be here or not, but it'll do for now :)
     context.NegotiationContext = new NegotiationContext
     {
         ModuleName = module.GetModuleName(),
         ModulePath = module.ModulePath,
     };
 }
Exemplo n.º 3
0
        internal void SetModule(INancyModule module)
        {
            if (module == null)
            {
                throw new ArgumentNullException("module");
            }

            this.ModuleName = module.GetModuleName();
            this.ModulePath = module.ModulePath;
        }
        public object GetMetadata(INancyModule module, RouteDescription routeDescription)
        {
            var entryAssembly = Assembly.GetEntryAssembly();

            if (module.GetType().Assembly != entryAssembly)
            {
                return(null);
            }

            DocumentationObject val = null;
            var    eps = BuildDocumentation(Types);
            string path;
            var    basePath = "/";

            if (module.ModulePath.Length > 1)
            {
                basePath = module.ModulePath;
                path     = routeDescription.Path.Replace(module.ModulePath, "");
                if (string.IsNullOrEmpty(path))
                {
                    path = "/";
                }
            }
            else
            {
                path = routeDescription.Path;
            }
            val = eps.FirstOrDefault(p => string.Equals(routeDescription.Method, p.HttpMethod.ToString(), StringComparison.CurrentCultureIgnoreCase) && p.BasePath == basePath && path == p.Path);
            if (val == null)
            {
                //TODO:(drose) throw exception to enfore usage?
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Out.WriteLine($"No Documentation Found For {module.GetModuleName()}Module : {routeDescription.Method} {path}");
                Console.ForegroundColor = ConsoleColor.White;
                return(null);
            }
            val.BasePath   = basePath;
            val.ModuleName = module.GetModuleName().ToLower();

            return(val);
        }
Exemplo n.º 5
0
        public void SetModule(INancyModule module)
        {
            if (module == null)
            {
                throw new ArgumentNullException("module");
            }

            this.ModuleName = module.GetModuleName();
            this.ModulePath = module.ModulePath;
        }