/// <summary> /// Checks whether the given ExternalResourceReference is formatted correctly for this server. /// The format should match one of the formats created in the SetupBrowserData method. /// </summary> public bool IsResourceWellFormed(ExternalResourceReference extRef) { if (extRef.ServerId != GetServerId()) { return(false); } if (!extRef.HasValidDisplayPath()) { return(false); } // Either the ExternalResourceReference has a valid database key (German/French keynote case) ... IDictionary <string, string> refMap = extRef.GetReferenceInformation(); if (refMap.ContainsKey(RefMapDBKeyEntry)) { return(KeynotesDatabase.IsValidDBKey(refMap[RefMapDBKeyEntry])); } else if (refMap.ContainsKey(RefMapLinkPathEntry)) // ... OR it is a Revit link file { return(File.Exists(GetFullServerLinkFilePath(extRef))); } // ... OR it is a keynote file (non- French/German cases). return(File.Exists(GetFullServerKeynoteFilePath(extRef))); }
/// <summary> /// Loads the keynote data resources, either from the fictitious French/German database, or from a file. /// </summary> /// <param name="resourceReference">An ExternalResourceReference identifying which particular resource to load.</param> /// <param name="loadContent">An ExternalResourceLoadContent object that will be populated with load data by the /// server. There are different subclasses of ExternalResourceLoadContent for different ExternalResourceTypes.</param> private void LoadKeynoteDataResource(ExternalResourceReference resourceReference, ExternalResourceLoadContent loadContent) { KeyBasedTreeEntriesLoadContent kdrlc = (KeyBasedTreeEntriesLoadContent)loadContent; if (kdrlc == null) { throw new ArgumentException("Wrong type of ExternalResourceLoadContent (expecting a KeyBasedTreeEntriesLoadContent) for keynote data.", "loadContent"); } kdrlc.Reset(); // Either the ExternalResourceReference has a valid database key (German/French case) ... IDictionary <string, string> refMap = resourceReference.GetReferenceInformation(); if (refMap.ContainsKey(RefMapDBKeyEntry)) { try { KeynotesDatabase.LoadKeynoteEntries(refMap[RefMapDBKeyEntry], ref kdrlc); kdrlc.BuildEntries(); loadContent.LoadStatus = ExternalResourceLoadStatus.Success; } catch (ArgumentOutOfRangeException) { } catch (ArgumentNullException) { } } else { // ... OR it is a real file (all other cases). String serverKeynoteFilePath = GetFullServerKeynoteFilePath(resourceReference); bool doesReadingSucceed = KeynoteEntries.LoadKeynoteEntriesFromFile(serverKeynoteFilePath, kdrlc); if (doesReadingSucceed) { kdrlc.BuildEntries(); loadContent.LoadStatus = ExternalResourceLoadStatus.Success; } } }