Rename Namespace
I made the mustache namespace upper case. An easy find/replace will fix this for most projects. I bumped the version up to a minor release anyway.
This commit is contained in:
parent
50a80f42ad
commit
22e0cb4c2a
|
@ -4,7 +4,7 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
namespace mustache.test
|
namespace Mustache.Test
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the FormatParser class.
|
/// Tests the FormatParser class.
|
||||||
|
|
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||||
//
|
//
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("0.0.7.2")]
|
[assembly: AssemblyVersion("0.1.0.0")]
|
||||||
[assembly: AssemblyFileVersion("0.0.7.2")]
|
[assembly: AssemblyFileVersion("0.1.0.0")]
|
||||||
|
|
|
@ -1,63 +1,63 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProductVersion>
|
<ProductVersion>
|
||||||
</ProductVersion>
|
</ProductVersion>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>{7F607362-0680-4751-B1DC-621219294AE3}</ProjectGuid>
|
<ProjectGuid>{7F607362-0680-4751-B1DC-621219294AE3}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>mustache.test</RootNamespace>
|
<RootNamespace>Mustache.Test</RootNamespace>
|
||||||
<AssemblyName>mustache-sharp.test</AssemblyName>
|
<AssemblyName>mustache-sharp.test</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
|
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
</CodeAnalysisDependentAssemblyPaths>
|
</CodeAnalysisDependentAssemblyPaths>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="FormatCompilerTester.cs" />
|
<Compile Include="FormatCompilerTester.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\mustache-sharp\mustache-sharp.csproj">
|
<ProjectReference Include="..\mustache-sharp\mustache-sharp.csproj">
|
||||||
<Project>{D71B378F-A4BA-4263-A4F0-07A49A0C528D}</Project>
|
<Project>{D71B378F-A4BA-4263-A4F0-07A49A0C528D}</Project>
|
||||||
<Name>mustache-sharp</Name>
|
<Name>mustache-sharp</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
</Target>
|
</Target>
|
||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
</Project>
|
</Project>
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Associates parameters to their argument values.
|
/// Associates parameters to their argument values.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Builds text by combining the output of other generators.
|
/// Builds text by combining the output of other generators.
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a tag that conditionally prints its content.
|
/// Defines a tag that conditionally prints its content.
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a tag that can contain inner text.
|
/// Defines a tag that can contain inner text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ContentTagDefinition : TagDefinition
|
public abstract class ContentTagDefinition : TagDefinition
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of a ContentTagDefinition.
|
/// Initializes a new instance of a ContentTagDefinition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tagName">The name of the tag being defined.</param>
|
/// <param name="tagName">The name of the tag being defined.</param>
|
||||||
protected ContentTagDefinition(string tagName)
|
protected ContentTagDefinition(string tagName)
|
||||||
: base(tagName)
|
: base(tagName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of a ContentTagDefinition.
|
/// Initializes a new instance of a ContentTagDefinition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tagName">The name of the tag being defined.</param>
|
/// <param name="tagName">The name of the tag being defined.</param>
|
||||||
/// <param name="isBuiltin">Specifies whether the tag is a built-in tag.</param>
|
/// <param name="isBuiltin">Specifies whether the tag is a built-in tag.</param>
|
||||||
internal ContentTagDefinition(string tagName, bool isBuiltin)
|
internal ContentTagDefinition(string tagName, bool isBuiltin)
|
||||||
: base(tagName, isBuiltin)
|
: base(tagName, isBuiltin)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether the tag can have content.
|
/// Gets or sets whether the tag can have content.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>True if the tag can have a body; otherwise, false.</returns>
|
/// <returns>True if the tag can have a body; otherwise, false.</returns>
|
||||||
protected override bool GetHasContent()
|
protected override bool GetHasContent()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a context within a template.
|
/// Represents a context within a template.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds information describing a parameter that creates a new context.
|
/// Holds information describing a parameter that creates a new context.
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a tag that can iterate over a collection of items and render
|
/// Defines a tag that can iterate over a collection of items and render
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a tag that conditionally renders its content if preceding if and elif tags fail.
|
/// Defines a tag that conditionally renders its content if preceding if and elif tags fail.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class ElifTagDefinition : ConditionTagDefinition
|
internal sealed class ElifTagDefinition : ConditionTagDefinition
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of an ElifTagDefinition.
|
/// Initializes a new instance of an ElifTagDefinition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ElifTagDefinition()
|
public ElifTagDefinition()
|
||||||
: base("elif")
|
: base("elif")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets whether the tag only exists within the scope of its parent.
|
/// Gets whether the tag only exists within the scope of its parent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override bool GetIsContextSensitive()
|
protected override bool GetIsContextSensitive()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the tags that indicate the end of the current tags context.
|
/// Gets the tags that indicate the end of the current tags context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override IEnumerable<string> GetClosingTags()
|
protected override IEnumerable<string> GetClosingTags()
|
||||||
{
|
{
|
||||||
return new string[] { "if" };
|
return new string[] { "if" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a tag that renders its content if all preceding if and elif tags.
|
/// Defines a tag that renders its content if all preceding if and elif tags.
|
||||||
|
|
|
@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using mustache.Properties;
|
using Mustache.Properties;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses a format string and returns a text generator.
|
/// Parses a format string and returns a text generator.
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates text by substituting an object's values for placeholders.
|
/// Generates text by substituting an object's values for placeholders.
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies the values of an object to the format plan, generating a string.
|
/// Applies the values of an object to the format plan, generating a string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal interface IGenerator
|
internal interface IGenerator
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates the text when applying the format plan.
|
/// Generates the text when applying the format plan.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scope">The current lexical scope of the keys.</param>
|
/// <param name="scope">The current lexical scope of the keys.</param>
|
||||||
/// <param name="writer">The text writer to send all text to.</param>
|
/// <param name="writer">The text writer to send all text to.</param>
|
||||||
/// <returns>The generated text.</returns>
|
/// <returns>The generated text.</returns>
|
||||||
void GetText(KeyScope scope, TextWriter writer);
|
void GetText(KeyScope scope, TextWriter writer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a tag that renders its content depending on the truthyness
|
/// Defines a tag that renders its content depending on the truthyness
|
||||||
/// of its argument, with optional elif and else nested tags.
|
/// of its argument, with optional elif and else nested tags.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class IfTagDefinition : ConditionTagDefinition
|
internal sealed class IfTagDefinition : ConditionTagDefinition
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of a IfTagDefinition.
|
/// Initializes a new instance of a IfTagDefinition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IfTagDefinition()
|
public IfTagDefinition()
|
||||||
: base("if")
|
: base("if")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets whether the tag only exists within the scope of its parent.
|
/// Gets whether the tag only exists within the scope of its parent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override bool GetIsContextSensitive()
|
protected override bool GetIsContextSensitive()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates the text for a tag that only exists on a single line.
|
/// Generates the text for a tag that only exists on a single line.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class InlineGenerator : IGenerator
|
internal sealed class InlineGenerator : IGenerator
|
||||||
{
|
{
|
||||||
private readonly TagDefinition _definition;
|
private readonly TagDefinition _definition;
|
||||||
private readonly ArgumentCollection _arguments;
|
private readonly ArgumentCollection _arguments;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of an InlineGenerator.
|
/// Initializes a new instance of an InlineGenerator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="definition">The tag to render the text for.</param>
|
/// <param name="definition">The tag to render the text for.</param>
|
||||||
/// <param name="arguments">The arguments passed to the tag.</param>
|
/// <param name="arguments">The arguments passed to the tag.</param>
|
||||||
public InlineGenerator(TagDefinition definition, ArgumentCollection arguments)
|
public InlineGenerator(TagDefinition definition, ArgumentCollection arguments)
|
||||||
{
|
{
|
||||||
_definition = definition;
|
_definition = definition;
|
||||||
_arguments = arguments;
|
_arguments = arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IGenerator.GetText(KeyScope scope, TextWriter writer)
|
void IGenerator.GetText(KeyScope scope, TextWriter writer)
|
||||||
{
|
{
|
||||||
Dictionary<string, object> arguments = _arguments.GetArguments(scope);
|
Dictionary<string, object> arguments = _arguments.GetArguments(scope);
|
||||||
_definition.GetText(writer, arguments);
|
_definition.GetText(writer, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a tag that cannot contain inner text.
|
/// Defines a tag that cannot contain inner text.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds the information about a key that was found.
|
/// Holds the information about a key that was found.
|
||||||
|
|
|
@ -1,51 +1,51 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Substitutes a key placeholder with the textual representation of the associated object.
|
/// Substitutes a key placeholder with the textual representation of the associated object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class KeyGenerator : IGenerator
|
internal sealed class KeyGenerator : IGenerator
|
||||||
{
|
{
|
||||||
private readonly string _key;
|
private readonly string _key;
|
||||||
private readonly string _format;
|
private readonly string _format;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of a KeyGenerator.
|
/// Initializes a new instance of a KeyGenerator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">The key to substitute with its value.</param>
|
/// <param name="key">The key to substitute with its value.</param>
|
||||||
/// <param name="alignment">The alignment specifier.</param>
|
/// <param name="alignment">The alignment specifier.</param>
|
||||||
/// <param name="formatting">The format specifier.</param>
|
/// <param name="formatting">The format specifier.</param>
|
||||||
public KeyGenerator(string key, string alignment, string formatting)
|
public KeyGenerator(string key, string alignment, string formatting)
|
||||||
{
|
{
|
||||||
_key = key;
|
_key = key;
|
||||||
_format = getFormat(alignment, formatting);
|
_format = getFormat(alignment, formatting);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string getFormat(string alignment, string formatting)
|
private static string getFormat(string alignment, string formatting)
|
||||||
{
|
{
|
||||||
StringBuilder formatBuilder = new StringBuilder();
|
StringBuilder formatBuilder = new StringBuilder();
|
||||||
formatBuilder.Append("{0");
|
formatBuilder.Append("{0");
|
||||||
if (!String.IsNullOrWhiteSpace(alignment))
|
if (!String.IsNullOrWhiteSpace(alignment))
|
||||||
{
|
{
|
||||||
formatBuilder.Append(",");
|
formatBuilder.Append(",");
|
||||||
formatBuilder.Append(alignment.TrimStart('+'));
|
formatBuilder.Append(alignment.TrimStart('+'));
|
||||||
}
|
}
|
||||||
if (!String.IsNullOrWhiteSpace(formatting))
|
if (!String.IsNullOrWhiteSpace(formatting))
|
||||||
{
|
{
|
||||||
formatBuilder.Append(":");
|
formatBuilder.Append(":");
|
||||||
formatBuilder.Append(formatting);
|
formatBuilder.Append(formatting);
|
||||||
}
|
}
|
||||||
formatBuilder.Append("}");
|
formatBuilder.Append("}");
|
||||||
return formatBuilder.ToString();
|
return formatBuilder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IGenerator.GetText(KeyScope scope, TextWriter writer)
|
void IGenerator.GetText(KeyScope scope, TextWriter writer)
|
||||||
{
|
{
|
||||||
object value = scope.Find(_key);
|
object value = scope.Find(_key);
|
||||||
writer.Write(_format, value);
|
writer.Write(_format, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds the information needed to handle a missing key.
|
/// Holds the information needed to handle a missing key.
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using mustache.Properties;
|
using Mustache.Properties;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a scope of keys.
|
/// Represents a scope of keys.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a pseudo tag that wraps the entire content of a format string.
|
/// Defines a pseudo tag that wraps the entire content of a format string.
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds the objects to use when processing a child context of another tag.
|
/// Holds the objects to use when processing a child context of another tag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class NestedContext
|
public sealed class NestedContext
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of a NestedContext.
|
/// Initializes a new instance of a NestedContext.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public NestedContext()
|
public NestedContext()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the writer to use when generating the child context.
|
/// Gets or sets the writer to use when generating the child context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>Setting the writer to null will indicate that the tag's writer should be used.</remarks>
|
/// <remarks>Setting the writer to null will indicate that the tag's writer should be used.</remarks>
|
||||||
public TextWriter Writer
|
public TextWriter Writer
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether the text sent to the returned writer needs to be added
|
/// Gets or sets whether the text sent to the returned writer needs to be added
|
||||||
/// to the parent tag's writer. This should be false if the parent writer is
|
/// to the parent tag's writer. This should be false if the parent writer is
|
||||||
/// being returned or is being wrapped.
|
/// being returned or is being wrapped.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool WriterNeedsConsidated
|
public bool WriterNeedsConsidated
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the scope to use when generating the child context.
|
/// Gets or sets the scope to use when generating the child context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>Setting the scope to null will indicate that the current scope should be used.</remarks>
|
/// <remarks>Setting the scope to null will indicate that the current scope should be used.</remarks>
|
||||||
public KeyScope KeyScope
|
public KeyScope KeyScope
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using mustache.Properties;
|
using Mustache.Properties;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds the information descibing a key that is found in a template.
|
/// Holds the information descibing a key that is found in a template.
|
||||||
|
|
|
@ -34,6 +34,6 @@ using System.Runtime.CompilerServices;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.0.7.2")]
|
[assembly: AssemblyVersion("0.1.0.0")]
|
||||||
[assembly: AssemblyFileVersion("0.0.7.2")]
|
[assembly: AssemblyFileVersion("0.1.0.0")]
|
||||||
[assembly: InternalsVisibleTo("mustache-sharp.test")]
|
[assembly: InternalsVisibleTo("mustache-sharp.test")]
|
|
@ -1,135 +1,135 @@
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.296
|
// Runtime Version:4.0.30319.296
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace mustache.Properties {
|
namespace Mustache.Properties {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
// class via a tool like ResGen or Visual Studio.
|
// class via a tool like ResGen or Visual Studio.
|
||||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
// with the /str option, or rebuild your VS project.
|
// with the /str option, or rebuild your VS project.
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Resources {
|
internal class Resources {
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
internal Resources() {
|
internal Resources() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mustache.Properties.Resources", typeof(Resources).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mustache.Properties.Resources", typeof(Resources).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides the current thread's CurrentUICulture property for all
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
/// resource lookups using this strongly typed resource class.
|
/// resource lookups using this strongly typed resource class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
get {
|
get {
|
||||||
return resourceCulture;
|
return resourceCulture;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
resourceCulture = value;
|
resourceCulture = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to An attempt was made to define a parameter with a null or an invalid identifier..
|
/// Looks up a localized string similar to An attempt was made to define a parameter with a null or an invalid identifier..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string BlankParameterName {
|
internal static string BlankParameterName {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("BlankParameterName", resourceCulture);
|
return ResourceManager.GetString("BlankParameterName", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to An attempt was made to define a tag with a null or an invalid identifier..
|
/// Looks up a localized string similar to An attempt was made to define a tag with a null or an invalid identifier..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string BlankTagName {
|
internal static string BlankTagName {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("BlankTagName", resourceCulture);
|
return ResourceManager.GetString("BlankTagName", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to A parameter with the same name already exists within the tag..
|
/// Looks up a localized string similar to A parameter with the same name already exists within the tag..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string DuplicateParameter {
|
internal static string DuplicateParameter {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("DuplicateParameter", resourceCulture);
|
return ResourceManager.GetString("DuplicateParameter", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to The {0} tag has already been registered..
|
/// Looks up a localized string similar to The {0} tag has already been registered..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string DuplicateTagDefinition {
|
internal static string DuplicateTagDefinition {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("DuplicateTagDefinition", resourceCulture);
|
return ResourceManager.GetString("DuplicateTagDefinition", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to The key {0} could not be found..
|
/// Looks up a localized string similar to The key {0} could not be found..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string KeyNotFound {
|
internal static string KeyNotFound {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("KeyNotFound", resourceCulture);
|
return ResourceManager.GetString("KeyNotFound", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Expected a matching {0} tag but none was found..
|
/// Looks up a localized string similar to Expected a matching {0} tag but none was found..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string MissingClosingTag {
|
internal static string MissingClosingTag {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("MissingClosingTag", resourceCulture);
|
return ResourceManager.GetString("MissingClosingTag", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Encountered an unknown tag. It was either not registered or exists in a different context..
|
/// Looks up a localized string similar to Encountered an unknown tag. It was either not registered or exists in a different context..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string UnknownTag {
|
internal static string UnknownTag {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("UnknownTag", resourceCulture);
|
return ResourceManager.GetString("UnknownTag", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to The wrong number of arguments were passed to an {0} tag..
|
/// Looks up a localized string similar to The wrong number of arguments were passed to an {0} tag..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string WrongNumberOfArguments {
|
internal static string WrongNumberOfArguments {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("WrongNumberOfArguments", resourceCulture);
|
return ResourceManager.GetString("WrongNumberOfArguments", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,237 +1,237 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides methods for creating instances of PropertyDictionary.
|
/// Provides methods for creating instances of PropertyDictionary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class PropertyDictionary : IDictionary<string, object>
|
internal sealed class PropertyDictionary : IDictionary<string, object>
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<Type, Dictionary<string, PropertyInfo>> _cache = new Dictionary<Type, Dictionary<string, PropertyInfo>>();
|
private static readonly Dictionary<Type, Dictionary<string, PropertyInfo>> _cache = new Dictionary<Type, Dictionary<string, PropertyInfo>>();
|
||||||
|
|
||||||
private readonly object _instance;
|
private readonly object _instance;
|
||||||
private readonly Dictionary<string, PropertyInfo> _typeCache;
|
private readonly Dictionary<string, PropertyInfo> _typeCache;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of a PropertyDictionary.
|
/// Initializes a new instance of a PropertyDictionary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="instance">The instance to wrap in the PropertyDictionary.</param>
|
/// <param name="instance">The instance to wrap in the PropertyDictionary.</param>
|
||||||
public PropertyDictionary(object instance)
|
public PropertyDictionary(object instance)
|
||||||
{
|
{
|
||||||
_instance = instance;
|
_instance = instance;
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
{
|
{
|
||||||
_typeCache = new Dictionary<string, PropertyInfo>();
|
_typeCache = new Dictionary<string, PropertyInfo>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_typeCache = getCacheType(_instance);
|
_typeCache = getCacheType(_instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<string, PropertyInfo> getCacheType(object instance)
|
private static Dictionary<string, PropertyInfo> getCacheType(object instance)
|
||||||
{
|
{
|
||||||
Type type = instance.GetType();
|
Type type = instance.GetType();
|
||||||
Dictionary<string, PropertyInfo> typeCache;
|
Dictionary<string, PropertyInfo> typeCache;
|
||||||
if (!_cache.TryGetValue(type, out typeCache))
|
if (!_cache.TryGetValue(type, out typeCache))
|
||||||
{
|
{
|
||||||
typeCache = new Dictionary<string, PropertyInfo>();
|
typeCache = new Dictionary<string, PropertyInfo>();
|
||||||
BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy;
|
BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy;
|
||||||
foreach (PropertyInfo propertyInfo in type.GetProperties(flags))
|
foreach (PropertyInfo propertyInfo in type.GetProperties(flags))
|
||||||
{
|
{
|
||||||
if (!propertyInfo.IsSpecialName)
|
if (!propertyInfo.IsSpecialName)
|
||||||
{
|
{
|
||||||
typeCache.Add(propertyInfo.Name, propertyInfo);
|
typeCache.Add(propertyInfo.Name, propertyInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_cache.Add(type, typeCache);
|
_cache.Add(type, typeCache);
|
||||||
}
|
}
|
||||||
return typeCache;
|
return typeCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the underlying instance.
|
/// Gets the underlying instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object Instance
|
public object Instance
|
||||||
{
|
{
|
||||||
get { return _instance; }
|
get { return _instance; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
void IDictionary<string, object>.Add(string key, object value)
|
void IDictionary<string, object>.Add(string key, object value)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether a property with the given name exists.
|
/// Determines whether a property with the given name exists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">The name of the property.</param>
|
/// <param name="key">The name of the property.</param>
|
||||||
/// <returns>True if the property exists; otherwise, false.</returns>
|
/// <returns>True if the property exists; otherwise, false.</returns>
|
||||||
public bool ContainsKey(string key)
|
public bool ContainsKey(string key)
|
||||||
{
|
{
|
||||||
return _typeCache.ContainsKey(key);
|
return _typeCache.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the properties in the type.
|
/// Gets the name of the properties in the type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ICollection<string> Keys
|
public ICollection<string> Keys
|
||||||
{
|
{
|
||||||
get { return _typeCache.Keys; }
|
get { return _typeCache.Keys; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
bool IDictionary<string, object>.Remove(string key)
|
bool IDictionary<string, object>.Remove(string key)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to get the value for the given property name.
|
/// Tries to get the value for the given property name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">The name of the property to get the value for.</param>
|
/// <param name="key">The name of the property to get the value for.</param>
|
||||||
/// <param name="value">The variable to store the value of the property or the default value if the property is not found.</param>
|
/// <param name="value">The variable to store the value of the property or the default value if the property is not found.</param>
|
||||||
/// <returns>True if a property with the given name is found; otherwise, false.</returns>
|
/// <returns>True if a property with the given name is found; otherwise, false.</returns>
|
||||||
/// <exception cref="System.ArgumentNullException">The name of the property was null.</exception>
|
/// <exception cref="System.ArgumentNullException">The name of the property was null.</exception>
|
||||||
public bool TryGetValue(string key, out object value)
|
public bool TryGetValue(string key, out object value)
|
||||||
{
|
{
|
||||||
PropertyInfo propertyInfo;
|
PropertyInfo propertyInfo;
|
||||||
if (!_typeCache.TryGetValue(key, out propertyInfo))
|
if (!_typeCache.TryGetValue(key, out propertyInfo))
|
||||||
{
|
{
|
||||||
value = null;
|
value = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
value = getValue(propertyInfo);
|
value = getValue(propertyInfo);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the values of all of the properties in the object.
|
/// Gets the values of all of the properties in the object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ICollection<object> Values
|
public ICollection<object> Values
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
ICollection<PropertyInfo> propertyInfos = _typeCache.Values;
|
ICollection<PropertyInfo> propertyInfos = _typeCache.Values;
|
||||||
List<object> values = new List<object>();
|
List<object> values = new List<object>();
|
||||||
foreach (PropertyInfo propertyInfo in propertyInfos)
|
foreach (PropertyInfo propertyInfo in propertyInfos)
|
||||||
{
|
{
|
||||||
object value = getValue(propertyInfo);
|
object value = getValue(propertyInfo);
|
||||||
values.Add(value);
|
values.Add(value);
|
||||||
}
|
}
|
||||||
return values.AsReadOnly();
|
return values.AsReadOnly();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the value of the property with the given name.
|
/// Gets or sets the value of the property with the given name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">The name of the property to get or set.</param>
|
/// <param name="key">The name of the property to get or set.</param>
|
||||||
/// <returns>The value of the property with the given name.</returns>
|
/// <returns>The value of the property with the given name.</returns>
|
||||||
/// <exception cref="System.ArgumentNullException">The property name was null.</exception>
|
/// <exception cref="System.ArgumentNullException">The property name was null.</exception>
|
||||||
/// <exception cref="System.Collections.Generic.KeyNotFoundException">The type does not have a property with the given name.</exception>
|
/// <exception cref="System.Collections.Generic.KeyNotFoundException">The type does not have a property with the given name.</exception>
|
||||||
/// <exception cref="System.ArgumentException">The property did not support getting or setting.</exception>
|
/// <exception cref="System.ArgumentException">The property did not support getting or setting.</exception>
|
||||||
/// <exception cref="System.ArgumentException">
|
/// <exception cref="System.ArgumentException">
|
||||||
/// The object does not match the target type, or a property is a value type but the value is null.
|
/// The object does not match the target type, or a property is a value type but the value is null.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public object this[string key]
|
public object this[string key]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
PropertyInfo propertyInfo = _typeCache[key];
|
PropertyInfo propertyInfo = _typeCache[key];
|
||||||
return getValue(propertyInfo);
|
return getValue(propertyInfo);
|
||||||
}
|
}
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item)
|
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
void ICollection<KeyValuePair<string, object>>.Clear()
|
void ICollection<KeyValuePair<string, object>>.Clear()
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item)
|
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item)
|
||||||
{
|
{
|
||||||
PropertyInfo propertyInfo;
|
PropertyInfo propertyInfo;
|
||||||
if (!_typeCache.TryGetValue(item.Key, out propertyInfo))
|
if (!_typeCache.TryGetValue(item.Key, out propertyInfo))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
object value = getValue(propertyInfo);
|
object value = getValue(propertyInfo);
|
||||||
return Equals(item.Value, value);
|
return Equals(item.Value, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
|
void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
|
||||||
{
|
{
|
||||||
List<KeyValuePair<string, object>> pairs = new List<KeyValuePair<string, object>>();
|
List<KeyValuePair<string, object>> pairs = new List<KeyValuePair<string, object>>();
|
||||||
ICollection<KeyValuePair<string, PropertyInfo>> collection = _typeCache;
|
ICollection<KeyValuePair<string, PropertyInfo>> collection = _typeCache;
|
||||||
foreach (KeyValuePair<string, PropertyInfo> pair in collection)
|
foreach (KeyValuePair<string, PropertyInfo> pair in collection)
|
||||||
{
|
{
|
||||||
PropertyInfo propertyInfo = pair.Value;
|
PropertyInfo propertyInfo = pair.Value;
|
||||||
object value = getValue(propertyInfo);
|
object value = getValue(propertyInfo);
|
||||||
pairs.Add(new KeyValuePair<string, object>(pair.Key, value));
|
pairs.Add(new KeyValuePair<string, object>(pair.Key, value));
|
||||||
}
|
}
|
||||||
pairs.CopyTo(array, arrayIndex);
|
pairs.CopyTo(array, arrayIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the number of properties in the type.
|
/// Gets the number of properties in the type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Count
|
public int Count
|
||||||
{
|
{
|
||||||
get { return _typeCache.Count; }
|
get { return _typeCache.Count; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether updates will be ignored.
|
/// Gets or sets whether updates will be ignored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool ICollection<KeyValuePair<string, object>>.IsReadOnly
|
bool ICollection<KeyValuePair<string, object>>.IsReadOnly
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item)
|
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the propety name/value pairs in the object.
|
/// Gets the propety name/value pairs in the object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
|
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, PropertyInfo> pair in _typeCache)
|
foreach (KeyValuePair<string, PropertyInfo> pair in _typeCache)
|
||||||
{
|
{
|
||||||
object value = getValue(pair.Value);
|
object value = getValue(pair.Value);
|
||||||
yield return new KeyValuePair<string, object>(pair.Key, value);
|
yield return new KeyValuePair<string, object>(pair.Key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
{
|
{
|
||||||
return GetEnumerator();
|
return GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
private object getValue(PropertyInfo propertyInfo)
|
private object getValue(PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
return propertyInfo.GetValue(_instance, null);
|
return propertyInfo.GetValue(_instance, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides utility methods that require regular expressions.
|
/// Provides utility methods that require regular expressions.
|
||||||
|
|
|
@ -1,54 +1,54 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates a static block of text.
|
/// Generates a static block of text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class StaticGenerator : IGenerator
|
internal sealed class StaticGenerator : IGenerator
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of a StaticGenerator.
|
/// Initializes a new instance of a StaticGenerator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public StaticGenerator()
|
public StaticGenerator()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the linked list node containing the current generator.
|
/// Gets or sets the linked list node containing the current generator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LinkedListNode<IGenerator> Node
|
public LinkedListNode<IGenerator> Node
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the static text.
|
/// Gets or sets the static text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Value
|
public string Value
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes the static text from the final output.
|
/// Removes the static text from the final output.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Prune()
|
public void Prune()
|
||||||
{
|
{
|
||||||
if (Node != null)
|
if (Node != null)
|
||||||
{
|
{
|
||||||
Node.List.Remove(Node);
|
Node.List.Remove(Node);
|
||||||
Node = null;
|
Node = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IGenerator.GetText(KeyScope scope, TextWriter writer)
|
void IGenerator.GetText(KeyScope scope, TextWriter writer)
|
||||||
{
|
{
|
||||||
writer.Write(Value);
|
writer.Write(Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using mustache.Properties;
|
using Mustache.Properties;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the attributes of a custom tag.
|
/// Defines the attributes of a custom tag.
|
||||||
|
|
|
@ -1,54 +1,54 @@
|
||||||
using System;
|
using System;
|
||||||
using mustache.Properties;
|
using Mustache.Properties;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a parameter belonging to a custom tag.
|
/// Defines a parameter belonging to a custom tag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class TagParameter
|
public sealed class TagParameter
|
||||||
{
|
{
|
||||||
private readonly string _name;
|
private readonly string _name;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of a TagParameter.
|
/// Initializes a new instance of a TagParameter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parameterName">The name of the parameter.</param>
|
/// <param name="parameterName">The name of the parameter.</param>
|
||||||
/// <exception cref="System.ArgumentException">The parameter name is null or an invalid identifier.</exception>
|
/// <exception cref="System.ArgumentException">The parameter name is null or an invalid identifier.</exception>
|
||||||
public TagParameter(string parameterName)
|
public TagParameter(string parameterName)
|
||||||
{
|
{
|
||||||
if (!RegexHelper.IsValidIdentifier(parameterName))
|
if (!RegexHelper.IsValidIdentifier(parameterName))
|
||||||
{
|
{
|
||||||
throw new ArgumentException(Resources.BlankParameterName, "parameterName");
|
throw new ArgumentException(Resources.BlankParameterName, "parameterName");
|
||||||
}
|
}
|
||||||
_name = parameterName;
|
_name = parameterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the parameter.
|
/// Gets the name of the parameter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return _name; }
|
get { return _name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether the field is required.
|
/// Gets or sets whether the field is required.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsRequired
|
public bool IsRequired
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the default value to use when an argument is not provided
|
/// Gets or sets the default value to use when an argument is not provided
|
||||||
/// for the parameter.
|
/// for the parameter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object DefaultValue
|
public object DefaultValue
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,147 +1,147 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes unnecessary lines from the final output.
|
/// Removes unnecessary lines from the final output.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class Trimmer
|
internal sealed class Trimmer
|
||||||
{
|
{
|
||||||
private readonly LinkedList<LineDetails> _lines;
|
private readonly LinkedList<LineDetails> _lines;
|
||||||
private LinkedListNode<LineDetails> _currentLine;
|
private LinkedListNode<LineDetails> _currentLine;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of a Trimmer.
|
/// Initializes a new instance of a Trimmer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Trimmer()
|
public Trimmer()
|
||||||
{
|
{
|
||||||
_lines = new LinkedList<LineDetails>();
|
_lines = new LinkedList<LineDetails>();
|
||||||
_currentLine = _lines.AddLast(new LineDetails());
|
_currentLine = _lines.AddLast(new LineDetails());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the state of the trimmer, indicating that the given text was encountered before an inline tag.
|
/// Updates the state of the trimmer, indicating that the given text was encountered before an inline tag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The text at the end of the format string.</param>
|
/// <param name="value">The text at the end of the format string.</param>
|
||||||
/// <param name="generator">The generator created for the inline tag.</param>
|
/// <param name="generator">The generator created for the inline tag.</param>
|
||||||
/// <returns>A static generator containing the passed text.</returns>
|
/// <returns>A static generator containing the passed text.</returns>
|
||||||
public IEnumerable<StaticGenerator> RecordText(string value, bool isTag, bool isOutput)
|
public IEnumerable<StaticGenerator> RecordText(string value, bool isTag, bool isOutput)
|
||||||
{
|
{
|
||||||
int newLineIndex = value.IndexOf(Environment.NewLine);
|
int newLineIndex = value.IndexOf(Environment.NewLine);
|
||||||
if (newLineIndex == -1)
|
if (newLineIndex == -1)
|
||||||
{
|
{
|
||||||
StaticGenerator generator = new StaticGenerator() { Value = value };
|
StaticGenerator generator = new StaticGenerator() { Value = value };
|
||||||
_currentLine.Value.Generators.Add(generator);
|
_currentLine.Value.Generators.Add(generator);
|
||||||
_currentLine.Value.HasTag |= isTag;
|
_currentLine.Value.HasTag |= isTag;
|
||||||
_currentLine.Value.HasOutput |= !String.IsNullOrWhiteSpace(value);
|
_currentLine.Value.HasOutput |= !String.IsNullOrWhiteSpace(value);
|
||||||
yield return generator;
|
yield return generator;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string[] lines = value.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
|
string[] lines = value.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
|
||||||
|
|
||||||
// get the trailing generator
|
// get the trailing generator
|
||||||
string trailing = lines[0];
|
string trailing = lines[0];
|
||||||
StaticGenerator trailingGenerator = new StaticGenerator() { Value = trailing };
|
StaticGenerator trailingGenerator = new StaticGenerator() { Value = trailing };
|
||||||
_currentLine.Value.Generators.Add(trailingGenerator);
|
_currentLine.Value.Generators.Add(trailingGenerator);
|
||||||
_currentLine.Value.HasOutput |= !String.IsNullOrWhiteSpace(trailing);
|
_currentLine.Value.HasOutput |= !String.IsNullOrWhiteSpace(trailing);
|
||||||
yield return trailingGenerator;
|
yield return trailingGenerator;
|
||||||
|
|
||||||
// get the middle generators
|
// get the middle generators
|
||||||
for (int lineIndex = 1; lineIndex < lines.Length - 1; ++lineIndex)
|
for (int lineIndex = 1; lineIndex < lines.Length - 1; ++lineIndex)
|
||||||
{
|
{
|
||||||
string middle = lines[lineIndex];
|
string middle = lines[lineIndex];
|
||||||
StaticGenerator middleGenerator = new StaticGenerator() { Value = middle };
|
StaticGenerator middleGenerator = new StaticGenerator() { Value = middle };
|
||||||
LineDetails middleDetails = new LineDetails() { HasTag = false };
|
LineDetails middleDetails = new LineDetails() { HasTag = false };
|
||||||
_currentLine = _lines.AddLast(middleDetails);
|
_currentLine = _lines.AddLast(middleDetails);
|
||||||
_currentLine.Value.Generators.Add(middleGenerator);
|
_currentLine.Value.Generators.Add(middleGenerator);
|
||||||
_currentLine.Value.HasOutput = true;
|
_currentLine.Value.HasOutput = true;
|
||||||
yield return middleGenerator;
|
yield return middleGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the leading generator
|
// get the leading generator
|
||||||
string leading = lines[lines.Length - 1];
|
string leading = lines[lines.Length - 1];
|
||||||
StaticGenerator leadingGenerator = new StaticGenerator() { Value = leading };
|
StaticGenerator leadingGenerator = new StaticGenerator() { Value = leading };
|
||||||
LineDetails details = new LineDetails() { HasTag = isTag };
|
LineDetails details = new LineDetails() { HasTag = isTag };
|
||||||
_currentLine = _lines.AddLast(details);
|
_currentLine = _lines.AddLast(details);
|
||||||
_currentLine.Value.Generators.Add(leadingGenerator);
|
_currentLine.Value.Generators.Add(leadingGenerator);
|
||||||
_currentLine.Value.HasOutput = !String.IsNullOrWhiteSpace(leading);
|
_currentLine.Value.HasOutput = !String.IsNullOrWhiteSpace(leading);
|
||||||
yield return leadingGenerator;
|
yield return leadingGenerator;
|
||||||
}
|
}
|
||||||
if (isOutput)
|
if (isOutput)
|
||||||
{
|
{
|
||||||
_currentLine.Value.HasOutput = true;
|
_currentLine.Value.HasOutput = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Trim()
|
public void Trim()
|
||||||
{
|
{
|
||||||
removeBlankLines();
|
removeBlankLines();
|
||||||
separateLines();
|
separateLines();
|
||||||
removeEmptyGenerators();
|
removeEmptyGenerators();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeBlankLines()
|
private void removeBlankLines()
|
||||||
{
|
{
|
||||||
LinkedListNode<LineDetails> current = _lines.First;
|
LinkedListNode<LineDetails> current = _lines.First;
|
||||||
while (current != null)
|
while (current != null)
|
||||||
{
|
{
|
||||||
LineDetails details = current.Value;
|
LineDetails details = current.Value;
|
||||||
LinkedListNode<LineDetails> temp = current;
|
LinkedListNode<LineDetails> temp = current;
|
||||||
current = current.Next;
|
current = current.Next;
|
||||||
if (details.HasTag && !details.HasOutput)
|
if (details.HasTag && !details.HasOutput)
|
||||||
{
|
{
|
||||||
foreach (StaticGenerator generator in temp.Value.Generators)
|
foreach (StaticGenerator generator in temp.Value.Generators)
|
||||||
{
|
{
|
||||||
generator.Prune();
|
generator.Prune();
|
||||||
}
|
}
|
||||||
temp.List.Remove(temp);
|
temp.List.Remove(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void separateLines()
|
private void separateLines()
|
||||||
{
|
{
|
||||||
LinkedListNode<LineDetails> current = _lines.First;
|
LinkedListNode<LineDetails> current = _lines.First;
|
||||||
while (current != _lines.Last)
|
while (current != _lines.Last)
|
||||||
{
|
{
|
||||||
List<StaticGenerator> generators = current.Value.Generators;
|
List<StaticGenerator> generators = current.Value.Generators;
|
||||||
StaticGenerator lastGenerator = generators[generators.Count - 1];
|
StaticGenerator lastGenerator = generators[generators.Count - 1];
|
||||||
lastGenerator.Value += Environment.NewLine;
|
lastGenerator.Value += Environment.NewLine;
|
||||||
current = current.Next;
|
current = current.Next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeEmptyGenerators()
|
private void removeEmptyGenerators()
|
||||||
{
|
{
|
||||||
LinkedListNode<LineDetails> current = _lines.First;
|
LinkedListNode<LineDetails> current = _lines.First;
|
||||||
while (current != null)
|
while (current != null)
|
||||||
{
|
{
|
||||||
foreach (StaticGenerator generator in current.Value.Generators)
|
foreach (StaticGenerator generator in current.Value.Generators)
|
||||||
{
|
{
|
||||||
if (generator.Value.Length == 0)
|
if (generator.Value.Length == 0)
|
||||||
{
|
{
|
||||||
generator.Prune();
|
generator.Prune();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = current.Next;
|
current = current.Next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class LineDetails
|
private sealed class LineDetails
|
||||||
{
|
{
|
||||||
public LineDetails()
|
public LineDetails()
|
||||||
{
|
{
|
||||||
Generators = new List<StaticGenerator>();
|
Generators = new List<StaticGenerator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasTag { get; set; }
|
public bool HasTag { get; set; }
|
||||||
|
|
||||||
public List<StaticGenerator> Generators { get; set; }
|
public List<StaticGenerator> Generators { get; set; }
|
||||||
|
|
||||||
public bool HasOutput { get; set; }
|
public bool HasOutput { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace mustache
|
namespace Mustache
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a tag that changes the scope to the object passed as an argument.
|
/// Defines a tag that changes the scope to the object passed as an argument.
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<ProjectGuid>{D71B378F-A4BA-4263-A4F0-07A49A0C528D}</ProjectGuid>
|
<ProjectGuid>{D71B378F-A4BA-4263-A4F0-07A49A0C528D}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>mustache</RootNamespace>
|
<RootNamespace>Mustache</RootNamespace>
|
||||||
<AssemblyName>mustache-sharp</AssemblyName>
|
<AssemblyName>mustache-sharp</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>$id$</id>
|
<id>$id$</id>
|
||||||
<version>$version$</version>
|
<version>$version$</version>
|
||||||
<title>$title$</title>
|
<title>$title$</title>
|
||||||
<authors>$author$</authors>
|
<authors>$author$</authors>
|
||||||
<owners>$author$</owners>
|
<owners>$author$</owners>
|
||||||
<projectUrl>http://github.com/jehugaleahsa/mustache-sharp</projectUrl>
|
<projectUrl>http://github.com/jehugaleahsa/mustache-sharp</projectUrl>
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
<description>$description$</description>
|
<description>$description$</description>
|
||||||
<releaseNotes>Initial commit</releaseNotes>
|
<copyright>Copyright 2013</copyright>
|
||||||
<copyright>Copyright 2013</copyright>
|
<tags>
|
||||||
<tags>
|
mustache handlebars.js text generation building template
|
||||||
mustache handlebars.js text generation building template
|
</tags>
|
||||||
</tags>
|
</metadata>
|
||||||
</metadata>
|
|
||||||
</package>
|
</package>
|
Loading…
Reference in New Issue