This commit is contained in:
Jordan Ellis 2017-12-01 13:52:31 -08:00
Родитель 88fbe228d6
Коммит 956e7c1c60
146 изменённых файлов: 11840 добавлений и 104 удалений

Двоичный файл не отображается.

Двоичные данные
Documentation/XboxConsole.chm

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <copyright file="AdapterConfigurationKeyMapping.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// This class holds mappings for configuration keys for Global XboxConsole keys to keys for the specific XDK.
/// </summary>
internal static class AdapterConfigurationKeyMapping
{
private static readonly Dictionary<string, string> KeyMappings = new Dictionary<string, string>()
{
{ "SessionKey", "AccessKey" },
};
/// <summary>
/// Maps the global XboxConsole configuration key to the XDK specific key.
/// </summary>
/// <param name="key">The key to map.</param>
/// <returns>The XDK specific key.</returns>
public static string MapKey(string key)
{
if (KeyMappings.ContainsKey(key))
{
return KeyMappings[key];
}
else
{
return key;
}
}
}
}

Двоичные данные
XboxConsole.Adapter.July2014/GlobalSuppressions.cs Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,31 @@
//------------------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
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("GamesTest.XboxConsole.Adapter.July2014")]
[assembly: AssemblyDescription("GamesTest.XboxConsole.Adapter.July2014")]
[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)]
[assembly: CLSCompliant(false)]
[assembly: InternalsVisibleTo("GamesTest.XboxConsole")]
[assembly: InternalsVisibleTo("GamesTest.XboxConsole.Adapter.Tests")]
[assembly: InternalsVisibleTo("GamesTest.XboxConsole.TestApp")]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("AA0D922B-029F-4865-AA61-FE6E7682CE23")]

Просмотреть файл

@ -0,0 +1,158 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{E842B4D7-58D2-4435-B876-004DE9A45FBD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Internal.GamesTest.Xbox.Adapter.July2014</RootNamespace>
<AssemblyName>GamesTest.XboxConsole.Adapter.July2014</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\dependencies\CodeAnalysis\Level3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\dependencies\CodeAnalysis\Level3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Xbox.Xtf, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xbox.Xtf.Application, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.Application.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xbox.Xtf.ConsoleControl, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.ConsoleControl.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xbox.Xtf.ConsoleManager, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.ConsoleManager.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xbox.Xtf.DebugMonitor, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.DebugMonitor.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xbox.Xtf.FileIO, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.FileIO.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xbox.Xtf.Input, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.Input.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xbox.Xtf.Interop">
<HintPath>$(DurangoXDK)\bin\Microsoft.Xbox.Xtf.Interop.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xbox.Xtf.RemoteRun, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.RemoteRun.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xbox.Xtf.User, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.User.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\AssemblyInfoCore.cs">
<Link>Properties\AssemblyInfoCore.cs</Link>
</Compile>
<Compile Include="AdapterConfigurationKeyMapping.cs" />
<Compile Include="XboxConsoleAdapter.User.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="XboxConsoleAdapter.Input.cs" />
<Compile Include="XboxConsoleAdapter.COMExceptionWhenConnectingHandler.cs" />
<Compile Include="XboxConsoleAdapter.ExecutableManagement.cs" />
<Compile Include="XboxDebugMonitorClient.cs" />
<Compile Include="XboxConsoleAdapter.ConsoleControl.cs" />
<Compile Include="XboxConsoleAdapter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XboxConsoleAdapter.Debug.cs" />
<Compile Include="XboxConsoleAdapter.FileIO.cs" />
<Compile Include="XboxGamepadAdapter.cs" />
<Compile Include="XboxXdk.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\XboxConsole.Infrastructure\XboxConsole.Infrastructure.csproj">
<Project>{e0785338-9f71-4d35-95a8-6388bc7f5518}</Project>
<Name>XboxConsole.Infrastructure</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="XboxConsoleAdapter.PackageManagement.cs" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="..\dependencies\CodeAnalysis\CustomDictionary.xml">
<Link>CustomDictionary.xml</Link>
</CodeAnalysisDictionary>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.Application.dll">
<Link>Microsoft.Xbox.Xtf.Application.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.ConsoleControl.dll">
<Link>Microsoft.Xbox.Xtf.ConsoleControl.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.ConsoleManager.dll">
<Link>Microsoft.Xbox.Xtf.ConsoleManager.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.DebugMonitor.dll">
<Link>Microsoft.Xbox.Xtf.DebugMonitor.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.dll">
<Link>Microsoft.Xbox.Xtf.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.FileIO.dll">
<Link>Microsoft.Xbox.Xtf.FileIO.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.Input.dll">
<Link>Microsoft.Xbox.Xtf.Input.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.RemoteRun.dll">
<Link>Microsoft.Xbox.Xtf.RemoteRun.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\dependencies\GamesTest.ManagedXtf.2014.07.1.0.40811.0\lib\net45\Microsoft.Xbox.Xtf.User.dll">
<Link>Microsoft.Xbox.Xtf.User.dll</Link>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>

Просмотреть файл

@ -0,0 +1,114 @@
//------------------------------------------------------------------------------
// <copyright file="XboxConsoleAdapter.COMExceptionWhenConnectingHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Microsoft.Internal.GamesTest.Xbox.Deployment;
/// <summary>
/// This class represents an implemenation of the XboxConsoleAdapter
/// that is supported by the July 2014 version of the XDK.
/// </summary>
internal partial class XboxConsoleAdapter : XboxConsoleAdapterBase
{
/// <summary>
/// A helper class designed to execute a function within the Adapter and check for a specific sequence of COMExceptions
/// that indicates that the console against which the user is making requests is currently rebooting. These COMExceptions
/// are transformed into CannotConnectExceptions for easier consumption.
/// </summary>
private class COMExceptionWhenConnectingHandler
{
// The COMException with HResult -1945042173 is ALWAYS the first COMException thrown when trying to poll the
// execution state of a package while the console is rebooting.
private const int COMExceptionHResult = -1945042173;
// There are a handful of COMExceptions that are thrown when trying to poll the package state after the console has
// been rebooted, all with different HResults, but they all share one commonality: The message contains
// the text "Class not registered".
private const string COMExceptionMessage = "Class not registered";
private bool rebootingBasedOnCOMExceptionStep1 = false;
private bool rebootingBasedOnCOMExceptionStep2 = false;
/// <summary>
/// Execute a function that returns an HResult and checks for a specific sequence of COMExceptions
/// that indicates that the console against which the user is making requests is currently rebooting. These COMExceptions
/// are transformed into CannotConnectExceptions for easier consumption.
/// </summary>
/// <param name="func">A function that makes a request of a console and returns an HResult.</param>
/// <param name="systemIpAddress">The ip address of the console being used.</param>
/// <returns>The HResult of the executed function.</returns>
public uint CheckForCOMExceptionWhenConnecting(Func<uint> func, string systemIpAddress)
{
uint funcReturn;
try
{
funcReturn = func();
// if we've made it this far after both stages of rebooting, we know that we've successfully completed rebooting
if (this.rebootingBasedOnCOMExceptionStep1 && this.rebootingBasedOnCOMExceptionStep2)
{
this.rebootingBasedOnCOMExceptionStep1 = false;
this.rebootingBasedOnCOMExceptionStep2 = false;
}
}
catch (COMException ex)
{
// The inability to connect to a rebooting console will manifest as several COMExceptions.
// At first a COMException with HResult -1945042173 is thrown, followed by one of several
// COMExceptions with varying HResults, all containing the message: "Class not registered".
if (ex.HResult == COMExceptionHResult)
{
// if we've encountered the first COMException, we know that we're rebooting
if (!this.rebootingBasedOnCOMExceptionStep1)
{
this.rebootingBasedOnCOMExceptionStep1 = true;
}
this.ThrowCannotConnectException(systemIpAddress, ex);
}
else if (ex.Message.Contains(COMExceptionMessage) && this.rebootingBasedOnCOMExceptionStep1)
{
// if we've encountered the second COMException AFTER the first, we know that we're rebooting
if (!this.rebootingBasedOnCOMExceptionStep2)
{
this.rebootingBasedOnCOMExceptionStep2 = true;
}
this.ThrowCannotConnectException(systemIpAddress, ex);
}
// if none of this is true, something bad has happened and we need to keep throwing the actual COMException
throw;
}
return funcReturn;
}
/// <summary>
/// Encapsulates a COMException within a CannotConnectException and throws the latter.
/// </summary>
/// <param name="systemIpAddress">The ip address of the unresponsive console.</param>
/// <param name="ex">The COMException to be encapsulated.</param>
private void ThrowCannotConnectException(string systemIpAddress, COMException ex)
{
// make sure to throw a CannotConnectException instead of the COMException
throw new CannotConnectException(string.Format(CultureInfo.CurrentCulture, "Cannot connect to console with IP {0}; console is likely rebooting.", systemIpAddress), ex);
}
}
}
}

Просмотреть файл

@ -0,0 +1,235 @@
//------------------------------------------------------------------------------
// <copyright file="XboxConsoleAdapter.ConsoleControl.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
using System.Threading;
/// <summary>
/// This class represents an implemenation of the XboxConsoleAdapter
/// that is supported by the July 2014 version of the XDK.
/// </summary>
internal partial class XboxConsoleAdapter : XboxConsoleAdapterBase
{
private static readonly TimeSpan MaxTimeBetweenRetries = TimeSpan.FromSeconds(1.0);
/// <summary>Reboot the Xbox console and wait no more than the specified amount of time for the console to become responsive again.</summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="timeout">The maximum amount of time to wait for the Xbox console to become
/// responsive again after initiating the reboot sequence.</param>
/// <exception cref="System.TimeoutException">Thrown if the reboot operation does not complete within the given timeout period.</exception>
protected override void RebootImpl(string systemIpAddress, TimeSpan timeout)
{
this.RebootImpl(systemIpAddress, systemIpAddress, timeout);
}
/// <summary>Reboot the Xbox console and wait no more than the specified amount of time for the console to become responsive again.</summary>
/// <param name="originalSystemIpAddress">The pre-reboot "System Ip" address of the Xbox kit.</param>
/// <param name="newSystemIpAddress">The post-reboot "System Ip" address of the Xbox kit.</param>
/// <param name="timeout">The maximum amount of time to wait for the Xbox console to become
/// responsive again after initiating the reboot sequence.</param>
/// <exception cref="System.TimeoutException">Thrown if the reboot operation does not complete within the given timeout period.</exception>
/// <remarks>
/// This overload should be used when the connection string to the console will have changed during the reboot
/// such as when rebooting after changing the session key.
/// </remarks>
protected override void RebootImpl(string originalSystemIpAddress, string newSystemIpAddress, TimeSpan timeout)
{
this.XboxXdk.Reboot(originalSystemIpAddress);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
this.WaitUntilConsoleIsUnresponsive(originalSystemIpAddress, timeout);
stopwatch.Stop();
if (timeout > TimeSpan.Zero)
{
timeout = timeout - stopwatch.Elapsed;
timeout = timeout > TimeSpan.Zero ? timeout : TimeSpan.Zero;
}
this.WaitUntilRebootIsComplete(newSystemIpAddress, timeout);
}
/// <summary>
/// Shutdown the Xbox console and wait no more than the specified amount of time for the operation to complete.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="timeout">The maximum amount of time to wait for the shutdown process to complete and for the Xbox console to become unresponsive.</param>
/// <exception cref="System.TimeoutException">Thrown if the shutdown operation does not complete within the given timeout period.</exception>
protected override void ShutdownImpl(string systemIpAddress, TimeSpan timeout)
{
this.XboxXdk.Shutdown(systemIpAddress);
this.WaitUntilConsoleIsUnresponsive(systemIpAddress, timeout);
}
/// <summary>
/// Captures a screenshot from the frame buffer of the specified console.
/// </summary>
/// <param name="systemIpAddress">The IP address of the console.</param>
/// <returns>A pointer to the location in memory of the uncompressed frame buffer captured off the console.</returns>
protected override IntPtr CaptureScreenshotImpl(string systemIpAddress)
{
var bitmapPointer = this.XboxXdk.CaptureScreenshot(systemIpAddress);
if (bitmapPointer == IntPtr.Zero)
{
throw new XboxConsoleException("Failed to capture screenshot.");
}
return bitmapPointer;
}
/// <summary>
/// Immediately after initiating a Shutdown or Reboot request, the console remains responsive
/// for a short period of time. This method is intended to block until the kit is verified
/// to no longer be responsive.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="timeout">The maximum amount of time to wait for the console to become unresponsive.</param>
/// <exception cref="Sytem.TimeoutException">Thrown if the console does not become unresponsive within the given timeout period.</exception>
protected override void WaitUntilConsoleIsUnresponsive(string systemIpAddress, TimeSpan timeout)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// Wait until console doesn't respond to pings anymore
bool success = this.RetryOperationUntilTimeout(
timeout,
() =>
{
return !this.RespondsToPing(systemIpAddress);
});
if (!success)
{
throw new TimeoutException("Console failed to become unresponsive during the given timeout period.");
}
stopwatch.Stop();
if (timeout > TimeSpan.Zero)
{
timeout = timeout - stopwatch.Elapsed;
timeout = timeout > TimeSpan.Zero ? timeout : TimeSpan.Zero;
}
// Also wait until console can't connect anymore
success = this.RetryOperationUntilTimeout(
timeout,
() =>
{
return !this.XboxXdk.CanConnect(systemIpAddress);
});
if (!success)
{
throw new TimeoutException("Console failed to become unresponsive during the given timeout period.");
}
}
/// <summary>
/// The XTF APIs do not offer a way to synchronously reboot a console therefore, we need to implement
/// our own logic to wait for a console to finish rebooting. This method should block until it has
/// confirmed that the console has completed rebooting or the timeout has been reached or exceeded.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="timeout">The maximum amount of time to wait for the console to finish rebooting.</param>
/// <exception cref="Sytem.TimeoutException">Thrown if the console does not become responsive within the given timeout period.</exception>
protected override void WaitUntilRebootIsComplete(string systemIpAddress, TimeSpan timeout)
{
bool success = this.RetryOperationUntilTimeout(
timeout,
() =>
{
try
{
IEnumerable<XboxProcessDefinition> runningProcesses = this.XboxXdk.GetRunningProcesses(systemIpAddress, XboxOperatingSystem.System);
return runningProcesses.Any(process => process.ImageFileName.IndexOf("Home.exe", StringComparison.OrdinalIgnoreCase) >= 0 || process.ImageFileName.IndexOf("oobe.exe", StringComparison.OrdinalIgnoreCase) >= 0);
}
catch (COMException)
{
// If a COMException is thrown when creating the ConsoleControlClient that means
// that the kit is just generally unresponsive so we need to wait and try again.
return false;
}
});
if (!success)
{
throw new TimeoutException("Console failed to become unresponsive during the given timeout period.");
}
}
/// <summary>
/// Continually performs an action until either the action succeeds (by returning true) or the timeout expires.
/// </summary>
/// <param name="timeout">The maximum amount of time to continue retrying the action until timing out.</param>
/// <param name="action">The action to continually be performed.</param>
/// <returns>True if the action completed within the given time span, otherwise false.</returns>
protected bool RetryOperationUntilTimeout(TimeSpan timeout, Func<bool> action)
{
Func<bool> loopCondition = null;
if (timeout < TimeSpan.Zero)
{
loopCondition = () => true;
}
else
{
loopCondition = () => timeout > TimeSpan.Zero;
}
do
{
bool operationCompletedSuccessfully = action();
if (operationCompletedSuccessfully)
{
return true;
}
TimeSpan sleepTime = MaxTimeBetweenRetries;
if (timeout >= TimeSpan.Zero && timeout < MaxTimeBetweenRetries)
{
sleepTime = timeout;
}
Thread.Sleep(sleepTime);
// If we received an input "timeout" of something less than zero
// and we decrement on every iteration then we run the risk of ending
// up decrementing "timeout" below TimeSpan.MinValue and getting
// an Overflow exception, so we need to do this check.
if (timeout > TimeSpan.Zero)
{
timeout -= sleepTime;
}
}
while (loopCondition());
return false;
}
private bool RespondsToPing(string systemIpAddress)
{
using (Ping ping = new Ping())
{
PingReply pingReply = ping.Send(systemIpAddress.Split('+')[0], 1000);
if (pingReply.Status == IPStatus.Success)
{
return true;
}
else
{
return false;
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,99 @@
//------------------------------------------------------------------------------
// <copyright file="XboxConsoleAdapter.Debug.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System;
using System.Collections.Generic;
/// <summary>
/// This class represents an implemenation of the XboxConsoleAdapter
/// that is supported by the July 2014 version of the XDK.
/// </summary>
internal partial class XboxConsoleAdapter : XboxConsoleAdapterBase
{
private IXboxDebugMonitorClient systemXboxDebugMonitorClient;
private IXboxDebugMonitorClient titleXboxDebugMonitorClient;
/// <summary>
/// Provides the adapter-specific implementation of the "GetRunningProcesses" method.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="operatingSystem">The Xbox operating system.</param>
/// <returns>The enumeration of XboxProcessDefinition instances.</returns>
protected override IEnumerable<XboxProcessDefinition> GetRunningProcessesImpl(string systemIpAddress, XboxOperatingSystem operatingSystem)
{
return this.XboxXdk.GetRunningProcesses(systemIpAddress, operatingSystem);
}
/// <summary>
/// Provides the adapter-specific implementation of the "StartDebug" method.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="operatingSystem">The Xbox operating system.</param>
/// <param name="processId">The process Id.</param>
/// <param name="handler">The handler called when a TextReceived event occurs.</param>
protected override void StartDebugImpl(string systemIpAddress, XboxOperatingSystem operatingSystem, uint processId, EventHandler<TextEventArgs> handler)
{
switch (operatingSystem)
{
case XboxOperatingSystem.System:
if (this.systemXboxDebugMonitorClient == null)
{
this.systemXboxDebugMonitorClient = this.XboxXdk.CreateDebugMonitorClient(systemIpAddress, XboxOperatingSystem.System);
}
this.systemXboxDebugMonitorClient.Start(processId, handler);
break;
case XboxOperatingSystem.Title:
if (this.titleXboxDebugMonitorClient == null)
{
this.titleXboxDebugMonitorClient = this.XboxXdk.CreateDebugMonitorClient(systemIpAddress, XboxOperatingSystem.Title);
}
this.titleXboxDebugMonitorClient.Start(processId, handler);
break;
default:
throw new ArgumentException("This operating system is not supported.");
}
}
/// <summary>
/// Provides the adapter-specific implementation of the "StopDebug" method.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="operatingSystem">The Xbox operating system.</param>
/// <param name="processId">The process Id.</param>
protected override void StopDebugImpl(string systemIpAddress, XboxOperatingSystem operatingSystem, uint processId)
{
switch (operatingSystem)
{
case XboxOperatingSystem.System:
if (this.systemXboxDebugMonitorClient == null)
{
this.systemXboxDebugMonitorClient = this.XboxXdk.CreateDebugMonitorClient(systemIpAddress, XboxOperatingSystem.System);
}
this.systemXboxDebugMonitorClient.Stop(processId);
break;
case XboxOperatingSystem.Title:
if (this.titleXboxDebugMonitorClient == null)
{
this.titleXboxDebugMonitorClient = this.XboxXdk.CreateDebugMonitorClient(systemIpAddress, XboxOperatingSystem.Title);
}
this.titleXboxDebugMonitorClient.Stop(processId);
break;
default:
throw new ArgumentException("This operating system is not supported.");
}
}
}
}

Просмотреть файл

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <copyright file="XboxConsoleAdapter.ExecutableManagement.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System;
/// <summary>
/// This class represents an implemenation of the XboxConsoleAdapter
/// that is supported by the July 2014 version of the XDK.
/// </summary>
internal partial class XboxConsoleAdapter : XboxConsoleAdapterBase
{
/// <summary>
/// Runs an executable on the console.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="fileName">The path to an executable to start.</param>
/// <param name="arguments">The command-line arguments to pass into the executable.</param>
/// <param name="operatingSystem">The <see cref="Microsoft.Internal.GamesTest.Xbox.XboxOperatingSystem"/> to run the executable on.</param>
/// <param name="outputRecievedCallback">A callback method that will be called when there is output from the process.</param>
protected override void RunExecutableImpl(string systemIpAddress, string fileName, string arguments, XboxOperatingSystem operatingSystem, Action<string> outputRecievedCallback)
{
this.XboxXdk.RunExecutable(systemIpAddress, fileName, arguments, operatingSystem, outputRecievedCallback);
}
}
}

Просмотреть файл

@ -0,0 +1,387 @@
//------------------------------------------------------------------------------
// <copyright file="XboxConsoleAdapter.FileIO.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using Microsoft.Internal.GamesTest.Xbox.IO;
/// <summary>
/// This class represents an implemenation of the XboxConsoleAdapter
/// that is supported by the July 2014 version of the XDK.
/// </summary>
internal partial class XboxConsoleAdapter : XboxConsoleAdapterBase
{
/// <summary>
/// Copies a file from a PC to an Xbox.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="sourceFilePath">The path to the file on the PC to be copied.</param>
/// <param name="destinationFile">The destination file to be copied to.</param>
/// <param name="metrics">The progress handler that the calling app uses to receive progress updates about metrics. This may be null.</param>
protected override void SendFileImpl(string systemIpAddress, string sourceFilePath, XboxPath destinationFile, IProgress<XboxFileTransferMetric> metrics)
{
if (destinationFile == null)
{
throw new ArgumentNullException("destinationFile");
}
if (string.IsNullOrWhiteSpace(sourceFilePath))
{
throw new ArgumentNullException("sourceFilePath");
}
this.XboxXdk.CopyFiles(systemIpAddress, sourceFilePath, destinationFile.FullName, destinationFile.OperatingSystem, 0, metrics);
}
/// <summary>
/// Copies a file from an Xbox to a PC.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="sourceFile">The source file to be copied.</param>
/// <param name="destinationFilePath">The destination of the file on the PC.</param>
/// <param name="metrics">The progress handler that the calling app uses to receive progress updates about metrics. This may be null.</param>
protected override void ReceiveFileImpl(string systemIpAddress, XboxPath sourceFile, string destinationFilePath, IProgress<XboxFileTransferMetric> metrics)
{
if (sourceFile == null)
{
throw new ArgumentNullException("sourceFile");
}
if (string.IsNullOrWhiteSpace(destinationFilePath))
{
throw new ArgumentNullException("destinationFilePath");
}
this.XboxXdk.CopyFiles(systemIpAddress, sourceFile.FullName, destinationFilePath, sourceFile.OperatingSystem, 0, metrics);
}
/// <summary>
/// Deletes a file from an Xbox.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="xboxFilePath">The complete path to the file to be deleted.</param>
protected override void DeleteFileImpl(string systemIpAddress, XboxPath xboxFilePath)
{
if (xboxFilePath == null)
{
throw new ArgumentNullException("xboxFilePath");
}
this.XboxXdk.DeleteFiles(systemIpAddress, xboxFilePath.FullName, xboxFilePath.OperatingSystem, 0);
}
/// <summary>
/// Copies a directory from a PC to an Xbox.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="sourceDirectory">The path to the directory on the PC to be copied.</param>
/// <param name="destinationDirectory">The destination directory on the Xbox.</param>
/// <param name="recursive">True to copy the directory and all of its sub-directories.</param>
/// <param name="metrics">The progress handler that the calling app uses to receive progress updates about metrics. This may be null.</param>
protected override void SendDirectoryImpl(string systemIpAddress, string sourceDirectory, XboxPath destinationDirectory, bool recursive, IProgress<XboxFileTransferMetric> metrics)
{
if (destinationDirectory == null)
{
throw new ArgumentNullException("destinationDirectory");
}
if (string.IsNullOrWhiteSpace(sourceDirectory))
{
throw new ArgumentNullException("sourceDirectory");
}
int recursionLevel = recursive ? -1 : 0;
string searchPattern = Path.Combine(sourceDirectory, "*");
this.XboxXdk.CopyFiles(systemIpAddress, searchPattern, destinationDirectory.FullName, destinationDirectory.OperatingSystem, recursionLevel, metrics);
}
/// <summary>
/// Copies a directory from the Xbox to a PC.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="sourceDirectory">The Xbox diretory to copy.</param>
/// <param name="destinationDirectory">The path to the destination directory on the PC.</param>
/// <param name="recursive">True to recurisve delete the content in the given directory and all of its subdirectories.</param>
/// <param name="metrics">The progress handler that the calling app uses to receive progress updates about metrics. This may be null.</param>
protected override void ReceiveDirectoryImpl(string systemIpAddress, XboxPath sourceDirectory, string destinationDirectory, bool recursive, IProgress<XboxFileTransferMetric> metrics)
{
if (sourceDirectory == null)
{
throw new ArgumentNullException("sourceDirectory");
}
if (string.IsNullOrWhiteSpace(destinationDirectory))
{
throw new ArgumentNullException("destinationDirectory");
}
if (recursive)
{
ulong totalBytes = 0;
if (metrics != null)
{
totalBytes = this.GetDirectorySizeRecursive(systemIpAddress, sourceDirectory);
}
// The January XDK will not copy empty directories, so we have to do it ourselves.
this.ReceiveDirectoryRecursive(systemIpAddress, sourceDirectory, destinationDirectory, totalBytes, metrics);
}
else
{
try
{
var contents = this.GetDirectoryContents(systemIpAddress, sourceDirectory);
if (contents.Any(f => !f.IsDirectory))
{
this.XboxXdk.CopyFiles(systemIpAddress, sourceDirectory.FullName, destinationDirectory, sourceDirectory.OperatingSystem, 0, metrics);
}
}
catch (FileNotFoundException)
{
// If the directory exists, but is empty then the XDK will throw a FileNotFoundException.
}
}
}
/// <summary>
/// Remove the given directory from the Xbox.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="directoryToDelete">The Xbox directory to remove.</param>
/// <param name="recursive">True to recursivly delete the directory, its content and all of its sub-directories.</param>
protected override void DeleteDirectoryImpl(string systemIpAddress, XboxPath directoryToDelete, bool recursive)
{
if (directoryToDelete == null)
{
throw new ArgumentNullException("directoryToDelete");
}
if (recursive)
{
// For some reason, recursive directory deleting is completely broken in the January XDK.
// If you try to use the recursive deleting functionality exposed by the XDK to delete an empty directory
// then it will throw a "FileNotFoundException" even if the directory exists.
// Therefore, we have to do the recursive delete ourselves.
this.DeleteDirectoryRecursive(systemIpAddress, directoryToDelete);
}
else
{
this.XboxXdk.RemoveDirectory(systemIpAddress, directoryToDelete.FullName, directoryToDelete.OperatingSystem, recursive);
}
}
/// <summary>
/// Retrieves an XboxFileSystemInfoDefintion object for the specified file system object.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="xboxFilePath">The file system object for a which an XboxFileSystemInfoDefinition object shall be retrieved.</param>
/// <returns>
/// An XboxFileSystemInfoDefinition object describing the file specified in the <paramref name="xboxFilePath" /> parameter.
/// </returns>
protected override XboxFileSystemInfoDefinition GetFileSystemInfoDefinitionImpl(string systemIpAddress, XboxPath xboxFilePath)
{
if (xboxFilePath == null)
{
throw new ArgumentNullException("xboxFilePath");
}
bool isRoot = XboxPath.IsRoot(xboxFilePath.FullName);
string cleanedFilePath = null;
// For disk roots we need cleanedFilePath to keep the trailing separator char to make a valid searchPattern for XboxXdk.FindFiles.
if (!isRoot &&
(xboxFilePath.FullName.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase) ||
xboxFilePath.FullName.EndsWith(Path.AltDirectorySeparatorChar.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase)))
{
cleanedFilePath = xboxFilePath.FullName.Substring(0, xboxFilePath.FullName.Length - 1);
}
else
{
cleanedFilePath = xboxFilePath.FullName;
}
// If the "xboxFilePath" parameter represents a directory and we just pass the string
// straight to the "FindFiles" method, then it will return only the content of the directory.
// By appending a "*" onto the end we can retrieve the directory itself. However, if the path ends with a trailing slash
// then the search pattern won't work as expected, which is why the trailing slash is removed above. Additionally, if "xboxFilePath"
// represents a file then this process works as well.
string searchPattern = string.Format(CultureInfo.InvariantCulture, "{0}*", cleanedFilePath);
var matchingFiles = this.XboxXdk.FindFiles(systemIpAddress, searchPattern, xboxFilePath.OperatingSystem, 0);
if (isRoot)
{
// For disk roots we create a definition object as long as XboxXdk.FindFiles above didn't throw an exception (that means the disk root was traversed successfully)
return new XboxFileSystemInfoDefinition(0, FileAttributes.Directory, xboxFilePath.FullName, xboxFilePath.OperatingSystem, 0, 0, 0);
}
else
{
XboxFileSystemInfoDefinition returnValue = matchingFiles.FirstOrDefault(f => f.Path.FullName.Equals(cleanedFilePath, StringComparison.OrdinalIgnoreCase));
if (returnValue == default(XboxFileSystemInfoDefinition))
{
throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, "Unable to locate file on the Xbox's {0} operating system.", xboxFilePath.OperatingSystem), xboxFilePath.FullName);
}
else
{
return returnValue;
}
}
}
/// <summary>
/// Retrieves the contents of a directory on an Xbox.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="xboxDirectory">The complete path to the directory.</param>
/// <returns>
/// The contents of a directory on an Xbox.
/// </returns>
protected override IEnumerable<XboxFileSystemInfoDefinition> GetDirectoryContentsImpl(string systemIpAddress, XboxPath xboxDirectory)
{
if (xboxDirectory == null)
{
throw new ArgumentNullException("xboxDirectory");
}
string searchPattern = Path.Combine(xboxDirectory.FullName, "*");
return this.XboxXdk.FindFiles(systemIpAddress, searchPattern, xboxDirectory.OperatingSystem, 0);
}
/// <summary>
/// Recursively delete the given directory and all of its subdirectories. Note all directories must already be empty.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="directoryToDelete">The directory to delete.</param>
protected void DeleteDirectoryRecursive(string systemIpAddress, XboxPath directoryToDelete)
{
if (directoryToDelete == null)
{
throw new ArgumentNullException("directoryToDelete");
}
// The January XDK is kind of crazy. If you try to enumerate a directory that
// exists, but is empty, then you will get a FileNotFoundException. If that happens
// then we can just ignore it and try to delete the directory anyway.
IEnumerable<XboxFileSystemInfoDefinition> directoryContents = null;
try
{
directoryContents = this.GetDirectoryContents(systemIpAddress, directoryToDelete);
}
catch (FileNotFoundException)
{
}
if (directoryContents != null)
{
if (directoryContents.Any(f => !f.IsDirectory))
{
string searchPattern = Path.Combine(directoryToDelete.FullName, "*");
this.XboxXdk.DeleteFiles(systemIpAddress, searchPattern, directoryToDelete.OperatingSystem, 0);
}
foreach (XboxFileSystemInfoDefinition subdirectory in directoryContents.Where(f => f.IsDirectory))
{
this.DeleteDirectoryRecursive(systemIpAddress, subdirectory.Path);
}
}
this.XboxXdk.RemoveDirectory(systemIpAddress, directoryToDelete.FullName, directoryToDelete.OperatingSystem, false);
}
/// <summary>
/// Recursively copies a directory from an Xbox to a PC.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="xboxDirectory">The xbox directory to be copied.</param>
/// <param name="destinationDirectory">The destination directory on the PC.</param>
/// <param name="totalSizeOfFolder">The total size of the initial directory.</param>
/// <param name="metrics">The progress handler that the calling app uses to receive progress updates about metrics. This may be null.</param>
protected void ReceiveDirectoryRecursive(string systemIpAddress, XboxPath xboxDirectory, string destinationDirectory, ulong totalSizeOfFolder, IProgress<XboxFileTransferMetric> metrics)
{
if (!Directory.Exists(destinationDirectory))
{
Directory.CreateDirectory(destinationDirectory);
}
try
{
double totalTransferred = 0;
double tempTransferred = 0;
IProgress<XboxFileTransferMetric> newMetrics = null;
if (metrics != null)
{
newMetrics = new Progress<XboxFileTransferMetric>((x) =>
{
tempTransferred = x.TotalBytesTransferred;
metrics.Report(new XboxFileTransferMetric(x.SourceFilePath, x.TargetFilePath, x.FileSizeInBytes, x.FileBytesTransferred, totalSizeOfFolder, totalTransferred + tempTransferred));
});
}
var contents = this.GetDirectoryContents(systemIpAddress, xboxDirectory);
if (contents.Any(f => !f.IsDirectory))
{
this.XboxXdk.CopyFiles(systemIpAddress, xboxDirectory.FullName, destinationDirectory, xboxDirectory.OperatingSystem, 0, newMetrics);
totalTransferred += tempTransferred;
tempTransferred = 0;
}
foreach (XboxFileSystemInfoDefinition subdirectory in contents.Where(f => f.IsDirectory))
{
string directoryName = Path.Combine(destinationDirectory, Path.GetFileNameWithoutExtension(subdirectory.Path.FullName));
this.ReceiveDirectoryRecursive(systemIpAddress, subdirectory.Path, directoryName, totalSizeOfFolder, newMetrics);
totalTransferred += tempTransferred;
tempTransferred = 0;
}
}
catch (FileNotFoundException)
{
}
}
/// <summary>
/// Creates a directory on an Xbox.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="xboxDirectoryPath">The complete path to the directory to be created.</param>
protected override void CreateDirectoryImpl(string systemIpAddress, XboxPath xboxDirectoryPath)
{
if (xboxDirectoryPath == null)
{
throw new ArgumentNullException("xboxDirectoryPath");
}
this.XboxXdk.CreateDirectory(systemIpAddress, xboxDirectoryPath.FullName, xboxDirectoryPath.OperatingSystem);
}
/// <summary>
/// Gets the size of a folder on the console.
/// </summary>
/// <param name="systemIpAddress">The ip of the console.</param>
/// <param name="sourceDirectory">The directory to the size.</param>
/// <returns>The size in bytes of the folder.</returns>
private ulong GetDirectorySizeRecursive(string systemIpAddress, XboxPath sourceDirectory)
{
var folder = this.GetDirectoryContents(systemIpAddress, sourceDirectory);
var sum = unchecked((ulong)folder.Sum(f => unchecked((long)f.FileSize)));
foreach (var dir in folder.Where(f => f.IsDirectory))
{
sum += this.GetDirectorySizeRecursive(systemIpAddress, dir.Path);
}
return sum;
}
}
}

Просмотреть файл

@ -0,0 +1,72 @@
//------------------------------------------------------------------------------
// <copyright file="XboxConsoleAdapter.Input.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.Internal.GamesTest.Xbox.Input;
/// <summary>
/// This class represents an implemenation of the XboxConsoleAdapter
/// that is supported by the July 2014 version of the XDK.
/// </summary>
internal partial class XboxConsoleAdapter : XboxConsoleAdapterBase
{
private List<IVirtualGamepad> gamepads = new List<IVirtualGamepad>();
/// <summary>
/// Connects the XboxGamepad to the console.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <returns>The id of the XboxGamepad.</returns>
protected override ulong ConnectXboxGamepadImpl(string systemIpAddress)
{
IVirtualGamepad gamepad = this.XboxXdk.CreateXboxGamepad(systemIpAddress);
this.gamepads.Add(gamepad);
return gamepad.Connect();
}
/// <summary>
/// Disconnects an XboxGamepad from the console.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="xboxGamepadId">The Id of the XboxGamepad to disconnect.</param>
protected override void DisconnectXboxGamepadImpl(string systemIpAddress, ulong xboxGamepadId)
{
var gamepad = this.GetXboxGamepad(xboxGamepadId);
gamepad.Disconnect();
this.gamepads.Remove(gamepad);
}
/// <summary>
/// Sets the state of the XboxGamepad.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="xboxGamepadId">The Id of the XboxGamepad to set the state of.</param>
/// <param name="report">The state to set.</param>
protected override void SendXboxGamepadReportImpl(string systemIpAddress, ulong xboxGamepadId, Input.XboxGamepadState report)
{
var gamepad = this.GetXboxGamepad(xboxGamepadId);
gamepad.SetGamepadState(report);
}
private IVirtualGamepad GetXboxGamepad(ulong id)
{
var gamepad = this.gamepads.FirstOrDefault(g => g.Id == id);
if (gamepad == null)
{
throw new XboxInputException(string.Format(CultureInfo.InvariantCulture, "Did not find a XboxGamepad with Id '{0}' in adapter.", id));
}
return gamepad;
}
}
}

Просмотреть файл

@ -0,0 +1,371 @@
//------------------------------------------------------------------------------
// <copyright file="XboxConsoleAdapter.PackageManagement.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Microsoft.Internal.GamesTest.Xbox.Deployment;
/// <summary>
/// This class represents an implemenation of the XboxConsoleAdapter
/// that is supported by the July 2014 version of the XDK.
/// </summary>
internal partial class XboxConsoleAdapter : XboxConsoleAdapterBase
{
private COMExceptionWhenConnectingHandler comExceptionWhenConnectingHandler = new COMExceptionWhenConnectingHandler();
/// <summary>
/// Connects to the console and retrieves the collection of installed packages.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <returns>The collection of packages installed on the console.</returns>
protected override IEnumerable<XboxPackageDefinition> GetInstalledPackagesImpl(string systemIpAddress)
{
// In the July 2014 XDK the format of the string returned by the XDK is a JSON object with this schema:
// {"Packages":[{"FullName":"Achievements_1.0.1308.7000_x64__8wekyb3d8bbwe","Applications":[{"Aumid":"Achievements_8wekyb3d8bbwe!App"}]}]}
string xdkOutput = this.XboxXdk.GetInstalledPackages(systemIpAddress);
List<XboxPackageDefinition> returnValue = new List<XboxPackageDefinition>();
InstalledPackages installedPackages;
try
{
using (XmlDictionaryReader jsonReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.Unicode.GetBytes(xdkOutput), XmlDictionaryReaderQuotas.Max))
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(InstalledPackages));
installedPackages = (InstalledPackages)serializer.ReadObject(jsonReader);
}
}
catch (ArgumentNullException ex)
{
throw new XboxConsoleException("Failed to parse installed packages string.", ex);
}
catch (SerializationException ex)
{
throw new XboxConsoleException("Failed to parse installed packages string.", ex);
}
foreach (var package in installedPackages.Packages)
{
string packageFullName = package.FullName;
XboxPackageDefinition newPackage = new XboxPackageDefinition(packageFullName, package.Applications.Select(app => app.Aumid));
returnValue.Add(newPackage);
}
return returnValue;
}
/// <summary>
/// Launches the given application.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="application">The application to be launched.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="package"/> parameter is null.</exception>
protected override void LaunchApplicationImpl(string systemIpAddress, XboxApplicationDefinition application)
{
if (application == null)
{
throw new ArgumentNullException("application");
}
this.XboxXdk.LaunchApplication(systemIpAddress, application.Aumid);
}
/// <summary>
/// Launches the given application with command line arguments.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="application">The application to be launched.</param>
/// <param name="arguments">Command line arguments to pass to the package executable.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="package"/> parameter is null.</exception>
protected override void LaunchApplicationImpl(string systemIpAddress, XboxApplicationDefinition application, string arguments)
{
if (application == null)
{
throw new ArgumentNullException("application");
}
if (string.IsNullOrEmpty(arguments))
{
// Passing null or empty string reverts to regular LaunchApplication behavior
this.XboxXdk.LaunchApplication(systemIpAddress, application.Aumid);
}
else
{
// Passing valid arguments concatenates them to AUMID with a space separator (we trust native Xtf to handle this properly)
this.XboxXdk.LaunchApplication(systemIpAddress, string.Format(CultureInfo.InvariantCulture, "{0} {1}", application.Aumid, arguments));
}
}
/// <summary>
/// Terminates the given package.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="package">The package to be terminated.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="package"/> parameter is null.</exception>
protected override void TerminatePackageImpl(string systemIpAddress, XboxPackageDefinition package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.XboxXdk.TerminatePackage(systemIpAddress, package.FullName);
}
/// <summary>
/// Resumes execution of a suspended package.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="package">The package to be resumed.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="package"/> parameter is null.</exception>
protected override void ResumePackageImpl(string systemIpAddress, XboxPackageDefinition package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.XboxXdk.ResumePackage(systemIpAddress, package.FullName);
}
/// <summary>
/// Suspends the given package.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="package">The package to be suspended.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="package"/> parameter is null.</exception>
protected override void SuspendPackageImpl(string systemIpAddress, XboxPackageDefinition package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.XboxXdk.SuspendPackage(systemIpAddress, package.FullName);
}
/// <summary>
/// Constrains the given package.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="package">The package to be constrained.</param>
protected override void ConstrainPackageImpl(string systemIpAddress, XboxPackageDefinition package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.XboxXdk.ConstrainPackage(systemIpAddress, package.FullName);
}
/// <summary>
/// Unconstrains a constrained package.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="package">The package to be unconstrained.</param>
protected override void UnconstrainPackageImpl(string systemIpAddress, XboxPackageDefinition package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.XboxXdk.UnconstrainPackage(systemIpAddress, package.FullName);
}
/// <summary>
/// Snaps the given application.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="application">The application to be snapped.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="application"/> parameter is null.</exception>
protected override void SnapApplicationImpl(string systemIpAddress, XboxApplicationDefinition application)
{
if (application == null)
{
throw new ArgumentNullException("application");
}
this.XboxXdk.SnapApplication(systemIpAddress, application.Aumid);
}
/// <summary>
/// Unsnaps the currently snapped application.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
protected override void UnsnapApplicationImpl(string systemIpAddress)
{
this.XboxXdk.UnsnapApplication(systemIpAddress);
}
/// <summary>
/// Retrieves the execution state of the given package.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="package">The package for which the execution state shall be retrieved.</param>
/// <returns>The current execution state of the package given by the <paramref name="package"/> parameter.</returns>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="package"/> parameter is null.</exception>
/// <exception cref="XboxConsoleException">Thrown if the execution state value returned by the XDK does not match one of the expected values.</exception>
protected override PackageExecutionState QueryPackageExecutionStateImpl(string systemIpAddress, XboxPackageDefinition package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
uint xdkValue = this.comExceptionWhenConnectingHandler.CheckForCOMExceptionWhenConnecting(() => { return this.XboxXdk.QueryPackageExecutionState(systemIpAddress, package.FullName); }, systemIpAddress);
// Interpretation of the following values comes from the XDK team's sources.
// The following C++ header files:
//
// $\sdpublic\xbox\sra\internal\sdk\inc\appmodeltools.h
// $\xbox\base\appmodel\appmodeltools\inc\appmodeltools.h
//
// define an enum containing constants we are using to distinguish package states:
//
// typedef enum {
// AMT_PACKAGE_STATE_UNKNOWN,
// AMT_PACKAGE_STATE_RUNNING,
// AMT_PACKAGE_STATE_SUSPENDING,
// AMT_PACKAGE_STATE_SUSPENDED,
// AMT_PACKAGE_STATE_TERMINATED,
// AMT_PACKAGE_STATE_CONSTRAINED,
// } AMT_PACKAGE_STATE;
switch (xdkValue)
{
case 0:
return PackageExecutionState.Unknown;
case 1:
return PackageExecutionState.Running;
case 2:
return PackageExecutionState.Suspending;
case 3:
return PackageExecutionState.Suspended;
case 4:
return PackageExecutionState.Terminated;
case 5:
return PackageExecutionState.Constrained;
default:
throw new XboxConsoleException(string.Format(CultureInfo.InvariantCulture, "Unknown package execution state value of '{0}'", xdkValue));
}
}
/// <summary>
/// Push deploys file to the console.
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="deployFilePath">The path to the folder to deploy.</param>
/// <param name="removeExtraFiles"><c>true</c> to remove any extra files, <c>false</c> otherwise.</param>
/// <param name="progressMetric">The progress handler that the calling app uses to receive progress updates about metrics. This may be null.</param>
/// <param name="progressError">The progress handler that the calling app uses to receive progress updates about errors. This may be null.</param>
/// <param name="progressExtraFile">The progress handler that the calling app uses to receive progress updates about extra files. This may be null.</param>
/// <returns>The task object representing the asynchronous operation whose result is the deployed package.</returns>
protected async override Task<XboxPackageDefinition> DeployPushImplAsync(string systemIpAddress, string deployFilePath, bool removeExtraFiles, IProgress<XboxDeploymentMetric> progressMetric, IProgress<XboxDeploymentError> progressError, IProgress<XboxDeploymentExtraFile> progressExtraFile)
{
if (deployFilePath == null)
{
throw new ArgumentNullException("deployFilePath");
}
// In the July 2014 XDK the format of the string returned by the XDK is a JSON object with this schema:
// {"Applications":["XboxConsole.XboxSample_zjr0dfhgjwvde!App"],"Identity":{"FullName":"XboxConsole.XboxSample_1.0.0.0_x64__zjr0dfhgjwvde"}}
string xdkOutput = await this.XboxXdk.DeployPushAsync(systemIpAddress, deployFilePath, removeExtraFiles, progressMetric, progressError, progressExtraFile);
DeploymentPackage package;
try
{
using (XmlDictionaryReader jsonReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.Unicode.GetBytes(xdkOutput), XmlDictionaryReaderQuotas.Max))
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(DeploymentPackage));
package = (DeploymentPackage)serializer.ReadObject(jsonReader);
}
}
catch (ArgumentNullException ex)
{
throw new XboxConsoleException("Failed to parse installed packages string.", ex);
}
catch (SerializationException ex)
{
throw new XboxConsoleException("Failed to parse installed packages string.", ex);
}
string packageFullName = package.Identity.FullName;
string aumid = package.Applications.FirstOrDefault();
return new XboxPackageDefinition(packageFullName, package.Applications);
}
/// <summary>
/// Uninstall a package from a given console based on its package full name.
/// </summary>
/// <param name="systemIpAddress">The IP address of the console to be affected.</param>
/// <param name="package">The package to be uninstalled.</param>
protected override void UninstallPackageImpl(string systemIpAddress, XboxPackageDefinition package)
{
if (string.IsNullOrWhiteSpace(systemIpAddress))
{
throw new ArgumentNullException("systemIpAddress");
}
if (package == null)
{
throw new ArgumentNullException("package");
}
this.XboxXdk.UninstallPackage(systemIpAddress, package.FullName);
}
[DataContract]
private class Package
{
[DataMember]
public string FullName { get; set; }
[DataMember]
public Application[] Applications { get; set; }
}
[DataContract]
private class Application
{
[DataMember]
public string Aumid { get; set; }
}
[DataContract]
private class InstalledPackages
{
[DataMember]
public Package[] Packages { get; set; }
}
[DataContract]
private class PackageIdentity
{
[DataMember]
public string FullName { get; set; }
}
[DataContract]
private class DeploymentPackage
{
[DataMember]
public string[] Applications { get; set; }
[DataMember]
public PackageIdentity Identity { get; set; }
}
}
}

Просмотреть файл

@ -0,0 +1,370 @@
//------------------------------------------------------------------------------
// <copyright file="XboxConsoleAdapter.User.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.InteropServices;
using Microsoft.Internal.GamesTest.Xbox;
/// <summary>
/// This class represents an implemenation of the XboxConsoleAdapter
/// that is supported by the May 2014 version of the XDK.
/// </summary>
internal partial class XboxConsoleAdapter : XboxConsoleAdapterBase
{
/// <summary>
/// Common message for NoLocalSignedInUsersInPartyException.
/// </summary>
private const string NoPartyMembersMessage = "There are no local signed in users in the party.";
/// <summary>
/// Common message for InvalidPartyInviteException.
/// </summary>
private const string InvalidPartyOperationMessage = "Invalid party invite operation or party ID";
/// <summary>
/// Common message for InvalidXuidException.
/// </summary>
private const string InvalidXuid = "Invalid XUID passed for one of the parameters, or one of the XUIDs cannot be used for the requested operation.";
/// <summary>
/// Connects to the console and retrieves the collection of users.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <returns>An enumeration of XboxUserDefinition instances.</returns>
protected override IEnumerable<XboxUserDefinition> GetUsersImpl(string systemIpAddress)
{
return this.XboxXdk.GetUsers(systemIpAddress);
}
/// <summary>
/// Adds a guest user.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <returns>The user id of the added guest user.</returns>
protected override uint AddGuestUserImpl(string systemIpAddress)
{
return this.XboxXdk.AddGuestUser(systemIpAddress);
}
/// <summary>
/// Adds a user to the console.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="emailAddress">The email address of the user to be added.</param>
/// <returns>An XboxUserDefinition of the added user.</returns>
protected override XboxUserDefinition AddUserImpl(string systemIpAddress, string emailAddress)
{
if (string.IsNullOrWhiteSpace(emailAddress))
{
throw new ArgumentException("emailAddress cannot be null or whitespace.", "emailAddress");
}
var user = this.XboxXdk.AddUser(systemIpAddress, emailAddress);
if (user == null)
{
throw new XboxConsoleException("An error occured while adding a user.", systemIpAddress);
}
return user;
}
/// <summary>
/// Removes all users from the console.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <remarks>Signed-in users are signed out before being removed from the console.</remarks>
protected override void DeleteAllUsersImpl(string systemIpAddress)
{
this.XboxXdk.DeleteAllUsers(systemIpAddress);
}
/// <summary>
/// Removes the specified user from the console.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="user">The user to be removed.</param>
/// <remarks>A signed-in user is signed out before being removed from the console.</remarks>
protected override void DeleteUserImpl(string systemIpAddress, XboxUserDefinition user)
{
this.XboxXdk.DeleteUser(systemIpAddress, user);
}
/// <summary>
/// Signs the given user into Xbox Live.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="user">The user to sign in.</param>
/// <param name="password">The password of the user for signing in. If a password has been stored on the console, <c>null</c> can be passed in.</param>
/// <param name="storePassword">If <c>true</c>, saves the given password on the console for later use.</param>
/// <returns>An XboxUserDefinition of the signed-in user.</returns>
protected override XboxUserDefinition SignInUserImpl(string systemIpAddress, XboxUserDefinition user, string password, bool storePassword)
{
if (user == null)
{
throw new ArgumentNullException("user", "user cannot be null");
}
try
{
return this.XboxXdk.SignInUser(systemIpAddress, user, password, storePassword);
}
catch (COMException ex)
{
switch (unchecked((uint)ex.ErrorCode))
{
case 0x80048823:
throw new XboxSignInException(string.Format(CultureInfo.InvariantCulture, "The given user's email address {0} is not valid.", user.EmailAddress), ex, systemIpAddress);
case 0x8004882E:
throw new XboxSignInException("The password for the given user is not stored on the console. You must supply a password as part of the sign in operation.", ex, systemIpAddress);
case 0x80048821:
throw new XboxSignInException("The password for the given user is invalid.", ex, systemIpAddress);
case 0x8015DC16:
throw new XboxSignInException("The given user is signed in on another console.", ex, systemIpAddress);
default:
throw;
}
}
}
/// <summary>
/// Signs out the given user.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="user">The user to sign-out.</param>
/// <returns>An XboxUserDefinition of the signed-out user.</returns>
protected override XboxUserDefinition SignOutUserImpl(string systemIpAddress, XboxUserDefinition user)
{
return this.XboxXdk.SignOutUser(systemIpAddress, user);
}
/// <summary>
/// Pairs the XboxGamepad to the XboxUser.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="gamepadId">The Id of the XboxGamepad to set the state of.</param>
/// <param name="userId">The Id of the XboxUser to pair to.</param>
protected override void PairGamepadToUserImpl(string systemIpAddress, ulong gamepadId, uint userId)
{
try
{
this.XboxXdk.PairControllerToUser(systemIpAddress, userId, gamepadId);
}
catch (COMException e)
{
if (e.HResult == -2136866047)
{
throw new XboxException("An invalid or signed-out user attempted to pair with a gamepad.", e);
}
else if (e.HResult == -2136866301)
{
throw new XboxException("A user attempted to pair with an invalid or nonexistent gamepad.", e);
}
else
{
throw;
}
}
}
/// <summary>
/// Creates a party for the given title ID (if one does not exist) and adds the given local users to it.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="actingUserXuid">Acting user XUID on whose behalf to add other users to the party.</param>
/// <param name="localUserXuidsToAdd">User XUIDs to add to the party.</param>
protected override void AddLocalUsersToPartyImpl(string systemIpAddress, uint titleId, string actingUserXuid, string[] localUserXuidsToAdd)
{
try
{
this.XboxXdk.AddLocalUsersToParty(systemIpAddress, titleId, actingUserXuid, localUserXuidsToAdd);
}
catch (COMException e)
{
if (e.HResult == unchecked((int)0x80004003))
{
throw new InvalidXuidException(InvalidXuid, e, systemIpAddress);
}
else
{
throw;
}
}
}
/// <summary>
/// Invites the given users on behalf of the acting user to the party associated with the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="actingUserXuid">Acting user XUID on whose behalf to invite other users to the party.</param>
/// <param name="remoteUserXuidsToInvite">Remote user XUIDs to invite to the party.</param>
protected override void InviteToPartyImpl(string systemIpAddress, uint titleId, string actingUserXuid, string[] remoteUserXuidsToInvite)
{
try
{
this.XboxXdk.InviteToParty(systemIpAddress, titleId, actingUserXuid, remoteUserXuidsToInvite);
}
catch (COMException e)
{
if (e.HResult == unchecked((int)0x80004003))
{
throw new InvalidXuidException(InvalidXuid, e, systemIpAddress);
}
else if (e.HResult == unchecked((int)0x87CC0007))
{
throw new NoLocalSignedInUsersInPartyException(NoPartyMembersMessage, e, systemIpAddress);
}
else
{
throw;
}
}
}
/// <summary>
/// Removes the given users from the party belonging to the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="localUserXuidsToRemove">Local user XUIDs to remove from the party.</param>
protected override void RemoveLocalUsersFromPartyImpl(string systemIpAddress, uint titleId, string[] localUserXuidsToRemove)
{
try
{
this.XboxXdk.RemoveLocalUsersFromParty(systemIpAddress, titleId, localUserXuidsToRemove);
}
catch (COMException e)
{
if (e.HResult == unchecked((int)0x87CC0007))
{
throw new NoLocalSignedInUsersInPartyException(NoPartyMembersMessage, e, systemIpAddress);
}
else if (e.HResult == unchecked((int)0x80004003))
{
throw new InvalidXuidException(InvalidXuid, e, systemIpAddress);
}
else
{
throw;
}
}
}
/// <summary>
/// Returns the party ID belonging to the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to get the associated party ID for.</param>
/// <returns>ID of existing party used to accept or decline an invitation to the party.</returns>
protected override string GetPartyIdImpl(string systemIpAddress, uint titleId)
{
try
{
return this.XboxXdk.GetPartyId(systemIpAddress, titleId);
}
catch (COMException e)
{
if (e.HResult == unchecked((int)0x87CC0007))
{
throw new NoLocalSignedInUsersInPartyException(NoPartyMembersMessage, e, systemIpAddress);
}
else
{
throw;
}
}
}
/// <summary>
/// Lists both the current members and the reserved members of the party belonging to given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to get party members for.</param>
/// <returns>Party member user XUIDs, which may contain a mix of local and remote users.</returns>
protected override string[] GetPartyMembersImpl(string systemIpAddress, uint titleId)
{
try
{
return this.XboxXdk.GetPartyMembers(systemIpAddress, titleId);
}
catch (COMException e)
{
if (e.HResult == unchecked((int)0x87CC0007))
{
throw new NoLocalSignedInUsersInPartyException(NoPartyMembersMessage, e, systemIpAddress);
}
else
{
throw;
}
}
}
/// <summary>
/// Accepts the party invitation on behalf of the given acting user to the party associated with the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="actingUserXuid">XUID of acting user on whose behalf to accept the invitation.</param>
/// <param name="partyId">Title ID of the party created by another user to accept the invitation to.</param>
protected override void AcceptInviteToPartyImpl(string systemIpAddress, string actingUserXuid, string partyId)
{
try
{
this.XboxXdk.AcceptInviteToParty(systemIpAddress, actingUserXuid, partyId);
}
catch (COMException e)
{
if (e.HResult == unchecked((int)0x8019019c))
{
throw new InvalidPartyInviteException(InvalidPartyOperationMessage, e, systemIpAddress);
}
else if (e.HResult == unchecked((int)0x80004003))
{
throw new InvalidXuidException(InvalidXuid, e, systemIpAddress);
}
else
{
throw;
}
}
}
/// <summary>
/// Declines the party invitation on behalf of the given acting user to the party associated with the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="actingUserXuid">XUID of acting user on whose behalf to decline the invitation.</param>
/// <param name="partyId">Title ID of the party created by another user to accept the invitation to.</param>
protected override void DeclineInviteToPartyImpl(string systemIpAddress, string actingUserXuid, string partyId)
{
try
{
this.XboxXdk.DeclineInviteToParty(systemIpAddress, actingUserXuid, partyId);
}
catch (COMException e)
{
if (e.HResult == unchecked((int)0x8019019c))
{
throw new InvalidPartyInviteException(InvalidPartyOperationMessage, e, systemIpAddress);
}
else if (e.HResult == unchecked((int)0x80004003))
{
throw new InvalidXuidException(InvalidXuid, e, systemIpAddress);
}
else
{
throw;
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,98 @@
//------------------------------------------------------------------------------
// <copyright file="XboxConsoleAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System.Net;
/// <summary>
/// This class represents an implemenation of the XboxConsoleAdapter
/// that is supported by the July 2014 version of the XDK.
/// </summary>
internal partial class XboxConsoleAdapter : XboxConsoleAdapterBase
{
/// <summary>
/// Initializes a new instance of the XboxConsoleAdapter class.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "This is taken care of in this.Dispose(bool)")]
public XboxConsoleAdapter()
: base(new XboxXdk())
{
}
/// <summary>
/// Initializes a new instance of the XboxConsoleAdapter class.
/// </summary>
/// <param name="xboxXdk">The XboxXdk functional facade implementation.</param>
public XboxConsoleAdapter(XboxXdkBase xboxXdk)
: base(xboxXdk)
{
}
/// <summary>
/// Gets or sets the default console address.
/// </summary>
protected override string DefaultConsoleImpl
{
get
{
return this.XboxXdk.DefaultConsole;
}
set
{
this.XboxXdk.DefaultConsole = value;
}
}
/// <summary>
/// Queries for and returns a value of an Xbox configuration property (see xbconnect command line utility).
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="key">The configuration property name.</param>
/// <returns>The configuration property value.</returns>
protected override string GetConfigValueImpl(string systemIpAddress, string key)
{
return this.XboxXdk.GetConfigValue(systemIpAddress, AdapterConfigurationKeyMapping.MapKey(key));
}
/// <summary>
/// Sets an Xbox configuration property to the specified value (see xbconnect command line utility).
/// </summary>
/// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param>
/// <param name="key">The configuration property name.</param>
/// <param name="value">The configuration property value.</param>
protected override void SetConfigValueImpl(string systemIpAddress, string key, string value)
{
this.XboxXdk.SetConfigValue(systemIpAddress, AdapterConfigurationKeyMapping.MapKey(key), value);
}
/// <summary>
/// Disposes of resources used by this class.
/// </summary>
/// <param name="disposing">The indicator whether Dispose() was called explicitly or from the finalizer.</param>
protected override void Dispose(bool disposing)
{
if (!this.IsDisposed)
{
if (disposing)
{
if (this.systemXboxDebugMonitorClient != null)
{
this.systemXboxDebugMonitorClient.Dispose();
}
if (this.titleXboxDebugMonitorClient != null)
{
this.titleXboxDebugMonitorClient.Dispose();
}
}
}
base.Dispose(disposing);
}
}
}

Просмотреть файл

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <copyright file="XboxDebugMonitorClient.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using Microsoft.Xbox.XTF.Diagnostics;
/// <summary>
/// XDK-agnostic wrapper of Xtf's DebugMonitorClient.
/// </summary>
internal class XboxDebugMonitorClient : DisposableObject, IXboxDebugMonitorClient
{
/// <summary>
/// Initializes a new instance of the XboxDebugMonitorClient class.
/// </summary>
/// <param name="address">The address used to instantiate the underlying DebugMonitorClient.</param>
internal XboxDebugMonitorClient(string address)
{
this.Client = new DebugMonitorClient(address);
}
private DebugMonitorClient Client { get; set; }
/// <summary>
/// Starts debug monitoring.
/// </summary>
/// <param name="processId">The Xbox Console process Id.</param>
/// <param name="handler">The text event handler.</param>
public void Start(uint processId, EventHandler<TextEventArgs> handler)
{
this.ThrowIfDisposed();
this.Client.Start(
processId,
StartFlags.None,
(sender, eventArgs) =>
{
if (handler != null)
{
handler(sender, new TextEventArgs(eventArgs.DebugString));
}
});
}
/// <summary>
/// Stops debug monitoring.
/// </summary>
/// <param name="processId">The Xbox Console process Id.</param>
public void Stop(uint processId)
{
this.ThrowIfDisposed();
this.Client.Stop(processId, StopFlags.None);
}
/// <summary>
/// Disposes of managed resources used by this class.
/// </summary>
protected override void DisposeManagedResources()
{
if (this.Client != null)
{
this.Client.Dispose();
}
base.DisposeManagedResources();
}
}
}

Просмотреть файл

@ -0,0 +1,129 @@
//------------------------------------------------------------------------------
// <copyright file="XboxGamepadAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.July2014
{
using System;
using System.Globalization;
using Microsoft.Internal.GamesTest.Xbox.Input;
using Microsoft.Xbox.Input;
using Microsoft.Xbox.XTF;
using Microsoft.Xbox.XTF.Input;
/// <summary>
/// Adapter specific logic for the XboxGamepad class.
/// </summary>
internal class XboxGamepadAdapter : IVirtualGamepad
{
// Constant used by Xtf to map a trigger value in the range 0.0 to 1.0 to the range 0.0 to 255.0. (Equivalent to 1.0 / 255.0.)
private const float TriggerConversion = 0.003922f;
private XtfGamepad xtfGamepad;
private string originalIpAddress;
/// <summary>
/// Initializes a new instance of the XboxGamepadAdapter class.
/// </summary>
/// <param name="systemIpAddress">Original IP address the XTF gamepad was connected to (used for error reporting).</param>
/// <param name="xtfGamepad">An XtfGamepad.</param>
public XboxGamepadAdapter(string systemIpAddress, XtfGamepad xtfGamepad)
{
this.originalIpAddress = systemIpAddress;
this.xtfGamepad = xtfGamepad;
}
/// <summary>
/// Gets the id of the connected gamepad.
/// </summary>
public ulong Id
{
get
{
return this.xtfGamepad.Id;
}
}
/// <summary>
/// Connects an XtfGamepad.
/// </summary>
/// <returns>The Id of the gamepad.</returns>
public ulong Connect()
{
try
{
this.xtfGamepad.Connect();
return this.xtfGamepad.Id;
}
catch (XtfInputException ex)
{
throw new XboxInputException(
string.Format(CultureInfo.InvariantCulture, "Could not connect gamepad.{0}**Hint** Max allowed connections is 16, controllers may still be connected if previous instances have crashed or debugging stopped. This may require a reboot of the kit.", Environment.NewLine),
ex,
this.originalIpAddress,
null);
}
}
/// <summary>
/// Disconnects an XtfGamepad.
/// </summary>
public void Disconnect()
{
this.xtfGamepad.Disconnect();
}
/// <summary>
/// Sets the gamepad state.
/// </summary>
/// <param name="state">The new state for the gamepad.</param>
public void SetGamepadState(XboxGamepadState state)
{
if (state == null)
{
throw new ArgumentNullException("state");
}
GAMEPAD_REPORT report;
report.Buttons = (ushort)state.Buttons;
report.LeftThumbstickX = this.ConvertGamepadStateThumbstickValue(state.LeftThumbstickX);
report.LeftThumbstickY = this.ConvertGamepadStateThumbstickValue(state.LeftThumbstickY);
report.RightThumbstickX = this.ConvertGamepadStateThumbstickValue(state.RightThumbstickX);
report.RightThumbstickY = this.ConvertGamepadStateThumbstickValue(state.RightThumbstickY);
report.LeftTrigger = this.ConvertGamepadStateTriggerValue(state.LeftTrigger);
report.RightTrigger = this.ConvertGamepadStateTriggerValue(state.RightTrigger);
this.xtfGamepad.SetGamepadState(report);
}
/// <summary>
/// Converts a trigger value from a GamepadState format to a GAMEPAD_REPORT format.
/// </summary>
/// <param name="val">Trigger value as a float.</param>
/// <returns>Trigger value as a ushort.</returns>
/// <remarks>
/// This conversion is the same one used by Xtf to map a floating point value in the range 0.0 to 1.0
/// to an integral value in the range 0 to 1023.
/// </remarks>
private ushort ConvertGamepadStateTriggerValue(float val)
{
return (ushort)((short)(val / TriggerConversion) * 4);
}
/// <summary>
/// Converts a thumbstick value from a GamepadState format to a GAMEPAD_REPORT format.
/// </summary>
/// <param name="val">Thumbstick value as a float.</param>
/// <returns>Thumbstick value as a ushort.</returns>
/// <remarks>
/// This conversion is the same one used by Xtf to map a floating point value in the range -1.0 to 1.0
/// to an integral value in the range -32768 to 32767.
/// </remarks>
private short ConvertGamepadStateThumbstickValue(float val)
{
return (short)(val * short.MaxValue);
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -9,7 +9,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AdapterVersion = Microsoft.Internal.GamesTest.Xbox.Adapter.May2014;
using AdapterVersion = Microsoft.Internal.GamesTest.Xbox.Adapter.July2014;
namespace Microsoft.Internal.GamesTest.Xbox.Adapter.Tests
{

Просмотреть файл

@ -198,6 +198,41 @@ namespace Microsoft.Internal.GamesTest.Xbox.Adapter.Tests
/// </summary>
public Action<string, uint, ulong> PairControllerToUserFunc { get; set; }
/// <summary>
/// Gets or sets the function to shim the "AddLocalUsersToParty" method.
/// </summary>
public Action<string, uint, string, string[]> AddLocalUsersToPartyFunc { get; set; }
/// <summary>
/// Gets or sets the function to shim the "InviteToParty" method.
/// </summary>
public Action<string, uint, string, string[]> InviteToPartyFunc { get; set; }
/// <summary>
/// Gets or sets the function to shim the "RemoveLocalUsersFromParty" method.
/// </summary>
public Action<string, uint, string[]> RemoveLocalUsersFromPartyFunc { get; set; }
/// <summary>
/// Gets or sets the function to shim the "GetPartyId" method.
/// </summary>
public Func<string, uint, string> GetPartyIdFunc { get; set; }
/// <summary>
/// Gets or sets the function to shim the "GetPartyMembers" method.
/// </summary>
public Func<string, uint, string[]> GetPartyMembersFunc { get; set; }
/// <summary>
/// Gets or sets the function to shim the "AcceptInviteToParty" method.
/// </summary>
public Action<string, string, string> AcceptInviteToPartyFunc { get; set; }
/// <summary>
/// Gets or sets the function to shim the "DeclineInviteToParty" method.
/// </summary>
public Action<string, string, string> DeclineInviteToPartyFunc { get; set; }
/// <summary>
/// Gets or sets the function to shim the "CaptureScreenshot" method.
/// </summary>
@ -830,6 +865,134 @@ namespace Microsoft.Internal.GamesTest.Xbox.Adapter.Tests
}
}
/// <summary>
/// Creates a party for the given title ID (if one does not exist) and adds the given local users to it.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="actingUserXuid">Acting user XUID on whose behalf to add other users to the party.</param>
/// <param name="localUserXuidsToAdd">User XUIDs to add to the party.</param>
public override void AddLocalUsersToParty(string ipAddress, uint titleId, string actingUserXuid, string[] localUserXuidsToAdd)
{
if (this.AddLocalUsersToPartyFunc != null)
{
this.AddLocalUsersToPartyFunc(ipAddress, titleId, actingUserXuid, localUserXuidsToAdd);
}
else
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
}
/// <summary>
/// Invites the given users on behalf of the acting user to the party associated with the given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="actingUserXuid">Acting user XUID on whose behalf to invite other users to the party.</param>
/// <param name="remoteUserXuidsToInvite">Remote user XUIDs to invite to the party.</param>
public override void InviteToParty(string ipAddress, uint titleId, string actingUserXuid, string[] remoteUserXuidsToInvite)
{
if (this.InviteToPartyFunc != null)
{
this.InviteToPartyFunc(ipAddress, titleId, actingUserXuid, remoteUserXuidsToInvite);
}
else
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
}
/// <summary>
/// Removes the given users from the party belonging to the given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="localUserXuidsToRemove">Local user XUIDs to remove from the party.</param>
public override void RemoveLocalUsersFromParty(string ipAddress, uint titleId, string[] localUserXuidsToRemove)
{
if (this.RemoveLocalUsersFromPartyFunc != null)
{
this.RemoveLocalUsersFromPartyFunc(ipAddress, titleId, localUserXuidsToRemove);
}
else
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
}
/// <summary>
/// Returns the party ID belonging to the given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="titleId">Title ID of the title to get the associated party ID for.</param>
/// <returns>ID of existing party used to accept or decline an invitation to the party.</returns>
public override string GetPartyId(string ipAddress, uint titleId)
{
if (this.GetPartyIdFunc != null)
{
return this.GetPartyIdFunc(ipAddress, titleId);
}
else
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
}
/// <summary>
/// Lists both the current members and the reserved members of the party belonging to given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="titleId">Title ID of the title to get party members for.</param>
/// <returns>Party member user XUIDs, which may contain a mix of local and remote users.</returns>
public override string[] GetPartyMembers(string ipAddress, uint titleId)
{
if (this.GetPartyMembersFunc != null)
{
return this.GetPartyMembersFunc(ipAddress, titleId);
}
else
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
}
/// <summary>
/// Accepts the party invitation on behalf of the given acting user to the party associated with the given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="actingUserXuid">XUID of acting user on whose behalf to accept the invitation.</param>
/// <param name="partyId">Title ID of the party created by another user to accept the invitation to.</param>
public override void AcceptInviteToParty(string ipAddress, string actingUserXuid, string partyId)
{
if (this.AcceptInviteToPartyFunc != null)
{
this.AcceptInviteToPartyFunc(ipAddress, actingUserXuid, partyId);
}
else
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
}
/// <summary>
/// Declines the party invitation on behalf of the given acting user to the party associated with the given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="actingUserXuid">XUID of acting user on whose behalf to decline the invitation.</param>
/// <param name="partyId">Title ID of the party created by another user to accept the invitation to.</param>
public override void DeclineInviteToParty(string ipAddress, string actingUserXuid, string partyId)
{
if (this.DeclineInviteToPartyFunc != null)
{
this.DeclineInviteToPartyFunc(ipAddress, actingUserXuid, partyId);
}
else
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
}
/// <summary>
/// Pairs a controller to a user on a console.
/// </summary>

Двоичный файл не отображается.

Просмотреть файл

@ -92,9 +92,9 @@
<Fakes Include="Fakes\mscorlib.fakes" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\XboxConsole.Adapter.May2014\XboxConsole.Adapter.May2014.csproj">
<Project>{7c44371f-e7ee-4a48-bdc8-54e69a4f7c0c}</Project>
<Name>XboxConsole.Adapter.May2014</Name>
<ProjectReference Include="..\XboxConsole.Adapter.July2014\XboxConsole.Adapter.July2014.csproj">
<Project>{e842b4d7-58d2-4435-b876-004de9a45fbd}</Project>
<Name>XboxConsole.Adapter.July2014</Name>
</ProjectReference>
<ProjectReference Include="..\XboxConsole.Infrastructure\XboxConsole.Infrastructure.csproj">
<Project>{e0785338-9f71-4d35-95a8-6388bc7f5518}</Project>

Просмотреть файл

@ -19,11 +19,18 @@ namespace Microsoft.Internal.GamesTest.Xbox.Adapter.Tests
{
private const string AdapterUserTestCategory = "Adapter.User";
private const string TestEmailAddressString = "TestEmailAddress@Test.test";
private const string TestXuidString = "1212121212121212";
private const string TestGamerTag = "TestGamerTag";
private const string TestPartyId = "1234567";
private const uint TestTitleId = 0x12345;
private const int InvalidEmailErrorCode = unchecked((int)0x80048823);
private const int PasswordNotStoredErrorCode = unchecked((int)0x8004882E);
private const int InvalidPasswordErrorCode = unchecked((int)0x80048821);
private const int SignedInElsewhereErrorCode = unchecked((int)0x8015DC16);
private const int InvalidXuidErrorCode = unchecked((int)0x80004003);
private const int NoLocalUsersErrorCode = unchecked((int)0x87CC0007);
private const int InvalidPartyInviteErrorCode = unchecked((int)0x8019019c);
/// <summary>
/// Verifies that if the XDK's GetUsers method throws a COMException, then the
@ -97,7 +104,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Adapter.Tests
[TestCategory(AdapterUserTestCategory)]
public void TestGetUsers()
{
var expectedDefinition = new XboxUserDefinition(0, "Test email address", "Test gamertag", true);
var expectedDefinition = new XboxUserDefinition(0, "Test email address", "Test gamertag", true, false, TestXuidString);
var expectedDefinitionCollection = new XboxUserDefinition[] { expectedDefinition };
this.fakeXboxXdk.GetUsersFunc = ipAddress =>
@ -531,7 +538,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Adapter.Tests
[TestCategory(AdapterUserTestCategory)]
public void TestDeleteUserCallsXdkDeleteUser()
{
XboxUserDefinition expectedUser = new XboxUserDefinition(1, TestEmailAddressString, "TestGamerTag", false);
XboxUserDefinition expectedUser = new XboxUserDefinition(1, TestEmailAddressString, TestGamerTag, false);
bool isCorrectFunctionCalled = false;
@ -609,7 +616,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Adapter.Tests
[TestCategory(AdapterUserTestCategory)]
public void TestSignOutUserCallsXdkSignOutUser()
{
XboxUserDefinition expectedUser = new XboxUserDefinition(1, TestEmailAddressString, "TestGamerTag", false);
XboxUserDefinition expectedUser = new XboxUserDefinition(1, TestEmailAddressString, TestGamerTag, false);
bool isCorrectFunctionCalled = false;
@ -697,7 +704,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Adapter.Tests
{
const string ExpectedPassword = "TestPassword";
XboxUserDefinition expectedUser = new XboxUserDefinition(1, "TestEmailAddress@test.test", "TestGamerTag", false);
XboxUserDefinition expectedUser = new XboxUserDefinition(1, "TestEmailAddress@test.test", TestGamerTag, false);
bool expectedStorePassword = false;
this.VerifyThrows<ArgumentNullException>(() => this.adapter.SignInUser(null, expectedUser, ExpectedPassword, expectedStorePassword));
@ -740,43 +747,882 @@ namespace Microsoft.Internal.GamesTest.Xbox.Adapter.Tests
[TestCategory(AdapterUserTestCategory)]
public void TestSignInUserTurnsSpecificComExceptionIntoXboxSignInExceptions()
{
COMException invalidEmailException = new COMException(null, InvalidEmailErrorCode);
COMException passwordNotStoredException = new COMException(null, PasswordNotStoredErrorCode);
COMException invalidPasswordException = new COMException(null, InvalidPasswordErrorCode);
COMException signedInElsewhereException = new COMException(null, SignedInElsewhereErrorCode);
Action adapterCall = () => { this.adapter.SignInUser(ConsoleAddress, new XboxUserDefinition(0, TestEmailAddressString, TestGamerTag, false, false, TestXuidString), null, false); };
this.VerifySignInHandlesSpecificComExceptions(invalidEmailException);
this.VerifySignInHandlesSpecificComExceptions(passwordNotStoredException);
this.VerifySignInHandlesSpecificComExceptions(invalidPasswordException);
this.VerifySignInHandlesSpecificComExceptions(signedInElsewhereException);
COMException invalidEmailException = new COMException(null, InvalidEmailErrorCode);
this.fakeXboxXdk.SignInUserFunc = (ipAddress, userDef, password, savePassword) => { throw invalidEmailException; };
this.VerifyFunctionHandlesSpecificComExceptions(
invalidEmailException,
typeof(XboxConsoleException),
adapterCall);
COMException passwordNotStoredException = new COMException(null, PasswordNotStoredErrorCode);
this.fakeXboxXdk.SignInUserFunc = (ipAddress, userDef, password, savePassword) => { throw passwordNotStoredException; };
this.VerifyFunctionHandlesSpecificComExceptions(
passwordNotStoredException,
typeof(XboxConsoleException),
adapterCall);
COMException invalidPasswordException = new COMException(null, InvalidPasswordErrorCode);
this.fakeXboxXdk.SignInUserFunc = (ipAddress, userDef, password, savePassword) => { throw invalidPasswordException; };
this.VerifyFunctionHandlesSpecificComExceptions(
invalidPasswordException,
typeof(XboxConsoleException),
adapterCall);
COMException signedInElsewhereException = new COMException(null, SignedInElsewhereErrorCode);
this.fakeXboxXdk.SignInUserFunc = (ipAddress, userDef, password, savePassword) => { throw signedInElsewhereException; };
this.VerifyFunctionHandlesSpecificComExceptions(
signedInElsewhereException,
typeof(XboxConsoleException),
adapterCall);
}
/// <summary>
/// Verifies that SignInUser correctly recognizes expected COMExceptions
/// and wraps them in a XboxSignInException.
/// Verifies that if the XDK's AddLocalUsersToParty method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
/// <param name="expectedCOMException">The COMException to be thrown and caught.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Need to catch all exception types so that I can verify we capture the correct exception type.")]
private void VerifySignInHandlesSpecificComExceptions(COMException expectedCOMException)
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestAddLocalUsersToPartyTurnsComExceptionIntoXboxConsoleException()
{
this.fakeXboxXdk.SignInUserFunc = (ipAddress, user, password, storePassword) =>
this.fakeXboxXdk.AddLocalUsersToPartyFunc = (ipAddress, titleId, actingUserXuid, localUserXuidsToAdd) =>
{
throw expectedCOMException;
throw new COMException();
};
try
{
this.adapter.SignInUser(ConsoleAddress, new XboxUserDefinition(0, null, null, false), null, false);
this.adapter.AddLocalUsersToParty(ConsoleAddress, TestTitleId, string.Empty, new string[0]);
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(XboxSignInException), "The adapter SignInUser method did not convert an expected COMException into an XboxSignInException.");
Assert.IsInstanceOfType(ex, typeof(XboxConsoleException), "The adapter AddLocalUsersToParty method did not convert a COMException into an XboxConsoleException.");
Assert.IsInstanceOfType(ex.InnerException, typeof(COMException), "The adapter AddLocalUsersToParty method did not include the COMException as the inner exception of the XboxConsoleException that it threw.");
}
}
/// <summary>
/// Verifies that an ObjectDisposedException is thrown if the AddLocalUsersToParty()
/// method is called after the object has been disposed.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ObjectDisposedException))]
public void TestAddLocalUsersToPartyThrowsObjectDisposedException()
{
this.adapter.Dispose();
this.adapter.AddLocalUsersToParty(ConsoleAddress, TestTitleId, string.Empty, new string[0]);
}
/// <summary>
/// Verifies that the adapter's AddLocalUsersToParty() method
/// calls the XboxXdk's AddLocalUsersToParty method.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestAddLocalUsersToPartyCallsXdkAddLocalUsersToParty()
{
bool isCorrectFunctionCalled = false;
this.fakeXboxXdk.AddLocalUsersToPartyFunc = (ipAddress, titleId, actingUserXuid, localUserXuids) =>
{
isCorrectFunctionCalled = true;
};
this.adapter.AddLocalUsersToParty(ConsoleAddress, TestTitleId, string.Empty, new string[0]);
Assert.IsTrue(isCorrectFunctionCalled, "The adapter's AddLocalUsersToParty function failed to call the XboxXdk's AddLocalUsersToParty function.");
}
/// <summary>
/// Verifies that the adapter's AddLocalUsersToParty method correctly handles passing on arguments.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestAddLocalUsersToPartyArguments()
{
this.fakeXboxXdk.AddLocalUsersToPartyFunc = (ipAddress, titleId, actingUserXuid, localUserXuids) =>
{
Assert.AreEqual(ConsoleAddress, ipAddress, "Adapter did not pass on the expected Console IP.");
Assert.AreEqual(TestTitleId, titleId, "Adapter did not pass on expected Title ID.");
Assert.AreEqual(TestXuidString, actingUserXuid, "Adapter did not pass on expected acting user XUID.");
Assert.AreEqual(1, localUserXuids.Length, "Adapter did not pass on expected number of local user XUIDs.");
Assert.AreEqual(TestXuidString, localUserXuids[0], "Adapter did not pass on expected local user XUID.");
};
this.adapter.AddLocalUsersToParty(ConsoleAddress, TestTitleId, TestXuidString, new string[] { TestXuidString });
}
/// <summary>
/// Verifies that an ArgumentNullException is thrown if the AddLocalUsersToParty()
/// method with null console.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ArgumentNullException))]
public void TestAddLocalUsersToPartyThrowsArgumentNullExceptionOnConsole()
{
this.adapter.AddLocalUsersToParty(null, TestTitleId, TestXuidString, new string[1] { TestXuidString });
}
/// <summary>
/// Verifies that if the XDK's AddLocalUsersToParty method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestAddLocalUsersToPartyTurnsSpecificComExceptionsIntoXboxConsoleExceptions()
{
Action adapterCall = () => { this.adapter.AddLocalUsersToParty(ConsoleAddress, TestTitleId, TestXuidString, new string[] { TestXuidString }); };
COMException invalidXuidException = new COMException(null, InvalidXuidErrorCode);
this.fakeXboxXdk.AddLocalUsersToPartyFunc = (ipAddress, titleId, actingUserXuid, addXuids) => { throw invalidXuidException; };
this.VerifyFunctionHandlesSpecificComExceptions(
invalidXuidException,
typeof(InvalidXuidException),
adapterCall);
}
/// <summary>
/// Verifies that if the XDK's InviteToParty method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Need to catch all exception types so that I can verify we capture the correct exception type.")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestInviteToPartyTurnsComExceptionIntoXboxConsoleException()
{
this.fakeXboxXdk.InviteToPartyFunc = (ipAddress, titleId, actingUserXuid, remoteUserXuidsToInvite) =>
{
throw new COMException();
};
try
{
this.adapter.InviteToParty(ConsoleAddress, TestTitleId, string.Empty, new string[0]);
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(XboxConsoleException), "The adapter InviteToParty method did not convert a COMException into an XboxConsoleException.");
Assert.IsInstanceOfType(ex.InnerException, typeof(COMException), "The adapter InviteToParty method did not include the COMException as the inner exception of the XboxConsoleException that it threw.");
}
}
/// <summary>
/// Verifies that an ObjectDisposedException is thrown if the InviteToParty()
/// method is called after the object has been disposed.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ObjectDisposedException))]
public void TestInviteToPartyThrowsObjectDisposedException()
{
this.adapter.Dispose();
this.adapter.InviteToParty(ConsoleAddress, TestTitleId, string.Empty, new string[0]);
}
/// <summary>
/// Verifies that the adapter's InviteToParty() method
/// calls the XboxXdk's InviteToParty method.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestInviteToPartyCallsXdkInviteToParty()
{
bool isCorrectFunctionCalled = false;
this.fakeXboxXdk.InviteToPartyFunc = (ipAddress, titleId, actingUserXuid, remoteUserXuids) =>
{
isCorrectFunctionCalled = true;
};
this.adapter.InviteToParty(ConsoleAddress, TestTitleId, string.Empty, new string[0]);
Assert.IsTrue(isCorrectFunctionCalled, "The adapter's InviteToParty function failed to call the XboxXdk's InviteToParty function.");
}
/// <summary>
/// Verifies that the adapter's InviteToParty method correctly handles passing on arguments.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestInviteToPartyArguments()
{
this.fakeXboxXdk.InviteToPartyFunc = (ipAddress, titleId, actingUserXuid, remoteUserXuids) =>
{
Assert.AreEqual(ConsoleAddress, ipAddress, "Adapter did not pass on the expected Console IP.");
Assert.AreEqual(TestTitleId, titleId, "Adapter did not pass on expected Title ID.");
Assert.AreEqual(TestXuidString, actingUserXuid, "Adapter did not pass on expected acting user XUID.");
Assert.AreEqual(1, remoteUserXuids.Length, "Adapter did not pass on expected number of local user XUIDs.");
Assert.AreEqual(TestXuidString, remoteUserXuids[0], "Adapter did not pass on expected local user XUID.");
};
this.adapter.InviteToParty(ConsoleAddress, TestTitleId, TestXuidString, new string[] { TestXuidString });
}
/// <summary>
/// Verifies that an ArgumentNullException is thrown if the InviteToParty()
/// method with null console.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ArgumentNullException))]
public void TestInviteToPartyThrowsArgumentNullExceptionOnConsole()
{
this.adapter.InviteToParty(null, TestTitleId, TestXuidString, new string[1] { TestXuidString });
}
/// <summary>
/// Verifies that if the XDK's InviteToParty method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestInviteToPartyTurnsSpecificComExceptionsIntoXboxConsoleExceptions()
{
Action adapterCall = () => { this.adapter.InviteToParty(ConsoleAddress, TestTitleId, TestXuidString, new string[] { TestXuidString }); };
COMException invalidXuidException = new COMException(null, InvalidXuidErrorCode);
this.fakeXboxXdk.InviteToPartyFunc = (ipAddress, titleId, actingUserXuid, partyId) => { throw invalidXuidException; };
this.VerifyFunctionHandlesSpecificComExceptions(
invalidXuidException,
typeof(InvalidXuidException),
adapterCall);
}
/// <summary>
/// Verifies that if the XDK's RemoveLocalUsersFromParty method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Need to catch all exception types so that I can verify we capture the correct exception type.")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestRemoveLocalUsersFromPartyTurnsComExceptionIntoXboxConsoleException()
{
this.fakeXboxXdk.RemoveLocalUsersFromPartyFunc = (ipAddress, titleId, remoteUserXuidsToInvite) =>
{
throw new COMException();
};
try
{
this.adapter.RemoveLocalUsersFromParty(ConsoleAddress, TestTitleId, new string[0]);
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(XboxConsoleException), "The adapter RemoveLocalUsersFromParty method did not convert a COMException into an XboxConsoleException.");
Assert.IsInstanceOfType(ex.InnerException, typeof(COMException), "The adapter RemoveLocalUsersFromParty method did not include the COMException as the inner exception of the XboxConsoleException that it threw.");
}
}
/// <summary>
/// Verifies that an ObjectDisposedException is thrown if the RemoveLocalUsersFromParty()
/// method is called after the object has been disposed.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ObjectDisposedException))]
public void TestRemoveLocalUsersFromPartyThrowsObjectDisposedException()
{
this.adapter.Dispose();
this.adapter.RemoveLocalUsersFromParty(ConsoleAddress, TestTitleId, new string[0]);
}
/// <summary>
/// Verifies that the adapter's RemoveLocalUsersFromParty() method
/// calls the XboxXdk's RemoveLocalUsersFromParty method and a null argument exception is thrown if Xbox IP is null.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestRemoveLocalUsersFromPartyCallsXdkRemoveLocalUsersFromParty()
{
bool isCorrectFunctionCalled = false;
this.fakeXboxXdk.RemoveLocalUsersFromPartyFunc = (ipAddress, titleId, remoteUserXuids) =>
{
isCorrectFunctionCalled = true;
};
this.adapter.RemoveLocalUsersFromParty(ConsoleAddress, TestTitleId, new string[0]);
Assert.IsTrue(isCorrectFunctionCalled, "The adapter's RemoveLocalUsersFromParty function failed to call the XboxXdk's RemoveLocalUsersFromParty function.");
this.VerifyThrows<ArgumentNullException>(() => this.adapter.RemoveLocalUsersFromParty(null, TestTitleId, new string[0]));
}
/// <summary>
/// Verifies that the adapter's RemoveLocalUsersFromParty method correctly handles passing on arguments.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestRemoveLocalUsersFromPartyArguments()
{
this.fakeXboxXdk.RemoveLocalUsersFromPartyFunc = (ipAddress, titleId, removeUserXuids) =>
{
Assert.AreEqual(ConsoleAddress, ipAddress, "Adapter did not pass on the expected Console IP.");
Assert.AreEqual(TestTitleId, titleId, "Adapter did not pass on expected Title ID.");
Assert.AreEqual(1, removeUserXuids.Length, "Adapter did not pass on expected number of local user XUIDs.");
Assert.AreEqual(TestXuidString, removeUserXuids[0], "Adapter did not pass on expected local user XUID.");
};
this.adapter.RemoveLocalUsersFromParty(ConsoleAddress, TestTitleId, new string[] { TestXuidString });
}
/// <summary>
/// Verifies that an ArgumentNullException is thrown if the RemoveLocalUsersFromParty()
/// method with null console.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ArgumentNullException))]
public void TestRemoveLocalUsersFromPartyThrowsArgumentNullExceptionOnConsole()
{
this.adapter.RemoveLocalUsersFromParty(null, TestTitleId, new string[1] { TestXuidString });
}
/// <summary>
/// Verifies that if the XDK's RemoveLocalUsersFromParty method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestRemoveLocalUsersFromPartyTurnsSpecificComExceptionsIntoXboxConsoleExceptions()
{
Action adapterCall = () => { this.adapter.RemoveLocalUsersFromParty(ConsoleAddress, TestTitleId, new string[] { TestXuidString }); };
COMException invalidXuidException = new COMException(null, InvalidXuidErrorCode);
this.fakeXboxXdk.RemoveLocalUsersFromPartyFunc = (ipAddress, titleId, removeXuids) => { throw invalidXuidException; };
this.VerifyFunctionHandlesSpecificComExceptions(
invalidXuidException,
typeof(InvalidXuidException),
adapterCall);
COMException partyDoesntExistException = new COMException(null, NoLocalUsersErrorCode);
this.fakeXboxXdk.RemoveLocalUsersFromPartyFunc = (ipAddress, titleId, removeXuids) => { throw partyDoesntExistException; };
this.VerifyFunctionHandlesSpecificComExceptions(
partyDoesntExistException,
typeof(NoLocalSignedInUsersInPartyException),
adapterCall);
}
/// <summary>
/// Verifies that if the XDK's GetPartyId method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Need to catch all exception types so that I can verify we capture the correct exception type.")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestGetPartyIdTurnsComExceptionIntoXboxConsoleException()
{
this.fakeXboxXdk.GetPartyIdFunc = (ipAddress, titleId) =>
{
throw new COMException();
};
try
{
this.adapter.GetPartyId(ConsoleAddress, 0);
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(XboxConsoleException), "The adapter GetPartyId method did not convert a COMException into an XboxConsoleException.");
Assert.IsInstanceOfType(ex.InnerException, typeof(COMException), "The adapter GetPartyId method did not include the COMException as the inner exception of the XboxConsoleException that it threw.");
}
}
/// <summary>
/// Verifies that an ObjectDisposedException is thrown if the GetPartyId()
/// method is called after the object has been disposed.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ObjectDisposedException))]
public void TestGetPartyIdThrowsObjectDisposedException()
{
this.adapter.Dispose();
this.adapter.GetPartyId(ConsoleAddress, 0);
}
/// <summary>
/// Verifies that the adapter's GetPartyId() method
/// calls the XboxXdk's GetPartyId method and a null argument exception is thrown if Xbox IP is null.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestGetPartyIdCallsXdkGetPartyId()
{
bool isCorrectFunctionCalled = false;
this.fakeXboxXdk.GetPartyIdFunc = (ipAddress, titleId) =>
{
isCorrectFunctionCalled = true;
return string.Empty;
};
this.adapter.GetPartyId(ConsoleAddress, 0);
Assert.IsTrue(isCorrectFunctionCalled, "The adapter's GetPartyId function failed to call the XboxXdk's GetPartyId function.");
}
/// <summary>
/// Verifies that the adapter's GetPartyId method correctly handles passing on arguments.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestGetPartyIdArguments()
{
this.fakeXboxXdk.GetPartyIdFunc = (ipAddress, titleId) =>
{
Assert.AreEqual(ConsoleAddress, ipAddress, "Adapter did not pass on the expected Console IP.");
Assert.AreEqual(TestTitleId, titleId, "Adapter did not pass on expected Title ID.");
return TestPartyId;
};
string returnPartyId = this.adapter.GetPartyId(ConsoleAddress, TestTitleId);
Assert.AreEqual(TestPartyId, returnPartyId, "Adapter did not return the expected Party ID.");
}
/// <summary>
/// Verifies that an ArgumentNullException is thrown if the GetPartyId()
/// method with null console.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ArgumentNullException))]
public void TestGetPartyIdThrowsArgumentNullExceptionOnConsole()
{
this.adapter.GetPartyId(null, 0);
}
/// <summary>
/// Verifies that if the XDK's GetPartyId method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestGetPartyIdTurnsSpecificComExceptionsIntoXboxConsoleExceptions()
{
Action adapterCall = () => { this.adapter.GetPartyId(ConsoleAddress, TestTitleId); };
COMException partyDoesntExistException = new COMException(null, NoLocalUsersErrorCode);
this.fakeXboxXdk.GetPartyIdFunc = (ipAddress, titleId) => { throw partyDoesntExistException; };
this.VerifyFunctionHandlesSpecificComExceptions(
partyDoesntExistException,
typeof(NoLocalSignedInUsersInPartyException),
adapterCall);
}
/// <summary>
/// Verifies that if the XDK's GetPartyMembers method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Need to catch all exception types so that I can verify we capture the correct exception type.")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestGetPartyMembersTurnsComExceptionIntoXboxConsoleException()
{
this.fakeXboxXdk.GetPartyMembersFunc = (ipAddress, titleId) =>
{
throw new COMException();
};
try
{
this.adapter.GetPartyMembers(ConsoleAddress, 0);
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(XboxConsoleException), "The adapter GetPartyMembers method did not convert a COMException into an XboxConsoleException.");
Assert.IsInstanceOfType(ex.InnerException, typeof(COMException), "The adapter GetPartyMembers method did not include the COMException as the inner exception of the XboxConsoleException that it threw.");
}
}
/// <summary>
/// Verifies that an ObjectDisposedException is thrown if the GetPartyMembers()
/// method is called after the object has been disposed.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ObjectDisposedException))]
public void TestGetPartyMembersThrowsObjectDisposedException()
{
this.adapter.Dispose();
this.adapter.GetPartyMembers(ConsoleAddress, 0);
}
/// <summary>
/// Verifies that the adapter's GetPartyMembers() method
/// calls the XboxXdk's GetPartyMembers method and a null argument exception is thrown if Xbox IP is null.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestGetPartyMembersCallsXdkGetPartyMembers()
{
bool isCorrectFunctionCalled = false;
this.fakeXboxXdk.GetPartyMembersFunc = (ipAddress, titleId) =>
{
isCorrectFunctionCalled = true;
return new string[0];
};
this.adapter.GetPartyMembers(ConsoleAddress, 0);
Assert.IsTrue(isCorrectFunctionCalled, "The adapter's GetPartyMembers function failed to call the XboxXdk's GetPartyMembers function.");
}
/// <summary>
/// Verifies that the adapter's GetPartyMembers method correctly handles passing on arguments.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestGetPartyMembersArguments()
{
this.fakeXboxXdk.GetPartyMembersFunc = (ipAddress, titleId) =>
{
Assert.AreEqual(ConsoleAddress, ipAddress, "Adapter did not pass on the expected Console IP.");
Assert.AreEqual(TestTitleId, titleId, "Adapter did not pass on expected Title ID.");
return new string[] { TestXuidString };
};
string[] returnMembers = this.adapter.GetPartyMembers(ConsoleAddress, TestTitleId);
Assert.AreEqual(1, returnMembers.Length, "Adapter did not return the correct number of party members.");
Assert.AreEqual(TestXuidString, returnMembers[0], "Adapter did not return the right party members.");
}
/// <summary>
/// Verifies that an ArgumentNullException is thrown if the GetPartyMembers()
/// method with null console.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ArgumentNullException))]
public void TestGetPartyMembersThrowsArgumentNullExceptionOnConsole()
{
this.adapter.GetPartyMembers(null, 0);
}
/// <summary>
/// Verifies that if the XDK's GetPartyMembers method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestGetPartyMembersTurnsSpecificComExceptionsIntoXboxConsoleExceptions()
{
Action adapterCall = () => { this.adapter.GetPartyMembers(ConsoleAddress, TestTitleId); };
COMException partyDoesntExistException = new COMException(null, NoLocalUsersErrorCode);
this.fakeXboxXdk.GetPartyMembersFunc = (ipAddress, titleId) => { throw partyDoesntExistException; };
this.VerifyFunctionHandlesSpecificComExceptions(
partyDoesntExistException,
typeof(NoLocalSignedInUsersInPartyException),
adapterCall);
}
/// <summary>
/// Verifies that if the XDK's AcceptInviteToParty method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Need to catch all exception types so that I can verify we capture the correct exception type.")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestAcceptInviteToPartyTurnsComExceptionIntoXboxConsoleException()
{
this.fakeXboxXdk.AcceptInviteToPartyFunc = (ipAddress, actingUserXuid, partyId) =>
{
throw new COMException();
};
try
{
this.adapter.AcceptInviteToParty(ConsoleAddress, string.Empty, string.Empty);
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(XboxConsoleException), "The adapter AcceptInviteToParty method did not convert a COMException into an XboxConsoleException.");
Assert.IsInstanceOfType(ex.InnerException, typeof(COMException), "The adapter AcceptInviteToParty method did not include the COMException as the inner exception of the XboxConsoleException that it threw.");
}
}
/// <summary>
/// Verifies that an ObjectDisposedException is thrown if the AcceptInviteToParty()
/// method is called after the object has been disposed.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ObjectDisposedException))]
public void TestAcceptInviteToPartyThrowsObjectDisposedException()
{
this.adapter.Dispose();
this.adapter.AcceptInviteToParty(ConsoleAddress, string.Empty, string.Empty);
}
/// <summary>
/// Verifies that the adapter's AcceptInviteToParty() method
/// calls the XboxXdk's AcceptInviteToParty method.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestAcceptInviteToPartyCallsXdkAcceptInviteToParty()
{
bool isCorrectFunctionCalled = false;
this.fakeXboxXdk.AcceptInviteToPartyFunc = (ipAddress, actingUserXuid, partyId) =>
{
isCorrectFunctionCalled = true;
};
this.adapter.AcceptInviteToParty(ConsoleAddress, string.Empty, string.Empty);
Assert.IsTrue(isCorrectFunctionCalled, "The adapter's AcceptInviteToParty function failed to call the XboxXdk's AcceptInviteToParty function.");
}
/// <summary>
/// Verifies that the adapter's AcceptInviteToParty method correctly handles passing on arguments.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestAcceptInviteToPartyArguments()
{
this.fakeXboxXdk.AcceptInviteToPartyFunc = (ipAddress, actingUserXuid, partyId) =>
{
Assert.AreEqual(ConsoleAddress, ipAddress, "Adapter did not pass on the expected Console IP.");
Assert.AreEqual(TestXuidString, actingUserXuid, "Adapter did not pass on expected Acting User XUID.");
Assert.AreEqual(TestPartyId, partyId, "Adapter did not pass on expected Party ID.");
};
this.adapter.AcceptInviteToParty(ConsoleAddress, TestXuidString, TestPartyId);
}
/// <summary>
/// Verifies that an ArgumentNullException is thrown if the AcceptInviteToParty()
/// method with null console.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ArgumentNullException))]
public void TestAcceptInviteToPartyThrowsArgumentNullExceptionOnConsole()
{
this.adapter.AcceptInviteToParty(null, TestXuidString, TestXuidString);
}
/// <summary>
/// Verifies that if the XDK's AcceptInviteToParty method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestAcceptInviteToPartyTurnsSpecificComExceptionsIntoXboxConsoleExceptions()
{
Action adapterCall = () => { this.adapter.AcceptInviteToParty(ConsoleAddress, TestXuidString, TestPartyId); };
COMException invalidXuidException = new COMException(null, InvalidXuidErrorCode);
this.fakeXboxXdk.AcceptInviteToPartyFunc = (ipAddress, actingUserXuid, partyId) => { throw invalidXuidException; };
this.VerifyFunctionHandlesSpecificComExceptions(
invalidXuidException,
typeof(InvalidXuidException),
adapterCall);
COMException invalidPartyInviteException = new COMException(null, InvalidPartyInviteErrorCode);
this.fakeXboxXdk.AcceptInviteToPartyFunc = (ipAddress, actingUserXuid, partyId) => { throw invalidPartyInviteException; };
this.VerifyFunctionHandlesSpecificComExceptions(
invalidPartyInviteException,
typeof(InvalidPartyInviteException),
adapterCall);
}
/// <summary>
/// Verifies that if the XDK's DeclineInviteToParty method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Need to catch all exception types so that I can verify we capture the correct exception type.")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestDeclineInviteToPartyTurnsComExceptionIntoXboxConsoleException()
{
this.fakeXboxXdk.DeclineInviteToPartyFunc = (ipAddress, actingUserXuid, partyId) =>
{
throw new COMException();
};
try
{
this.adapter.DeclineInviteToParty(ConsoleAddress, string.Empty, string.Empty);
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(XboxConsoleException), "The adapter DeclineInviteToParty method did not convert a COMException into an XboxConsoleException.");
Assert.IsInstanceOfType(ex.InnerException, typeof(COMException), "The adapter DeclineInviteToParty method did not include the COMException as the inner exception of the XboxConsoleException that it threw.");
}
}
/// <summary>
/// Verifies that an ObjectDisposedException is thrown if the DeclineInviteToParty()
/// method is called after the object has been disposed.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ObjectDisposedException))]
public void TestDeclineInviteToPartyThrowsObjectDisposedException()
{
this.adapter.Dispose();
this.adapter.DeclineInviteToParty(ConsoleAddress, string.Empty, string.Empty);
}
/// <summary>
/// Verifies that the adapter's DeclineInviteToParty() method
/// calls the XboxXdk's DeclineInviteToParty method and a null argument exception is thrown if Xbox IP is null.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestDeclineInviteToPartyCallsXdkDeclineInviteToParty()
{
bool isCorrectFunctionCalled = false;
this.fakeXboxXdk.DeclineInviteToPartyFunc = (ipAddress, actingUserXuid, partyId) =>
{
isCorrectFunctionCalled = true;
};
this.adapter.DeclineInviteToParty(ConsoleAddress, string.Empty, string.Empty);
Assert.IsTrue(isCorrectFunctionCalled, "The adapter's DeclineInviteToParty function failed to call the XboxXdk's DeclineInviteToParty function.");
}
/// <summary>
/// Verifies that the adapter's DeclineInviteToParty method correctly handles passing on arguments.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestDeclineInviteToPartyArguments()
{
this.fakeXboxXdk.DeclineInviteToPartyFunc = (ipAddress, actingUserXuid, partyId) =>
{
Assert.AreEqual(ConsoleAddress, ipAddress, "Adapter did not pass on the expected Console IP.");
Assert.AreEqual(TestXuidString, actingUserXuid, "Adapter did not pass on expected Acting User XUID.");
Assert.AreEqual(TestPartyId, partyId, "Adapter did not pass on expected Party ID.");
};
this.adapter.DeclineInviteToParty(ConsoleAddress, TestXuidString, TestPartyId);
}
/// <summary>
/// Verifies that an ArgumentNullException is thrown if the DeclineInviteToParty()
/// method with null console.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
[ExpectedException(typeof(ArgumentNullException))]
public void TestDeclineInviteToPartyThrowsArgumentNullExceptionOnConsole()
{
this.adapter.DeclineInviteToParty(null, TestXuidString, TestXuidString);
}
/// <summary>
/// Verifies that if the XDK's DeclineInviteToParty method throws a COMException, then the
/// XboxConsoleAdapter will wrap that into an XboxConsoleException with the COMException as its inner exception.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Need to simulate XDK")]
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(AdapterUserTestCategory)]
public void TestDeclineInviteToPartyTurnsSpecificComExceptionsIntoXboxConsoleExceptions()
{
Action adapterCall = () => { this.adapter.DeclineInviteToParty(ConsoleAddress, TestXuidString, TestPartyId); };
COMException invalidXuidException = new COMException(null, InvalidXuidErrorCode);
this.fakeXboxXdk.DeclineInviteToPartyFunc = (ipAddress, actingUserXuid, partyId) => { throw invalidXuidException; };
this.VerifyFunctionHandlesSpecificComExceptions(
invalidXuidException,
typeof(InvalidXuidException),
adapterCall);
COMException invalidPartyInviteException = new COMException(null, InvalidPartyInviteErrorCode);
this.fakeXboxXdk.DeclineInviteToPartyFunc = (ipAddress, actingUserXuid, partyId) => { throw invalidPartyInviteException; };
this.VerifyFunctionHandlesSpecificComExceptions(
invalidPartyInviteException,
typeof(InvalidPartyInviteException),
adapterCall);
}
/// <summary>
/// Verifies that DeclineInviteToParty correctly recognizes expected COMExceptions
/// and wraps them in a XboxConsoleException-derived exception.
/// </summary>
/// <param name="expectedCOMException">The COMException to be thrown and caught.</param>
/// <param name="expectedType">Expected type of the compound exception.</param>
/// <param name="callAction">Action called to cause the exception to be thrown.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Need to catch all exception types so that I can verify we capture the correct exception type.")]
private void VerifyFunctionHandlesSpecificComExceptions(COMException expectedCOMException, Type expectedType, Action callAction)
{
try
{
if (callAction != null)
{
callAction();
}
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, expectedType, "The adapter method did not convert an expected COMException into an XboxConsole exception.");
Assert.AreSame(
expectedCOMException,
ex.InnerException,
"The adapter SignInUser method did not include the expected COMException with error code {0} as the inner exception of the XboxSignInException that it threw.",
"The adapter method did not include the expected COMException with error code {0} as the inner exception of the XboxConsoleException that it threw.",
expectedCOMException.ErrorCode);
}
}
}
}
}

Просмотреть файл

@ -42,10 +42,15 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Practices.EnterpriseLibrary.SemanticLogging">
<HintPath>..\packages\EnterpriseLibrary.SemanticLogging.1.1.1403.1\lib\net45\Microsoft.Practices.EnterpriseLibrary.SemanticLogging.dll</HintPath>
<Reference Include="Microsoft.Practices.EnterpriseLibrary.SemanticLogging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EnterpriseLibrary.SemanticLogging.2.0.1406.1\lib\net45\Microsoft.Practices.EnterpriseLibrary.SemanticLogging.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<Reference Include="Microsoft.Practices.EnterpriseLibrary.SemanticLogging.EventSourceAnalyzer">
<HintPath>..\packages\EnterpriseLibrary.SemanticLogging.EventSourceAnalyzer.2.0.1406.1\lib\net45\Microsoft.Practices.EnterpriseLibrary.SemanticLogging.EventSourceAnalyzer.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
@ -91,6 +96,7 @@
</CodeAnalysisDictionary>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Choose>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.SemanticLogging" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EnterpriseLibrary.SemanticLogging" version="1.1.1403.1" targetFramework="net45" />
<package id="EnterpriseLibrary.SemanticLogging" version="2.0.1406.1" targetFramework="net45" />
<package id="EnterpriseLibrary.SemanticLogging.EventSourceAnalyzer" version="2.0.1406.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
</packages>

Просмотреть файл

@ -152,6 +152,127 @@ namespace Microsoft.Internal.GamesTest.Xbox
"Failed to pair a gamepad to a user.");
}
/// <summary>
/// Creates a party for the given title ID (if one does not exist) and adds the given local users to it.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="actingUserXuid">Acting user XUID on whose behalf to add other users to the party.</param>
/// <param name="localUserXuidsToAdd">User XUIDs to add to the party.</param>
public void AddLocalUsersToParty(string systemIpAddress, uint titleId, string actingUserXuid, string[] localUserXuidsToAdd)
{
this.ThrowIfDisposed();
this.ThrowIfInvalidSystemIpAddress(systemIpAddress);
this.PerformXdkAction(
systemIpAddress,
() => this.AddLocalUsersToPartyImpl(systemIpAddress, titleId, actingUserXuid, localUserXuidsToAdd),
"Failed to add local users to a party.");
}
/// <summary>
/// Invites the given users on behalf of the acting user to the party associated with the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="actingUserXuid">Acting user XUID on whose behalf to invite other users to the party.</param>
/// <param name="remoteUserXuidsToInvite">Remote user XUIDs to invite to the party.</param>
public void InviteToParty(string systemIpAddress, uint titleId, string actingUserXuid, string[] remoteUserXuidsToInvite)
{
this.ThrowIfDisposed();
this.ThrowIfInvalidSystemIpAddress(systemIpAddress);
this.PerformXdkAction(
systemIpAddress,
() => this.InviteToPartyImpl(systemIpAddress, titleId, actingUserXuid, remoteUserXuidsToInvite),
"Failed to invite remote users to a party.");
}
/// <summary>
/// Removes the given users from the party belonging to the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="localUserXuidsToRemove">Local user XUIDs to remove from the party.</param>
public void RemoveLocalUsersFromParty(string systemIpAddress, uint titleId, string[] localUserXuidsToRemove)
{
this.ThrowIfDisposed();
this.ThrowIfInvalidSystemIpAddress(systemIpAddress);
this.PerformXdkAction(
systemIpAddress,
() => this.RemoveLocalUsersFromPartyImpl(systemIpAddress, titleId, localUserXuidsToRemove),
"Failed to remove local users from a party.");
}
/// <summary>
/// Returns the party ID belonging to the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to get the associated party ID for.</param>
/// <returns>ID of existing party used to accept or decline an invitation to the party.</returns>
public string GetPartyId(string systemIpAddress, uint titleId)
{
this.ThrowIfDisposed();
this.ThrowIfInvalidSystemIpAddress(systemIpAddress);
return this.PerformXdkFunc(
systemIpAddress,
() => this.GetPartyIdImpl(systemIpAddress, titleId),
"Failed to get party ID.");
}
/// <summary>
/// Lists both the current members and the reserved members of the party belonging to given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to get party members for.</param>
/// <returns>Party member user XUIDs, which may contain a mix of local and remote users.</returns>
public string[] GetPartyMembers(string systemIpAddress, uint titleId)
{
this.ThrowIfDisposed();
this.ThrowIfInvalidSystemIpAddress(systemIpAddress);
return this.PerformXdkFunc(
systemIpAddress,
() => this.GetPartyMembersImpl(systemIpAddress, titleId),
"Failed to get party members.");
}
/// <summary>
/// Accepts the party invitation on behalf of the given acting user to the party associated with the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="actingUserXuid">XUID of acting user on whose behalf to accept the invitation.</param>
/// <param name="partyId">Title ID of the party created by another user to accept the invitation to.</param>
public void AcceptInviteToParty(string systemIpAddress, string actingUserXuid, string partyId)
{
this.ThrowIfDisposed();
this.ThrowIfInvalidSystemIpAddress(systemIpAddress);
this.PerformXdkAction(
systemIpAddress,
() => this.AcceptInviteToPartyImpl(systemIpAddress, actingUserXuid, partyId),
"Failed to accept an invitation to a party.");
}
/// <summary>
/// Declines the party invitation on behalf of the given acting user to the party associated with the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="actingUserXuid">XUID of acting user on whose behalf to decline the invitation.</param>
/// <param name="partyId">Title ID of the party created by another user to accept the invitation to.</param>
public void DeclineInviteToParty(string systemIpAddress, string actingUserXuid, string partyId)
{
this.ThrowIfDisposed();
this.ThrowIfInvalidSystemIpAddress(systemIpAddress);
this.PerformXdkAction(
systemIpAddress,
() => this.DeclineInviteToPartyImpl(systemIpAddress, actingUserXuid, partyId),
"Failed to decline an invitation to a party.");
}
/// <summary>
/// Connects to the console and retrieves the collection of users.
/// </summary>
@ -238,5 +359,84 @@ namespace Microsoft.Internal.GamesTest.Xbox
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Creates a party for the given title ID (if one does not exist) and adds the given local users to it.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="actingUserXuid">Acting user XUID on whose behalf to add other users to the party.</param>
/// <param name="localUserXuidsToAdd">User XUIDs to add to the party.</param>
protected virtual void AddLocalUsersToPartyImpl(string systemIpAddress, uint titleId, string actingUserXuid, string[] localUserXuidsToAdd)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Invites the given users on behalf of the acting user to the party associated with the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="actingUserXuid">Acting user XUID on whose behalf to invite other users to the party.</param>
/// <param name="remoteUserXuidsToInvite">Remote user XUIDs to invite to the party.</param>
protected virtual void InviteToPartyImpl(string systemIpAddress, uint titleId, string actingUserXuid, string[] remoteUserXuidsToInvite)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Removes the given users from the party belonging to the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="localUserXuidsToRemove">Local user XUIDs to remove from the party.</param>
protected virtual void RemoveLocalUsersFromPartyImpl(string systemIpAddress, uint titleId, string[] localUserXuidsToRemove)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Returns the party ID belonging to the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to get the associated party ID for.</param>
/// <returns>ID of existing party used to accept or decline an invitation to the party.</returns>
protected virtual string GetPartyIdImpl(string systemIpAddress, uint titleId)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Lists both the current members and the reserved members of the party belonging to given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="titleId">Title ID of the title to get party members for.</param>
/// <returns>Party member user XUIDs, which may contain a mix of local and remote users.</returns>
protected virtual string[] GetPartyMembersImpl(string systemIpAddress, uint titleId)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Accepts the party invitation on behalf of the given acting user to the party associated with the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="actingUserXuid">XUID of acting user on whose behalf to accept the invitation.</param>
/// <param name="partyId">Title ID of the party created by another user to accept the invitation to.</param>
protected virtual void AcceptInviteToPartyImpl(string systemIpAddress, string actingUserXuid, string partyId)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Declines the party invitation on behalf of the given acting user to the party associated with the given title ID.
/// </summary>
/// <param name="systemIpAddress">The system IP address of the console.</param>
/// <param name="actingUserXuid">XUID of acting user on whose behalf to decline the invitation.</param>
/// <param name="partyId">Title ID of the party created by another user to accept the invitation to.</param>
protected virtual void DeclineInviteToPartyImpl(string systemIpAddress, string actingUserXuid, string partyId)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
}
}

Просмотреть файл

@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
// <copyright file="ColorDepthType.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Configuration
{
/// <summary>
/// Range of valid values for ColorDepthType configuration setting.
/// </summary>
public enum ColorDepthType
{
/// <summary>
/// 24 bit color depth.
/// </summary>
TwentyFourBit,
/// <summary>
/// 30 bit color depth.
/// </summary>
ThirtyBit,
/// <summary>
/// 36 bit color depth.
/// </summary>
ThirtySixBit,
}
}

Просмотреть файл

@ -111,7 +111,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Configuration
/// <summary>
/// Gets the ColorDepth value.
/// </summary>
int ColorDepth { get; }
ColorDepthType ColorDepth { get; }
/// <summary>
/// Gets the NetworkType value.

Просмотреть файл

@ -17,13 +17,13 @@ namespace Microsoft.Internal.GamesTest.Xbox.Configuration
NoTimeout,
/// <summary>
/// One minute (value of "60").
/// One Hour (value of "60").
/// </summary>
TimeoutOneMinute,
TimeoutOneHour,
/// <summary>
/// One hour (value of "360").
/// Six hours (value of "360").
/// </summary>
TimeoutOneHour
TimeoutSixHours
}
}

Просмотреть файл

@ -13,7 +13,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Configuration
/// An explicit override of the XboxConfigurationSetting class meant to represent the use of the string
/// of the ColorDepth configuration setting (see xbconfig command line utility).
/// </summary>
internal class XboxColorDepthConfigurationSetting : XboxConfigurationSetting<int>
internal class XboxColorDepthConfigurationSetting : XboxConfigurationSetting<ColorDepthType>
{
/// <summary>
/// Initializes a new instance of the XboxColorDepthConfigurationSetting class.
@ -27,23 +27,44 @@ namespace Microsoft.Internal.GamesTest.Xbox.Configuration
/// <summary>
/// Converts a strongly-typed value into a string value.
/// </summary>
/// <param name="colorDepth">The value to be converted.</param>
/// <param name="displayResolution">The value to be converted.</param>
/// <returns>The string value that corresponds to the specified value.</returns>
protected override string GetStringValueFromValue(int colorDepth)
protected override string GetStringValueFromValue(ColorDepthType displayResolution)
{
if (colorDepth == 0)
// Enforce allowed values.
switch (displayResolution)
{
return null;
default:
case ColorDepthType.TwentyFourBit:
return "24";
case ColorDepthType.ThirtyBit:
return "30";
case ColorDepthType.ThirtySixBit:
return "36";
}
}
/// <summary>
/// Converts a string value into a stringly-typed value.
/// </summary>
/// <param name="stringVal">The string value to be converted.</param>
/// <returns>The strongly typed value corresponding to the specified string value.</returns>
protected override ColorDepthType GetValueFromStringValue(string stringVal)
{
if (string.IsNullOrEmpty(stringVal))
{
return ColorDepthType.TwentyFourBit;
}
// Enforce allowed values.
if (colorDepth == 24 || colorDepth == 30 || colorDepth == 36)
switch (stringVal.ToUpperInvariant())
{
return colorDepth.ToString(CultureInfo.InvariantCulture);
}
else
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "ColorDepth must be 24, 30, or 36. '{0}' passed.", colorDepth.ToString(CultureInfo.InvariantCulture)), "colorDepth");
default:
case "24":
return ColorDepthType.TwentyFourBit;
case "30":
return ColorDepthType.ThirtyBit;
case "36":
return ColorDepthType.ThirtySixBit;
}
}
}

Просмотреть файл

@ -38,9 +38,9 @@ namespace Microsoft.Internal.GamesTest.Xbox.Configuration
case IdleShutdownTimeoutType.NoTimeout:
return "0";
case IdleShutdownTimeoutType.TimeoutOneHour:
return "360";
case IdleShutdownTimeoutType.TimeoutOneMinute:
return "60";
case IdleShutdownTimeoutType.TimeoutSixHours:
return "360";
}
}
@ -62,9 +62,9 @@ namespace Microsoft.Internal.GamesTest.Xbox.Configuration
case "0":
return IdleShutdownTimeoutType.NoTimeout;
case "60":
return IdleShutdownTimeoutType.TimeoutOneMinute;
case "360":
return IdleShutdownTimeoutType.TimeoutOneHour;
case "360":
return IdleShutdownTimeoutType.TimeoutSixHours;
}
}
}

Просмотреть файл

@ -0,0 +1,81 @@
//------------------------------------------------------------------------------
// <copyright file="InvalidPartyInviteException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using System.Runtime.Serialization;
/// <summary>
/// Invalid party invite operation or party ID (0x8019019C).
/// </summary>
[Serializable]
public class InvalidPartyInviteException : XboxConsoleException
{
/// <summary>
/// Initializes a new instance of the <see cref="InvalidPartyInviteException"/> class.
/// </summary>
public InvalidPartyInviteException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InvalidPartyInviteException"/> class.
/// </summary>
/// <param name="message">The message.</param>
public InvalidPartyInviteException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InvalidPartyInviteException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
public InvalidPartyInviteException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InvalidPartyInviteException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="xboxName">The Xbox name.</param>
public InvalidPartyInviteException(string message, string xboxName)
: base(message, xboxName)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InvalidPartyInviteException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
/// <param name="xboxName">The Xbox name.</param>
public InvalidPartyInviteException(string message, Exception innerException, string xboxName)
: base(message, innerException, xboxName)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InvalidPartyInviteException"/> class.
/// </summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
/// <exception cref="T:System.ArgumentNullException">
/// The <paramref name="info"/> parameter is null.
/// </exception>
/// <exception cref="T:System.Runtime.Serialization.SerializationException">
/// The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0).
/// </exception>
protected InvalidPartyInviteException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

Просмотреть файл

@ -0,0 +1,81 @@
//------------------------------------------------------------------------------
// <copyright file="InvalidXuidException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using System.Runtime.Serialization;
/// <summary>
/// Invalid XUID passed for one of the parameters, or the XUID passed cannot be used in the way required by this function.
/// </summary>
[Serializable]
public class InvalidXuidException : XboxConsoleException
{
/// <summary>
/// Initializes a new instance of the <see cref="InvalidXuidException"/> class.
/// </summary>
public InvalidXuidException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InvalidXuidException"/> class.
/// </summary>
/// <param name="message">The message.</param>
public InvalidXuidException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InvalidXuidException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
public InvalidXuidException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InvalidXuidException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="xboxName">The Xbox name.</param>
public InvalidXuidException(string message, string xboxName)
: base(message, xboxName)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InvalidXuidException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
/// <param name="xboxName">The Xbox name.</param>
public InvalidXuidException(string message, Exception innerException, string xboxName)
: base(message, innerException, xboxName)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InvalidXuidException"/> class.
/// </summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
/// <exception cref="T:System.ArgumentNullException">
/// The <paramref name="info"/> parameter is null.
/// </exception>
/// <exception cref="T:System.Runtime.Serialization.SerializationException">
/// The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0).
/// </exception>
protected InvalidXuidException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

Просмотреть файл

@ -0,0 +1,81 @@
//------------------------------------------------------------------------------
// <copyright file="NoLocalSignedInUsersInPartyException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using System.Runtime.Serialization;
/// <summary>
/// There are no local signed in users in the party (0x87CC0007).
/// </summary>
[Serializable]
public class NoLocalSignedInUsersInPartyException : XboxConsoleException
{
/// <summary>
/// Initializes a new instance of the <see cref="NoLocalSignedInUsersInPartyException"/> class.
/// </summary>
public NoLocalSignedInUsersInPartyException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="NoLocalSignedInUsersInPartyException"/> class.
/// </summary>
/// <param name="message">The message.</param>
public NoLocalSignedInUsersInPartyException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="NoLocalSignedInUsersInPartyException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
public NoLocalSignedInUsersInPartyException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="NoLocalSignedInUsersInPartyException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="xboxName">The Xbox name.</param>
public NoLocalSignedInUsersInPartyException(string message, string xboxName)
: base(message, xboxName)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="NoLocalSignedInUsersInPartyException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
/// <param name="xboxName">The Xbox name.</param>
public NoLocalSignedInUsersInPartyException(string message, Exception innerException, string xboxName)
: base(message, innerException, xboxName)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="NoLocalSignedInUsersInPartyException"/> class.
/// </summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
/// <exception cref="T:System.ArgumentNullException">
/// The <paramref name="info"/> parameter is null.
/// </exception>
/// <exception cref="T:System.Runtime.Serialization.SerializationException">
/// The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0).
/// </exception>
protected NoLocalSignedInUsersInPartyException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

Просмотреть файл

@ -0,0 +1,81 @@
//------------------------------------------------------------------------------
// <copyright file="XboxUserNotSignedInException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using System.Runtime.Serialization;
/// <summary>
/// Represents an XboxException where Xuid property of the user could not be retrieved because the user is not signed in.
/// </summary>
[Serializable]
public class XboxUserNotSignedInException : XboxConsoleException
{
/// <summary>
/// Initializes a new instance of the <see cref="XboxUserNotSignedInException"/> class.
/// </summary>
public XboxUserNotSignedInException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="XboxUserNotSignedInException"/> class.
/// </summary>
/// <param name="message">The message.</param>
public XboxUserNotSignedInException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="XboxUserNotSignedInException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
public XboxUserNotSignedInException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="XboxUserNotSignedInException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="xboxName">The Xbox name.</param>
public XboxUserNotSignedInException(string message, string xboxName)
: base(message, xboxName)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="XboxUserNotSignedInException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="innerException">The inner exception.</param>
/// <param name="xboxName">The Xbox name.</param>
public XboxUserNotSignedInException(string message, Exception innerException, string xboxName)
: base(message, innerException, xboxName)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="XboxUserNotSignedInException"/> class.
/// </summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
/// <exception cref="T:System.ArgumentNullException">
/// The <paramref name="info"/> parameter is null.
/// </exception>
/// <exception cref="T:System.Runtime.Serialization.SerializationException">
/// The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0).
/// </exception>
protected XboxUserNotSignedInException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

Просмотреть файл

@ -37,6 +37,7 @@ using System.Runtime.InteropServices;
[assembly: InternalsVisibleTo("GamesTest.XboxConsole.Adapter.March2014")]
[assembly: InternalsVisibleTo("GamesTest.XboxConsole.Adapter.April2014")]
[assembly: InternalsVisibleTo("GamesTest.XboxConsole.Adapter.May2014")]
[assembly: InternalsVisibleTo("GamesTest.XboxConsole.Adapter.July2014")]
[assembly: InternalsVisibleTo("GamesTest.XboxConsole.Fakes")]
[assembly: InternalsVisibleTo("GamesTest.XboxConsole.Infrastructure.Fakes")]

Просмотреть файл

@ -17,7 +17,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Telemetry
/// </summary>
public static class TelemetrySink
{
private const string LoggingConnectionString = "";
private const string LoggingConnectionString = "";
private static ObservableEventListener processEventListener;
private static SinkSubscription<SqlDatabaseSink> sinkSubscription;

Просмотреть файл

@ -39,24 +39,21 @@
<DocumentationFile>bin\x64\Release\GamesTest.XboxConsole.Infrastructure.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Practices.EnterpriseLibrary.SemanticLogging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Practices.EnterpriseLibrary.SemanticLogging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EnterpriseLibrary.SemanticLogging.1.1.1403.1\lib\net45\Microsoft.Practices.EnterpriseLibrary.SemanticLogging.dll</HintPath>
<HintPath>..\packages\EnterpriseLibrary.SemanticLogging.2.0.1406.1\lib\net45\Microsoft.Practices.EnterpriseLibrary.SemanticLogging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Database, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EnterpriseLibrary.SemanticLogging.Database.1.1.1403.1\lib\net45\Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Database.dll</HintPath>
<HintPath>..\packages\EnterpriseLibrary.SemanticLogging.Database.2.0.1406.1\lib\net45\Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Database.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling">
<HintPath>..\packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data">
<HintPath>..\packages\EnterpriseLibrary.TransientFaultHandling.Data.6.0.1304.1\lib\NET45\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="sysglobl" />
@ -81,6 +78,7 @@
<Compile Include="AdapterBase\XboxConsoleAdapterBase.PackageManagement.cs" />
<Compile Include="AdapterBase\XboxConsoleAdapterBase.ExecutableManagement.cs" />
<Compile Include="Configuration\BaseXboxConfiguration.cs" />
<Compile Include="Configuration\ColorDepthType.cs" />
<Compile Include="Configuration\ColorSpaceType.cs" />
<Compile Include="Configuration\AudioBitstreamFormatType.cs" />
<Compile Include="Configuration\XboxIdleShutdownTimeoutConfigurationSetting.cs" />
@ -113,6 +111,9 @@
<Compile Include="Deployment\XboxDeploymentInfo.cs" />
<Compile Include="Deployment\XtfDeployCallbackActions.cs" />
<Compile Include="DisposableObject.cs" />
<Compile Include="Exceptions\InvalidPartyInviteException.cs" />
<Compile Include="Exceptions\InvalidXuidException.cs" />
<Compile Include="Exceptions\NoLocalSignedInUsersInPartyException.cs" />
<Compile Include="Exceptions\XboxAggregateException.cs" />
<Compile Include="Exceptions\XboxConsoleFeatureNotSupportedException.cs" />
<Compile Include="Exceptions\XboxDeployException.cs" />
@ -120,6 +121,7 @@
<Compile Include="Exceptions\XboxSessionKeyException.cs" />
<Compile Include="Exceptions\XboxSignInException.cs" />
<Compile Include="Exceptions\XboxSnapException.cs" />
<Compile Include="Exceptions\XboxUserNotSignedInException.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Input\XboxGamepadButtons.cs" />
<Compile Include="Input\XboxGamepadReading.cs" />

Просмотреть файл

@ -11,6 +11,25 @@ namespace Microsoft.Internal.GamesTest.Xbox
/// </summary>
internal class XboxUserDefinition
{
/// <summary>
/// Initializes a new instance of the XboxUserDefinition class.
/// </summary>
/// <param name="userId">A unique identifier for the user.</param>
/// <param name="emailAddress">The email address used to sign the user in.</param>
/// <param name="gamertag">The user's Gamertag.</param>
/// <param name="signedIn">Is the user is signed in.</param>
/// <param name="autoSignIn">Whether the user is signed in automatically.</param>
/// <param name="xuid">User unique Live identifier.</param>
public XboxUserDefinition(uint userId, string emailAddress, string gamertag, bool signedIn, bool autoSignIn, string xuid)
{
this.UserId = userId;
this.EmailAddress = emailAddress;
this.Gamertag = gamertag;
this.IsSignedIn = signedIn;
this.AutoSignIn = autoSignIn;
this.Xuid = xuid;
}
/// <summary>
/// Initializes a new instance of the XboxUserDefinition class.
/// </summary>
@ -24,6 +43,8 @@ namespace Microsoft.Internal.GamesTest.Xbox
this.EmailAddress = emailAddress;
this.Gamertag = gamertag;
this.IsSignedIn = signedIn;
this.AutoSignIn = false;
this.Xuid = string.Empty;
}
/// <summary>
@ -45,5 +66,15 @@ namespace Microsoft.Internal.GamesTest.Xbox
/// Gets a value indicating whether the user is signed in.
/// </summary>
public bool IsSignedIn { get; private set; }
/// <summary>
/// Gets a value indicating whether the user is setup for automatic sign in.
/// </summary>
public bool AutoSignIn { get; private set; }
/// <summary>
/// Gets the unique Xbox Live identifier for the user.
/// </summary>
public string Xuid { get; private set; }
}
}

Просмотреть файл

@ -455,6 +455,85 @@ namespace Microsoft.Internal.GamesTest.Xbox
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Creates a party for the given title ID (if one does not exist) and adds the given local users to it.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="actingUserXuid">Acting user XUID on whose behalf to add other users to the party.</param>
/// <param name="localUserXuidsToAdd">User XUIDs to add to the party.</param>
public virtual void AddLocalUsersToParty(string ipAddress, uint titleId, string actingUserXuid, string[] localUserXuidsToAdd)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Invites the given users on behalf of the acting user to the party associated with the given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="actingUserXuid">Acting user XUID on whose behalf to invite other users to the party.</param>
/// <param name="remoteUserXuidsToInvite">Remote user XUIDs to invite to the party.</param>
public virtual void InviteToParty(string ipAddress, uint titleId, string actingUserXuid, string[] remoteUserXuidsToInvite)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Removes the given users from the party belonging to the given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="titleId">Title ID of the title to manage a party for.</param>
/// <param name="localUserXuidsToRemove">Local user XUIDs to remove from the party.</param>
public virtual void RemoveLocalUsersFromParty(string ipAddress, uint titleId, string[] localUserXuidsToRemove)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Returns the party ID belonging to the given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="titleId">Title ID of the title to get the associated party ID for.</param>
/// <returns>ID of existing party used to accept or decline an invitation to the party.</returns>
public virtual string GetPartyId(string ipAddress, uint titleId)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Lists both the current members and the reserved members of the party belonging to given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="titleId">Title ID of the title to get party members for.</param>
/// <returns>Party member user XUIDs, which may contain a mix of local and remote users.</returns>
public virtual string[] GetPartyMembers(string ipAddress, uint titleId)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Accepts the party invitation on behalf of the given acting user to the party associated with the given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="actingUserXuid">XUID of acting user on whose behalf to accept the invitation.</param>
/// <param name="partyId">Title ID of the party created by another user to accept the invitation to.</param>
public virtual void AcceptInviteToParty(string ipAddress, string actingUserXuid, string partyId)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
/// <summary>
/// Declines the party invitation on behalf of the given acting user to the party associated with the given title ID.
/// </summary>
/// <param name="ipAddress">The IP address of the console.</param>
/// <param name="actingUserXuid">XUID of acting user on whose behalf to decline the invitation.</param>
/// <param name="partyId">Title ID of the party created by another user to accept the invitation to.</param>
public virtual void DeclineInviteToParty(string ipAddress, string actingUserXuid, string partyId)
{
throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage);
}
private static byte[] CreateRawAssembly(Stream streamFromResources)
{
if (streamFromResources == null || !streamFromResources.CanSeek || streamFromResources.Length == 0)

Просмотреть файл

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EnterpriseLibrary.SemanticLogging" version="1.1.1403.1" targetFramework="net45" />
<package id="EnterpriseLibrary.SemanticLogging.Database" version="1.1.1403.1" targetFramework="net45" />
<package id="EnterpriseLibrary.SemanticLogging" version="2.0.1406.1" targetFramework="net45" />
<package id="EnterpriseLibrary.SemanticLogging.Database" version="2.0.1406.1" targetFramework="net45" />
<package id="EnterpriseLibrary.TransientFaultHandling" version="6.0.1304.0" targetFramework="net45" />
<package id="EnterpriseLibrary.TransientFaultHandling.Data" version="6.0.1304.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -98,7 +98,10 @@
<Compile Include="XboxInputTests.cs" />
<Compile Include="XboxPackageTests.cs" />
<Compile Include="XboxConsoleTests.cs" />
<Compile Include="XboxPartyTests.cs" />
<Compile Include="XboxProcessTests.cs" />
<Compile Include="XboxRemotePartyTests.cs" />
<Compile Include="XboxRemoteUserTests.cs" />
<Compile Include="XboxUserTests.cs" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -982,7 +982,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
isCorrectMethodCalled = true;
};
XboxUser user = new XboxUser(this.console, 0, null, null);
XboxUser user = new XboxUser(this.console, 0, null, null, false);
this.console.DeleteUser(user);
Assert.IsTrue(isCorrectMethodCalled, "The XboxConsole object did not call the adapter's DeleteUser method.");
@ -996,7 +996,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[TestCategory(XboxConsoleTestCategory)]
public void TestDeleteUserPassesArguments()
{
XboxUser user = new XboxUser(this.console, 0, null, null);
XboxUser user = new XboxUser(this.console, 0, null, null, false);
ShimXboxConsoleAdapterBase.AllInstances.DeleteUserStringXboxUserDefinition = (adapter, systemIpAddress, userDefinition) =>
{

Просмотреть файл

@ -0,0 +1,151 @@
//------------------------------------------------------------------------------
// <copyright file="XboxPartyTests.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Tests
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Microsoft.Internal.GamesTest.Xbox.Fakes;
using Microsoft.Internal.GamesTest.Xbox.Input;
using Microsoft.QualityTools.Testing.Fakes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Represents tests for the XboxParty type.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "This is test code and the object is disposed in the TestCleanup method.")]
[TestClass]
public class XboxPartyTests
{
private const string XboxPartyTestCategory = "XboxConsole.XboxParty";
private const string ConsoleAddress = "10.124.151.244"; // The actual IP address used here is irrelevant.
private const string TestXuidString = "111111111111111";
private const string TestXuidString2 = "222222222222222";
private const uint TestTitleId = 12345;
private const string TestPartyId = "1234";
private IDisposable shimsContext;
private XboxConsole xboxConsole;
/// <summary>
/// Called once before each test to setup shim and stub objects.
/// </summary>
[TestInitialize]
public void TestInitialize()
{
this.shimsContext = ShimsContext.Create();
ShimXboxConsole.ConstructorIPAddress = (console, address) =>
{
var myShim = new ShimXboxConsole(console)
{
AdapterGet = () => new StubXboxConsoleAdapterBase(null),
SystemIpAddressGet = () => IPAddress.Parse(XboxPartyTests.ConsoleAddress),
SystemIpAddressStringGet = () => this.xboxConsole.SystemIpAddress.ToString(),
XboxGamepadsGet = () => new List<Input.XboxGamepad>(),
};
};
ShimXboxConsoleAdapterBase.ConstructorXboxXdkBase = (adapter, xboxXdk) =>
{
};
this.xboxConsole = new XboxConsole((IPAddress)null);
}
/// <summary>
/// Called once after each test to clean up shim and stub objects.
/// </summary>
[TestCleanup]
public void TestCleanup()
{
this.shimsContext.Dispose();
}
/// <summary>
/// Verifies that the constructors of the Xboxparty class correctly set the properties.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(XboxPartyTestCategory)]
public void TestConstructorsCorrectlySetProperties()
{
XboxParty party = new XboxParty(this.xboxConsole, TestTitleId);
Assert.AreSame(this.xboxConsole, party.Console);
Assert.AreEqual(TestTitleId, party.TitleId);
party = XboxParty.FromTitleId(this.xboxConsole, TestTitleId);
Assert.AreSame(this.xboxConsole, party.Console);
Assert.AreEqual(TestTitleId, party.TitleId);
}
/// <summary>
/// Verifies that PartyId property calls Adapter GetPartyId and passes the correct return value and arguments.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(XboxPartyTestCategory)]
public void TestPartyIdCallsAdapterGetPartyId()
{
bool isCorrectMethodCalled = false;
ShimXboxConsoleAdapterBase.AllInstances.GetPartyIdStringUInt32 = (adapter, systemIpAddress, titleId) =>
{
isCorrectMethodCalled = true;
Assert.AreEqual(ConsoleAddress, systemIpAddress);
Assert.AreEqual(TestTitleId, titleId);
return TestPartyId;
};
XboxParty party = new XboxParty(this.xboxConsole, TestTitleId);
Assert.AreEqual(TestPartyId, party.PartyId);
Assert.IsTrue(isCorrectMethodCalled, "XboxParty PartyId property did not call Adapter GetPartyId.");
}
/// <summary>
/// Verifies that Members property calls Adapter GetPartyMembers and passes the correct return value and arguments.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(XboxPartyTestCategory)]
public void TestMembersCallsAdapterGetPartyMembers()
{
bool isCorrectMethodCalled = false;
// Overload GetUsers() to fake TestXuidString as the only local user (therefore TestXuidString2 will be assumed to be a remote user)
ShimXboxConsoleAdapterBase.AllInstances.GetUsersString = (adapter, systemIpAddress) =>
{
return new XboxUserDefinition[] { new XboxUserDefinition(0, string.Empty, string.Empty, true, false, TestXuidString) };
};
// Verify parameters are correct and adapter method is called.
ShimXboxConsoleAdapterBase.AllInstances.GetPartyMembersStringUInt32 = (adapter, systemIpAddress, titleId) =>
{
isCorrectMethodCalled = true;
Assert.AreEqual(TestTitleId, titleId, "Incorrect Title ID passed into GetPartyMembers.");
return new string[] { TestXuidString, TestXuidString2 };
};
XboxParty party = new XboxParty(this.xboxConsole, TestTitleId);
XboxUserBase[] returnValue = party.Members.ToArray();
Assert.IsTrue(isCorrectMethodCalled, "XboxParty Members property did not call Adapter GetPartyMembers.");
// Verify return value was passed correctly, TestXuidString was converted into XboxUser, and TestXuidString2 into XboxRemoteUser
Assert.AreEqual(2, returnValue.Length);
Assert.AreEqual(returnValue[0].Xuid, TestXuidString);
Assert.AreEqual(returnValue[1].Xuid, TestXuidString2);
Assert.IsInstanceOfType(returnValue[0], typeof(XboxUser));
Assert.IsInstanceOfType(returnValue[1], typeof(XboxRemoteUser));
}
}
}

Просмотреть файл

@ -0,0 +1,82 @@
//------------------------------------------------------------------------------
// <copyright file="XboxRemotePartyTests.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Tests
{
using System;
using System.Collections.Generic;
using System.Net;
using Microsoft.Internal.GamesTest.Xbox.Fakes;
using Microsoft.Internal.GamesTest.Xbox.Input;
using Microsoft.QualityTools.Testing.Fakes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Represents tests for the XboxRemoteParty type.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "This is test code and the object is disposed in the TestCleanup method.")]
[TestClass]
public class XboxRemotePartyTests
{
private const string XboxRemotePartyTestCategory = "XboxConsole.XboxRemoteParty";
private const string ConsoleAddress = "10.124.151.244"; // The actual IP address used here is irrelevant.
private const string TestPartyId = "1245";
private IDisposable shimsContext;
private XboxConsole xboxConsole;
/// <summary>
/// Called once before each test to setup shim and stub objects.
/// </summary>
[TestInitialize]
public void TestInitialize()
{
this.shimsContext = ShimsContext.Create();
ShimXboxConsole.ConstructorIPAddress = (console, address) =>
{
var myShim = new ShimXboxConsole(console)
{
AdapterGet = () => new StubXboxConsoleAdapterBase(null),
SystemIpAddressGet = () => IPAddress.Parse(XboxRemotePartyTests.ConsoleAddress),
SystemIpAddressStringGet = () => this.xboxConsole.SystemIpAddress.ToString(),
XboxGamepadsGet = () => new List<Input.XboxGamepad>(),
};
};
ShimXboxConsoleAdapterBase.ConstructorXboxXdkBase = (adapter, xboxXdk) =>
{
};
this.xboxConsole = new XboxConsole((IPAddress)null);
}
/// <summary>
/// Called once after each test to clean up shim and stub objects.
/// </summary>
[TestCleanup]
public void TestCleanup()
{
this.shimsContext.Dispose();
}
/// <summary>
/// Verifies that the constructors of the XboxRemoteParty class set the properties correctly.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(XboxRemotePartyTestCategory)]
public void TestConstructorsCorrectlySetProperties()
{
XboxRemoteParty remoteParty = new XboxRemoteParty(this.xboxConsole, TestPartyId);
Assert.AreSame(this.xboxConsole, remoteParty.Console);
Assert.AreEqual(TestPartyId, remoteParty.PartyId);
remoteParty = XboxRemoteParty.FromPartyId(this.xboxConsole, TestPartyId);
Assert.AreSame(this.xboxConsole, remoteParty.Console);
Assert.AreEqual(TestPartyId, remoteParty.PartyId);
}
}
}

Просмотреть файл

@ -0,0 +1,84 @@
//------------------------------------------------------------------------------
// <copyright file="XboxRemoteUserTests.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox.Tests
{
using System;
using System.Collections.Generic;
using System.Net;
using Microsoft.Internal.GamesTest.Xbox.Fakes;
using Microsoft.Internal.GamesTest.Xbox.Input;
using Microsoft.QualityTools.Testing.Fakes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
/// <summary>
/// Represents tests for the XboxRemoteUser type.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "This is test code and the object is disposed in the TestCleanup method.")]
[TestClass]
public class XboxRemoteUserTests
{
private const string XboxRemoteUserTestCategory = "XboxConsole.XboxRemoteUser";
private const string ConsoleAddress = "10.124.151.244"; // The actual IP address used here is irrelevant.
private const string TestXuidString = "1111111111111111";
private IDisposable shimsContext;
private XboxConsole xboxConsole;
/// <summary>
/// Called once before each test to setup shim and stub objects.
/// </summary>
[TestInitialize]
public void TestInitialize()
{
this.shimsContext = ShimsContext.Create();
ShimXboxConsole.ConstructorIPAddress = (console, address) =>
{
var myShim = new ShimXboxConsole(console)
{
AdapterGet = () => new StubXboxConsoleAdapterBase(null),
SystemIpAddressGet = () => IPAddress.Parse(XboxRemoteUserTests.ConsoleAddress),
SystemIpAddressStringGet = () => this.xboxConsole.SystemIpAddress.ToString(),
XboxGamepadsGet = () => new List<Input.XboxGamepad>(),
};
};
ShimXboxConsoleAdapterBase.ConstructorXboxXdkBase = (adapter, xboxXdk) =>
{
};
this.xboxConsole = new XboxConsole((IPAddress)null);
}
/// <summary>
/// Called once after each test to clean up shim and stub objects.
/// </summary>
[TestCleanup]
public void TestCleanup()
{
this.shimsContext.Dispose();
}
/// <summary>
/// Verifies that the constructors of the XboxUser class set the properties correctly.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(XboxRemoteUserTestCategory)]
public void TestConstructorsCorrectlySetProperties()
{
const string ExpectedXuidValue = TestXuidString;
XboxRemoteUser remoteUser = new XboxRemoteUser(this.xboxConsole, ExpectedXuidValue);
Assert.AreSame(this.xboxConsole, remoteUser.Console);
Assert.AreEqual(ExpectedXuidValue, remoteUser.Xuid);
remoteUser = XboxRemoteUser.FromXuid(this.xboxConsole, ExpectedXuidValue);
Assert.AreSame(this.xboxConsole, remoteUser.Console);
Assert.AreEqual(ExpectedXuidValue, remoteUser.Xuid);
}
}
}

Просмотреть файл

@ -23,6 +23,12 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
{
private const string XboxUserTestCategory = "XboxConsole.XboxUser";
private const string ConsoleAddress = "10.124.151.244"; // The actual IP address used here is irrelevant.
private const string TestGamertag = "Test Gamertag";
private const string TestEmailAddress = "TestAddress@test.test";
private const string TestXuidString = "1111111111111111";
private const uint TestUserId = 12345;
private const string TestPartyId = "1234";
private const uint TestTitleId = 12255;
private IDisposable shimsContext;
private XboxConsole xboxConsole;
@ -73,7 +79,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
var gamepad = new XboxGamepad(this.xboxConsole);
gamepad.Connect();
XboxUser user = new XboxUser(this.xboxConsole, 0, null, null, false);
XboxUser user = this.CreateTestUser();
bool isCorrectMethodCalled = false;
@ -99,11 +105,11 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[TestCategory(XboxUserTestCategory)]
public void TestPairWithMethodsPassOnIds()
{
const uint ExpectedUserId = 12345;
const uint ExpectedUserId = TestUserId;
const ulong ExpectedGamepadId = 9876543210;
var gamepad = new XboxGamepad(this.xboxConsole);
XboxUser user = new XboxUser(this.xboxConsole, ExpectedUserId, null, null, false);
XboxUser user = this.CreateTestUser();
ShimXboxConsoleAdapterBase.AllInstances.ConnectXboxGamepadString = (_, __) => ExpectedGamepadId;
@ -129,7 +135,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[ExpectedException(typeof(ArgumentNullException))]
public void TestPairWithVirtualControllerThrowsArgumentNullExceptions()
{
XboxUser user = new XboxUser(this.xboxConsole, 0, null, null, false);
XboxUser user = this.CreateTestUser();
ShimXboxConsoleAdapterBase.AllInstances.PairGamepadToUserStringUInt64UInt32 = (adapter, systemIpAddress, gamepadId, userId) =>
{
@ -149,7 +155,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
public void TestPairWithVirtualControllerThrowsArgumentExceptions()
{
XboxGamepad gamepad = new XboxGamepad(this.xboxConsole);
XboxUser user = new XboxUser(this.xboxConsole, 0, null, null, false);
XboxUser user = this.CreateTestUser();
ShimXboxConsoleAdapterBase.AllInstances.PairGamepadToUserStringUInt64UInt32 = (adapter, systemIpAddress, gamepadId, userId) =>
{
@ -167,10 +173,12 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[TestCategory(XboxUserTestCategory)]
public void TestConstructorsCorrectlySetProperties()
{
const uint ExpectedId = 12345;
const string ExpectedEmail = "Test Email String";
const string ExpectedGamerTag = "Test Gamertag";
const uint ExpectedId = TestUserId;
const string ExpectedEmail = TestEmailAddress;
const string ExpectedGamerTag = TestGamertag;
const string ExpectedXuidValue = TestXuidString;
bool expectedAutoSignInValue = true;
bool expectedIsSignedInValue = false;
this.TestXboxUserProperties(
@ -178,7 +186,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
ExpectedEmail,
ExpectedGamerTag,
expectedIsSignedInValue,
() => new XboxUser(this.xboxConsole, ExpectedId, ExpectedEmail, ExpectedGamerTag));
() => new XboxUser(this.xboxConsole, ExpectedId, ExpectedEmail, ExpectedGamerTag, false));
this.TestXboxUserProperties(
ExpectedId,
@ -187,7 +195,17 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
expectedIsSignedInValue,
() => new XboxUser(this.xboxConsole, ExpectedId, ExpectedEmail, ExpectedGamerTag, expectedIsSignedInValue));
this.TestXboxUserProperties(
ExpectedId,
ExpectedEmail,
ExpectedGamerTag,
expectedIsSignedInValue,
expectedAutoSignInValue,
ExpectedXuidValue,
() => new XboxUser(this.xboxConsole, ExpectedId, ExpectedEmail, ExpectedGamerTag, expectedIsSignedInValue, expectedAutoSignInValue, ExpectedXuidValue));
expectedIsSignedInValue = true;
expectedAutoSignInValue = false;
this.TestXboxUserProperties(
ExpectedId,
@ -196,6 +214,15 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
expectedIsSignedInValue,
() => new XboxUser(this.xboxConsole, ExpectedId, ExpectedEmail, ExpectedGamerTag, expectedIsSignedInValue));
this.TestXboxUserProperties(
ExpectedId,
ExpectedEmail,
ExpectedGamerTag,
expectedIsSignedInValue,
expectedAutoSignInValue,
ExpectedXuidValue,
() => new XboxUser(this.xboxConsole, ExpectedId, ExpectedEmail, ExpectedGamerTag, expectedIsSignedInValue, expectedAutoSignInValue, ExpectedXuidValue));
XboxUserDefinition definition = new XboxUserDefinition(ExpectedId, ExpectedEmail, ExpectedGamerTag, expectedIsSignedInValue);
this.TestXboxUserProperties(
@ -214,14 +241,14 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[TestCategory(XboxUserTestCategory)]
public void TestSignInCallsAdapterSignIn()
{
XboxUser user = new XboxUser(this.xboxConsole, 0, null, null, false);
XboxUser user = this.CreateTestUser();
bool isCorrectMethodCalled = false;
ShimXboxConsoleAdapterBase.AllInstances.SignInUserStringXboxUserDefinitionStringBoolean = (adapter, systemIpAddress, userDefinition, password, storePassword) =>
{
isCorrectMethodCalled = true;
return new XboxUserDefinition(0, null, null, false);
return this.CreateTestUserDefinition();
};
user.SignIn(null, false);
@ -236,9 +263,9 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[TestCategory(XboxUserTestCategory)]
public void TestSignInPassesArguments()
{
const uint ExpectedUserId = 54;
const string ExpectedEmailAddress = "TestAddress@test.test";
const string ExpectedGamerTag = "TestGamerTag";
const uint ExpectedUserId = TestUserId;
const string ExpectedEmailAddress = TestEmailAddress;
const string ExpectedGamerTag = TestGamertag;
const string ExpectedPassword = "TestPassword";
const bool ExpectedIsSignedInValue = true;
@ -271,7 +298,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[ExpectedException(typeof(XboxSignInException))]
public void TestSignInHandlesNullReturn()
{
XboxUser user = new XboxUser(this.xboxConsole, 0, "TestEmailAddress", null, false);
XboxUser user = this.CreateTestUser();
ShimXboxConsoleAdapterBase.AllInstances.SignInUserStringXboxUserDefinitionStringBoolean = (adapter, systemIpAddress, userDefinition, password, storePassword) =>
{
@ -290,11 +317,11 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[ExpectedException(typeof(XboxSignInException))]
public void TestSignInHandlesIncorrectReturn()
{
XboxUser user = new XboxUser(this.xboxConsole, 0, "TestEmailAddress", null, false);
XboxUser user = this.CreateTestUser();
ShimXboxConsoleAdapterBase.AllInstances.SignInUserStringXboxUserDefinitionStringBoolean = (adapter, systemIpAddress, userDefinition, password, storePassword) =>
{
return new XboxUserDefinition(0, "DifferentEmail", null, false);
return new XboxUserDefinition(TestUserId, "DifferentEmail", null, false);
};
user.SignIn(null, false);
@ -308,14 +335,14 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[TestCategory(XboxUserTestCategory)]
public void TestSignOutInvokesAdapterSignOut()
{
XboxUser user = new XboxUser(this.xboxConsole, 0, null, null, false);
XboxUser user = this.CreateTestUser();
bool isCorrectMethodCalled = false;
ShimXboxConsoleAdapterBase.AllInstances.SignOutUserStringXboxUserDefinition = (adapter, systemIpAddress, userDefinition) =>
{
isCorrectMethodCalled = true;
return new XboxUserDefinition(0, null, null, false);
return this.CreateTestUserDefinition();
};
user.SignOut();
@ -330,9 +357,9 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[TestCategory(XboxUserTestCategory)]
public void TestSignOutPassesArguments()
{
const uint ExpectedUserId = 54;
const string ExpectedEmailAddress = "TestAddress@test.test";
const string ExpectedGamerTag = "TestGamerTag";
const uint ExpectedUserId = TestUserId;
const string ExpectedEmailAddress = TestEmailAddress;
const string ExpectedGamerTag = TestGamertag;
const bool ExpectedIsSignedInValue = false;
@ -358,7 +385,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[ExpectedException(typeof(XboxSignInException))]
public void TestSignOutHandlesNullReturn()
{
XboxUser user = new XboxUser(this.xboxConsole, 0, "TestEmailAddress", null, false);
XboxUser user = this.CreateTestUser();
ShimXboxConsoleAdapterBase.AllInstances.SignOutUserStringXboxUserDefinition = (adapter, systemIpAddress, userDefinition) =>
{
@ -377,16 +404,114 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
[ExpectedException(typeof(XboxSignInException))]
public void TestSignOutHandlesIncorrectReturn()
{
XboxUser user = new XboxUser(this.xboxConsole, 0, "TestEmailAddress", null, false);
XboxUser user = this.CreateTestUser();
ShimXboxConsoleAdapterBase.AllInstances.SignOutUserStringXboxUserDefinition = (adapter, systemIpAddress, userDefinition) =>
{
return new XboxUserDefinition(0, "DifferentEmail", null, false);
return new XboxUserDefinition(TestUserId, "DifferentEmail", null, false);
};
user.SignOut();
}
/// <summary>
/// Verifies that this method calls the corresponding method on the adapter and passes the correct parameters.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(XboxUserTestCategory)]
public void TestAddLocalUsersToPartyInvokesAdapterAddLocalUsersToParty()
{
bool isCorrectMethodCalled = false;
ShimXboxConsoleAdapterBase.AllInstances.AddLocalUsersToPartyStringUInt32StringStringArray = (adapter, systemIpAddress, titleId, actingUserXuid, addUserXuids) =>
{
isCorrectMethodCalled = true;
Assert.AreEqual(TestTitleId, titleId);
Assert.AreEqual(TestXuidString, actingUserXuid);
Assert.IsNotNull(addUserXuids);
Assert.AreEqual(1, addUserXuids.Length);
Assert.AreEqual(TestXuidString, addUserXuids[0]);
};
this.CreateTestUser().AddLocalUsersToParty(XboxParty.FromTitleId(this.xboxConsole, TestTitleId), new XboxUser[] { this.CreateTestUser() });
Assert.IsTrue(isCorrectMethodCalled, "XboxUser method did not call the correct Adapter method.");
}
/// <summary>
/// Verifies that this method calls the corresponding method on the adapter and passes the correct parameters.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(XboxUserTestCategory)]
public void TestInviteToPartyInvokesAdapterInviteToParty()
{
bool isCorrectMethodCalled = false;
ShimXboxConsoleAdapterBase.AllInstances.InviteToPartyStringUInt32StringStringArray = (adapter, systemIpAddress, titleId, actingUserXuid, inviteUserXuids) =>
{
isCorrectMethodCalled = true;
Assert.AreEqual(TestTitleId, titleId);
Assert.AreEqual(TestXuidString, actingUserXuid);
Assert.IsNotNull(inviteUserXuids);
Assert.AreEqual(1, inviteUserXuids.Length);
Assert.AreEqual(TestXuidString, inviteUserXuids[0]);
};
this.CreateTestUser().InviteToParty(XboxParty.FromTitleId(this.xboxConsole, TestTitleId), new XboxRemoteUser[] { this.CreateTestRemoteUser() });
Assert.IsTrue(isCorrectMethodCalled, "XboxUser method did not call the correct Adapter method.");
}
/// <summary>
/// Verifies that this method calls the corresponding method on the adapter and passes the correct parameters.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(XboxUserTestCategory)]
public void TestAcceptInviteToPartyInvokesAdapterAcceptInviteToParty()
{
bool isCorrectMethodCalled = false;
ShimXboxConsoleAdapterBase.AllInstances.AcceptInviteToPartyStringStringString = (adapter, systemIp, actingUserXuid, partyId) =>
{
isCorrectMethodCalled = true;
Assert.AreEqual(TestXuidString, actingUserXuid);
Assert.AreEqual(TestPartyId, partyId);
};
this.CreateTestUser().AcceptInviteToParty(XboxRemoteParty.FromPartyId(this.xboxConsole, TestPartyId));
Assert.IsTrue(isCorrectMethodCalled, "XboxUser method did not call the correct Adapter method.");
}
/// <summary>
/// Verifies that this method calls the corresponding method on the adapter and passes the correct parameters.
/// </summary>
[TestMethod]
[TestCategory("UnitTest")]
[TestCategory(XboxUserTestCategory)]
public void TestDeclineInviteToPartyInvokesAdapterDeclineInviteToParty()
{
bool isCorrectMethodCalled = false;
ShimXboxConsoleAdapterBase.AllInstances.DeclineInviteToPartyStringStringString = (adapter, systemIp, actingUserXuid, partyId) =>
{
isCorrectMethodCalled = true;
Assert.AreEqual(TestXuidString, actingUserXuid);
Assert.AreEqual(TestPartyId, partyId);
};
this.CreateTestUser().DeclineInviteToParty(XboxRemoteParty.FromPartyId(this.xboxConsole, TestPartyId));
Assert.IsTrue(isCorrectMethodCalled, "XboxUser method did not call the correct Adapter method.");
}
private void TestXboxUserProperties(uint expectedId, string expectedEmail, string expectedGamerTag, bool expectedIsSignedInValue, Func<XboxUser> constructorFunc)
{
XboxUser user = constructorFunc();
@ -396,5 +521,32 @@ namespace Microsoft.Internal.GamesTest.Xbox.Tests
Assert.AreEqual(expectedGamerTag, user.GamerTag, "GamerTag Property did not match expected value");
Assert.AreEqual(expectedIsSignedInValue, user.IsSignedIn, "IsSignedIn Property did not match expected value");
}
private void TestXboxUserProperties(uint expectedId, string expectedEmail, string expectedGamerTag, bool expectedIsSignedInValue, bool expectedAutoSignInValue, string expectedXuidValue, Func<XboxUser> constructorFunc)
{
XboxUser user = constructorFunc();
Assert.AreEqual(expectedId, user.UserId, "UserId Property did not match expected value");
Assert.AreEqual(expectedEmail, user.EmailAddress, "EmailAddress Property did not match expected value");
Assert.AreEqual(expectedGamerTag, user.GamerTag, "GamerTag Property did not match expected value");
Assert.AreEqual(expectedIsSignedInValue, user.IsSignedIn, "IsSignedIn Property did not match expected value");
Assert.AreEqual(expectedAutoSignInValue, user.AutoSignIn, "AutoSignIn Property did not match the expected value");
Assert.AreEqual(expectedXuidValue, user.Xuid, "Xuid Property did not match the expected value");
}
private XboxUserDefinition CreateTestUserDefinition()
{
return new XboxUserDefinition(TestUserId, TestEmailAddress, TestGamertag, false, false, TestXuidString);
}
private XboxUser CreateTestUser()
{
return new XboxUser(this.xboxConsole, this.CreateTestUserDefinition());
}
private XboxRemoteUser CreateTestRemoteUser()
{
return new XboxRemoteUser(this.xboxConsole, TestXuidString);
}
}
}

Просмотреть файл

@ -20,6 +20,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XboxConsole.Adapter.April20
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XboxConsole.Adapter.May2014", "XboxConsole.Adapter.May2014\XboxConsole.Adapter.May2014.csproj", "{7C44371F-E7EE-4A48-BDC8-54E69A4F7C0C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XboxConsole.Adapter.July2014", "XboxConsole.Adapter.July2014\XboxConsole.Adapter.July2014.csproj", "{E842B4D7-58D2-4435-B876-004DE9A45FBD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{BBFC58FA-BC44-4760-8F48-85A4C24F6EAA}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
@ -54,6 +56,9 @@ Global
SccProjectUniqueName7 = XboxConsole.Adapter.May2014\\XboxConsole.Adapter.May2014.csproj
SccProjectName7 = XboxConsole.Adapter.May2014
SccLocalPath7 = XboxConsole.Adapter.May2014
SccProjectUniqueName8 = XboxConsole.Adapter.July2014\\XboxConsole.Adapter.July2014.csproj
SccProjectName8 = XboxConsole.Adapter.July2014
SccLocalPath8 = XboxConsole.Adapter.July2014
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@ -88,6 +93,16 @@ Global
{7C44371F-E7EE-4A48-BDC8-54E69A4F7C0C}.Debug|x64.Build.0 = Debug|x64
{7C44371F-E7EE-4A48-BDC8-54E69A4F7C0C}.Release|x64.ActiveCfg = Release|x64
{7C44371F-E7EE-4A48-BDC8-54E69A4F7C0C}.Release|x64.Build.0 = Release|x64
{E842B4D7-58D2-4435-B876-004DE9A45FBD}.Debug|Any CPU.ActiveCfg = Debug|x64
{E842B4D7-58D2-4435-B876-004DE9A45FBD}.Debug|Mixed Platforms.ActiveCfg = Debug|x64
{E842B4D7-58D2-4435-B876-004DE9A45FBD}.Debug|Mixed Platforms.Build.0 = Debug|x64
{E842B4D7-58D2-4435-B876-004DE9A45FBD}.Debug|x64.ActiveCfg = Debug|x64
{E842B4D7-58D2-4435-B876-004DE9A45FBD}.Debug|x64.Build.0 = Debug|x64
{E842B4D7-58D2-4435-B876-004DE9A45FBD}.Release|Any CPU.ActiveCfg = Release|x64
{E842B4D7-58D2-4435-B876-004DE9A45FBD}.Release|Mixed Platforms.ActiveCfg = Release|x64
{E842B4D7-58D2-4435-B876-004DE9A45FBD}.Release|Mixed Platforms.Build.0 = Release|x64
{E842B4D7-58D2-4435-B876-004DE9A45FBD}.Release|x64.ActiveCfg = Release|x64
{E842B4D7-58D2-4435-B876-004DE9A45FBD}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Просмотреть файл

@ -273,7 +273,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Configuration
/// <summary>
/// Gets the ColorDepth.
/// </summary>
public int ColorDepth
public ColorDepthType ColorDepth
{
get
{

Просмотреть файл

@ -359,7 +359,7 @@ namespace Microsoft.Internal.GamesTest.Xbox.Configuration
/// <summary>
/// Gets or sets the ColorDepth value. Call XboxConsole.Reboot method to apply configuration to a console.
/// </summary>
public int ColorDepth
public ColorDepthType ColorDepth
{
get
{

Просмотреть файл

@ -43,7 +43,7 @@ namespace Microsoft.Internal.GamesTest.Xbox
TelemetrySink.StopTelemetry();
};
XboxConsoleEventSource.Logger.ModuleLoaded(Process.GetCurrentProcess().ProcessName, WindowsIdentity.GetCurrent().Name, Dns.GetHostEntry("localhost").HostName, Assembly.GetExecutingAssembly().GetName().Version.ToString());
XboxConsoleEventSource.Logger.ModuleLoaded(Process.GetCurrentProcess().ProcessName, WindowsIdentity.GetCurrent().Name, Dns.GetHostEntry("localhost").HostName, FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion.ToString());
}
/// <summary>
@ -148,7 +148,7 @@ namespace Microsoft.Internal.GamesTest.Xbox
if (!IPAddress.TryParse(connectionString, out systemIpAddress))
{
// Resolve IP address from host name if passed host name
systemIpAddress = Dns.GetHostAddresses(connectionString).FirstOrDefault(o => o.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);
systemIpAddress = Dns.GetHostAddresses(connectionString).FirstOrDefault(o => o.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);
}
if (systemIpAddress == null)
@ -355,8 +355,7 @@ namespace Microsoft.Internal.GamesTest.Xbox
}
/// <summary>
/// Gets the Xbox console adapter to use. Making this a protected property instead of a private field
/// allows it to be accessed by the Shim framework used in the unit tests.
/// Gets the Xbox console adapter to use.
/// </summary>
internal XboxConsoleAdapterBase Adapter { get; private set; }
@ -458,7 +457,7 @@ namespace Microsoft.Internal.GamesTest.Xbox
public void Shutdown(TimeSpan timeout)
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
this.ThrowIfDisposed();
this.Adapter.Shutdown(this.SystemIpAddressAndSessionKeyCombined, timeout);

Просмотреть файл

@ -70,8 +70,13 @@
<Compile Include="XboxConsoleAdapterFactory.cs" />
<Compile Include="XboxItem.cs" />
<Compile Include="XboxPackage.cs" />
<Compile Include="XboxParty.cs" />
<Compile Include="XboxPartyBase.cs" />
<Compile Include="XboxProcess.cs" />
<Compile Include="XboxRemoteParty.cs" />
<Compile Include="XboxRemoteUser.cs" />
<Compile Include="XboxUser.cs" />
<Compile Include="XboxUserBase.cs" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="..\dependencies\CodeAnalysis\CustomDictionary.xml">
@ -83,6 +88,10 @@
<Project>{5e7a10c7-20e2-4c7d-91b8-f744207eddcc}</Project>
<Name>XboxConsole.Adapter.April2014</Name>
</ProjectReference>
<ProjectReference Include="..\XboxConsole.Adapter.July2014\XboxConsole.Adapter.July2014.csproj">
<Project>{e842b4d7-58d2-4435-b876-004de9a45fbd}</Project>
<Name>XboxConsole.Adapter.July2014</Name>
</ProjectReference>
<ProjectReference Include="..\XboxConsole.Adapter.May2014\XboxConsole.Adapter.May2014.csproj">
<Project>{7c44371f-e7ee-4a48-bdc8-54e69a4f7c0c}</Project>
<Name>XboxConsole.Adapter.May2014</Name>

Просмотреть файл

@ -20,6 +20,7 @@ namespace Microsoft.Internal.GamesTest.Xbox
/// </summary>
internal static class XboxConsoleAdapterFactory
{
private const int July2014XdkBuild = 11274;
private const int May2014XdkBuild = 10951;
private const int April2014XdkBuild = 10812;
@ -29,6 +30,7 @@ namespace Microsoft.Internal.GamesTest.Xbox
{
new Tuple<int, Func<XboxConsoleAdapterBase>>(April2014XdkBuild, () => new Adapter.April2014.XboxConsoleAdapter()),
new Tuple<int, Func<XboxConsoleAdapterBase>>(May2014XdkBuild, () => new Adapter.May2014.XboxConsoleAdapter()),
new Tuple<int, Func<XboxConsoleAdapterBase>>(July2014XdkBuild, () => new Adapter.July2014.XboxConsoleAdapter()),
};
/// <summary>
@ -38,6 +40,7 @@ namespace Microsoft.Internal.GamesTest.Xbox
{
{ "xb_rel_1404", April2014XdkBuild },
{ "xb_rel_1405", May2014XdkBuild },
{ "xb_rel_1407", July2014XdkBuild },
};
/// <summary>

103
XboxConsole/XboxParty.cs Normal file
Просмотреть файл

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <copyright file="XboxParty.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Internal.GamesTest.Xbox.Input;
using Microsoft.Internal.GamesTest.Xbox.Telemetry;
/// <summary>
/// Represents a party started by a local user.
/// </summary>
public class XboxParty : XboxPartyBase
{
/// <summary>
/// Initializes a new instance of the <see cref="XboxParty"/> class.
/// </summary>
/// <param name="console">The console on which the party is to be created.</param>
/// <param name="titleId">The Title ID of the title the party is for.</param>
/// <returns>The XboxParty object which can be used with XboxUser party management functions or to get party members.</returns>
internal XboxParty(XboxConsole console, uint titleId)
: base(console)
{
XboxConsoleEventSource.Logger.ObjectCreated(XboxConsoleEventSource.GetCurrentConstructor());
this.TitleId = titleId;
}
/// <summary>
/// Gets the TitleID of the title the party has been created for.
/// </summary>
public uint TitleId
{
get;
private set;
}
/// <summary>
/// Gets the local party ID for the title the party was created for.
/// </summary>
public override string PartyId
{
get
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
return Console.Adapter.GetPartyId(Console.SystemIpAddressAndSessionKeyCombined, this.TitleId);
}
}
/// <summary>
/// Gets the party member XUIDs.
/// </summary>
public IEnumerable<XboxUserBase> Members
{
get
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
string[] members = this.Console.Adapter.GetPartyMembers(this.Console.ConnectionString, this.TitleId);
XboxUser[] localUsers = this.Console.Users.ToArray();
XboxUserBase[] memberObjects = new XboxUserBase[members.Length];
for (int n = 0; n < memberObjects.Length; n++)
{
XboxUser localUser = (from xu in localUsers where xu.IsSignedIn && xu.Xuid == members[n] select xu).SingleOrDefault();
if (localUser == null)
{
memberObjects[n] = new XboxRemoteUser(this.Console, members[n]);
}
else
{
memberObjects[n] = localUser;
}
}
return memberObjects;
}
}
/// <summary>
/// Gets the local party associated with a specified Title ID.
/// Until the party has been created, this object will throw an XboxConsoleException upon use.
/// </summary>
/// <param name="console">The console object on which the title's party has been created.</param>
/// <param name="titleId">Title ID the party is for.</param>
/// <returns>The party object which can be passed into other functions or for getting party members.</returns>
public static XboxParty FromTitleId(XboxConsole console, uint titleId)
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
return new XboxParty(console, titleId);
}
}
}

Просмотреть файл

@ -0,0 +1,36 @@
//------------------------------------------------------------------------------
// <copyright file="XboxPartyBase.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using System.Linq;
using Microsoft.Internal.GamesTest.Xbox.Input;
using Microsoft.Internal.GamesTest.Xbox.Telemetry;
/// <summary>
/// Virtual party base class.
/// </summary>
public abstract class XboxPartyBase : XboxItem
{
/// <summary>
/// Initializes a new instance of the <see cref="XboxPartyBase"/> class.
/// </summary>
/// <param name="console">The XboxConsole object that the party object is associated with.</param>
internal XboxPartyBase(XboxConsole console)
: base(console)
{
}
/// <summary>
/// Gets the unique party identifier.
/// </summary>
public abstract string PartyId
{
get;
}
}
}

Просмотреть файл

@ -0,0 +1,61 @@
//------------------------------------------------------------------------------
// <copyright file="XboxRemoteParty.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using System.Linq;
using Microsoft.Internal.GamesTest.Xbox.Input;
using Microsoft.Internal.GamesTest.Xbox.Telemetry;
/// <summary>
/// Represents a party started on another console to which an invitation can be accepted or declined.
/// </summary>
public class XboxRemoteParty : XboxPartyBase
{
/// <summary>
/// Backing variable for the PartyID property.
/// </summary>
private string partyId;
/// <summary>
/// Initializes a new instance of the <see cref="XboxRemoteParty"/> class.
/// </summary>
/// <param name="console">The XboxConsole object that this object will be associated with.</param>
/// <param name="initPartyId">Remote party ID to initialize with.</param>
internal XboxRemoteParty(XboxConsole console, string initPartyId)
: base(console)
{
XboxConsoleEventSource.Logger.ObjectCreated(XboxConsoleEventSource.GetCurrentConstructor());
this.partyId = initPartyId;
}
/// <summary>
/// Gets the Party ID useful for interoperation with external tools.
/// </summary>
public override string PartyId
{
get
{
return this.partyId;
}
}
/// <summary>
/// Gets the remote party associated with a specified Party ID.
/// </summary>
/// <param name="console">The XboxConsole object that this object will be associated with.</param>
/// <param name="partyId">Unique identifier of a party created on another console.</param>
/// <returns>The remote party object which can be passed into other functions.</returns>
public static XboxRemoteParty FromPartyId(XboxConsole console, string partyId)
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
return new XboxRemoteParty(console, partyId);
}
}
}

Просмотреть файл

@ -0,0 +1,60 @@
//------------------------------------------------------------------------------
// <copyright file="XboxRemoteUser.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using Microsoft.Internal.GamesTest.Xbox.Input;
using Microsoft.Internal.GamesTest.Xbox.Telemetry;
/// <summary>
/// A virtual user object referring to a user on another console.
/// </summary>
public class XboxRemoteUser : XboxUserBase
{
/// <summary>
/// Backing variable to store user's XUID.
/// </summary>
private string userXuid;
/// <summary>
/// Initializes a new instance of the <see cref="XboxRemoteUser"/> class.
/// </summary>
/// <param name="console">The XboxConsole object that this object will be associated with.</param>
/// <param name="xuid">The unique Xbox Live identifier to initialize with.</param>
internal XboxRemoteUser(XboxConsole console, string xuid)
: base(console)
{
XboxConsoleEventSource.Logger.ObjectCreated(XboxConsoleEventSource.GetCurrentConstructor());
this.userXuid = xuid;
}
/// <summary>
/// Gets the user's unique Xbox Live identifier.
/// </summary>
public override string Xuid
{
get
{
return this.userXuid;
}
}
/// <summary>
/// Creates a new instance of the <see cref="XboxRemoteUser"/> class.
/// </summary>
/// <param name="console">The XboxConsole object that this object will be associated with.</param>
/// <param name="xuid">A unique Xbox Live identifier for the user.</param>
/// <returns>A new instance of XboxRemoteUser.</returns>
public static XboxRemoteUser FromXuid(XboxConsole console, string xuid)
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
return new XboxRemoteUser(console, xuid);
}
}
}

Просмотреть файл

@ -7,13 +7,16 @@
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.Internal.GamesTest.Xbox.Input;
using Microsoft.Internal.GamesTest.Xbox.Telemetry;
/// <summary>
/// A virtual user.
/// </summary>
public class XboxUser : XboxItem
public class XboxUser : XboxUserBase
{
/// <summary>
/// Initializes a new instance of the XboxUser class.
@ -23,10 +26,14 @@ namespace Microsoft.Internal.GamesTest.Xbox
/// <param name="emailAddress">The email address used to sign the user in.</param>
/// <param name="gamertag">The user's GamerTag.</param>
/// <param name="signedin">If true, the user is signed in on the console.</param>
internal XboxUser(XboxConsole console, uint userId, string emailAddress, string gamertag, bool signedin)
/// <param name="autoSignIn">If true, the user is setup for automatic sign in on the console.</param>
/// <param name="xuid">The unique Xbox Live identifier for the user.</param>
internal XboxUser(XboxConsole console, uint userId, string emailAddress, string gamertag, bool signedin, bool autoSignIn, string xuid)
: base(console)
{
this.Definition = new XboxUserDefinition(userId, emailAddress, gamertag, signedin);
XboxConsoleEventSource.Logger.ObjectCreated(XboxConsoleEventSource.GetCurrentConstructor());
this.Definition = new XboxUserDefinition(userId, emailAddress, gamertag, signedin, autoSignIn, xuid);
}
/// <summary>
@ -36,9 +43,11 @@ namespace Microsoft.Internal.GamesTest.Xbox
/// <param name="userId">A unique identifier for the user.</param>
/// <param name="emailAddress">The email address used to sign the user in.</param>
/// <param name="gamertag">The user's GamerTag.</param>
internal XboxUser(XboxConsole console, uint userId, string emailAddress, string gamertag)
: this(console, userId, emailAddress, gamertag, false)
/// <param name="signedin">If true, the user is signed in on the console.</param>
internal XboxUser(XboxConsole console, uint userId, string emailAddress, string gamertag, bool signedin)
: this(console, userId, emailAddress, gamertag, signedin, false, null)
{
XboxConsoleEventSource.Logger.ObjectCreated(XboxConsoleEventSource.GetCurrentConstructor());
}
/// <summary>
@ -49,6 +58,8 @@ namespace Microsoft.Internal.GamesTest.Xbox
internal XboxUser(XboxConsole console, XboxUserDefinition userData)
: base(console)
{
XboxConsoleEventSource.Logger.ObjectCreated(XboxConsoleEventSource.GetCurrentConstructor());
if (userData == null)
{
throw new ArgumentNullException("userData", "userData can't be null");
@ -89,6 +100,40 @@ namespace Microsoft.Internal.GamesTest.Xbox
get { return this.Definition.IsSignedIn; }
}
/// <summary>
/// Gets a value indicating whether the user is setup for auto login.
/// </summary>
public bool AutoSignIn
{
get
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
return this.Definition.AutoSignIn;
}
}
/// <summary>
/// Gets a unique Xbox Live identifier for the user.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Justification = "Xuid is not available when the user is not signed in.")]
public override string Xuid
{
get
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
if (string.IsNullOrEmpty(this.Definition.Xuid))
{
throw new XboxUserNotSignedInException(string.Format(CultureInfo.CurrentCulture, "Could not retrieve XUID for {0} because this user is not signed in.", this.Definition.EmailAddress));
}
else
{
return this.Definition.Xuid;
}
}
}
/// <summary>
/// Gets the definition object backing this package object.
/// This is a property and not a field so that it can be shimmed in the Unit Tests.
@ -168,5 +213,105 @@ namespace Microsoft.Internal.GamesTest.Xbox
this.Definition = newDefinition;
}
/// <summary>
/// Creates a party for the given title ID (if one does not exist) and adds the given local users to it.
/// </summary>
/// <param name="party">The party to add local users to.</param>
/// <param name="localUsersToAdd">Users to add to the party.</param>
public void AddLocalUsersToParty(XboxParty party, XboxUser[] localUsersToAdd)
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
if (party == null)
{
throw new ArgumentNullException("party");
}
if (localUsersToAdd == null)
{
throw new ArgumentNullException("localUsersToAdd");
}
this.Console.Adapter.AddLocalUsersToParty(this.Console.SystemIpAddressAndSessionKeyCombined, party.TitleId, this.Xuid, (from xu in localUsersToAdd select xu.Xuid).ToArray());
}
/// <summary>
/// Invites the given users on behalf of the acting user to the given party (associated with a specific Title ID).
/// </summary>
/// <param name="party">The party to invite remote users to.</param>
/// <param name="remoteUsersToInvite">Remote users to invite to the party.</param>
public void InviteToParty(XboxParty party, IEnumerable<XboxRemoteUser> remoteUsersToInvite)
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
if (party == null)
{
throw new ArgumentNullException("party");
}
if (remoteUsersToInvite == null)
{
throw new ArgumentNullException("remoteUsersToInvite");
}
this.Console.Adapter.InviteToParty(this.Console.SystemIpAddressAndSessionKeyCombined, party.TitleId, this.Xuid, (from xu in remoteUsersToInvite select xu.Xuid).ToArray());
}
/// <summary>
/// Removes the given users from the given party belonging to a specific title ID.
/// </summary>
/// <param name="party">The party to remove local users from.</param>
/// <param name="localUsersToRemove">Local users to remove from the party.</param>
public void RemoveLocalUsersFromParty(XboxParty party, IEnumerable<XboxUser> localUsersToRemove)
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
if (party == null)
{
throw new ArgumentNullException("party");
}
if (localUsersToRemove == null)
{
throw new ArgumentNullException("localUsersToRemove");
}
this.Console.Adapter.RemoveLocalUsersFromParty(this.Console.SystemIpAddressAndSessionKeyCombined, party.TitleId, (from xu in localUsersToRemove select xu.Xuid).ToArray());
}
/// <summary>
/// Accepts the party invitation to a party created on another console and associated with a specific title ID.
/// </summary>
/// <param name="party">Party created by another user to accept the invitation to.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Specific type used to communicate that party invites can only be declined to remote parties.")]
public void AcceptInviteToParty(XboxRemoteParty party)
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
if (party == null)
{
throw new ArgumentNullException("party");
}
this.Console.Adapter.AcceptInviteToParty(this.Console.SystemIpAddressAndSessionKeyCombined, this.Xuid, party.PartyId);
}
/// <summary>
/// Declines the party invitation to a party created on another console and associated with a specific title ID.
/// </summary>
/// <param name="party">Party created by another user to accept the invitation to.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Specific type used to communicate that party invites can only be declined to remote parties.")]
public void DeclineInviteToParty(XboxRemoteParty party)
{
XboxConsoleEventSource.Logger.MethodCalled(XboxConsoleEventSource.GetCurrentMethod());
if (party == null)
{
throw new ArgumentNullException("party");
}
this.Console.Adapter.DeclineInviteToParty(this.Console.SystemIpAddressAndSessionKeyCombined, this.Xuid, party.PartyId);
}
}
}

Просмотреть файл

@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <copyright file="XboxUserBase.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Internal.GamesTest.Xbox
{
using System;
using System.Linq;
using Microsoft.Internal.GamesTest.Xbox.Input;
using Microsoft.Internal.GamesTest.Xbox.Telemetry;
/// <summary>
/// The base class of virtual users.
/// </summary>
public abstract class XboxUserBase : XboxItem
{
/// <summary>
/// Initializes a new instance of the <see cref="XboxUserBase"/> class.
/// </summary>
/// <param name="console">The XboxConsole object that this object will be associated with.</param>
internal XboxUserBase(XboxConsole console) : base(console)
{
}
/// <summary>
/// Gets a unique Xbox Live identifier for the user.
/// </summary>
public abstract string Xuid
{
get;
}
}
}

Просмотреть файл

@ -38,6 +38,7 @@
<Word>Hdmi</Word>
<Word>Bitstream</Word>
<Word>Dts</Word>
<Word>Xuid</Word>
</Recognized>
</Words>
<Acronyms>
@ -53,6 +54,7 @@
<Acronym>Ip</Acronym>
<Acronym>UI</Acronym>
<Acronym>OOBE</Acronym>
<Acronym>XUID</Acronym>
</CasingExceptions>
</Acronyms>
</Dictionary>

Двоичные данные
dependencies/GamesTest.ManagedXtf.2014.07.1.0.40811.0/lib/net45/Microsoft.Xbox.Xtf.Application.dll поставляемый Normal file

Двоичный файл не отображается.

Двоичные данные
dependencies/GamesTest.ManagedXtf.2014.07.1.0.40811.0/lib/net45/Microsoft.Xbox.Xtf.ConsoleControl.dll поставляемый Normal file

Двоичный файл не отображается.

Двоичные данные
dependencies/GamesTest.ManagedXtf.2014.07.1.0.40811.0/lib/net45/Microsoft.Xbox.Xtf.ConsoleManager.dll поставляемый Normal file

Двоичный файл не отображается.

Двоичные данные
dependencies/GamesTest.ManagedXtf.2014.07.1.0.40811.0/lib/net45/Microsoft.Xbox.Xtf.DebugMonitor.dll поставляемый Normal file

Двоичный файл не отображается.

Двоичные данные
dependencies/GamesTest.ManagedXtf.2014.07.1.0.40811.0/lib/net45/Microsoft.Xbox.Xtf.FileIO.dll поставляемый Normal file

Двоичный файл не отображается.

Двоичные данные
dependencies/GamesTest.ManagedXtf.2014.07.1.0.40811.0/lib/net45/Microsoft.Xbox.Xtf.Input.dll поставляемый Normal file

Двоичный файл не отображается.

Двоичные данные
dependencies/GamesTest.ManagedXtf.2014.07.1.0.40811.0/lib/net45/Microsoft.Xbox.Xtf.RemoteRun.dll поставляемый Normal file

Двоичный файл не отображается.

Двоичные данные
dependencies/GamesTest.ManagedXtf.2014.07.1.0.40811.0/lib/net45/Microsoft.Xbox.Xtf.User.dll поставляемый Normal file

Двоичный файл не отображается.

Двоичные данные
dependencies/GamesTest.ManagedXtf.2014.07.1.0.40811.0/lib/net45/Microsoft.Xbox.Xtf.dll поставляемый Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,27 @@
//------------------------------------------------------------------------------
// <copyright file="AssemblyInfoCore.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyProduct("Microsoft.Xbox.Xtf")]
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif
// Version information for this assembly consists of the following four values:
//
// Major Version
// Minor Version
// 0 for local builds, an encoded date for team builds. (Year Mod 5)(2 digit Month)(2 digit Day)
// 0 for local builds, a per Major.Minor.Date revision for team builds.
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -0,0 +1,13 @@
Copyright 2014 Microsoft
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Просмотреть файл

@ -0,0 +1,101 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xbox.Xtf", "Microsoft.Xbox.Xtf\Microsoft.Xbox.Xtf.csproj", "{CD844E25-CD50-42CE-AA1B-7396D633D630}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xbox.Xtf.ConsoleControl", "Microsoft.Xbox.Xtf.ConsoleControl\Microsoft.Xbox.Xtf.ConsoleControl.csproj", "{D40650CC-8930-4F66-B7E2-12A328CA4070}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xbox.Xtf.Application", "Microsoft.Xbox.Xtf.Application\Microsoft.Xbox.Xtf.Application.csproj", "{54511C68-F811-4F7C-B7D2-CCBC53542328}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xbox.Xtf.ConsoleManager", "Microsoft.Xbox.Xtf.ConsoleManager\Microsoft.Xbox.Xtf.ConsoleManager.csproj", "{91EE26BB-006F-470D-8BDE-E83573832AF2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xbox.Xtf.FileIO", "Microsoft.Xbox.Xtf.FileIO\Microsoft.Xbox.Xtf.FileIO.csproj", "{79812B36-1FE0-4CB7-B0DE-74672D67279F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xbox.Xtf.DebugMonitor", "Microsoft.Xbox.Xtf.DebugMonitor\Microsoft.Xbox.Xtf.DebugMonitor.csproj", "{4D6D3F7E-2058-46EA-BA44-DEB06D860751}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xbox.Xtf.Input", "Microsoft.Xbox.Xtf.Input\Microsoft.Xbox.Xtf.Input.csproj", "{6DEF3A22-B038-4D02-82DE-4D569009D686}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xbox.Xtf.RemoteRun", "Microsoft.Xbox.Xtf.RemoteRun\Microsoft.Xbox.Xtf.RemoteRun.csproj", "{B452577E-086B-41C7-9B20-ED40681D62AE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xbox.Xtf.User", "Microsoft.Xbox.Xtf.User\Microsoft.Xbox.Xtf.User.csproj", "{859D543E-1563-430B-A434-0CADE9446660}"
EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 10
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = http://vstfpg03:8080/tfs/cts
SccLocalPath0 = .
SccProjectUniqueName1 = Microsoft.Xbox.Xtf.ConsoleControl\\Microsoft.Xbox.Xtf.ConsoleControl.csproj
SccProjectName1 = Microsoft.Xbox.Xtf.ConsoleControl
SccLocalPath1 = Microsoft.Xbox.Xtf.ConsoleControl
SccProjectUniqueName2 = Microsoft.Xbox.Xtf.Application\\Microsoft.Xbox.Xtf.Application.csproj
SccProjectName2 = Microsoft.Xbox.Xtf.Application
SccLocalPath2 = Microsoft.Xbox.Xtf.Application
SccProjectUniqueName3 = Microsoft.Xbox.Xtf.ConsoleManager\\Microsoft.Xbox.Xtf.ConsoleManager.csproj
SccProjectName3 = Microsoft.Xbox.Xtf.ConsoleManager
SccLocalPath3 = Microsoft.Xbox.Xtf.ConsoleManager
SccProjectUniqueName4 = Microsoft.Xbox.Xtf.FileIO\\Microsoft.Xbox.Xtf.FileIO.csproj
SccProjectName4 = Microsoft.Xbox.Xtf.FileIO
SccLocalPath4 = Microsoft.Xbox.Xtf.FileIO
SccProjectUniqueName5 = Microsoft.Xbox.Xtf.DebugMonitor\\Microsoft.Xbox.Xtf.DebugMonitor.csproj
SccProjectName5 = Microsoft.Xbox.Xtf.DebugMonitor
SccLocalPath5 = Microsoft.Xbox.Xtf.DebugMonitor
SccProjectUniqueName6 = Microsoft.Xbox.Xtf\\Microsoft.Xbox.Xtf.csproj
SccProjectName6 = Microsoft.Xbox.Xtf
SccLocalPath6 = Microsoft.Xbox.Xtf
SccProjectUniqueName7 = Microsoft.Xbox.Xtf.Input\\Microsoft.Xbox.Xtf.Input.csproj
SccProjectName7 = Microsoft.Xbox.Xtf.Input
SccLocalPath7 = Microsoft.Xbox.Xtf.Input
SccProjectUniqueName8 = Microsoft.Xbox.Xtf.RemoteRun\\Microsoft.Xbox.Xtf.RemoteRun.csproj
SccProjectName8 = Microsoft.Xbox.Xtf.RemoteRun
SccLocalPath8 = Microsoft.Xbox.Xtf.RemoteRun
SccProjectUniqueName9 = Microsoft.Xbox.Xtf.User\\Microsoft.Xbox.Xtf.User.csproj
SccProjectName9 = Microsoft.Xbox.Xtf.User
SccLocalPath9 = Microsoft.Xbox.Xtf.User
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD844E25-CD50-42CE-AA1B-7396D633D630}.Debug|x64.ActiveCfg = Debug|x64
{CD844E25-CD50-42CE-AA1B-7396D633D630}.Debug|x64.Build.0 = Debug|x64
{CD844E25-CD50-42CE-AA1B-7396D633D630}.Release|x64.ActiveCfg = Release|x64
{CD844E25-CD50-42CE-AA1B-7396D633D630}.Release|x64.Build.0 = Release|x64
{D40650CC-8930-4F66-B7E2-12A328CA4070}.Debug|x64.ActiveCfg = Debug|x64
{D40650CC-8930-4F66-B7E2-12A328CA4070}.Debug|x64.Build.0 = Debug|x64
{D40650CC-8930-4F66-B7E2-12A328CA4070}.Release|x64.ActiveCfg = Release|x64
{D40650CC-8930-4F66-B7E2-12A328CA4070}.Release|x64.Build.0 = Release|x64
{54511C68-F811-4F7C-B7D2-CCBC53542328}.Debug|x64.ActiveCfg = Debug|x64
{54511C68-F811-4F7C-B7D2-CCBC53542328}.Debug|x64.Build.0 = Debug|x64
{54511C68-F811-4F7C-B7D2-CCBC53542328}.Release|x64.ActiveCfg = Release|x64
{54511C68-F811-4F7C-B7D2-CCBC53542328}.Release|x64.Build.0 = Release|x64
{91EE26BB-006F-470D-8BDE-E83573832AF2}.Debug|x64.ActiveCfg = Debug|x64
{91EE26BB-006F-470D-8BDE-E83573832AF2}.Debug|x64.Build.0 = Debug|x64
{91EE26BB-006F-470D-8BDE-E83573832AF2}.Release|x64.ActiveCfg = Release|x64
{91EE26BB-006F-470D-8BDE-E83573832AF2}.Release|x64.Build.0 = Release|x64
{79812B36-1FE0-4CB7-B0DE-74672D67279F}.Debug|x64.ActiveCfg = Debug|x64
{79812B36-1FE0-4CB7-B0DE-74672D67279F}.Debug|x64.Build.0 = Debug|x64
{79812B36-1FE0-4CB7-B0DE-74672D67279F}.Release|x64.ActiveCfg = Release|x64
{79812B36-1FE0-4CB7-B0DE-74672D67279F}.Release|x64.Build.0 = Release|x64
{4D6D3F7E-2058-46EA-BA44-DEB06D860751}.Debug|x64.ActiveCfg = Debug|x64
{4D6D3F7E-2058-46EA-BA44-DEB06D860751}.Debug|x64.Build.0 = Debug|x64
{4D6D3F7E-2058-46EA-BA44-DEB06D860751}.Release|x64.ActiveCfg = Release|x64
{4D6D3F7E-2058-46EA-BA44-DEB06D860751}.Release|x64.Build.0 = Release|x64
{6DEF3A22-B038-4D02-82DE-4D569009D686}.Debug|x64.ActiveCfg = Debug|x64
{6DEF3A22-B038-4D02-82DE-4D569009D686}.Debug|x64.Build.0 = Debug|x64
{6DEF3A22-B038-4D02-82DE-4D569009D686}.Release|x64.ActiveCfg = Release|x64
{6DEF3A22-B038-4D02-82DE-4D569009D686}.Release|x64.Build.0 = Release|x64
{B452577E-086B-41C7-9B20-ED40681D62AE}.Debug|x64.ActiveCfg = Debug|x64
{B452577E-086B-41C7-9B20-ED40681D62AE}.Debug|x64.Build.0 = Debug|x64
{B452577E-086B-41C7-9B20-ED40681D62AE}.Release|x64.ActiveCfg = Release|x64
{B452577E-086B-41C7-9B20-ED40681D62AE}.Release|x64.Build.0 = Release|x64
{859D543E-1563-430B-A434-0CADE9446660}.Debug|x64.ActiveCfg = Debug|x64
{859D543E-1563-430B-A434-0CADE9446660}.Debug|x64.Build.0 = Debug|x64
{859D543E-1563-430B-A434-0CADE9446660}.Release|x64.ActiveCfg = Release|x64
{859D543E-1563-430B-A434-0CADE9446660}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,248 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Text;
using Microsoft.Xbox.XTF;
using Microsoft.Win32.SafeHandles;
namespace Microsoft.Xbox.XTF.Application
{
public sealed partial class ApplicationClient : IDisposable
{
private const string UnsnapCommand = "close";
// Use method LazyClient() instead of this member.
private IXtfApplicationClient lazyClient;
private bool disposed = false;
private Guid mediumId;
private string address;
public ApplicationClient(Guid mediumId, string address)
{
this.lazyClient = null;
this.mediumId = mediumId;
this.address = address;
}
public ApplicationClient(Guid mediumId)
: this(mediumId, null)
{
}
public ApplicationClient(string address)
: this(Guid.Empty, address)
{
}
public ApplicationClient()
: this(Guid.Empty, null)
{
}
~ApplicationClient()
{
this.Dispose(false);
}
public string Address
{
get
{
return this.address;
}
}
public string GetInstalled()
{
string toReturn = String.Empty;
toReturn = LazyClient().GetInstalled();
return toReturn;
}
/// <summary>
/// Deploy an application from a PC to an Xbox.
/// </summary>
/// <param name="deployFilePath">The path to the directory that contains the title to be deployed.</param>
/// <param name="removeExtraFiles">True to remove files that exist on the Xbox that are not in the directory given by the <paramref name="deployFilePath"/>.</param>
/// <param name="progressCallback">A callback object whose methods will be invoked when progress is made during the deployment process.</param>
/// <param name="result">The result of the deployment. Zero indicates success, all else are failure.</param>
/// <param name="packageFullName">The packageFullName of the package that has been deployed.</param>
/// <returns>The AUMID of the newly deployed package.</returns>
public string Deploy(string deployFilePath, bool removeExtraFiles, DeploymentProgress progressCallback, out bool canceled, out int result, out string packageFullName)
{
string toReturn = String.Empty;
int iCanceled = 0;
toReturn = LazyClient().Deploy(deployFilePath, removeExtraFiles ? 1 : 0, progressCallback, out iCanceled, out result, out packageFullName);
canceled = (iCanceled != 0);
return toReturn;
}
public string Deploy(string deployFilePath, bool removeExtraFiles, IXtfDeployCallback callback, out bool canceled, out int result, out string packageFullName)
{
string toReturn = String.Empty;
int iCanceled = 0;
toReturn = LazyClient().Deploy(deployFilePath, removeExtraFiles ? 1 : 0, callback, out iCanceled, out result, out packageFullName);
canceled = (iCanceled != 0);
return toReturn;
}
public void Launch(string applicationUserModelId)
{
LazyClient().Launch(applicationUserModelId);
}
public uint QueryExecutionState(string packageMoniker)
{
return LazyClient().QueryExecutionState(packageMoniker);
}
public void Suspend(string packageMoniker)
{
LazyClient().Suspend(packageMoniker, 1);
}
public void Suspend(string packageMoniker, int fAsDebugger)
{
LazyClient().Suspend(packageMoniker, fAsDebugger);
}
public void Resume(string packageMoniker)
{
LazyClient().Resume(packageMoniker);
}
public void Constrain(string packageMoniker)
{
LazyClient().Constrain(packageMoniker);
}
public void Unconstrain(string packageMoniker)
{
LazyClient().Unconstrain(packageMoniker);
}
public void Terminate(string packageMoniker)
{
LazyClient().Terminate(packageMoniker);
}
public void Uninstall(string packageMoniker)
{
LazyClient().Uninstall(packageMoniker);
}
public void Snap(string applicationUserModelId)
{
LazyClient().Snap(applicationUserModelId);
}
public void Unsnap()
{
LazyClient().Snap(UnsnapCommand);
}
#region IDisposable members
public void Dispose()
{
this.Dispose(true);
//
// Avoid cleaning up twice. Calling Dispose(true)
// implies that managed objects will be cleaned up as well
// as unmanaged objects so the garbage collector will
// have no work to do when finalizing this object.
//
GC.SuppressFinalize(this);
}
#endregion
#region Private members
private void Dispose(bool disposing)
{
if (!this.disposed)
{
if (null != this.lazyClient)
{
Extensions.ReleaseComObject(ref this.lazyClient);
}
//
// Since the garbage collector's Finalize() runs on
// a background thread, managed objects are not safe
// to reference. Only clean up managed objects if this
// is being explicitly disposed.
//
if (disposing)
{
this.address = null;
}
this.disposed = true;
}
}
internal IXtfApplicationClient LazyClient()
{
if (disposed)
{
throw new ObjectDisposedException("Internal resource");
}
if(this.lazyClient == null)
{
System.Guid riid = typeof(IXtfApplicationClient).GUID;
IntPtr ppvObj;
if(API.XtfCreateApplicationClient(this.address, ref riid, out ppvObj) < 0)
{
throw new XtfApplicationNoConnectionException("Unable to connect to " + this.address);
}
this.lazyClient = Marshal.GetObjectForIUnknown(ppvObj) as IXtfApplicationClient;
Marshal.Release(ppvObj);
}
return this.lazyClient;
}
#endregion
}
public sealed class XtfApplicationNoConnectionException : System.Exception
{
public XtfApplicationNoConnectionException() :
base()
{
}
public XtfApplicationNoConnectionException(string message) :
base(message)
{
}
private XtfApplicationNoConnectionException(SerializationInfo info, StreamingContext context) :
base(info, context)
{
}
public XtfApplicationNoConnectionException(string innerError, Exception innerException) :
base(innerError, innerException)
{
}
}
}

Просмотреть файл

@ -0,0 +1,320 @@
//------------------------------------------------------------------------------
// <copyright file="DeploymentProgress.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Xbox.XTF.Application
{
using System;
/// <summary>
/// A simple class that implements the IXtfDeployCallback interface so that users
/// of this class don't need to have a reference to the Xtf Primary Interop Assembly.
/// </summary>
public class DeploymentProgress : IXtfDeployCallback
{
private Action<ChangeEvaluationCallbackArgs> changeEvaluationCallback;
private Action<ErrorCallbackArgs> errorCallback;
private Action<ExtraFileDetectedCallbackArgs> extraFileDetectedCallback;
private Action<ExtraFileRemovedCallbackArgs> extraFileRemovedCallback;
private Action<FileProgressCallbackArgs> fileProgressCallback;
private Action initializedCallback;
private Action<MetricsCallbackArgs> metricsCallback;
/// <summary>
/// Initializes a new instance of the DeploymentProgress class.
/// </summary>
/// <param name="changeEvaluationCallback">This callback invoked when XTF is evaluating which files need to be transferred or deleted.</param>
/// <param name="errorCallback">This callback invoked when deployment has encountered an error.</param>
/// <param name="extraFileDetectedCallback">This callback invoked when an extra file has been detected.</param>
/// <param name="extraFileRemovedCallback">This callback invoked to report that an extra file on the console has been removed.</param>
/// <param name="fileProgressCallback">This callback invoked to report progress in deploying a file to the console.</param>
/// <param name="initializedCallback">This callback invoked when deploy is beginning.</param>
/// <param name="metricsCallback">This callback invoked when deployment metrics are reported.</param>
public DeploymentProgress(
Action<ChangeEvaluationCallbackArgs> changeEvaluationCallback,
Action<ErrorCallbackArgs> errorCallback,
Action<ExtraFileDetectedCallbackArgs> extraFileDetectedCallback,
Action<ExtraFileRemovedCallbackArgs> extraFileRemovedCallback,
Action<FileProgressCallbackArgs> fileProgressCallback,
Action initializedCallback,
Action<MetricsCallbackArgs> metricsCallback)
{
this.changeEvaluationCallback = changeEvaluationCallback;
this.errorCallback = errorCallback;
this.extraFileDetectedCallback = extraFileDetectedCallback;
this.extraFileRemovedCallback = extraFileRemovedCallback;
this.fileProgressCallback = fileProgressCallback;
this.initializedCallback = initializedCallback;
this.metricsCallback = metricsCallback;
}
/// <summary>
/// Callback invoked when XTF is evaluating which files need to be transferred or deleted.
/// </summary>
/// <remarks>
/// This callback is invoked when the deployment system is evaluating which files need to be deployed to the console or deleted
/// from the console. You can use this callback to update a progress indicator. Note that if you are deploying a game or app
/// that has not been registered on the target console, then all files must be deployed, and this callback will not be invoked
/// at all.
/// </remarks>
/// <param name="ullFilesProcessed">Number of files that have been evaluated so far.</param>
/// <param name="ullTotalFiles">Total number of files to be evaluated.</param>
public void OnDeployChangeEvaluation(ulong ullFilesProcessed, ulong ullTotalFiles)
{
if (this.changeEvaluationCallback != null)
{
this.changeEvaluationCallback(new ChangeEvaluationCallbackArgs(ullFilesProcessed, ullTotalFiles));
}
}
/// <summary>
/// Callback invoked when deployment has encountered an error.
/// </summary>
/// <param name="hrError">An error HRESULT describing the error encountered in deployment.</param>
/// <remarks><c>OnDeployError</c> is not used by the current implementation, but is reserved for future use.</remarks>
public void OnDeployError(int hrError)
{
if (this.errorCallback != null)
{
this.errorCallback(new ErrorCallbackArgs(hrError));
}
}
/// <summary>
/// Callback invoked when an extra file has been detected.
/// </summary>
/// <param name="pszFilePath">The absolute path to the extra file, on the console.</param>
/// <remarks>
/// Called once for every file found on the console that is not on the deploying PC.
/// </remarks>
public void OnDeployExtraFileDetected(string pszFilePath)
{
if (this.extraFileDetectedCallback != null)
{
this.extraFileDetectedCallback(new ExtraFileDetectedCallbackArgs(pszFilePath));
}
}
/// <summary>
/// Callback invoked to report that an extra file on the console has been removed.
/// </summary>
/// <param name="pszFilePath">Path to the extra file that was removed.</param>
/// <remarks>
/// If the fRemoveExtraFiles parameter to Deploy was set to TRUE, this callback is invoked
/// when a file is deleted from the console.
/// </remarks>
public void OnDeployExtraFileRemoved(string pszFilePath)
{
if (this.extraFileRemovedCallback != null)
{
this.extraFileRemovedCallback(new ExtraFileRemovedCallbackArgs(pszFilePath));
}
}
/// <summary>
/// Callback invoked to report progress in deploying a file to the console
/// </summary>
/// <param name="pszFilePath">File path of the file.</param>
/// <param name="ullBytesTransferred">Bytes transferred so far.</param>
/// <param name="ullFileSize">Total size of the file being transferred, in bytes.</param>
/// <remarks>
/// <para>
/// This callback is invoked every time that a buffer block is successfully transferred for a file. Note
/// that the transfer process uses multiple threads, and your code must ensure that it is correlating
/// progress messages by pszFilePath and protecting against the usual multi-threading issues.
/// </para>
/// <para>
/// This callback is always invoked once at the start of the deployment, and once at the end of deployment,
/// so that if a zero-length file is being deployed, both invocations will report that zero bytes out of
/// zero bytes have been transferred.
/// </para>
/// </remarks>
public void OnDeployFileProgress(string pszFilePath, ulong ullBytesTransferred, ulong ullFileSize)
{
if (this.fileProgressCallback != null)
{
this.fileProgressCallback(new FileProgressCallbackArgs(pszFilePath, ullBytesTransferred, ullFileSize));
}
}
/// <summary>
/// Callback invoked when deploy is beginning.
/// </summary>
/// <remarks>
/// This callback is invoked to indicate that the deployment system has successfully initialized and is beginning
/// the deployment process. If your code needs to store a starting time to measure deployment time, or to
/// initialize a progress dialog, this is a good place to do it.
/// </remarks>
public void OnDeployInitialized()
{
if (this.initializedCallback != null)
{
this.initializedCallback();
}
}
/// <summary>
/// Callback invoked when deployment metrics are reported.
/// </summary>
/// <param name="ullTotalFiles">Number of files that will be deployed.</param>
/// <param name="ullTotalBytes">Number of bytes that will be transferred during deployment.</param>
/// <remarks>
/// This callback is invoked once at the end of the evaluation process, to report how many files will be deployed
/// to the console and the total number of bytes to be transferred.
/// </remarks>
public void OnDeployMetrics(ulong ullTotalFiles, ulong ullTotalBytes)
{
if (this.metricsCallback != null)
{
this.metricsCallback(new MetricsCallbackArgs(ullTotalFiles, ullTotalBytes));
}
}
}
/// <summary>
/// A class that representing callback arguments for deployment change evaluations.
/// </summary>
public class ChangeEvaluationCallbackArgs
{
/// <summary>
/// Initializes a new instance of the ChangeEvaluationCallbackArgs class.
/// </summary>
/// <param name="filesProcessed">Number of files that have been evaluated so far.</param>
/// <param name="totalFiles">Total number of files to be evaluated.</param>
public ChangeEvaluationCallbackArgs(ulong filesProcessed, ulong totalFiles)
{
this.FilesProcessed = filesProcessed;
this.TotalFiles = totalFiles;
}
/// <summary>
/// Gets the number of files that have been evaluated so far.
/// </summary>
public ulong FilesProcessed { get; private set; }
/// <summary>
/// Gets the total number of files to be evaluated.
/// </summary>
public ulong TotalFiles { get; private set; }
}
/// <summary>
/// A class that representing callback arguments for deployment errors.
/// </summary>
public class ErrorCallbackArgs
{
/// <summary>
/// Initializes a new instance of the DeploymentProgress class.
/// </summary>
/// <param name="error">An error HRESULT describing the error encountered in deployment.</param>
public ErrorCallbackArgs(int error)
{
this.Error = error;
}
/// <summary>
/// Gets an error HRESULT describing the error encountered in deployment.
/// </summary>
public int Error { get; private set; }
}
/// <summary>
/// A class that representing callback arguments for deployment detection of extra files.
/// </summary>
public class ExtraFileDetectedCallbackArgs
{
/// <summary>
/// Initializes a new instance of the DeploymentProgress class.
/// </summary>
/// <param name="filePath">The absolute path to the extra file, on the console.</param>
public ExtraFileDetectedCallbackArgs(string filePath)
{
this.FilePath = filePath;
}
/// <summary>
/// Gets the absolute path to the extra file, on the console.
/// </summary>
public string FilePath { get; private set; }
}
/// <summary>
/// A class that representing callback arguments for deployment removal of extra files.
/// </summary>
public class ExtraFileRemovedCallbackArgs
{
/// <summary>
/// Initializes a new instance of the DeploymentProgress class.
/// </summary>
/// <param name="filePath">Path to the extra file that was removed.</param>
public ExtraFileRemovedCallbackArgs(string filePath)
{
this.FilePath = filePath;
}
/// <summary>
/// Gets the path to the extra file that was removed.
/// </summary>
public string FilePath { get; private set; }
}
/// <summary>
/// A class that representing callback arguments for deployment file progress.
/// </summary>
public class FileProgressCallbackArgs
{
/// <summary>
/// Initializes a new instance of the DeploymentProgress class.
/// </summary>
/// <param name="filePath">File path of the file.</param>
/// <param name="bytesTransferred">Bytes transferred so far.</param>
/// <param name="fileSize">Total size of the file being transferred, in bytes.</param>
public FileProgressCallbackArgs(string filePath, ulong bytesTransferred, ulong fileSize)
{
this.FilePath = filePath;
this.BytesTransferred = bytesTransferred;
this.FileSize = fileSize;
}
/// <summary>
/// Gets the file path of the file.
/// </summary>
public string FilePath { get; private set; }
/// <summary>
/// Gets the bytes transferred so far.
/// </summary>
public ulong BytesTransferred { get; private set; }
/// <summary>
/// Gets the total size of the file being transferred, in bytes.
/// </summary>
public ulong FileSize { get; private set; }
}
/// <summary>
/// A class that representing callback arguments for deployment metrics.
/// </summary>
public class MetricsCallbackArgs
{
/// <summary>
/// Initializes a new instance of the DeploymentProgress class.
/// </summary>
/// <param name="totalFiles">Number of files that will be deployed.</param>
/// <param name="totalBytes">Number of bytes that will be transferred during deployment.</param>
public MetricsCallbackArgs(ulong totalFiles, ulong totalBytes)
{
this.TotalFiles = totalFiles;
this.TotalBytes = totalBytes;
}
/// <summary>
/// Gets the number of files that will be deployed.
/// </summary>
public ulong TotalFiles { get; private set; }
/// <summary>
/// Gets the number of bytes that will be transferred during deployment.
/// </summary>
public ulong TotalBytes { get; private set; }
}
}

Просмотреть файл

@ -0,0 +1,25 @@
using System;
using System.Threading;
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
namespace Microsoft.Xbox.XTF
{
//
// TODO TFS 769989
//
// Make Microsoft.Xbox.XTF.dll public and remove redundant hresult.cs and extension.cs from other assemblies
//
internal static partial class Extensions
{
public static void ReleaseComObject<T>(ref T obj) where T : class
{
if(null != obj)
{
Marshal.ReleaseComObject(obj);
obj = null;
}
}
}
}

Просмотреть файл

@ -0,0 +1,23 @@
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Xbox.XTF
{
//
// TODO TFS 769989
//
// Make Microsoft.Xbox.XTF.dll public and remove redundant hresult.cs and extension.cs from other assemblies
//
internal static class HRESULT
{
public const int S_OK = 0;
public const int S_FALSE = 1;
public const int E_PENDING = -2147483638;
public const int E_NOTIMPL = -2147467262;
public const int E_FAIL = -2147467259;
public const int E_ABORT = -2147467260;
public const int XTF_E_NOT_A_RESPONSE = -1;
}
}

Просмотреть файл

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{54511C68-F811-4F7C-B7D2-CCBC53542328}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Xbox.Xtf.Application</RootNamespace>
<AssemblyName>Microsoft.Xbox.Xtf.Application</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\dependencies\CodeAnalysis\Level3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\dependencies\CodeAnalysis\Level3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Xbox.Xtf.Interop">
<HintPath>$(DurangoXDK)\bin\Microsoft.Xbox.Xtf.Interop.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\AssemblyInfoCore.cs">
<Link>Properties\AssemblyInfoCore.cs</Link>
</Compile>
<Compile Include="Client.cs" />
<Compile Include="DeploymentProgress.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="HRESULT.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>

Просмотреть файл

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Xbox.XTF;
namespace Microsoft.Xbox.XTF.Application
{
public static class API
{
// IXtfApplicationClient
[DllImport(@"XtfApplication.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, EntryPoint = "XtfCreateApplicationClient", ExactSpelling = true, PreserveSig = true)]
public static extern int XtfCreateApplicationClient(string address,
ref System.Guid riid, out System.IntPtr ppvObject);
}
}

Просмотреть файл

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
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("Microsoft.Xbox.Xtf.Application")]
[assembly: AssemblyDescription("Microsoft.Xbox.Xtf.Application")]
[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)]
[assembly: CLSCompliant(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("cc1efea4-9c90-4ab8-a9e5-18fcc5aa7031")]

Просмотреть файл

@ -0,0 +1,51 @@
//------------------------------------------------------------------------------
// <copyright file="Client.CTS.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Xbox.XTF.Console
{
using System;
partial class ConsoleControlClient
{
public string GetConfigValue(string key)
{
if (this.disposed)
{
throw new ObjectDisposedException("Internal resource");
}
return this.BaseObject.GetConfigValue(key);
}
public void SetConfigValue(string key, string value)
{
if (this.disposed)
{
throw new ObjectDisposedException("Internal resource");
}
this.BaseObject.SetConfigValue(key, value);
}
/// <summary>
/// Captures a screenshot on the specified console
/// </summary>
/// <param name="address">The address of the console to grab a screenshot on.</param>
/// <returns>
/// A <see cref="System.IntPtr"/> pointing to an HBITMAP containing the screenshot.
/// When you have finished using this bitmap, use DeleteObject to free the resources
/// associated with the HBITMAP.
/// </returns>
public static IntPtr CaptureScreenshot(string address)
{
IntPtr phBitmap = IntPtr.Zero;
HRESULT.CHK(NativeMethods.XtfCaptureScreenshot(address, out phBitmap));
return phBitmap;
}
}
}

Просмотреть файл

@ -0,0 +1,211 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Win32.SafeHandles;
using Microsoft.Xbox.XTF;
namespace Microsoft.Xbox.XTF.Console
{
[Flags]
public enum ShutdownConsoleFlags : uint
{
None = 0x00000000,
Reboot = 0x00000001
}
public class ProcessInfo
{
internal XTFPROCESSINFO _ProcessInfo;
public ProcessInfo(uint processId, string imageFileName)
{
_ProcessInfo = new XTFPROCESSINFO();
this.ProcessId = processId;
this.ImageFileName = imageFileName;
}
public uint ProcessId
{
get { return _ProcessInfo.dwProcessId; }
set { _ProcessInfo.dwProcessId = value; }
}
public string ImageFileName
{
get { return _ProcessInfo.pszImageFileName; }
set { _ProcessInfo.pszImageFileName = value; }
}
}
public class RunningProcessEventArgs : EventArgs
{
public ProcessInfo ProcessInfo;
internal RunningProcessEventArgs(XTFPROCESSINFO xpi)
{
this.ProcessInfo = new ProcessInfo(xpi.dwProcessId, xpi.pszImageFileName);
}
}
public delegate void RunningProcessEventHandler(object sender, RunningProcessEventArgs e);
internal class RunningProcessCallback : IXtfRunningProcessCallback
{
ConsoleControlClient _Client;
RunningProcessEventHandler _EventHandler;
public static RunningProcessCallback Create(ConsoleControlClient client, RunningProcessEventHandler eventHandler)
{
if(null == eventHandler)
{
return null;
}
return new RunningProcessCallback(client, eventHandler);
}
RunningProcessCallback(ConsoleControlClient client, RunningProcessEventHandler eventHandler)
{
_Client = client;
_EventHandler = eventHandler;
}
void IXtfRunningProcessCallback.OnFoundProcess(ref XTFPROCESSINFO xpi)
{
_EventHandler(_Client, new RunningProcessEventArgs(xpi));
}
}
public sealed partial class ConsoleControlClient : IDisposable
{
internal IXtfConsoleControlClient BaseObject;
private bool disposed = false;
public ConsoleControlClient(string address)
{
System.Guid riid = typeof(IXtfConsoleControlClient).GUID;
IntPtr ppvObj;
HRESULT.CHK(NativeMethods.XtfCreateConsoleControlClient(address, ref riid, out ppvObj));
this.BaseObject = Marshal.GetObjectForIUnknown(ppvObj) as IXtfConsoleControlClient;
Marshal.Release(ppvObj);
}
public ConsoleControlClient()
{
System.Guid riid = typeof(IXtfConsoleControlClient).GUID;
IntPtr ppvObj;
HRESULT.CHK(NativeMethods.XtfCreateConsoleControlClient(null, ref riid, out ppvObj));
this.BaseObject = Marshal.GetObjectForIUnknown(ppvObj) as IXtfConsoleControlClient;
Marshal.Release(ppvObj);
}
~ConsoleControlClient()
{
this.Dispose(false);
}
public DateTime SystemTime
{
get
{
if (this.disposed)
{
throw new ObjectDisposedException("Internal resource");
}
XTFSYSTEMTIME systemTime = new XTFSYSTEMTIME();
BaseObject.GetSystemTime(out systemTime);
try
{
return new DateTime(
systemTime.wYear,
systemTime.wMonth,
systemTime.wDay,
systemTime.wHour,
systemTime.wMinute,
systemTime.wSecond,
systemTime.wMilliseconds);
}
catch
{
// Swallow the exception and return the defualt value if
// the system does not respond with valid data.
return default(DateTime);
}
}
}
public void ShutdownConsole(ShutdownConsoleFlags flags)
{
if (this.disposed)
{
throw new ObjectDisposedException("Internal resource");
}
BaseObject.ShutdownConsole((uint)flags);
}
public bool UpdatesPending
{
get
{
if (this.disposed)
{
throw new ObjectDisposedException("Internal resource");
}
return 0 != BaseObject.UpdatesPending();
}
}
public void GetRunningProcesses(RunningProcessEventHandler eventHandler)
{
if (this.disposed)
{
throw new ObjectDisposedException("Internal resource");
}
BaseObject.GetRunningProcesses(RunningProcessCallback.Create(this, eventHandler));
}
public void Dispose()
{
this.Dispose(true);
//
// Avoid cleaning up twice. Calling Dispose(true)
// implies that managed objects will be cleaned up as well
// as unmanaged objects so the garbage collector will
// have no work to do when finalizing this object.
//
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!this.disposed)
{
Extensions.ReleaseComObject(ref BaseObject);
//
// Since the garbage collector's Finalize() runs on
// a background thread, managed objects are not safe
// to reference. Only clean up managed objects if this
// is being explicitly disposed.
//
// if (disposing)
// {
// // ... Clean up managed objects
// }
//
this.disposed = true;
}
}
}
}

Просмотреть файл

@ -0,0 +1,25 @@
using System;
using System.Threading;
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
namespace Microsoft.Xbox.XTF
{
//
// TODO TFS 769989
//
// Make Microsoft.Xbox.XTF.dll public and remove redundant hresult.cs and extension.cs from other assemblies
//
internal static partial class Extensions
{
public static void ReleaseComObject<T>(ref T obj) where T : class
{
if(null != obj)
{
Marshal.ReleaseComObject(obj);
obj = null;
}
}
}
}

Просмотреть файл

@ -0,0 +1,36 @@
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Xbox.XTF
{
//
// TODO TFS 769989
//
// Make Microsoft.Xbox.XTF.dll public and remove redundant hresult.cs and extension.cs from other assemblies
//
internal static class HRESULT
{
public const int S_OK = 0;
public const int S_FALSE = 1;
public const int E_PENDING = -2147483638;
public const int E_NOTIMPL = -2147467262;
public const int E_FAIL = -2147467259;
public const int E_ABORT = -2147467260;
public const int XTF_E_NOT_A_RESPONSE = -1;
public static bool FAILED(int hr)
{
return hr < 0;
}
public static void CHK(int hr)
{
if(FAILED(hr))
{
throw new COMException(String.Empty, hr);
}
}
}
}

Просмотреть файл

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{D40650CC-8930-4F66-B7E2-12A328CA4070}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Xbox.Xtf.Console</RootNamespace>
<AssemblyName>Microsoft.Xbox.Xtf.ConsoleControl</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\dependencies\CodeAnalysis\Level3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\dependencies\CodeAnalysis\Level3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Xbox.Xtf.Interop">
<HintPath>$(DurangoXDK)\bin\Microsoft.Xbox.Xtf.Interop.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\AssemblyInfoCore.cs">
<Link>Properties\AssemblyInfoCore.cs</Link>
</Compile>
<Compile Include="Client.cs" />
<Compile Include="Client.CTS.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="HRESULT.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>

Просмотреть файл

@ -0,0 +1,29 @@
using System;
using System.Runtime.InteropServices;
using Microsoft.Xbox.XTF;
namespace Microsoft.Xbox.XTF.Console
{
internal static partial class NativeMethods
{
// IXtfConsoleControlClient
[DllImport(@"XtfConsoleControl.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = true)]
public static extern int XtfCreateConsoleControlClient(string pszAddress,
ref System.Guid riid, out System.IntPtr ppvObject);
[DllImport(@"XtfConsoleControl.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, EntryPoint = "XtfCaptureScreenshot", ExactSpelling = true, PreserveSig = true)]
public static extern int XtfCaptureScreenshot(string address, out System.IntPtr phBitmap);
/// <summary>
/// Deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object. After the object is deleted, the specified handle is no longer valid.
/// </summary>
/// <param name="hObject">A handle to a logical pen, brush, font, bitmap, region, or palette.</param>
/// <returns>
/// If the function succeeds, the return value is <c>true</c>. If the specified handle is not valid or is currently selected into a DC, the return value is <c>false</c>.
/// </returns>
[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteObject([In] IntPtr hObject);
}
}

Просмотреть файл

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
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("Microsoft.Xbox.Xtf.ConsoleControl")]
[assembly: AssemblyDescription("Microsoft.Xbox.Xtf.ConsoleControl")]
[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)]
[assembly: CLSCompliant(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1ecf4fde-56c5-4c5d-90bb-37f18a2acb2f")]

Просмотреть файл

@ -0,0 +1,189 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Microsoft.Xbox.XTF;
namespace Microsoft.Xbox.XTF.Console
{
[Flags]
public enum AddFlags : uint
{
None = 0x00000000,
SetDefault = 0x00000001
}
internal class ConsoleEnumeratorCallback : IXtfEnumerateConsolesCallback
{
internal List<XtfConsole> consoles;
internal ConsoleEnumeratorCallback()
{
this.consoles = new List<XtfConsole>();
}
public void OnConsoleFound(ref _XTFCONSOLEDATA consoleData)
{
this.consoles.Add(new XtfConsole(consoleData));
}
}
public class ConsoleManager : IDisposable
{
internal IXtfConsoleManager consoleManager;
internal ConsoleManagerCallback callback;
private bool disposed = false;
public event EventHandler<ConsoleEventArgs> ConsoleAdded;
public event EventHandler<ConsoleEventArgs> ConsoleRemoved;
public event EventHandler<ConsoleEventArgs> DefaultConsoleChanged;
public ConsoleManager()
{
this.callback = new ConsoleManagerCallback(this);
this.callback.ConsoleAdded += this.OnConsoleAdded;
this.callback.ConsoleRemoved += this.OnConsoleRemoved;
this.callback.DefaultConsoleChanged += this.OnDefaultConsoleChanged;
System.Guid riid = typeof(IXtfConsoleManager).GUID;
IntPtr ppvObj;
HRESULT.CHK(NativeMethods.XtfCreateConsoleManager(this.callback, ref riid, out ppvObj));
this.consoleManager = null;
this.consoleManager = Marshal.GetObjectForIUnknown(ppvObj) as IXtfConsoleManager;
Marshal.Release(ppvObj);
}
~ConsoleManager()
{
this.Dispose(false);
}
public static string GetDefaultAddress()
{
ConsoleManager cm = new ConsoleManager();
XtfConsole c = cm.GetDefaultConsole();
return c.Address;
}
public void AddConsole(string alias, string address, AddFlags flags)
{
this.consoleManager.AddConsole(alias, address, (uint)flags);
}
public void AddConsole(string alias, string address)
{
this.consoleManager.AddConsole(alias, address, (uint)AddFlags.None);
}
public void RemoveConsole(string alias)
{
this.consoleManager.RemoveConsole(alias);
}
public XtfConsole GetConsole(string alias)
{
XtfConsole console = null;
try
{
console = new XtfConsole(this.consoleManager.GetConsole(alias));
}
catch (COMException)
{
console = null;
}
return console;
}
public List<XtfConsole> GetConsoles()
{
ConsoleEnumeratorCallback callback = new ConsoleEnumeratorCallback();
consoleManager.EnumerateConsoles(callback);
return callback.consoles;
}
public XtfConsole GetDefaultConsole()
{
XtfConsole console = null;
try
{
return new XtfConsole(this.consoleManager.GetDefaultConsole());
}
catch (COMException)
{
// If an exception is thrown the default console is not set so return null.
console = null;
}
return console;
}
public void SetDefaultConsole(string alias)
{
this.consoleManager.SetDefaultConsole(alias);
}
public void Dispose()
{
this.Dispose(true);
//
// Avoid cleaning up twice. Calling Dispose(true)
// implies that managed objects will be cleaned up as well
// as unmanaged objects so the garbage collector will
// have no work to do when finalizing this object.
//
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!this.disposed)
{
if (null != this.consoleManager)
{
Marshal.ReleaseComObject(this.consoleManager);
this.consoleManager = null;
}
//
// Since the garbage collector's Finalize() runs on
// a background thread, managed objects are not safe
// to reference. Only clean up managed objects if this
// is being explicitly disposed.
//
// if (disposing)
// {
// // ... Clean up managed objects
// }
//
this.disposed = true;
}
}
internal void OnConsoleAdded(object sender, ConsoleEventArgs e)
{
EventHandler<ConsoleEventArgs> handler = this.ConsoleAdded;
if (handler != null)
{
handler(this, e);
}
}
internal void OnConsoleRemoved(object sender, ConsoleEventArgs e)
{
EventHandler<ConsoleEventArgs> handler = this.ConsoleRemoved;
if (null != handler)
{
handler(this, e);
}
}
internal void OnDefaultConsoleChanged(object sender, ConsoleEventArgs e)
{
EventHandler<ConsoleEventArgs> handler = this.DefaultConsoleChanged;
if (null != handler)
{
handler(this, e);
}
}
}
}

Просмотреть файл

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.Xbox.XTF.Console
{
public class ConsoleEventArgs : EventArgs
{
public readonly XtfConsole console;
public ConsoleEventArgs(XtfConsole console)
{
this.console = console;
}
}
internal class ConsoleManagerCallback : IXtfConsoleManagerCallback
{
private object sender;
public event EventHandler<ConsoleEventArgs> ConsoleAdded;
public event EventHandler<ConsoleEventArgs> ConsoleRemoved;
public event EventHandler<ConsoleEventArgs> DefaultConsoleChanged;
public ConsoleManagerCallback(object sender)
{
this.sender = sender;
}
void IXtfConsoleManagerCallback.OnAddConsole(ref _XTFCONSOLEDATA consoleData)
{
EventHandler<ConsoleEventArgs> handler = ConsoleAdded;
if(null != handler)
{
handler(this.sender, new ConsoleEventArgs(new XtfConsole(consoleData)));
}
}
void IXtfConsoleManagerCallback.OnRemoveConsole(ref _XTFCONSOLEDATA consoleData)
{
EventHandler<ConsoleEventArgs> handler = ConsoleRemoved;
if (null != handler)
{
handler(this.sender, new ConsoleEventArgs(new XtfConsole(consoleData)));
}
}
void IXtfConsoleManagerCallback.OnChangedDefaultConsole(ref _XTFCONSOLEDATA consoleData)
{
EventHandler<ConsoleEventArgs> handler = DefaultConsoleChanged;
if (null != handler)
{
handler(this.sender, new ConsoleEventArgs(null == consoleData.bstrAlias ? null : new XtfConsole(consoleData)));
}
}
}
}

Просмотреть файл

@ -0,0 +1,17 @@
using System;
using System.Threading;
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
namespace Microsoft.Xbox.XTF
{
//
// TODO TFS 769989
//
// Make Microsoft.Xbox.XTF.dll public and remove redundant hresult.cs and extension.cs from other assemblies
//
internal static partial class Extensions
{
}
}

Просмотреть файл

@ -0,0 +1,36 @@
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Xbox.XTF
{
//
// TODO TFS 769989
//
// Make Microsoft.Xbox.XTF.dll public and remove redundant hresult.cs and extension.cs from other assemblies
//
internal static class HRESULT
{
public const int S_OK = 0;
public const int S_FALSE = 1;
public const int E_PENDING = -2147483638;
public const int E_NOTIMPL = -2147467262;
public const int E_FAIL = -2147467259;
public const int E_ABORT = -2147467260;
public const int XTF_E_NOT_A_RESPONSE = -1;
public static bool FAILED(int hr)
{
return hr < 0;
}
public static void CHK(int hr)
{
if(FAILED(hr))
{
throw new COMException(String.Empty, hr);
}
}
}
}

Просмотреть файл

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{91EE26BB-006F-470D-8BDE-E83573832AF2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Xbox.Xtf.Console</RootNamespace>
<AssemblyName>Microsoft.Xbox.Xtf.ConsoleManager</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\dependencies\CodeAnalysis\Level3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\dependencies\CodeAnalysis\Level3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Xbox.Xtf.Interop">
<HintPath>$(DurangoXDK)\bin\Microsoft.Xbox.Xtf.Interop.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\AssemblyInfoCore.cs">
<Link>Properties\AssemblyInfoCore.cs</Link>
</Compile>
<Compile Include="ConsoleManager.cs" />
<Compile Include="ConsoleManagerCallback.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="HRESULT.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XtfConsole.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>

Просмотреть файл

@ -0,0 +1,13 @@
using System;
using System.Runtime.InteropServices;
using Microsoft.Xbox.XTF;
namespace Microsoft.Xbox.XTF.Console
{
internal static partial class NativeMethods
{
// IXtfConsoleManager
[DllImport(@"XtfConsoleManager.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = true)]
public static extern int XtfCreateConsoleManager(IXtfConsoleManagerCallback callback, ref System.Guid riid, out System.IntPtr ppvObject);
}
}

Просмотреть файл

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
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("Microsoft.Xbox.Xtf.ConsoleManager")]
[assembly: AssemblyDescription("Microsoft.Xbox.Xtf.ConsoleManager")]
[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)]
[assembly: CLSCompliant(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b81bdde8-b85b-46c1-9bb9-0a23c2d7d99b")]

Просмотреть файл

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.Xbox.XTF.Console
{
public class XtfConsole
{
internal _XTFCONSOLEDATA consoleData;
internal XtfConsole(_XTFCONSOLEDATA consoleData)
{
this.consoleData = consoleData;
}
public string Alias
{
get
{
return consoleData.bstrAlias;
}
}
public string Address
{
get
{
return consoleData.bstrAddress;
}
}
public override bool Equals(object other)
{
if (null == other)
{
return false;
}
if (other.GetType() != this.GetType())
{
return false;
}
XtfConsole otherConsole = (XtfConsole)other;
return this.GetHashCode() == otherConsole.GetHashCode();
}
public override int GetHashCode()
{
return this.Alias.GetHashCode();
}
}
}

Просмотреть файл

@ -0,0 +1,60 @@
using System;
using Microsoft.Xbox.XTF;
namespace Microsoft.Xbox.XTF.Diagnostics
{
public class OutputDebugStringEventArgs
{
public uint ProcessId { get; private set; }
public string DebugString { get; private set; }
public OutputDebugStringEventArgs(uint processId, String value)
{
this.ProcessId = processId;
this.DebugString = value;
}
}
public delegate void OutputDebugStringEventHandler(object sender, OutputDebugStringEventArgs e);
internal class DebugMonitorCallback : IXtfDebugMonitorCallback
{
private IXtfDebugMonitorClient client;
private OutputDebugStringEventHandler outputDebugStringHandler;
public DebugMonitorCallback(IXtfDebugMonitorClient client)
{
this.client = client;
}
public OutputDebugStringEventHandler EventHandler
{
get
{
lock(this)
{
return this.outputDebugStringHandler;
}
}
set
{
lock(this)
{
this.outputDebugStringHandler = value;
}
}
}
void IXtfDebugMonitorCallback.OnOutputDebugString(ref XTF_OUTPUT_DEBUG_STRING_DATA data)
{
lock(this)
{
if(null != this.outputDebugStringHandler)
{
this.outputDebugStringHandler(this, new OutputDebugStringEventArgs(data.dwProcessId, data.pszDbgStr));
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,124 @@
using Microsoft.Xbox.XTF;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace Microsoft.Xbox.XTF.Diagnostics
{
[Flags]
public enum StartFlags
{
None = 0x00000000
}
[Flags]
public enum StopFlags
{
None = 0x00000000
}
public class DebugMonitorClient : IDisposable
{
internal IXtfDebugMonitorClient debugClient;
private bool disposed = false;
private DebugMonitorCallback callback = null;
public DebugMonitorClient(string address)
{
System.Guid riid = typeof(IXtfDebugMonitorClient).GUID;
IntPtr ppvObj;
int hr = NativeMethods.XtfCreateDebugMonitorClient(address, ref riid, out ppvObj);
if (hr < 0)
{
throw new COMException("Unable to create object.", hr);
}
this.debugClient = Marshal.GetObjectForIUnknown(ppvObj) as IXtfDebugMonitorClient;
Marshal.Release(ppvObj);
this.callback = new DebugMonitorCallback(debugClient);
}
public DebugMonitorClient()
{
System.Guid riid = typeof(IXtfDebugMonitorClient).GUID;
IntPtr ppvObj;
int hr = NativeMethods.XtfCreateDebugMonitorClient(null, ref riid, out ppvObj);
if (hr < 0)
{
throw new COMException("Unable to create object.", hr);
}
this.debugClient = Marshal.GetObjectForIUnknown(ppvObj) as IXtfDebugMonitorClient;
Marshal.Release(ppvObj);
this.callback = new DebugMonitorCallback(debugClient);
}
~DebugMonitorClient()
{
this.Dispose(false);
}
public void Start(uint processId, StartFlags flags, OutputDebugStringEventHandler handler)
{
if (this.disposed)
{
throw new ObjectDisposedException("Internal resource");
}
this.callback.EventHandler = handler;
debugClient.Start(processId, (uint)flags, this.callback);
}
public void Stop(uint processId, StopFlags flags)
{
if (this.disposed)
{
throw new ObjectDisposedException("Internal resource");
}
debugClient.Stop(processId, (uint)flags);
this.callback.EventHandler = null;
}
public void Dispose()
{
this.Dispose(true);
//
// Avoid cleaning up twice. Calling Dispose(true)
// implies that managed objects will be cleaned up as well
// as unmanaged objects so the garbage collector will
// have no work to do when finalizing this object.
//
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!this.disposed)
{
Marshal.ReleaseComObject(this.debugClient);
//
// Since the garbage collector's Finalize() runs on
// a background thread, managed objects are not safe
// to reference. Only clean up managed objects if this
// is being explicitly disposed.
//
// if (disposing)
// {
// // ... Clean up managed objects
// }
//
this.disposed = true;
}
}
}
}

Просмотреть файл

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{4D6D3F7E-2058-46EA-BA44-DEB06D860751}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Xbox.Xtf.Diagnostics</RootNamespace>
<AssemblyName>Microsoft.Xbox.Xtf.DebugMonitor</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\dependencies\CodeAnalysis\Level3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\dependencies\CodeAnalysis\Level3.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Xbox.Xtf.Interop">
<HintPath>$(DurangoXDK)\bin\Microsoft.Xbox.Xtf.Interop.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\AssemblyInfoCore.cs">
<Link>Properties\AssemblyInfoCore.cs</Link>
</Compile>
<Compile Include="DebugEventHandler.cs" />
<Compile Include="DebugMonitorClient.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше