public AppContentResponder(ContentResponder commonResponder, AppConf conf, DataSettings dataSettings = null, ILogger logger = null)
            : base(commonResponder.BamConf, logger)
        {
            if (conf.BamConf == null)
            {
                conf.BamConf = commonResponder.BamConf;
            }
            DataSettings       = dataSettings ?? DataSettings.Current;
            ContentResponder   = commonResponder;
            ServerRoot         = commonResponder.ServerRoot;
            AppConf            = conf;
            AppRoot            = AppConf.AppRoot;
            AppTemplateManager = new AppDustRenderer(this);
            AppContentLocator  = ContentLocator.Load(this);
            Fs commonRoot = new Fs(new DirectoryInfo(Path.Combine(ServerRoot.Root, CommonFolder)));

            ContentHandlers   = new Dictionary <string, ContentHandler>();
            AllRequestHandler = new ContentHandler($"{conf.Name}.AllRequestHandler", AppRoot)
            {
                CheckPaths = false
            };
            CustomHandlerMethods = new List <MethodInfo>();
            CommonContentLocator = ContentLocator.Load(commonRoot);
            SetUploadHandler();
            SetBaseIgnorePrefixes();
            ContentHandlerScanTask = ScanForContentHandlers();
            SetAllRequestHandler();
        }
Example #2
0
        public static ContentLocator Load(Fs rootToCheck)
        {
            ContentLocator locator = null;

            if (rootToCheck.FileExists(FileName))
            {
                FileInfo file = rootToCheck.GetFile(FileName);//new FileInfo(filePath);
                locator = file.FromJsonFile <ContentLocator>();
            }
            else
            {
                locator = new ContentLocator(rootToCheck);
                string[] imageDirs = new string[] { "~/img", "~/image" };
                locator.AddSearchRule(".png", imageDirs);
                locator.AddSearchRule(".gif", imageDirs);
                locator.AddSearchRule(".jpg", imageDirs);

                string[] pageDirs = new string[] { "~/pages" };
                locator.AddSearchRule(".htm", pageDirs);
                locator.AddSearchRule(".html", pageDirs);

                string[] cssDirs = new string[] { "~/css" };
                locator.AddSearchRule(".css", cssDirs);

                string[] jsDirs = new string[] { "~/js", "~/3rdParty", "~/common" };
                locator.AddSearchRule(".js", jsDirs);

                locator.Save();
            }

            locator.ContentRoot = rootToCheck;
            return(locator);
        }
Example #3
0
        public static ContentLocator Load(AppContentResponder appContent)
        {
            ContentLocator locator = Load(appContent.AppRoot);

            locator.AppName = appContent.AppConf.Name;
            return(locator);
        }
        public AppContentResponder(ContentResponder commonResponder, AppConf conf)
            : base(commonResponder.BamConf)
        {
            if (conf.BamConf == null)
            {
                conf.BamConf = commonResponder.BamConf;
            }

            ContentResponder    = commonResponder;
            ServerRoot          = commonResponder.ServerRoot;
            AppConf             = conf;
            AppRoot             = AppConf.AppRoot;
            AppTemplateRenderer = new AppDustRenderer(this);
            AppContentLocator   = ContentLocator.Load(this);
            Fs commonRoot = new Fs(new DirectoryInfo(Path.Combine(ServerRoot.Root, CommonFolder)));

            CommonContentLocator = ContentLocator.Load(commonRoot);

            SetBaseIgnorePrefixes();
        }