/// <summary> /// Raises the ResourceRequested event. /// </summary> /// <param name="e">Event arguments</param> private void OnResourceRequested(ResourceRequestedEventArgs e) { try { _additionalResourceRequestedEvent(this, e); } catch {} }
/// <summary> /// Returns the request resource as a memory stream. /// </summary> /// <param name="absoluteUri"></param> /// <param name="role"></param> /// <param name="ofObjectToReturn"></param> /// <returns></returns> override public object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) { try { //raise the requested event ResourceRequestedEventArgs e = new ResourceRequestedEventArgs(StripInternalTags(absoluteUri.ToString()), Resources[absoluteUri.AbsoluteUri]); OnResourceRequested(e); //extract the resource content from the event args (which allow the consumer to override) into the returning stream MemoryStream ms = new MemoryStream(e.ResourceContent.Length); StreamWriter sw = new StreamWriter(ms); sw.Write(e.ResourceContent); sw.Flush(); ms.Position = 0; return(ms); } catch { return(null); } }
/// <summary> /// Returns the request resource as a memory stream. /// </summary> /// <param name="absoluteUri"></param> /// <param name="role"></param> /// <param name="ofObjectToReturn"></param> /// <returns></returns> override public object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) { try { //raise the requested event ResourceRequestedEventArgs e = new ResourceRequestedEventArgs(StripInternalTags(absoluteUri.ToString()), Resources[absoluteUri.AbsoluteUri]); OnResourceRequested(e); //extract the resource content from the event args (which allow the consumer to override) into the returning stream MemoryStream ms = new MemoryStream(e.ResourceContent.Length); StreamWriter sw = new StreamWriter(ms); sw.Write(e.ResourceContent); sw.Flush(); ms.Position = 0; return ms; } catch { return null; } }