/// <summary> /// Get URL of a JavaScript library. /// </summary> /// <param name="lib">Library to get URL of.</param> /// <param name="location">Location to obtain library.</param> /// <param name="version">Version string, ie "1.4.0"</param> /// <returns>URL of JavaScript library.</returns> public static string GetLibraryPath(JavaScriptLibrary lib, LibraryLocation location, string version) { // Setup version if (string.IsNullOrEmpty(version)) { version = _defaultVersions[lib]; } if (location == LibraryLocation.Custom) { // Get location from config string configKey = "Forms.Contrib:LocationUrl" + lib.ToString(); string url = ConfigurationManager.AppSettings.Get(configKey); if (string.IsNullOrEmpty(url)) { throw new ConfigurationErrorsException( string.Format(CultureInfo.CurrentUICulture, "Custom location url was not defined in AppSettings[\"{0}\"].", configKey)); } return(url); } else { return(string.Format(CultureInfo.InvariantCulture, _defaultLocations[location][lib], version)); } }
private static void readLibraryLocations() { string[] locations = File.ReadAllLines(@"C:\AppFiles\librarycoords.txt"); for (int i = 0; i < locations.Length; i++) { LibraryLocation loc = new LibraryLocation(); string[] temp = locations[i].Split(';'); loc.Name = temp[0]; loc.SubTitle = temp[1]; loc.Latitude = double.Parse(temp[2]); loc.Longitude = double.Parse(temp[3]); LocationAPI.AddLibraryLocation(loc); } }
/// <summary> /// Read the configuration file, establish what library locations need to be read /// </summary> private void InitialiseLibraryLocations() { // get a hook to the DB to use IDBClient db = Database.RetrieveClient(); IList <LibraryLocation> confirmedLocations = new List <LibraryLocation>(); // get the list from the config file first foreach (XmlNode locationNode in GetLibraryLocations()) { string name = locationNode.Attributes["Name"].Value; string path = locationNode.Attributes["Path"].Value; // either find the existing location or create a new one LibraryLocation location = Database.RetrieveLibraryLocation(db, name, path) ?? new AudioLibraryLocation(name, path); // add it to the ones that should be there confirmedLocations.Add(location); } // now we'll prune the ones which shouldn't be here IList <AudioLibraryLocation> locations = Database.RetrieveLibraryLocations(db); if (locations.Count != 0) { foreach (AudioLibraryLocation location in locations) { if (!confirmedLocations.Contains(location)) { Database.RemoveLibraryLocation(db, location); } } } // wasteful, but we'll just reconfirm them all foreach (AudioLibraryLocation location in confirmedLocations) { Database.UpdateAddLibraryLocation(db, location); } db.Close(); }
public static void UseManualLibraryLocation(string fileName) { LibraryLocation.SetManualLocation(fileName); }
/// <summary> /// Get URL of a JavaScript library. /// </summary> /// <param name="lib">Library to get URL of.</param> /// <param name="location">Location to obtain library.</param> /// <returns>URL of JavaScript library.</returns> public static string GetLibraryPath(JavaScriptLibrary lib, LibraryLocation location) { return(GetLibraryPath(lib, location, null)); }