public void UnloadService(ServiceWrapper wrapper) => StopService(wrapper); // Unload the service using the wrapper public void Init() // Initializes the service manager { if (Initialized) // Don't bother initializing if it already is initialized { return; } if (!Directory.Exists(ConfigurationPath)) { Directory.CreateDirectory(ConfigurationPath); // Create the services configuration } UniServicesData = new UniversalData(PointBlankServer.ConfigurationsPath + "/Services"); // Open the file ServicesData = UniServicesData.GetData(EDataType.JSON) as JsonData; // Get the JSON foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies().Where(a => Attribute.GetCustomAttribute(a, typeof(PointBlankExtensionAttribute)) != null)) { foreach (Type class_type in asm.GetTypes()) { LoadService(class_type); } } foreach (PointBlankService ser in _tempServices.OrderBy(a => a.LaunchIndex)) { RunService(ser); } _tempServices.Clear(); // Setup the events PointBlankPluginEvents.OnPluginLoaded += new PointBlankPluginEvents.PluginEventHandler(OnPluginLoaded); // Set the variables Initialized = true; }
public override void Load() { // Setup universal configs UniSteamGoupConfig = new UniversalData(SteamGroupPath); UniPlayerConfig = new UniversalData(PlayerPath); // Setup configs SteamGroupConfig = UniSteamGoupConfig.GetData(EDataType.JSON) as JsonData; PlayerConfig = UniPlayerConfig.GetData(EDataType.JSON) as JsonData; // Setup events ServerEvents.OnPlayerConnected += new ServerEvents.PlayerConnectionHandler(OnPlayerJoin); ServerEvents.OnPlayerDisconnected += new ServerEvents.PlayerConnectionHandler(OnPlayerLeave); // Load the configs if (!UniSteamGoupConfig.CreatedNew) { LoadSteamGroups(); } else { FirstSteamGroups(); } if (UniPlayerConfig.CreatedNew) { FirstPlayers(); } }
private void LoadConfigurable(Type configurable) { string path = null; ConfigurationList configurations = null; Dictionary <Type, IConfigurable> dictionary = null; IConfigurable cfg = (IConfigurable)Activator.CreateInstance(configurable); path = cfg.ConfigurationDirectory; configurations = cfg.Configurations; dictionary = cfg.ConfigurationDictionary; if (dictionary != null) { dictionary.Add(configurable, cfg); } UniversalData UniData; if (_SavedConfigs.ContainsKey(cfg)) { UniData = _SavedConfigs[cfg]; } else { UniData = new UniversalData(PointBlankServer.ConfigurationsPath + "/" + (string.IsNullOrEmpty(path) ? "" : path + "/") + configurable.Name); } JsonData JSON = UniData.GetData(EDataType.JSON) as JsonData; if (!_SavedConfigs.ContainsKey(cfg)) { _SavedConfigs.Add(cfg, UniData); } if (UniData.CreatedNew) { foreach (KeyValuePair <string, object> kvp in configurations) { if (JSON.CheckKey(kvp.Key)) { JSON.Document[kvp.Key] = JToken.FromObject(kvp.Value); } else { JSON.Document.Add(kvp.Key, JToken.FromObject(kvp.Value)); } } } else { foreach (JProperty property in JSON.Document.Properties()) { if (configurations[property.Name] == null) { continue; } configurations[property.Name] = property.Value.ToObject(configurations[property.Name].GetType()); } } UniData.Save(); }
private void LoadTranslatable(Type translatable) { string path = null; TranslationList translations = null; Dictionary <Type, ITranslatable> dictionary = null; ITranslatable translater = (ITranslatable)Activator.CreateInstance(translatable); path = translater.TranslationDirectory; translations = translater.Translations; dictionary = translater.TranslationDictionary; if (dictionary != null) { dictionary.Add(translatable, translater); } UniversalData UniData; if (_SavedTranslations.ContainsKey(translater)) { UniData = _SavedTranslations[translater]; } else { UniData = new UniversalData(PointBlankServer.TranslationsPath + "/" + (string.IsNullOrEmpty(path) ? "" : path + "/") + translatable.Name); } JsonData JSON = UniData.GetData(EDataType.JSON) as JsonData; if (!_SavedTranslations.ContainsKey(translater)) { _SavedTranslations.Add(translater, UniData); } if (UniData.CreatedNew) { foreach (KeyValuePair <string, string> kvp in translations) { if (JSON.CheckKey(kvp.Key)) { JSON.Document[kvp.Key] = kvp.Value; } else { JSON.Document.Add(kvp.Key, kvp.Value); } } } else { foreach (JProperty property in JSON.Document.Properties()) { if (translations[property.Name] == null) { continue; } translations[property.Name] = (string)property.Value; } } UniData.Save(); }
public override void Load() { if (!Directory.Exists(PointBlankServer.LibrariesPath)) { Directory.CreateDirectory(PointBlankServer.LibrariesPath); // Create libraries directory } if (!Directory.Exists(PointBlankServer.PluginsPath)) { Directory.CreateDirectory(PointBlankServer.PluginsPath); // Create plugins directory } if (!Directory.Exists(ConfigurationPath)) { Directory.CreateDirectory(ConfigurationPath); // Create plugins directory } if (!Directory.Exists(TranslationPath)) { Directory.CreateDirectory(TranslationPath); // Create plugins directory } // Setup the config UniConfig = new UniversalData(SM.ConfigurationPath + "\\PluginManager"); JSONConfig = UniConfig.GetData(EDataType.JSON) as JsonData; LoadConfig(); foreach (string library in Directory.GetFiles(PointBlankServer.LibrariesPath, "*.dll")) // Get all the dll files in libraries directory { _libraries.Add(Assembly.Load(File.ReadAllBytes(library))); // Load and add the library } foreach (string plugin in Directory.GetFiles(PointBlankServer.PluginsPath, "*.dll")) // Get all the dll files in plugins directory { try { PluginWrapper wrapper = new PluginWrapper(plugin); // Create the plugin wrapper _plugins.Add(wrapper); // Add the wrapper if (!wrapper.Load() && !PluginConfiguration.ContinueOnError) { break; } } catch (Exception ex) { PointBlankLogging.LogError("Error initializing plugin!", ex); if (!PluginConfiguration.ContinueOnError) { break; } } } PointBlankPluginEvents.RunPluginsLoaded(); }
public override void Load() { // Setup config UniGroupConfig = new UniversalData(GroupPath); GroupConfig = UniGroupConfig.GetData(EDataType.JSON) as JsonData; if (!UniGroupConfig.CreatedNew) { LoadGroups(); } else { FirstGroups(); } }
void DeviceNetworkInformation_NetworkAvailabilityChanged(object sender, NetworkNotificationEventArgs e) { switch (e.NotificationType) { case NetworkNotificationType.InterfaceConnected: if (!UniversalData.loaded) { UniversalData.loadData(null, null); } break; case NetworkNotificationType.InterfaceDisconnected: break; case NetworkNotificationType.CharacteristicUpdate: break; default: break; } }
public PluginWrapper(string pluginPath) { Location = pluginPath; Name = Path.GetFileNameWithoutExtension(pluginPath); // Get the file name Enabled = false; // Set enabled to false PluginAssembly = Assembly.Load(File.ReadAllBytes(pluginPath)); // Load the assembly UniConfigurationData = new UniversalData(PluginManager.ConfigurationPath + "\\" + Name); // Load the configuration data ConfigurationData = UniConfigurationData.GetData(EDataType.JSON) as JsonData; // Get the JSON UniTranslationData = new UniversalData(PluginManager.TranslationPath + "\\" + Name); // Load the translation data TranslationData = UniTranslationData.GetData(EDataType.JSON) as JsonData; // Get the JSON // Setup the thread t = new Thread(new ThreadStart(delegate() { while (Enabled) { if (LastUpdateCheck != null && !((DateTime.Now - LastUpdateCheck).TotalSeconds >= PluginConfiguration.CheckUpdateTimeSeconds)) { continue; } if (CheckUpdates()) { if (PluginConfiguration.NotifyUpdates) { Notify(); } if (PluginConfiguration.AutoUpdate) { Update(); } } LastUpdateCheck = DateTime.Now; } })); }
public override void Load() { // Setup variables Commands = new List <CommandWrapper>(); UniConfig = new UniversalData(ConfigurationPath); JSONConfig = UniConfig.GetData(EDataType.JSON) as JsonData; // Setup events PointBlankPluginEvents.OnPluginLoaded += new PointBlankPluginEvents.PluginEventHandler(OnPluginLoaded); // Run code every time a plugin is loaded // Run the code LoadConfig(); foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies().Where(a => Attribute.GetCustomAttribute(a, typeof(PointBlankExtensionAttribute)) != null)) { foreach (Type tClass in asm.GetTypes()) { if (tClass.IsClass) { LoadCommand(tClass); } } } }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard XAML initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Language display initialization InitializeLanguage(); // Show graphics profiling information while debugging. if (Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Prevent the screen from turning off while under the debugger by disabling // the application's idle detection. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } ParseClient.Initialize("", ""); UniversalData.loadData(null, null); DeviceNetworkInformation.NetworkAvailabilityChanged += DeviceNetworkInformation_NetworkAvailabilityChanged; }