Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 5 commits
  • 8 files changed
  • 0 commit comments
  • 3 contributors
Commits on Apr 23, 2011
@activa Updated MonoTouch project file to include all new files 6839324
Commits on Oct 29, 2011
@rmboggs rmboggs Added the Comment TemplateTokenType and comment symbols to the Double…
…Curly, ProMesh, and Velocity Tokenizers.
a6fced1
@activa Merge pull request #2 from rmboggs/master
Comment Template Token
c15603d
Commits on Feb 27, 2012
@activa Merge pull request #3 from activa/master
Bug fix in date parsing
e531e5e
Commits on Mar 01, 2012
@activa JSON support for circular references f519372
View
9 Library/Json/JsonSerializer.cs
@@ -22,6 +22,7 @@ public class JsonSerializer
{
private readonly StringBuilder _output = new StringBuilder();
private readonly JsonDateFormat _dateFormat;
+ private readonly HashSet<object> _serializedObjects = new HashSet<object>();
public JsonSerializer()
{
@@ -107,6 +108,14 @@ private void WriteDate(DateTime date)
private void WriteObject(object obj)
{
+ if (_serializedObjects.Contains(obj))
+ {
+ WriteValue(null);
+ return;
+ }
+
+ _serializedObjects.Add(obj);
+
_output.Append('{');
bool pendingSeparator = false;
View
3  Library/Parser/TemplateParser/TemplateConfigs/DoubleCurly/DoubleCurlyTokenizer.cs
@@ -59,6 +59,7 @@ public DoubleCurlyTokenizer()
AddTokenMatcher(TemplateTokenType.ElseIf, new WrappedExpressionMatcher("{{", "elseif", "}}"), true);
AddTokenMatcher(TemplateTokenType.Else, new WrappedExpressionMatcher("{{", "else", "}}"),true);
AddTokenMatcher(TemplateTokenType.Expression, new WrappedExpressionMatcher("{{", "}}"));
+ AddTokenMatcher(TemplateTokenType.Comment, new WrappedExpressionMatcher("{#", "#}"), true);
}
}
-}
+}
View
4 Library/Parser/TemplateParser/TemplateConfigs/ProMesh/ProMeshTokenizer.cs
@@ -39,6 +39,7 @@ public ProMeshTokenizer()
AddTokenMatcher(TemplateTokenType.MacroCall, new WrappedExpressionMatcher("<!--{{", "call", "}}-->"));
AddTokenMatcher(TemplateTokenType.Statement, new WrappedExpressionMatcher(false, "<!--{{", "}}-->"));
AddTokenMatcher(TemplateTokenType.Expression, new WrappedExpressionMatcher(false, "{{", "}}"));
+ AddTokenMatcher(TemplateTokenType.Comment, new WrappedExpressionMatcher("<!--{#", "#}-->"), true);
AddTokenMatcher(TemplateTokenType.EndBlock, new WrappedExpressionMatcher(false, "<!--$[", "endfor", "]-->"));
AddTokenMatcher(TemplateTokenType.EndBlock, new WrappedExpressionMatcher(false, "<!--$[", "endif", "]-->"));
@@ -50,6 +51,7 @@ public ProMeshTokenizer()
AddTokenMatcher(TemplateTokenType.MacroCall, new WrappedExpressionMatcher("<!--$[", "call", "]-->"));
AddTokenMatcher(TemplateTokenType.Statement, new WrappedExpressionMatcher(false, "<!--$[", "]-->"));
AddTokenMatcher(TemplateTokenType.Expression, new WrappedExpressionMatcher(false, "$[", "]"));
+ AddTokenMatcher(TemplateTokenType.Comment, new WrappedExpressionMatcher("<!--[#", "#]-->"), true);
}
}
-}
+}
View
3  Library/Parser/TemplateParser/TemplateConfigs/Velocity/VelocityTokenizer.cs
@@ -42,6 +42,7 @@ public VelocityTokenizer()
AddTokenMatcher(TemplateTokenType.Statement, new WrappedExpressionMatcher("${#", "}"), true);
AddTokenMatcher(TemplateTokenType.Expression, new WrappedExpressionMatcher("${","}"));
AddTokenMatcher(TemplateTokenType.Expression, new DollarExpressionMatcher());
+ AddTokenMatcher(TemplateTokenType.Comment, new WrappedExpressionMatcher("#*", "*#"), true);
}
private class VelocityForEachMatcher : CompositeMatcher
@@ -89,4 +90,4 @@ protected override string TranslateToken(string originalToken, CompositeTokenPro
}
-}
+}
View
3  Library/Parser/TemplateParser/Tokenizer/TemplateTokenType.cs
@@ -30,6 +30,7 @@ namespace Vici.Core.Parser
{
public enum TemplateTokenType
{
+ Comment,
Expression,
Statement,
ForEach,
@@ -42,4 +43,4 @@ public enum TemplateTokenType
MacroDefinition,
MacroCall
}
-}
+}
View
3  Library/Scheduler/CyclicScheduler.cs
@@ -6,8 +6,7 @@ public class CyclicScheduler : Scheduler
{
public TimeSpan Interval { get; set; }
- public CyclicScheduler(string scheduleId, TimeSpan interval)
- : base(scheduleId)
+ public CyclicScheduler(string scheduleId, TimeSpan interval) : base(scheduleId)
{
Interval = interval;
}
View
2  Library/Vici.Core.MonoTouch.csproj
@@ -264,6 +264,8 @@
<Compile Include="Parser\ExpressionParser\Expression\ContainerClasses\IMethodDefinition.cs" />
<Compile Include="CompatibilityLayer.cs" />
<Compile Include="CoreExtensions.cs" />
+ <Compile Include="EasyConfig\FieldOrPropertyInfo.cs" />
+ <Compile Include="EasyConfig\FieldOrPropertyInfoExtensions.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
View
37 Tests/Json/JsonSeralizerTestFixture.cs
@@ -141,5 +141,42 @@ public void TestArrayInObject()
Assert.AreEqual("{\"Field1\":\"abc\",\"Field2\":[1,2,3]}", JsonSerializer.ToJson(new TestClass2()));
}
+ [Test]
+ public void TestCircularReferences()
+ {
+ json_ParentClass obj1 = new json_ParentClass();
+ json_ParentClass obj2 = new json_ParentClass();
+
+ obj1.Id = "A";
+ obj2.Id = "B";
+
+ obj1.Children = new List<json_ChildClass>()
+ {
+ new json_ChildClass
+ {
+ Id = "A1",
+ Parent = obj1,
+ Others = new List<json_ParentClass>() { obj1,obj2 }
+ }
+ };
+
+ string json = JsonSerializer.ToJson(obj1);
+
+ Assert.AreEqual("{\"Id\":\"A\",\"Children\":[{\"Id\":\"A1\",\"Parent\":null,\"Others\":[null,{\"Id\":\"B\",\"Children\":null}]}]}",json);
+
+ }
+
+ private class json_ParentClass
+ {
+ public string Id;
+ public List<json_ChildClass> Children;
+ }
+
+ private class json_ChildClass
+ {
+ public string Id;
+ public json_ParentClass Parent;
+ public List<json_ParentClass> Others;
+ }
}
}

No commit comments for this range

Something went wrong with that request. Please try again.