Commit Graph

36 Commits

Author SHA1 Message Date
Travis Parks 76a3f60a94 Treat DBNull as False in Conditions 2014-08-01 11:35:37 -04:00
Travis Parks 2bf2f0c25c Update assembly version for NuGet 2014-08-01 11:26:45 -04:00
Zbynek Zavadil 758f112836 KeyFoundEventArgs constructor fix
KeyFoundEventArgs constructor didn't set value leading to always
substituting with an empty string
2014-07-14 21:14:55 +02:00
Travis Parks 8135db68df Eliminate recursive calls in UpcastDictionary
I realized I had tail-end recursion, which could be easily eliminated.
Because of yield return, I think this greatly simplified the code.
2014-06-26 15:21:01 -04:00
Travis Parks f73814e3d9 Upcast Dictionary Improvements
I wanted to improve the predictability and the efficiency of the latest
UpcastDictionary code. I switched to a breadth-first search of
sub-types, filtering out duplicates.
2014-06-26 14:45:21 -04:00
Travis Parks 55ff1ef5de Even more powerful dictionary detection
There were some more cases where an IDictionary<string, T> was not being
detected by the UpcastDictionary.
2014-06-25 11:04:51 -04:00
Travis Parks 80824c4e4b Add mutex lock to PropertyDictionary
It was pointed out that since the PropertyDictionary is caching the
properties of types using a static dictionary, it must be made thread
safe.
2014-06-25 10:19:08 -04:00
Travis Parks 19a0710d49 Allow string and number arguments 2014-05-21 17:02:31 -04:00
Travis Parks 60f8294eb4 Allow for the preservation of newlines 2014-05-21 13:38:39 -04:00
Travis Parks 10304d811c Handle dictionaries with non-object values.
In cases where a Dictionary property had a non-object value type, the
dictionary couldn't be treated like an object. This code will wrap a
dictionary so its non-object values are upcast to objects.
2014-05-20 19:34:54 -04:00
Travis Parks 7bda253bab Handle properties and fields being replaced by derived classes.
I added code that will (correctly) chose the most derived property/field
when a conflict exists between the parent and child.

According to Microsoft, there is no guarantee of the order that members
will be returned, so I had to determine the members distance from the
object's type down the inheritance hierarchy and pick the closest.
2014-03-02 00:43:08 -05:00
Travis Parks 517e38a6db Support public fields for keys 2014-03-01 23:11:52 -05:00
Travis Parks 5cabfa4e9b Updated project version for NuGet 2013-10-30 15:42:07 -04:00
Travis Parks 6a272230af Support firing event when keys/variables used as arguments. 2013-10-30 15:39:38 -04:00
Travis Parks 6e74fa1fcc Support scoped variables
I have been slowly working toward supporting variables that can be
declared/updated during output generation. This code also cleans up the
code for searching within a scope.
2013-10-28 15:58:50 -04:00
Travis Parks f136dd61a5 Begin implementation of context scopes.
Instead of context data being a single object, it now supports the same
scoping rules as keys.
Now the #index tag is always available.
2013-08-16 23:36:06 -04:00
Travis Parks e2fd882ef1 Force newlines to be explicit
Since there weren't consistent rules for when to include newlines, I
decided to make an explicit tag (similar to HTML's <br /> tag). This can
have a dramatic impact on your existing code (unless it is just HTML).
2013-07-23 08:44:48 -04:00
Travis Parks 65b79062d6 Fix Bug with inline tags in compound tags
Whenever there was an inline tag in a compound tag, it would consume one
too many chunks.
2013-07-22 22:25:13 -04:00
Travis Parks d7a0ab3b38 Add support for index in each tags
It was requested that the current index could be accessed in the each
tag.
2013-07-20 12:06:38 -04:00
Travis Parks 3795a77354 Give more details for unknown tags 2013-07-18 12:04:12 -04:00
Travis Parks 22e0cb4c2a 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.
2013-05-03 08:44:57 -04:00
Travis Parks f07a80d5a1 Eliminate RegexOptions.Compiled
RegexOptions.Compiled does not seem to improve performance and actually
is a bottleneck in most cases. I am removing it for the time being. I
may add a flag to the FormatCompiler if it is needed in the future.
2013-05-01 10:48:25 -04:00
Travis Parks 11b73b696e Pop Context When Exiting Tag
I was not removing context when I was leaving a tag. This caused the
context to grow indefinitely, which is not a valid representation of
where the placeholder was located in the template.
2013-04-25 08:46:03 -04:00
Travis Parks 42463a888f Provide context when placeholders found.
It could be useful to know the context when discovering a placeholder.
I also renamed MissingKeyEventArgs to KeyNotFoundEventArgs.
I created a new event KeyFoundEventArgs.
2013-04-24 21:21:00 -04:00
Travis Parks 20dcfc059d Fire event whenever a placeholder is found.
It could be useful to track which placeholders were found when parsing
the template. This event will allow keys to be mapped to different keys,
and support changing alignment and formatting.
2013-04-24 08:58:19 -04:00
Travis Parks a6c7933bab Provide more details when keys not found.
A request was made to provide the original key as well as the member
that was not found. In compound keys {{Customer.Address.ZipCode}}, any
of the names could be invalid, but knowing the fully-qualified name is
useful for error handling.

I also detected a bug where the code wasn't handling the case that a
sub-key didn't exist. This needs to be handled using the KeyNotFound
event.
2013-04-19 08:56:21 -04:00
Travis Parks ac09c8fc38 Support Missing Key Handlers
A request was made to allow missing keys to be handled in a custom
manner. I created an event that can be registered with the Generator
instances.

I also fixed a deployment issue causing debug versions of the library to
be packaged and released to NuGet. This should boost performance
considerably.
2013-04-18 19:27:09 -04:00
Travis Parks fe54d9522b Default the Scope and Writer for Nested Contexts
I forgot to default the KeyScope and TextWriter to the parent tag's
scope and writer if they are not provided.
2013-01-16 16:06:35 -05:00
Travis Parks 790f856b44 Optimized text generation.
The way the code was implemented before, each block of text was
generating a string which was then being added to a StringBuilder. This
only improved performance within a block itself. Needing to then copy
the results of that builder into the parent tag's builder was wasteful.
Now, a single TextWriter is used for all tags. If a block needs to be
processed after-the-fact, the tag can indicate that it wants to provide
a new text writer and that it wants to consolidate the text.
2013-01-16 15:10:25 -05:00
Travis Parks f848d63d9a Handle Unknown Tags
I added code to detect unknown tags and throw an exception. I also
provided a default implementation so tags are in the global scope by
default.
2013-01-12 20:22:31 -05:00
Travis Parks a64d3a73fc Added NuGet deployment items. 2013-01-12 15:18:54 -05:00
Travis Parks 7d75c7a2e4 Implemented better custom tag handling.
I needed to make it easier to handle scopes and define custom tags,
including context-sensitive tags.
2013-01-12 14:53:12 -05:00
Travis Parks 49f9478c79 Added support for trimming unnecessary newlines. 2013-01-09 21:58:45 -05:00
Travis Parks 0b84ca8877 Made progress implementing the object model, including all of the built-in tags. 2013-01-09 21:17:45 -05:00
Travis Parks f8628aaf86 Implement custom tags.
This is the first step towards supporting custom tags. There are
wrinkles I need to work out, since I'm not 100% sure what the finished
code will look like.
2013-01-08 21:33:53 -05:00
Travis Parks 827faa5d6e Initial Commit
This is the code almost verbatim from the NList project. This project is
due for a major overhaul, but I don't know the order I will be breaking
out NList in the upcoming weeks.
2013-01-01 21:01:34 -05:00