public static ApiKeyManager LoadFromResource(string resourceName) { ApiKeyManager apiman; var assembly = Assembly.GetExecutingAssembly(); var assemblyName = assembly.GetName().Name; var stream = assembly.GetManifestResourceStream($"{assemblyName}.{resourceName}"); if (stream != null) { try { var serializer = new XmlSerializer(typeof(ApiKeyManager)); apiman = (ApiKeyManager)serializer.Deserialize(stream); } finally { stream.Close(); stream.Dispose(); } } else { // No resource found, create an empty manager Debug.WriteLine($"WARNING: {resourceName} not found"); apiman = new ApiKeyManager(); } apiman.filename = resourceName; return(apiman); }
public App() { this.DispatcherUnhandledException += App_DispatcherUnhandledException; db = new Database(); apiKeys = ApiKeyManager.LoadFromResource("ApiKeys.xml"); }
public static ApiKeyManager LoadFromFile(string filename) { //var serializer = XmlSerializer(); var apiman = new ApiKeyManager(); apiman.filename = filename; return(apiman); }