public Sentinel ( string sentinelLabel ) : |
||
sentinelLabel | string | An arbitrary string. |
Résultat |
/// <summary> /// Opens a stream from a store by its key string. /// </summary> /// <param name="key">The key, including store prefix</param> /// <returns>A stream, or null if not found.</returns> public Stream Open(SwiffotronContext ctx, string key) { Uri storeURI = new Uri(key); if (storeURI.Scheme != "store") /* ISSUE 67: Constants, please. */ { throw new SwiffotronException( SwiffotronError.BadInputXML, ctx, @"Store paths should begin with store://"); } string storeId = storeURI.Host; if (!stores.ContainsKey(storeId)) { throw new SwiffotronException( SwiffotronError.BadInputXML, ctx, @"Store '" + storeId + @"' not registered."); } try { return(stores[storeId].OpenInput(storeURI.LocalPath.Substring(1))); } catch (FileNotFoundException fnfe) { throw new SwiffotronException( SwiffotronError.BadPathOrID, ctx.Sentinel("FileNotFoundInStore"), "File not found: " + key, fnfe); } }
/// <summary> /// Opens a stream from a store by its key string. /// </summary> /// <param name="key">The key, including store prefix</param> /// <returns>A stream, or null if not found.</returns> public Stream Open(SwiffotronContext ctx, string key) { Uri storeURI = new Uri(key); if (storeURI.Scheme != "store") /* ISSUE 67: Constants, please. */ { throw new SwiffotronException( SwiffotronError.BadInputXML, ctx, @"Store paths should begin with store://"); } string storeId = storeURI.Host; if (!stores.ContainsKey(storeId)) { throw new SwiffotronException( SwiffotronError.BadInputXML, ctx, @"Store '" + storeId + @"' not registered."); } try { return stores[storeId].OpenInput(storeURI.LocalPath.Substring(1)); } catch (FileNotFoundException fnfe) { throw new SwiffotronException( SwiffotronError.BadPathOrID, ctx.Sentinel("FileNotFoundInStore"), "File not found: " + key, fnfe); } }