internal static string TranslateFilePath(string path, Configuration config) { string appdir = AppDomain.CurrentDomain.BaseDirectory; if (config != null) { appdir = config.AppBase; } return path.Replace("{APPPATH}", appdir); }
public static void Start(string[] args) { Configuration config = new Configuration(); // TODO: In the future change make this configurable config.AppBase = AppDomain.CurrentDomain.BaseDirectory; SetupBinaries( config.AppBase); Context context = new Context(); context.Config = config; // Load the configuration LoadConfiguration(config); IApplicationController controller = Activator.CreateInstance(config.AppControllerType) as IApplicationController; controller.Initialize(context); controller.Run(); }
private static void LoadConfiguration( Configuration config) { string configPath = Helper.TranslateFilePath( "{APPPATH}polaris.config", config); Helper.VerifyFileExists(configPath, "Polaris configuration file was not found. It was expected at {0} location"); XmlDocument doc = new XmlDocument(); doc.Load(configPath); config.AppControllerType = Helper.GetType( doc.SelectSingleNode(XPATH_APP_CONTROLLER).InnerText); config.ApiProviderType = Helper.GetType(doc.SelectSingleNode(XPATH_API_PROVIDER).InnerText); config.HostType = Helper.GetType(doc.SelectSingleNode(XPATH_APP_HOST).InnerText); config.StartPage = doc.SelectSingleNode(XPATH_START_PAGE).InnerText; XmlNodeList xnlModuleNames = doc.SelectNodes(XPATH_API_MODULES); List<Type> modules = new List<Type>(); foreach (XmlNode xndModule in xnlModuleNames) { string moduleTypename = xndModule.InnerText; Type typModule = Helper.GetType(moduleTypename); modules.Add(typModule); } config.ApiModules = modules.ToArray(); }