Skip to content

Commit

Permalink
Fluent Every.Day, Version Bump and doc fluent update
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiasnordqvist committed Mar 28, 2016
1 parent 53d96eb commit dd053f0
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
27 changes: 27 additions & 0 deletions GoldenFox.Fluent/DayBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using GoldenFox.Internal;
using GoldenFox.Internal.Operators.Intervals;

namespace GoldenFox.Fluent
{
public class DayBuilder : Every
{
private Timestamp _time = "00:00";

public DayBuilder At(Timestamp timestamp)
{
_time = timestamp;
return this;
}

internal override OperatorBuilder InternalBuild()
{
var dayInWeek = new Day(_time);
return new OperatorBuilder(
x =>
{
dayInWeek.AddConstraints(x);
return dayInWeek;
});
}
}
}
5 changes: 5 additions & 0 deletions GoldenFox.Fluent/Every.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public static WeekBuilder Sunday()
return new WeekBuilder(7);
}

public static DayBuilder Day()
{
return new DayBuilder();
}

public static HourBuilder Hour()
{
var hourBuilder = new HourBuilder();
Expand Down
1 change: 1 addition & 0 deletions GoldenFox.Fluent/GoldenFox.Fluent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<ItemGroup>
<Compile Include="BetweenConstraint.cs" />
<Compile Include="ConstraintExtensions.cs" />
<Compile Include="DayBuilder.cs" />
<Compile Include="Every.cs" />
<Compile Include="First.cs" />
<Compile Include="FromConstraint.cs" />
Expand Down
4 changes: 2 additions & 2 deletions GoldenFox/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
[assembly: AssemblyCopyright("Copyright © Mattias Nordqvist")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("2.1.0")]
[assembly: AssemblyFileVersion("2.1.0")]
[assembly: AssemblyVersion("2.2.0")]
[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyProduct("Golden Fox")]
[assembly: AssemblyCompany("Mattias Nordqvist")]

Expand Down
4 changes: 1 addition & 3 deletions ParseConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
using System.Linq;

using GoldenFox;
using GoldenFox.Fluent;
using GoldenFox.Internal;
using GoldenFox.Internal.Operators.Intervals;

namespace TestConsole
{
Expand All @@ -16,6 +13,7 @@ public static void Main(string[] args)
{
var line = Console.ReadLine();
Console.WriteLine("Next occurence: ");

var result = new Fox(line, DateTime.Now).First();
Console.WriteLine(result);
}
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ Can be added to any interval. Defines a starting point for the interval. `every
### Until
This constraint is a little special. You use it just like you use `From`. `every day until 2020-01-01`. So what will happen the day we pass in a date higher than `2020-01-01`? Well. There´s no sensible next occurence really, so we will throw an `InvalidOperationException`. Would we get an exception if we passed in `2010-01-01`? Remeber, constraints are inclusive, so no, we wouldn't.

## Fluent Api
In version 2.2.0, I added a fluent version of the api. You can explore it yourself by start typing any of these lines:
```csharp

using GoldenFox.Fluent

Every. // use intellisense from here
1.St(). // use intellisense from here
First(). // use intellisense from here
2.Nd(). // use intellisense from here
Last(). // use intellisense from here
```

## Contribute

Besides being used in production code in some of my projects, this is my pet project for learning how to create DSLs. All ideas on new features and how to improve the code are welcome.
Expand Down

0 comments on commit dd053f0

Please sign in to comment.