Skip to content
Browse files

- Fixed support for FW2: Added OrderBy, removed JSON support.

  • Loading branch information...
1 parent 36d9a1d commit 586f31049ae1f26a7667f780bab476e9a9d7a19b @adrianaisemberg committed Dec 20, 2011
View
6 CLAP/CLAP.csproj
@@ -10,7 +10,8 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CLAP</RootNamespace>
<AssemblyName>CLAP</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion Condition=" '$(Configuration)' == 'ReleaseFW2' ">v2.0</TargetFrameworkVersion>
+ <TargetFrameworkVersion Condition=" '$(Configuration)' != 'ReleaseFW2' ">v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
@@ -70,11 +71,12 @@
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
<DocumentationFile>bin\ReleaseFW2\CLAP.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
+ <DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
- <Reference Include="System.Web.Extensions" />
+ <Reference Condition=" '$(Configuration)' != 'ReleaseFW2'" Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
View
24 CLAP/FW2Stuff.cs
@@ -9,8 +9,13 @@ namespace CLAP
#region Delegates
public delegate void Action();
+ public delegate void Action<T>(T arg);
+ public delegate void Action<T1, T2>(T1 arg1, T2 arg2);
+ public delegate TResult Func<TResult>();
public delegate TResult Func<T, TResult>(T arg);
+ public delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2);
+ public delegate TResult Func<T1, T2, T3, TResult>(T1 arg1, T2 arg2, T3 arg3);
#endregion Delegates
@@ -162,6 +167,25 @@ public static T[] ToArray<T>(this IEnumerable<T> collection)
return arr;
}
+ public static IEnumerable<TItem> OrderBy<TItem, TResult>(
+ this IEnumerable<TItem> collection,
+ Func<TItem, TResult> func)
+ {
+ var items = collection.ToArray();
+ var keysList = new List<TResult>();
+
+ foreach (var item in collection)
+ {
+ keysList.Add(func(item));
+ }
+
+ var keys = keysList.ToArray();
+
+ Array.Sort(keys, items);
+
+ return items;
+ }
+
public static IEnumerable<T> Skip<T>(this IEnumerable<T> collection, int count)
{
foreach (var item in collection)
View
5 CLAP/HelpGenerator.cs
@@ -1,10 +1,13 @@
using System;
-using System.Linq;
using System.Reflection;
using System.Text;
using System.Diagnostics;
using System.Collections;
+#if !FW2
+using System.Linq;
+#endif
+
namespace CLAP
{
internal static class HelpGenerator
View
3 CLAP/MultiParser.cs
@@ -1,6 +1,9 @@
using System;
using System.Diagnostics;
+
+#if !FW2
using System.Linq;
+#endif
namespace CLAP
{
View
3 CLAP/ParametersExpressionValidator.cs
@@ -1,5 +1,8 @@
using System.Data;
+
+#if !FW2
using System.Linq;
+#endif
namespace CLAP
{
View
3 CLAP/Parser.cs
@@ -1,6 +1,9 @@
using System;
using System.Diagnostics;
+
+#if !FW2
using System.Linq;
+#endif
namespace CLAP
{
View
4 CLAP/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("3.2.0.0")]
-[assembly: AssemblyFileVersion("3.2.0.0")]
+[assembly: AssemblyVersion("3.4.0.0")]
+[assembly: AssemblyFileVersion("3.4.0.0")]
View
16 CLAP/Serialization.cs
@@ -1,8 +1,11 @@
using System;
using System.IO;
-using System.Web.Script.Serialization;
using System.Xml.Serialization;
+#if !FW2
+using System.Web.Script.Serialization;
+#endif
+
namespace CLAP
{
internal static class Serialization
@@ -20,6 +23,12 @@ public static bool Deserialize(string str, Type type, ref object obj)
return true;
}
+#if FW2
+ else
+ {
+ return false;
+ }
+#else
else if (str.StartsWith(new[] { "{", "[" }))
{
obj = DeserializeJson(str, type);
@@ -28,9 +37,11 @@ public static bool Deserialize(string str, Type type, ref object obj)
}
return false;
+#endif
}
- public static object DeserializeJson(string json, Type type)
+#if !FW2
+ private static object DeserializeJson(string json, Type type)
{
var serializer = new JavaScriptSerializer();
@@ -42,6 +53,7 @@ public static object DeserializeJson(string json, Type type)
return obj;
}
+#endif
public static object DeserializeXml(string xml, Type type)
{
View
5 CLAP/TypeValidator.cs
@@ -1,7 +1,10 @@
using System.Diagnostics;
-using System.Linq;
using System.Reflection;
+#if !FW2
+using System.Linq;
+#endif
+
namespace CLAP
{
internal static class TypeValidator
View
5 CLAP/ValuesFactory.cs
@@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Reflection;
using CLAP.Interception;
using System.ComponentModel;
+#if !FW2
+using System.Linq;
+#endif
+
namespace CLAP
{
internal static class ValuesFactory
View
2 ConsoleTest/Program.cs
@@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
+using System.Reflection;
using System.Threading;
using CLAP;
using CLAP.Validation;
-using System.Reflection;
namespace ConsoleTest
{
View
2 Tests/MultiParserTests.cs
@@ -1,8 +1,8 @@
using System;
+using System.Linq;
using System.Reflection;
using CLAP;
using NUnit.Framework;
-using System.Linq;
namespace Tests
{
View
18 Tests/Tests.cs
@@ -2194,15 +2194,15 @@ public void PostVerbExecution_MismatchArgs_Exception_2()
Parser.Run<Sample_59>(new[] { "" });
}
- [Test, Ignore]
- public void Parameter_NameAsAlias()
- {
- Parser.Run<Sample_60>(new[]
- {
- "foo",
- "-c=5",
- });
- }
+ //[Test, Ignore]
+ //public void Parameter_NameAsAlias()
+ //{
+ // Parser.Run<Sample_60>(new[]
+ // {
+ // "foo",
+ // "-c=5",
+ // });
+ //}
[Test]
public void Parameter_NullableInt()
View
2 Tests/Tests.csproj
@@ -20,6 +20,7 @@
<OldToolsVersion>4.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@@ -32,7 +33,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>

0 comments on commit 586f310

Please sign in to comment.
Something went wrong with that request. Please try again.