-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from gantt42/master
Minor improvements
- Loading branch information
Showing
12 changed files
with
320 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bin | ||
obj | ||
packages | ||
.vs | ||
.suo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
|
||
namespace CAOS | ||
{ | ||
public class CaosExpection : Exception | ||
{ | ||
public CaosExpection() | ||
{ } | ||
|
||
public CaosExpection(string message) : base(message) | ||
{ } | ||
|
||
public CaosExpection(string message, Exception innerException) : base(message, innerException) | ||
{ } | ||
} | ||
|
||
public class NoGameCaosException : CaosExpection | ||
{ | ||
public NoGameCaosException() | ||
{ } | ||
|
||
public NoGameCaosException(string message) : base(message) | ||
{ } | ||
|
||
public NoGameCaosException(string message, Exception innerException) : base(message, innerException) | ||
{ } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" 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)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{013D15C0-A7FF-4D80-B36B-25E3D58E1FA4}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>ConsoleApp1</RootNamespace> | ||
<AssemblyName>ConsoleApp1</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<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.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\CAOS\CAOS.csproj"> | ||
<Project>{a4ef3e36-9042-44ae-ad4d-b644a4f7c719}</Project> | ||
<Name>CAOS</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using CAOS; | ||
using System.Diagnostics; | ||
|
||
namespace ConsoleApp1 | ||
{ | ||
class Demo | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
CaosInjector injector = new CaosInjector("Docking Station"); | ||
|
||
if (injector.CanConnectToGame()) | ||
{ | ||
TryCatchStrategy(injector); | ||
TryReturnBoolStrategy(injector); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Couldn't connect to game."); | ||
} | ||
Console.ReadKey(); | ||
} | ||
|
||
private static void TryCatchStrategy(CaosInjector injector) | ||
{ | ||
try | ||
{ | ||
CaosResult result = injector.ExecuteCaos("outs \"hi\""); | ||
if (result.Success) | ||
{ | ||
Console.WriteLine(result.Content); | ||
} | ||
else | ||
{ | ||
Console.WriteLine($"Error Code: {result.ResultCode}"); | ||
} | ||
} | ||
catch (NoGameCaosException e) | ||
{ | ||
Console.WriteLine($"Game exited unexpectedly. Error message: {e.Message}"); | ||
} | ||
} | ||
|
||
private static void TryReturnBoolStrategy(CaosInjector injector) | ||
{ | ||
CaosResult result; | ||
if (injector.TryExecuteCaos("outs \"hi\"", out result)) | ||
{ | ||
if (result.Success) | ||
{ | ||
Console.WriteLine(result.Content); | ||
//Just try to do it, we don't care about the results | ||
injector.TryExecuteCaos("targ norn doif targ <> null sezz \"Yo yo! What up?\" endi"); | ||
} | ||
else | ||
{ | ||
Debug.Assert(result.ResultCode != 0); | ||
Console.WriteLine($"Error Code: {result.ResultCode}"); | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Execution failed. Game may have exited."); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.