Skip to content
This repository has been archived by the owner on Dec 24, 2022. It is now read-only.

Commit

Permalink
Added support for XBOX
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDunn committed Aug 27, 2011
1 parent 6a68495 commit a2ddfbb
Show file tree
Hide file tree
Showing 16 changed files with 355 additions and 47 deletions.
34 changes: 34 additions & 0 deletions src/ServiceStack.Text.XBox360/Properties/AssemblyInfo.cs
@@ -0,0 +1,34 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ServiceStack.Text.XBox360")]
[assembly: AssemblyProduct("ServiceStack.Text.XBox360")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. Only Windows
// assemblies support COM.
[assembly: ComVisible(false)]

// On Windows, the following GUID is for the ID of the typelib if this
// project is exposed to COM. On other platforms, it unique identifies the
// title storage container when deploying this assembly to the device.
[assembly: Guid("bec96c96-54be-440b-a791-2c0e1c12d6f7")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
78 changes: 78 additions & 0 deletions src/ServiceStack.Text.XBox360/ServiceStack.Text.XBox360.csproj
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{E2B0C358-6CC5-4D15-AD73-41730FBF5530}</ProjectGuid>
<ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">Xbox 360</Platform>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ServiceStack.Text.XBox360</RootNamespace>
<AssemblyName>ServiceStack.Text.XBox360</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
<XnaPlatform>Xbox 360</XnaPlatform>
<XnaProfile>HiDef</XnaProfile>
<XnaCrossPlatformGroupID>0ed135ea-1216-457e-bc3e-9a191a60dafa</XnaCrossPlatformGroupID>
<XnaOutputType>Library</XnaOutputType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Xbox 360' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Xbox 360\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;XBOX;XBOX360</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
<UseVSHostingProcess>false</UseVSHostingProcess>
<XnaCompressContent>true</XnaCompressContent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Xbox 360' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Xbox 360\Release</OutputPath>
<DefineConstants>TRACE;XBOX;XBOX360</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
<UseVSHostingProcess>false</UseVSHostingProcess>
<XnaCompressContent>true</XnaCompressContent>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Xna.Framework" />
<Reference Include="Microsoft.Xna.Framework.Game" />
<Reference Include="Microsoft.Xna.Framework.Graphics" />
<Reference Include="Microsoft.Xna.Framework.GamerServices" />
<Reference Include="Microsoft.Xna.Framework.Xact" />
<Reference Include="Microsoft.Xna.Framework.Video" />
<Reference Include="Microsoft.Xna.Framework.Avatar" />
<Reference Include="Microsoft.Xna.Framework.Net" />
<Reference Include="Microsoft.Xna.Framework.Storage" />
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Net" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
49 changes: 44 additions & 5 deletions src/ServiceStack.Text.sln
Expand Up @@ -11,26 +11,68 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Text", "Servic
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Text.Tests", "..\tests\ServiceStack.Text.Tests\ServiceStack.Text.Tests.csproj", "{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Text.XBox360", "ServiceStack.Text\ServiceStack.Text.XBox360.csproj", "{E2B0C358-6CC5-4D15-AD73-41730FBF5530}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Xbox 360 = Debug|Xbox 360
MonoTouch|Any CPU = MonoTouch|Any CPU
MonoTouch|Mixed Platforms = MonoTouch|Mixed Platforms
MonoTouch|Xbox 360 = MonoTouch|Xbox 360
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Xbox 360 = Release|Xbox 360
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Debug|Xbox 360.ActiveCfg = Debug|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.MonoTouch|Any CPU.ActiveCfg = MonoTouch|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.MonoTouch|Any CPU.Build.0 = MonoTouch|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.MonoTouch|Mixed Platforms.ActiveCfg = MonoTouch|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.MonoTouch|Mixed Platforms.Build.0 = MonoTouch|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.MonoTouch|Xbox 360.ActiveCfg = MonoTouch|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Release|Any CPU.Build.0 = Release|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Release|Xbox 360.ActiveCfg = Release|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.Debug|Xbox 360.ActiveCfg = Debug|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.MonoTouch|Any CPU.ActiveCfg = MonoTouch|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.MonoTouch|Mixed Platforms.ActiveCfg = MonoTouch|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.MonoTouch|Mixed Platforms.Build.0 = MonoTouch|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.MonoTouch|Xbox 360.ActiveCfg = MonoTouch|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.Release|Any CPU.Build.0 = Release|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{9770BD40-AA3B-4785-B5E0-F4C470F9F14E}.Release|Xbox 360.ActiveCfg = Release|Any CPU
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.Debug|Any CPU.ActiveCfg = Debug|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.Debug|Mixed Platforms.ActiveCfg = Debug|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.Debug|Mixed Platforms.Build.0 = Debug|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.Debug|Xbox 360.ActiveCfg = Debug|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.Debug|Xbox 360.Build.0 = Debug|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.MonoTouch|Any CPU.ActiveCfg = Release|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.MonoTouch|Mixed Platforms.ActiveCfg = Release|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.MonoTouch|Mixed Platforms.Build.0 = Release|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.MonoTouch|Xbox 360.ActiveCfg = Release|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.MonoTouch|Xbox 360.Build.0 = Release|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.Release|Any CPU.ActiveCfg = Release|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.Release|Mixed Platforms.ActiveCfg = Release|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.Release|Mixed Platforms.Build.0 = Release|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.Release|Xbox 360.ActiveCfg = Release|Xbox 360
{E2B0C358-6CC5-4D15-AD73-41730FBF5530}.Release|Xbox 360.Build.0 = Release|Xbox 360
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = ServiceStack.Text\ServiceStack.Text.csproj
Expand All @@ -42,7 +84,4 @@ Global
$2.Text =
$2.IncludeInNewFiles = True
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file modified src/ServiceStack.Text.suo
Binary file not shown.
8 changes: 8 additions & 0 deletions src/ServiceStack.Text/AssemblyUtils.cs
Expand Up @@ -15,6 +15,7 @@ public class AssemblyUtils
private const string ExeExt = "dll";
private const char UriSeperator = '/';

#if !XBOX
/// <summary>
/// Find the type from the name supplied
/// </summary>
Expand All @@ -32,7 +33,9 @@ public static Type FindType(string typeName)
return FindTypeFromLoadedAssemblies(typeDef.TypeName);
}
}
#endif

#if !XBOX
/// <summary>
/// Find type if it exists
/// </summary>
Expand Down Expand Up @@ -60,7 +63,9 @@ public static Type FindType(string typeName, string assemblyName)
}
return assembly != null ? assembly.GetType(typeName) : null;
}
#endif

#if !XBOX
public static Type FindTypeFromLoadedAssemblies(string typeName)
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
Expand All @@ -73,12 +78,14 @@ public static Type FindTypeFromLoadedAssemblies(string typeName)
}
return null;
}
#endif

private static Assembly LoadAssembly(string assemblyPath)
{
return Assembly.LoadFrom(assemblyPath);
}

#if !XBOX
public static string GetAssemblyBinPath(Assembly assembly)
{
var binPathPos = assembly.CodeBase.LastIndexOf(UriSeperator);
Expand All @@ -89,5 +96,6 @@ public static string GetAssemblyBinPath(Assembly assembly)
}
return assemblyPath;
}
#endif
}
}
2 changes: 2 additions & 0 deletions src/ServiceStack.Text/Common/DeserializeCollection.cs
Expand Up @@ -73,8 +73,10 @@ private static ICollection<T> CreateAndPopulate<T>(Type ofCollectionType, T[] wi
if (ofCollectionType == null) return new List<T>(withItems);

var genericTypeDefinition = ofCollectionType.GetGenericTypeDefinition();
#if !XBOX
if (genericTypeDefinition == typeof(HashSet<T>))
return new HashSet<T>(withItems);
#endif
if (genericTypeDefinition == typeof(LinkedList<T>))
return new LinkedList<T>(withItems);

Expand Down
8 changes: 5 additions & 3 deletions src/ServiceStack.Text/Common/DeserializeType.cs
Expand Up @@ -10,12 +10,14 @@
// Licensed under the same terms of ServiceStack: new BSD license.
//

#if !XBOX
using System.Linq.Expressions ;
#endif

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;

namespace ServiceStack.Text.Common
{
Expand Down Expand Up @@ -103,7 +105,7 @@ public static SetPropertyDelegate GetSetPropertyMethod(Type type, PropertyInfo p
var setMethodInfo = propertyInfo.GetSetMethod(true);
if (setMethodInfo == null) return null;

#if SILVERLIGHT || MONOTOUCH
#if SILVERLIGHT || MONOTOUCH || XBOX
return (instance, value) => setMethodInfo.Invoke(instance, new[] {value});
#else
var oInstanceParam = Expression.Parameter(typeof(object), "oInstanceParam");
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceStack.Text/Common/StaticParseMethod.cs
Expand Up @@ -47,7 +47,7 @@ public static ParseStringDelegate GetParseFn()
{
parseDelegate = (ParseDelegate)Delegate.CreateDelegate(typeof(ParseDelegate), parseMethodInfo);
}
catch (ArgumentException bindingException)
catch ( ArgumentException )
{
//Try wrapping strongly-typed return with wrapper fn.
var typedParseDelegate = (Func<string,T>)Delegate.CreateDelegate(typeof(Func<string,T>), parseMethodInfo);
Expand Down
4 changes: 2 additions & 2 deletions src/ServiceStack.Text/Common/WriteType.cs
Expand Up @@ -12,9 +12,9 @@

using System;
using System.IO;
using System.Linq;
using ServiceStack.Text.Json;
using ServiceStack.Text.Reflection;
using ServiceStack.Text.Reflection ;


namespace ServiceStack.Text.Common
{
Expand Down
28 changes: 14 additions & 14 deletions src/ServiceStack.Text/Reflection/StaticAccessors.cs
Expand Up @@ -9,38 +9,35 @@
//
// Licensed under the same terms of ServiceStack: new BSD license.
//

using System;
using System.Linq.Expressions;
using System.Reflection;

#if !XBOX
using System.Linq.Expressions ;
#endif
namespace ServiceStack.Text.Reflection
{
public static class StaticAccessors
{
public static Func<object, object> GetValueGetter(this PropertyInfo propertyInfo, Type type)
{
//if (type != propertyInfo.DeclaringType)
//{
// throw new ArgumentException();
//}
#if SILVERLIGHT || MONOTOUCH || XBOX
var getMethodInfo = propertyInfo.GetGetMethod();
if (getMethodInfo == null) return null;
return x => getMethodInfo.Invoke(x, new object[0]);
#else

var instance = Expression.Parameter(typeof(object), "i");
var convertInstance = Expression.TypeAs(instance, propertyInfo.DeclaringType);
var property = Expression.Property(convertInstance, propertyInfo);
var convertProperty = Expression.TypeAs(property, typeof(object));
return Expression.Lambda<Func<object, object>>(convertProperty, instance).Compile();
#endif
}

public static Func<T, object> GetValueGetter<T>(this PropertyInfo propertyInfo)
{
//Not true for interface types
//if (typeof(T) != propertyInfo.DeclaringType)
//{
// throw new ArgumentException();
//}

#if SILVERLIGHT || MONOTOUCH
#if SILVERLIGHT || MONOTOUCH || XBOX
var getMethodInfo = propertyInfo.GetGetMethod();
if (getMethodInfo == null) return null;
return x => getMethodInfo.Invoke(x, new object[0]);
Expand All @@ -52,6 +49,7 @@ public static class StaticAccessors
#endif
}

#if !XBOX
public static Action<T, object> GetValueSetter<T>(this PropertyInfo propertyInfo)
{
if (typeof(T) != propertyInfo.DeclaringType)
Expand All @@ -71,6 +69,8 @@ public static class StaticAccessors
setterCall, instance, argument
).Compile();
}
#endif

}
}
}

0 comments on commit a2ddfbb

Please sign in to comment.