Permalink
Browse files

Silverlight fixes and test project

  • Loading branch information...
1 parent b4746ba commit 0a7d817c07019d9ae7519b75c32cbd5c0a9cfe97 @MrBretticus MrBretticus committed Dec 22, 2011
View
@@ -17,6 +17,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestfulieClientTests", "Res
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestfulieSilverlightClient", "RestfulieSilverlightClient\RestfulieSilverlightClient.csproj", "{7051A42C-A5AB-448E-ABEA-1DE47C2454C9}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestfulieSilverlightClientTest", "RestfulieSilverlightClientTest\RestfulieSilverlightClientTest.csproj", "{EB9484F1-7C0D-4C70-815C-B60549C53588}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestfulieSilverlightClientTest.Web", "RestfulieSilverlightClientTest.Web\RestfulieSilverlightClientTest.Web.csproj", "{8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}"
+EndProject
Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = RestfulieClient.vsmdi
@@ -60,6 +64,26 @@ Global
{7051A42C-A5AB-448E-ABEA-1DE47C2454C9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{7051A42C-A5AB-448E-ABEA-1DE47C2454C9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7051A42C-A5AB-448E-ABEA-1DE47C2454C9}.Release|x86.ActiveCfg = Release|Any CPU
+ {EB9484F1-7C0D-4C70-815C-B60549C53588}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EB9484F1-7C0D-4C70-815C-B60549C53588}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EB9484F1-7C0D-4C70-815C-B60549C53588}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {EB9484F1-7C0D-4C70-815C-B60549C53588}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {EB9484F1-7C0D-4C70-815C-B60549C53588}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {EB9484F1-7C0D-4C70-815C-B60549C53588}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EB9484F1-7C0D-4C70-815C-B60549C53588}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EB9484F1-7C0D-4C70-815C-B60549C53588}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {EB9484F1-7C0D-4C70-815C-B60549C53588}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {EB9484F1-7C0D-4C70-815C-B60549C53588}.Release|x86.ActiveCfg = Release|Any CPU
+ {8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -117,7 +117,7 @@ public class DefaultRequestDispatcher : IRequestDispatcher
}
catch (Exception ex)
{
- throw new ArgumentException(string.Format("An error occurred while connecting to the resource in url {0} with message {1}.", uri, ex.Message), ex);
+ throw new ArgumentException(string.Format("An error occurred while connecting to the resource in url {0} with message {1}", uri, ex.Message), ex);
}
}
}
@@ -36,13 +36,24 @@ public class EntryPointService : IRemoteResourceService
_dispatcher = dispatcher;
}
+ private IResource CreateResource(string contentType, HttpRemoteResponse response) {
+ if (contentType.IndexOf("application/xml", StringComparison.OrdinalIgnoreCase) > -1 ||
+ contentType.IndexOf("text/xml", StringComparison.OrdinalIgnoreCase) > -1)
+ return new DynamicXmlResource(response, this);
+
+ return null;
+ }
+
private IResource ParseResponse(HttpRemoteResponse response) {
if (response.StatusCode >= HttpStatusCode.BadRequest ||
response.HasNoContent() || !response.Headers.ContainsKey("Content-Type"))
return new EmptyResource(response);
- if (response.Headers["Content-Type"].IndexOf("application/xml", StringComparison.OrdinalIgnoreCase) > -1)
- return new DynamicXmlResource(response, this);
+ string contentType = response.Headers["Content-Type"];
+ IResource resource = CreateResource(contentType, response);
+
+ if (resource != null)
+ return resource;
throw new InvalidOperationException("unsupported media type: " + response.Headers["Content-Type"]);
}
@@ -0,0 +1,35 @@
+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("RestfulieSilverlightClientTest.Web")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("RestfulieSilverlightClientTest.Web")]
+[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.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("d1cf0e45-97f7-4efc-b853-ad3571ea22f8")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>
+ </ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{8B5F787E-1D02-4B16-BEE2-10E9FA3EFEA4}</ProjectGuid>
+ <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>RestfulieSilverlightClientTest.Web</RootNamespace>
+ <AssemblyName>RestfulieSilverlightClientTest.Web</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <UseIISExpress>false</UseIISExpress>
+ <SilverlightApplicationList>{EB9484F1-7C0D-4C70-815C-B60549C53588}|..\RestfulieSilverlightClientTest\RestfulieSilverlightClientTest.csproj|ClientBin|False</SilverlightApplicationList>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Web.DynamicData" />
+ <Reference Include="System.Web.Entity" />
+ <Reference Include="System.Web.ApplicationServices" />
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Web.Extensions" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Web.Services" />
+ <Reference Include="System.EnterpriseServices" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="order.xml" />
+ <Content Include="ClientBin\RestfulieSilverlightClientTest.xap" />
+ <Content Include="RestfulieSilverlightClientTestTestPage.aspx" />
+ <Content Include="RestfulieSilverlightClientTestTestPage.html" />
+ <Content Include="Silverlight.js" />
+ <Content Include="Web.config" />
+ <Content Include="Web.Debug.config">
+ <DependentUpon>Web.config</DependentUpon>
+ </Content>
+ <Content Include="Web.Release.config">
+ <DependentUpon>Web.config</DependentUpon>
+ </Content>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
+ <WebProjectProperties>
+ <UseIIS>False</UseIIS>
+ <AutoAssignPort>True</AutoAssignPort>
+ <DevelopmentServerPort>62968</DevelopmentServerPort>
+ <DevelopmentServerVPath>/</DevelopmentServerVPath>
+ <IISUrl>
+ </IISUrl>
+ <NTLMAuthentication>False</NTLMAuthentication>
+ <UseCustomServer>False</UseCustomServer>
+ <CustomServerUrl>
+ </CustomServerUrl>
+ <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
+ </WebProjectProperties>
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+ <!-- 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>
@@ -0,0 +1,74 @@
+<%@ Page Language="C#" AutoEventWireup="true" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head runat="server">
+ <title>RestfulieSilverlightClientTest</title>
+ <style type="text/css">
+ html, body {
+ height: 100%;
+ overflow: auto;
+ }
+ body {
+ padding: 0;
+ margin: 0;
+ }
+ #silverlightControlHost {
+ height: 100%;
+ text-align:center;
+ }
+ </style>
+ <script type="text/javascript" src="Silverlight.js"></script>
+ <script type="text/javascript">
+ function onSilverlightError(sender, args) {
+ var appSource = "";
+ if (sender != null && sender != 0) {
+ appSource = sender.getHost().Source;
+ }
+
+ var errorType = args.ErrorType;
+ var iErrorCode = args.ErrorCode;
+
+ if (errorType == "ImageError" || errorType == "MediaError") {
+ return;
+ }
+
+ var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n" ;
+
+ errMsg += "Code: "+ iErrorCode + " \n";
+ errMsg += "Category: " + errorType + " \n";
+ errMsg += "Message: " + args.ErrorMessage + " \n";
+
+ if (errorType == "ParserError") {
+ errMsg += "File: " + args.xamlFile + " \n";
+ errMsg += "Line: " + args.lineNumber + " \n";
+ errMsg += "Position: " + args.charPosition + " \n";
+ }
+ else if (errorType == "RuntimeError") {
+ if (args.lineNumber != 0) {
+ errMsg += "Line: " + args.lineNumber + " \n";
+ errMsg += "Position: " + args.charPosition + " \n";
+ }
+ errMsg += "MethodName: " + args.methodName + " \n";
+ }
+
+ throw new Error(errMsg);
+ }
+ </script>
+</head>
+<body>
+ <form id="form1" runat="server" style="height:100%">
+ <div id="silverlightControlHost">
+ <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
+ <param name="source" value="ClientBin/RestfulieSilverlightClientTest.xap"/>
+ <param name="onError" value="onSilverlightError" />
+ <param name="background" value="white" />
+ <param name="minRuntimeVersion" value="4.0.50826.0" />
+ <param name="autoUpgrade" value="true" />
+ <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
+ <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
+ </a>
+ </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
+ </form>
+</body>
+</html>
@@ -0,0 +1,73 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" >
+
+<head>
+ <title>RestfulieSilverlightClientTest</title>
+ <style type="text/css">
+ html, body {
+ height: 100%;
+ overflow: auto;
+ }
+ body {
+ padding: 0;
+ margin: 0;
+ }
+ #silverlightControlHost {
+ height: 100%;
+ text-align:center;
+ }
+ </style>
+ <script type="text/javascript" src="Silverlight.js"></script>
+ <script type="text/javascript">
+ function onSilverlightError(sender, args) {
+ var appSource = "";
+ if (sender != null && sender != 0) {
+ appSource = sender.getHost().Source;
+ }
+
+ var errorType = args.ErrorType;
+ var iErrorCode = args.ErrorCode;
+
+ if (errorType == "ImageError" || errorType == "MediaError") {
+ return;
+ }
+
+ var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n" ;
+
+ errMsg += "Code: "+ iErrorCode + " \n";
+ errMsg += "Category: " + errorType + " \n";
+ errMsg += "Message: " + args.ErrorMessage + " \n";
+
+ if (errorType == "ParserError") {
+ errMsg += "File: " + args.xamlFile + " \n";
+ errMsg += "Line: " + args.lineNumber + " \n";
+ errMsg += "Position: " + args.charPosition + " \n";
+ }
+ else if (errorType == "RuntimeError") {
+ if (args.lineNumber != 0) {
+ errMsg += "Line: " + args.lineNumber + " \n";
+ errMsg += "Position: " + args.charPosition + " \n";
+ }
+ errMsg += "MethodName: " + args.methodName + " \n";
+ }
+
+ throw new Error(errMsg);
+ }
+ </script>
+</head>
+<body>
+ <form id="form1" runat="server" style="height:100%">
+ <div id="silverlightControlHost">
+ <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
+ <param name="source" value="ClientBin/RestfulieSilverlightClientTest.xap"/>
+ <param name="onError" value="onSilverlightError" />
+ <param name="background" value="white" />
+ <param name="minRuntimeVersion" value="4.0.50826.0" />
+ <param name="autoUpgrade" value="true" />
+ <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
+ <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
+ </a>
+ </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
+ </form>
+</body>
+</html>
Oops, something went wrong.

0 comments on commit 0a7d817

Please sign in to comment.