/// <summary> /// Initializes the DirectOutput framework.<br/> /// The method has to be called before any data is sent to DOF.<br/> /// It loads all necessary configuration data and starts all internal processes. /// </summary> /// <param name="HostingApplicationName">Name of the hosting application.</param> /// <param name="TableFilename">The table filename (specify a dummy filename of no table file is available).</param> /// <param name="RomName">Name of the rom (If thhere is no rom name of a table, specify your own unique name for the game).</param> /// <exception cref="System.Exception">Object has already been initialized. You must call Finish() before initializing again.</exception> public static void Init(string HostingApplicationName, string TableFilename, string RomName) { if (Pinball == null) { //Check config dir for global config file string HostAppFilename = HostingApplicationName.Replace(".", ""); foreach (char C in Path.GetInvalidFileNameChars()) { HostAppFilename = HostAppFilename.Replace(C.ToString(), ""); } foreach (char C in Path.GetInvalidPathChars()) { HostAppFilename = HostAppFilename.Replace(C.ToString(), ""); } HostAppFilename = "GlobalConfig_{0}".Build(HostAppFilename); //Check config dir for global config file FileInfo F = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "config", "GlobalConfig_{0}.xml".Build(HostAppFilename))); if (!F.Exists) { //Check if a shortcut to the config dir exists FileInfo LnkFile = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "config", "GlobalConfig_{0}.lnk".Build(HostAppFilename))); if (LnkFile.Exists) { string ConfigDirPath = ResolveShortcut(LnkFile); if (Directory.Exists(ConfigDirPath)) { F = new FileInfo(Path.Combine(ConfigDirPath, "GlobalConfig_{0}.xml".Build(HostAppFilename))); } } if (!F.Exists) { //Check default dir for global config file F = new FileInfo("GlobalConfig_{0}.xml".Build(HostAppFilename)); if (!F.Exists) { //Check dll dir for global config file F = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "GlobalConfig_{0}.xml".Build(HostAppFilename))); if (!F.Exists) { //if global config file does not exist, set filename to config directory. F = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "config", "GlobalConfig_{0}.xml".Build(HostAppFilename))); if (!F.Directory.Exists) { //If the config dir does not exist set the dll dir for the config F = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "GlobalConfig_{0}.xml".Build(HostAppFilename))); } } } } } Pinball = new DirectOutput.Pinball(); Pinball.Setup((F.Exists ? F.FullName : ""), TableFilename, RomName); Pinball.Init(); } else { throw new Exception("Object has already been initialized. You must call Finish() before initializing again."); } }
/// <summary> /// Initializes the DirectOutput framework.<br/> /// The method has to be called before any data is sent to DOF.<br/> /// It loads all necessary configuration data and starts all internal processes. /// </summary> /// <param name="HostingApplicationName">Name of the hosting application.</param> /// <param name="TableFilename">The table filename (specify a dummy filename of no table file is available).</param> /// <param name="RomName">Name of the rom (If thhere is no rom name of a table, specify your own unique name for the game).</param> /// <exception cref="System.Exception">Object has already been initialized. You must call Finish() before initializing again.</exception> public static void Init(string HostingApplicationName, string TableFilename, string RomName) { if (Pinball == null) { //Check config dir for global config file string HostAppFilename = HostingApplicationName.Replace(".", ""); foreach (char C in Path.GetInvalidFileNameChars()) { HostAppFilename = HostAppFilename.Replace(C.ToString(), ""); } foreach (char C in Path.GetInvalidPathChars()) { HostAppFilename = HostAppFilename.Replace(C.ToString(), ""); } HostAppFilename = "GlobalConfig_{0}".Build(HostAppFilename); //Check config dir for global config file FileInfo F = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "config", "GlobalConfig_{0}.xml".Build(HostAppFilename))); if (!F.Exists) { //Check if a shortcut to the config dir exists FileInfo LnkFile = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "config", "GlobalConfig_{0}.lnk".Build(HostAppFilename))); if (LnkFile.Exists) { string ConfigDirPath = ResolveShortcut(LnkFile); if (Directory.Exists(ConfigDirPath)) { F = new FileInfo(Path.Combine(ConfigDirPath, "GlobalConfig_{0}.xml".Build(HostAppFilename))); } } if (!F.Exists) { //Check default dir for global config file F = new FileInfo("GlobalConfig_{0}.xml".Build(HostAppFilename)); if (!F.Exists) { //Check dll dir for global config file F = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "GlobalConfig_{0}.xml".Build(HostAppFilename))); if (!F.Exists) { //if global config file does not exist, set filename to config directory. F = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "config", "GlobalConfig_{0}.xml".Build(HostAppFilename))); if (!F.Directory.Exists) { //If the config dir does not exist set the dll dir for the config F = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "GlobalConfig_{0}.xml".Build(HostAppFilename))); } } } } } Pinball = new DirectOutput.Pinball(); Pinball.Init((F.Exists ? F.FullName : ""), TableFilename, RomName); } else { throw new Exception("Object has already been initialized. You must call Finish() before initializing again."); } }