#region Apache Notice /***************************************************************************** * $Header: $ * $Revision: 591621 $ * $Date$ * * iBATIS.NET Data Mapper * Copyright (C) 2008/2005 - The Apache Software Foundation * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ********************************************************************************/ #endregion using System; using System.IO; using System.Text; namespace Apache.Ibatis.Common.Resources { /// /// Adapts a static string content as an /// public class StaticContentResource : AbstractResource { private readonly string contents; /// /// Initializes a new instance of the class. /// /// The contents. public StaticContentResource(String contents) { this.contents = contents; stream = new MemoryStream(Encoding.Default.GetBytes(contents)); } /// /// Returns the handle for this resource. /// /// public override Uri Uri { get { throw new NotImplementedException("The method or operation is not implemented."); } } /// /// Returns a handle for this resource. /// /// The handle for this resource. /// ///

/// For safety, always check the value of the /// property prior to /// accessing this property; resources that cannot be exposed as /// a will typically return /// from a call to this property. ///

///
/// /// If the resource is not available on a filesystem, or cannot be /// exposed as a handle. /// public override FileInfo FileInfo { get { throw new NotImplementedException("The method or operation is not implemented."); } } /// /// Return an for this resource. /// /// An . /// /// /// Clients of this interface must be aware that every access of this /// property will create a fresh /// ; /// it is the responsibility of the calling code to close any such /// . /// /// /// /// If the stream could not be opened. /// public override Stream Stream { get { return stream; } } /// /// Returns a description for this resource. /// /// A description for this resource. /// ///

/// The description is typically used for diagnostics and other such /// logging when working with the resource. ///

///

/// Implementations are also encouraged to return this value from their /// method. ///

///
public override string Description { get { return contents; } } /// /// Creates a resource relative to this resource. /// /// The path (always resolved as relative to this resource). /// The relative resource. /// /// If the relative resource could not be created from the supplied /// path. /// /// /// If the resource does not support the notion of a relative path. /// public override IResource CreateRelative(string relativePath) { throw new NotImplementedException("The method or operation is not implemented."); } } }