Permalink
Browse files

- adding Silverlight support

  • Loading branch information...
1 parent ae20ebc commit 3e8b23bf50c968b80ac6c22a5be0d11e6de74a8b @mckamey mckamey committed Aug 7, 2010
View
@@ -4,6 +4,7 @@ PUSHD "%~dp0"
SET MSBuild=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
IF NOT EXIST "%MSBuild%" (
ECHO Installation of .NET Framework 4.0 is required to build this project, including .NET v2.0 and v3.5 releases
+ ECHO NOTE: Visual Studio is NOT needed to successfully build this project.
ECHO http://www.microsoft.com/downloads/details.aspx?FamilyID=0a391abd-25c1-4fc0-919f-b21f31ab88b7
START /d "~\iexplore.exe" http://www.microsoft.com/downloads/details.aspx?FamilyID=0a391abd-25c1-4fc0-919f-b21f31ab88b7
EXIT /b 1
@@ -16,11 +17,22 @@ IF NOT EXIST "keys\JsonFx_Key.pfx" (
SET Configuration=Signed
)
+ECHO.
ECHO Building unit test pass...
"%MSBuild%" JsonFx.sln /target:rebuild /property:TargetFrameworkVersion=v4.0;Configuration=Release;RunTests=True
-ECHO Building specific releases for v2.0, v3.5 and v4.0...
+ECHO.
+ECHO Building specific releases for .NET Framework v2.0, v3.5 and v4.0...
FOR %%i IN (v2.0 v3.5 v4.0) DO "%MSBuild%" src/JsonFx/JsonFx.csproj /target:rebuild /property:TargetFrameworkVersion=%%i;Configuration=%Configuration%
+ECHO.
+ECHO Building specific release for Silverlight v4.0...
+IF EXIST "%SystemRoot%\Program Files\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets" (
+ "%MSBuild%" src/JsonFx/JsonFx.csproj /target:rebuild /property:TargetFrameworkVersion=v4.0;TargetFrameworkIdentifier=Silverlight;Configuration=%Configuration%
+)
+REM IF EXIST "%SystemRoot%\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets" (
+ "%MSBuild%" src/JsonFx/JsonFx.csproj /target:rebuild /property:TargetFrameworkVersion=v4.0;TargetFrameworkIdentifier=Silverlight;Configuration=%Configuration%
+REM )
+
:END
POPD
View
@@ -0,0 +1,8 @@
+@ECHO off
+
+ECHO Building...
+
+SET LOG=%~dp0build/Build.log
+
+CALL "%~dp0Build.bat" %* > "%LOG%"
+START notepad.exe "%LOG%"
@@ -431,6 +431,38 @@ public static SetterDelegate GetFieldSetter(FieldInfo fieldInfo)
#region Method Generators
+ public static ProxyDelegate GetMethodProxy(Type declaringType, string methodName, params Type[] argTypes)
+ {
+ if (declaringType == null)
+ {
+ throw new ArgumentNullException("declaringType");
+ }
+ if (String.IsNullOrEmpty(methodName))
+ {
+ throw new ArgumentNullException("methodName");
+ }
+
+
+ MethodInfo methodInfo;
+ if (argTypes.Length > 0)
+ {
+ methodInfo = declaringType.GetMethod(
+ methodName,
+ BindingFlags.Instance|BindingFlags.Static|BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.FlattenHierarchy,
+ null,
+ argTypes,
+ null);
+ }
+ else
+ {
+ methodInfo = declaringType.GetMethod(
+ methodName,
+ BindingFlags.Instance|BindingFlags.Static|BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.FlattenHierarchy);
+ }
+
+ return DynamicMethodGenerator.GetMethodProxy(methodInfo);
+ }
+
/// <summary>
/// Creates a proxy delegate accepting a target instance and corresponding arguments
/// </summary>
@@ -336,10 +336,7 @@ private object ConsumeArray(IStream<Token<CommonTokenType>> tokens, Type arrayTy
// if itemType was specified by caller, then isn't just a hint
bool isItemTypeHint = (itemType == null);
- // using ArrayList since has .ToArray(Type) method
- // cannot create List<T> at runtime
- ArrayList array = new ArrayList();
-
+ IList array = new List<object>();
while (!tokens.IsCompleted)
{
token = tokens.Peek();
@@ -358,7 +355,7 @@ private object ConsumeArray(IStream<Token<CommonTokenType>> tokens, Type arrayTy
{
// end of the array loop
tokens.Pop();
- return this.Coercion.CoerceArrayList(arrayType, itemType, array);
+ return this.Coercion.CoerceCollection(arrayType, itemType, array);
}
case CommonTokenType.ObjectBegin:
{
@@ -49,19 +49,23 @@ namespace JsonFx.Common.Filters
/// </remarks>
public class MSAjaxDateFilter : CommonFilter<DateTime>
{
- #region Constant
+ #region Constants
private static readonly DateTime EcmaScriptEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
private static readonly long MinValueMilliseconds = -62135596800000L;
private static readonly long MaxValueMilliseconds = 253402300800000L;
private const string MSAjaxDatePattern = @"^\\/Date\(([+\-]?\d+?)\)\\/$";
- private static readonly Regex MSAjaxDateRegex = new Regex(MSAjaxDatePattern, RegexOptions.Compiled|RegexOptions.CultureInvariant|RegexOptions.ECMAScript);
+ private static readonly Regex MSAjaxDateRegex = new Regex(MSAjaxDatePattern,
+#if !SILVERLIGHT
+ RegexOptions.Compiled|
+#endif
+ RegexOptions.CultureInvariant|RegexOptions.ECMAScript);
private const string MSAjaxDatePrefix = @"\/Date(";
private const string MSAjaxDateSuffix = @")\/";
- #endregion Constant
+ #endregion Constants
#region IDataFilter<DataTokenType,DateTime> Members
@@ -37,6 +37,12 @@ THE SOFTWARE.
using JsonFx.Markup;
using JsonFx.Serialization;
+#if SILVERLIGHT
+using CanonicalList=System.Collections.Generic.Dictionary<JsonFx.Serialization.DataName, JsonFx.Serialization.Token<JsonFx.Markup.MarkupTokenType>>;
+#else
+using CanonicalList=System.Collections.Generic.SortedList<JsonFx.Serialization.DataName, JsonFx.Serialization.Token<JsonFx.Markup.MarkupTokenType>>;
+#endif
+
namespace JsonFx.Html
{
/// <summary>
@@ -216,7 +222,7 @@ public void Format(TextWriter writer, IEnumerable<Token<MarkupTokenType>> tokens
if (attributes == null)
{
attributes = this.canonicalForm ?
- (IDictionary<DataName, Token<MarkupTokenType>>)new SortedList<DataName, Token<MarkupTokenType>>() :
+ (IDictionary<DataName, Token<MarkupTokenType>>)new CanonicalList() :
(IDictionary<DataName, Token<MarkupTokenType>>)new Dictionary<DataName, Token<MarkupTokenType>>();
}
DataName attrName = token.Name;
@@ -527,7 +533,7 @@ private void WriteLocalName(TextWriter writer, string value)
// use XmlSerializer-hex-style encoding of UTF-16
writer.Write("_x");
- writer.Write(Char.ConvertToUtf32(value, i).ToString("X4"));
+ writer.Write(ConvertToUtf32(value, i).ToString("X4"));
writer.Write("_");
}
@@ -600,7 +606,7 @@ private void WriteCharData(TextWriter writer, string value)
((ch >= 0xFDD0) && (ch <= 0xFDEF)))
{
// encode all control chars except CRLF/Tab: http://www.w3.org/TR/xml/#charsets
- int utf16 = Char.ConvertToUtf32(value, i);
+ int utf16 = ConvertToUtf32(value, i);
entity = String.Concat("&#x", utf16.ToString("X", CultureInfo.InvariantCulture), ';');
break;
}
@@ -700,7 +706,7 @@ private void WriteAttributeValue(TextWriter writer, string value)
((ch >= 0xFDD0) && (ch <= 0xFDEF)))
{
// encode all control chars: http://www.w3.org/TR/xml/#charsets
- int utf16 = Char.ConvertToUtf32(value, i);
+ int utf16 = ConvertToUtf32(value, i);
entity = String.Concat("&#x", utf16.ToString("X", CultureInfo.InvariantCulture), ';');
break;
}
@@ -739,5 +745,18 @@ private void WriteUnparsedBlock(TextWriter writer, string name, string value)
}
#endregion Write Methods
+
+ #region Utility Methods
+
+ private static int ConvertToUtf32(string value, int i)
+ {
+#if SILVERLIGHT
+ return (int)value[i];
+#else
+ return Char.ConvertToUtf32(value, i);
+#endif
+ }
+
+ #endregion Utility Methods
}
}
Oops, something went wrong.

0 comments on commit 3e8b23b

Please sign in to comment.