From: Jaben C. <ja...@us...> - 2007-02-08 00:49:49
|
Update of /cvsroot/yafdotnet/yafsrc/URLRewriter.NET/Transforms In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv25871/yafsrc/URLRewriter.NET/Transforms Added Files: Tag: v1_0_2_NETv2 Base64DecodeTransform.cs Base64Transform.cs DecodeTransform.cs EncodeTransform.cs IRewriteTransform.cs LowerTransform.cs StaticMappingTransform.cs UpperTransform.cs Log Message: URL Rewriter class --- NEW FILE: UpperTransform.cs --- // UrlRewriter - A .NET URL Rewriter module // Version 1.7 // // Copyright 2006 Intelligencia // Copyright 2006 Seth Yates // using System; using Intelligencia.UrlRewriter.Utilities; namespace Intelligencia.UrlRewriter.Transforms { /// <summary> /// Transforms the input to upper case. /// </summary> public sealed class UpperTransform : IRewriteTransform { /// <summary> /// Applies a transformation to the input string. /// </summary> /// <param name="input">The input string.</param> /// <returns>The transformed string.</returns> public string ApplyTransform(string input) { return input.ToUpper(); } /// <summary> /// The name of the action. /// </summary> public string Name { get { return Constants.TransformUpper; } } } } --- NEW FILE: Base64DecodeTransform.cs --- // UrlRewriter - A .NET URL Rewriter module // Version 1.7 // // Copyright 2006 Intelligencia // Copyright 2006 Seth Yates // using System; using System.Text; using Intelligencia.UrlRewriter.Utilities; namespace Intelligencia.UrlRewriter.Transforms { /// <summary> /// Base 64 encodes the input. /// </summary> public sealed class Base64Transform : IRewriteTransform { /// <summary> /// Applies a transformation to the input string. /// </summary> /// <param name="input">The input string.</param> /// <returns>The transformed string.</returns> public string ApplyTransform(string input) { return Convert.ToBase64String(Encoding.UTF8.GetBytes(input)); } /// <summary> /// The name of the action. /// </summary> public string Name { get { return Constants.TransformBase64Decode; } } } } --- NEW FILE: DecodeTransform.cs --- // UrlRewriter - A .NET URL Rewriter module // Version 1.7 // // Copyright 2006 Intelligencia // Copyright 2006 Seth Yates // using System; using System.Web; using Intelligencia.UrlRewriter.Utilities; namespace Intelligencia.UrlRewriter.Transforms { /// <summary> /// Url decodes the input. /// </summary> public sealed class DecodeTransform : IRewriteTransform { /// <summary> /// Applies a transformation to the input string. /// </summary> /// <param name="input">The input string.</param> /// <returns>The transformed string.</returns> public string ApplyTransform(string input) { return HttpUtility.UrlDecode(input); } /// <summary> /// The name of the action. /// </summary> public string Name { get { return Constants.TransformDecode; } } } } --- NEW FILE: IRewriteTransform.cs --- // UrlRewriter - A .NET URL Rewriter module // Version 1.7 // // Copyright 2006 Intelligencia // Copyright 2006 Seth Yates // using System; namespace Intelligencia.UrlRewriter { /// <summary> /// Interface for transforming replacements. /// </summary> public interface IRewriteTransform { /// <summary> /// Applies a transformation to the input string. /// </summary> /// <param name="input">The input string.</param> /// <returns>The transformed string.</returns> string ApplyTransform(string input); /// <summary> /// The name of the transform. /// </summary> string Name { get; } } } --- NEW FILE: EncodeTransform.cs --- // UrlRewriter - A .NET URL Rewriter module // Version 1.7 // // Copyright 2006 Intelligencia // Copyright 2006 Seth Yates // using System; using System.Web; using Intelligencia.UrlRewriter.Utilities; namespace Intelligencia.UrlRewriter.Transforms { /// <summary> /// Url encodes the input. /// </summary> public sealed class EncodeTransform : IRewriteTransform { /// <summary> /// Applies a transformation to the input string. /// </summary> /// <param name="input">The input string.</param> /// <returns>The transformed string.</returns> public string ApplyTransform(string input) { return HttpUtility.UrlEncode(input); } /// <summary> /// The name of the action. /// </summary> public string Name { get { return Constants.TransformEncode; } } } } --- NEW FILE: LowerTransform.cs --- // UrlRewriter - A .NET URL Rewriter module // Version 1.7 // // Copyright 2006 Intelligencia // Copyright 2006 Seth Yates // using System; using Intelligencia.UrlRewriter.Utilities; namespace Intelligencia.UrlRewriter.Transforms { /// <summary> /// Transforms the input to lower case. /// </summary> public sealed class LowerTransform : IRewriteTransform { /// <summary> /// Applies a transformation to the input string. /// </summary> /// <param name="input">The input string.</param> /// <returns>The transformed string.</returns> public string ApplyTransform(string input) { return input.ToLower(); } /// <summary> /// The name of the action. /// </summary> public string Name { get { return Constants.TransformLower; } } } } --- NEW FILE: StaticMappingTransform.cs --- // UrlRewriter - A .NET URL Rewriter module // Version 1.7 // // Copyright 2006 Intelligencia // Copyright 2006 Seth Yates // using System; using System.Collections.Specialized; namespace Intelligencia.UrlRewriter.Transforms { /// <summary> /// Default RewriteMapper, reads its maps from config. /// Note that the mapping is CASE-INSENSITIVE. /// </summary> public sealed class StaticMappingTransform : IRewriteTransform { /// <summary> /// Default constructor. /// </summary> /// <param name="name">The name of the mapping.</param> /// <param name="map">The mappings.</param> public StaticMappingTransform(string name, StringDictionary map) { _name = name; _map = map; } /// <summary> /// Maps the specified value in the specified map to its replacement value. /// </summary> /// <param name="input">The value being mapped.</param> /// <returns>The value mapped to, or null if no mapping could be performed.</returns> public string ApplyTransform(string input) { return _map[input]; } /// <summary> /// The name of the action. /// </summary> public string Name { get { return _name; } } private string _name; private StringDictionary _map; } } --- NEW FILE: Base64Transform.cs --- // UrlRewriter - A .NET URL Rewriter module // Version 1.7 // // Copyright 2006 Intelligencia // Copyright 2006 Seth Yates // using System; using System.Text; using Intelligencia.UrlRewriter.Utilities; namespace Intelligencia.UrlRewriter.Transforms { /// <summary> /// Base 64 encodes the input. /// </summary> public sealed class Base64DecodeTransform : IRewriteTransform { /// <summary> /// Applies a transformation to the input string. /// </summary> /// <param name="input">The input string.</param> /// <returns>The transformed string.</returns> public string ApplyTransform(string input) { return Encoding.UTF8.GetString(Convert.FromBase64String(input)); } /// <summary> /// The name of the action. /// </summary> public string Name { get { return Constants.TransformBase64; } } } } |