You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2008/06/01 20:50:35 UTC
svn commit: r662264 - in /ibatis/trunk/cs/V3/src/Apache.Ibatis.Common:
Apache.Ibatis.Common.2005.csproj Resources/StaticContentResource.cs
Author: gbayon
Date: Sun Jun 1 11:50:35 2008
New Revision: 662264
URL: http://svn.apache.org/viewvc?rev=662264&view=rev
Log:
Add StaticContentResource which adapts a static string content as an IResource
Added:
ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/StaticContentResource.cs (with props)
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Apache.Ibatis.Common.2005.csproj
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Apache.Ibatis.Common.2005.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Apache.Ibatis.Common.2005.csproj?rev=662264&r1=662263&r2=662264&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Apache.Ibatis.Common.2005.csproj (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Apache.Ibatis.Common.2005.csproj Sun Jun 1 11:50:35 2008
@@ -206,6 +206,7 @@
<Compile Include="Logging\LogSetting.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Resources\StaticContentResource.cs" />
<Compile Include="Transaction\IsolationLevel.cs">
<SubType>Code</SubType>
</Compile>
Added: ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/StaticContentResource.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/StaticContentResource.cs?rev=662264&view=auto
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/StaticContentResource.cs (added)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/StaticContentResource.cs Sun Jun 1 11:50:35 2008
@@ -0,0 +1,139 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 591621 $
+ * $Date$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *
+ *
+ * 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
+{
+ /// <summary>
+ /// Adapts a static string content as an <see cref="IResource"/>
+ /// </summary>
+ public class StaticContentResource : AbstractResource
+ {
+ private readonly string contents;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="StaticContentResource"/> class.
+ /// </summary>
+ /// <param name="contents">The contents.</param>
+ public StaticContentResource(String contents)
+ {
+ this.contents = contents;
+ stream = new MemoryStream(Encoding.Default.GetBytes(contents));
+
+ }
+
+
+ /// <summary>
+ /// Returns the <see cref="System.Uri"/> handle for this resource.
+ /// </summary>
+ /// <value></value>
+ public override Uri Uri
+ {
+ get { throw new NotImplementedException("The method or operation is not implemented."); }
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.IO.FileInfo"/> handle for this resource.
+ /// </summary>
+ /// <value>The <see cref="System.IO.FileInfo"/> handle for this resource.</value>
+ /// <remarks>
+ /// <p>
+ /// For safety, always check the value of the
+ /// <see cref="System.Uri.IsFile "/> property prior to
+ /// accessing this property; resources that cannot be exposed as
+ /// a <see cref="System.IO.FileInfo"/> will typically return
+ /// <see langword="false"/> from a call to this property.
+ /// </p>
+ /// </remarks>
+ /// <exception cref="System.IO.IOException">
+ /// If the resource is not available on a filesystem, or cannot be
+ /// exposed as a <see cref="System.IO.FileInfo"/> handle.
+ /// </exception>
+ public override FileInfo FileInfo
+ {
+ get { throw new NotImplementedException("The method or operation is not implemented."); }
+ }
+
+ /// <summary>
+ /// Return an <see cref="System.IO.Stream"/> for this resource.
+ /// </summary>
+ /// <value>An <see cref="System.IO.Stream"/>.</value>
+ /// <remarks>
+ /// <note type="caution">
+ /// Clients of this interface must be aware that every access of this
+ /// property will create a <i>fresh</i>
+ /// <see cref="System.IO.Stream"/>;
+ /// it is the responsibility of the calling code to close any such
+ /// <see cref="System.IO.Stream"/>.
+ /// </note>
+ /// </remarks>
+ /// <exception cref="System.IO.IOException">
+ /// If the stream could not be opened.
+ /// </exception>
+ public override Stream Stream
+ {
+ get { return stream; }
+ }
+
+ /// <summary>
+ /// Returns a description for this resource.
+ /// </summary>
+ /// <value>A description for this resource.</value>
+ /// <remarks>
+ /// <p>
+ /// The description is typically used for diagnostics and other such
+ /// logging when working with the resource.
+ /// </p>
+ /// <p>
+ /// Implementations are also encouraged to return this value from their
+ /// <see cref="System.Object.ToString()"/> method.
+ /// </p>
+ /// </remarks>
+ public override string Description
+ {
+ get { return contents; }
+ }
+
+ /// <summary>
+ /// Creates a resource relative to this resource.
+ /// </summary>
+ /// <param name="relativePath">The path (always resolved as relative to this resource).</param>
+ /// <returns>The relative resource.</returns>
+ /// <exception cref="System.IO.IOException">
+ /// If the relative resource could not be created from the supplied
+ /// path.
+ /// </exception>
+ /// <exception cref="System.NotSupportedException">
+ /// If the resource does not support the notion of a relative path.
+ /// </exception>
+ public override IResource CreateRelative(string relativePath)
+ {
+ throw new NotImplementedException("The method or operation is not implemented.");
+ }
+ }
+}
Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/StaticContentResource.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/StaticContentResource.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy