55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
namespace NHibernate.AdoNet.Util
|
|
{
|
|
using System;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
public class FormatStyle
|
|
{
|
|
public static readonly FormatStyle Basic = new FormatStyle("basic", new BasicFormatter());
|
|
public static readonly FormatStyle Ddl = new FormatStyle("ddl", new DdlFormatter());
|
|
public static readonly FormatStyle None = new FormatStyle("none", new NoFormatImpl());
|
|
|
|
private FormatStyle(string name, IFormatter formatter)
|
|
{
|
|
this.Name = name;
|
|
this.Formatter = formatter;
|
|
}
|
|
|
|
public bool Equals(FormatStyle other)
|
|
{
|
|
if (other == null)
|
|
{
|
|
return false;
|
|
}
|
|
return (object.ReferenceEquals(this, other) || object.Equals(other.Name, this.Name));
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
return this.Equals(obj as FormatStyle);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
if (this.Name == null)
|
|
{
|
|
return 0;
|
|
}
|
|
return this.Name.GetHashCode();
|
|
}
|
|
|
|
public IFormatter Formatter { get; private set; }
|
|
|
|
public string Name { get; private set; }
|
|
|
|
private class NoFormatImpl : IFormatter
|
|
{
|
|
public string Format(string source)
|
|
{
|
|
return source;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|