├── Project
├── Codeer.Friendly
│ ├── Properties
│ │ ├── Resources.ja.Designer.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.ja.resx
│ │ └── Resources.resx
│ ├── Codeer.Friendly.snk
│ ├── IDefinition.cs
│ ├── IAppVarOwner.cs
│ ├── Inside
│ │ ├── Protocol
│ │ │ ├── VarAddress.cs
│ │ │ ├── IFriendlyConnector.cs
│ │ │ ├── ReturnInfo.cs
│ │ │ ├── ProtocolType.cs
│ │ │ ├── ProtocolInfo.cs
│ │ │ └── ExceptionInfo.cs
│ │ ├── FriendlyInfoAttribute.cs
│ │ ├── AsyncFriendlyOperationOwner.cs
│ │ ├── OperationTalker.cs
│ │ ├── FriendlyOperationOwner.cs
│ │ ├── InformationException.cs
│ │ ├── InternalException.cs
│ │ ├── StaticOperationTalker.cs
│ │ └── FriendlyTalker.cs
│ ├── IAppVarSelf.cs
│ ├── FriendlyOperation.cs
│ ├── ExplicitAppVar.cs
│ ├── AppVarHelper.cs
│ ├── Enumerate.cs
│ ├── OperationTypeInfo.cs
│ ├── NewInfo.cs
│ ├── FriendlyOperationException.cs
│ ├── Codeer.Friendly.sln
│ ├── Async.cs
│ ├── Codeer.Friendly.csproj
│ └── AppVar.cs
├── Codeer.Friendly.Dynamic
│ ├── Properties
│ │ ├── Resources.ja.Designer.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.ja.resx
│ │ └── Resources.resx
│ ├── Codeer.Friendly.Dynamic.snk
│ ├── AppVarExtensions.cs
│ ├── Inside
│ │ ├── TypeChahe.cs
│ │ └── DynamicFriendlyOperationUtility.cs
│ ├── Codeer.Friendly.Dynamic.csproj
│ ├── AppFriendExtensions.cs
│ ├── DynamicAppType.cs
│ └── DynamicAppVar.cs
└── Nuget
│ ├── NuGet.exe
│ ├── MakeNupack.bat
│ └── Friendly.nuspec
├── Img
├── AppVar.jpg
├── Dlls.png
├── CpuType.png
├── Drivers.png
├── Libraries.jpg
├── Serialize.jpg
├── CantSerialize.jpg
├── NumericUpDwon.png
├── DriverAndScenario.jpg
├── WindowDriverTarget.png
├── DriverAndScenario.jp.jpg
└── UserControlDriverTarget.png
├── FriendlyNuget128.png
├── .gitignore
├── CustomSerializer.jp.md
├── CustomSerializer.md
├── TestAutomationDesign.jp.md
├── LICENSE
└── TestAutomationDesign.md
/Project/Codeer.Friendly/Properties/Resources.ja.Designer.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly.Dynamic/Properties/Resources.ja.Designer.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Img/AppVar.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/AppVar.jpg
--------------------------------------------------------------------------------
/Img/Dlls.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/Dlls.png
--------------------------------------------------------------------------------
/Img/CpuType.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/CpuType.png
--------------------------------------------------------------------------------
/Img/Drivers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/Drivers.png
--------------------------------------------------------------------------------
/Img/Libraries.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/Libraries.jpg
--------------------------------------------------------------------------------
/Img/Serialize.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/Serialize.jpg
--------------------------------------------------------------------------------
/FriendlyNuget128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/FriendlyNuget128.png
--------------------------------------------------------------------------------
/Img/CantSerialize.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/CantSerialize.jpg
--------------------------------------------------------------------------------
/Img/NumericUpDwon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/NumericUpDwon.png
--------------------------------------------------------------------------------
/Project/Nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Project/Nuget/NuGet.exe
--------------------------------------------------------------------------------
/Img/DriverAndScenario.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/DriverAndScenario.jpg
--------------------------------------------------------------------------------
/Img/WindowDriverTarget.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/WindowDriverTarget.png
--------------------------------------------------------------------------------
/Img/DriverAndScenario.jp.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/DriverAndScenario.jp.jpg
--------------------------------------------------------------------------------
/Img/UserControlDriverTarget.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Img/UserControlDriverTarget.png
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Codeer.Friendly.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Project/Codeer.Friendly/Codeer.Friendly.snk
--------------------------------------------------------------------------------
/Project/Codeer.Friendly.Dynamic/Codeer.Friendly.Dynamic.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Codeer-Software/Friendly/HEAD/Project/Codeer.Friendly.Dynamic/Codeer.Friendly.Dynamic.snk
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/IDefinition.cs:
--------------------------------------------------------------------------------
1 | namespace Codeer.Friendly
2 | {
3 | #if ENG
4 | ///
5 | /// 定義であることの識別子。
6 | /// ライブラリ内で使います。
7 | ///
8 | #else
9 | ///
10 | /// 定義であることの識別子。
11 | /// ライブラリ内で使います。
12 | ///
13 | #endif
14 | public interface IDefinition { }
15 | }
16 |
--------------------------------------------------------------------------------
/Project/Nuget/MakeNupack.bat:
--------------------------------------------------------------------------------
1 | rd /s /q "../ReleaseBinary"
2 | "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.exe" "../Codeer.Friendly/Codeer.Friendly.sln" /rebuild Release
3 | "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.exe" "../Codeer.Friendly/Codeer.Friendly.sln" /rebuild Release-Eng
4 | nuget pack friendly.nuspec
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/IAppVarOwner.cs:
--------------------------------------------------------------------------------
1 | namespace Codeer.Friendly
2 | {
3 | #if ENG
4 | ///
5 | /// Demonstrating interface keeping the AppVar therein.
6 | ///
7 | #else
8 | ///
9 | /// 内部にAppVarを保持することを明示するインターフェイス。
10 | ///
11 | #endif
12 | public interface IAppVarOwner
13 | {
14 | #if ENG
15 | ///
16 | /// Variable in the application.
17 | ///
18 | #else
19 | ///
20 | /// 内部的に保持する対象アプリケーション内変数。
21 | ///
22 | #endif
23 | AppVar AppVar { get; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/Protocol/VarAddress.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Codeer.Friendly.Inside.Protocol
4 | {
5 | ///
6 | /// 変数アドレス。
7 | ///
8 | [Serializable]
9 | public class VarAddress
10 | {
11 | ///
12 | /// コア。
13 | ///
14 | public int Core { get; set; }
15 |
16 | ///
17 | /// コンストラクタ
18 | ///
19 | public VarAddress() { }
20 |
21 | ///
22 | /// コンストラクタ。
23 | ///
24 | /// コア。
25 | public VarAddress(int core)
26 | {
27 | Core = core;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/Protocol/IFriendlyConnector.cs:
--------------------------------------------------------------------------------
1 | using Codeer.Friendly;
2 |
3 | namespace Codeer.Friendly.Inside.Protocol
4 | {
5 | ///
6 | /// 接続者。
7 | ///
8 | public interface IFriendlyConnector
9 | {
10 | ///
11 | /// 接続者を区別するためのユニークなオブジェクト。
12 | ///
13 | object Identity { get; }
14 |
15 | ///
16 | /// 送受信。
17 | ///
18 | /// 通信情報。
19 | /// 戻り値。
20 | ReturnInfo SendAndReceive(ProtocolInfo info);
21 |
22 | ///
23 | /// アプリケーション操作クラスを取得します。
24 | ///
25 | AppFriend App { get; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/FriendlyInfoAttribute.cs:
--------------------------------------------------------------------------------
1 | #define CODE_ANALYSIS
2 | using System;
3 | using System.Diagnostics.CodeAnalysis;
4 |
5 | namespace Codeer.Friendly.Inside
6 | {
7 | ///
8 | /// Friendly情報。
9 | ///
10 | [AttributeUsage(AttributeTargets.All)]
11 | [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
12 | public class FriendlyInfoAttribute : Attribute
13 | {
14 | private string _info;
15 |
16 | ///
17 | /// 情報。
18 | ///
19 | public string Info { get { return _info; } }
20 |
21 | ///
22 | /// コンストラクタ。
23 | ///
24 | /// 情報。
25 | public FriendlyInfoAttribute(string info) { _info = info; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/IAppVarSelf.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace Codeer.Friendly
3 | {
4 | #if ENG
5 | ///
6 | /// Show that it is equivalent to him.
7 | /// Generally, please use IAppVarOwner.
8 | ///
9 | #else
10 | ///
11 | /// AppVarとほぼ等価な存在を表すインターフェイス。
12 | /// ライブラリ内で使います。
13 | /// 一般的にはIAppVarOwnerを使ってください。
14 | ///
15 | #endif
16 | [Obsolete("Please use one of the following. IAppVarOwner", false)]
17 | public interface IAppVarSelf
18 | {
19 | #if ENG
20 | ///
21 | /// Variable in the application
22 | ///
23 | #else
24 | ///
25 | /// 内部的に保持する対象アプリケーション内変数。
26 | ///
27 | #endif
28 | AppVar CodeerFriendlyAppVar { get; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/FriendlyOperation.cs:
--------------------------------------------------------------------------------
1 | namespace Codeer.Friendly
2 | {
3 | #if ENG
4 | ///
5 | /// A delegate to call operations within the target application.
6 | ///
7 | /// Parameters corresponding to the operation. Can be null, a serializable objecr, or an AppVar.
8 | ///
9 | /// When the operation has a return value, the result is stored in a variable declared within the target class, and an object for manipulating that variable is returned.
10 | /// When there is no return value, returns null.
11 | ///
12 | #else
13 | ///
14 | /// アプリケーションに対する操作実行デリゲート。
15 | ///
16 | /// 引数。
17 | /// 戻り値。
18 | #endif
19 | public delegate AppVar FriendlyOperation(params object[] args);
20 | }
21 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/Protocol/ReturnInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Codeer.Friendly.Inside.Protocol
4 | {
5 | ///
6 | /// 戻り値情報。
7 | ///
8 | [Serializable]
9 | public class ReturnInfo
10 | {
11 | ///
12 | /// 戻り値。
13 | ///
14 | public object ReturnValue { get; set; }
15 |
16 | ///
17 | /// 例外。
18 | ///
19 | public ExceptionInfo Exception { get; set; }
20 |
21 | ///
22 | /// コンストラクタ。
23 | ///
24 | public ReturnInfo() { }
25 |
26 | ///
27 | /// コンストラクタ。
28 | ///
29 | /// 戻り値。
30 | public ReturnInfo(object returnValue)
31 | {
32 | ReturnValue = returnValue;
33 | }
34 |
35 | ///
36 | /// コンストラクタ。
37 | ///
38 | /// 例外情報。
39 | public ReturnInfo(ExceptionInfo exception)
40 | {
41 | Exception = exception;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/Protocol/ProtocolType.cs:
--------------------------------------------------------------------------------
1 | namespace Codeer.Friendly.Inside.Protocol
2 | {
3 | ///
4 | /// 通信タイプ。
5 | ///
6 | public enum ProtocolType
7 | {
8 | ///
9 | /// 変数初期化。
10 | ///
11 | VarInitialize,
12 |
13 | ///
14 | /// 変数生成。
15 | ///
16 | VarNew,
17 |
18 | ///
19 | /// 変数を捨てる。
20 | ///
21 | BinOff,
22 |
23 | ///
24 | /// 値を設定。
25 | ///
26 | GetValue,
27 |
28 | ///
29 | /// 値を取得。
30 | ///
31 | SetValue,
32 |
33 | ///
34 | /// 要素取得。
35 | ///
36 | GetElements,
37 |
38 | ///
39 | /// 操作。
40 | ///
41 | Operation,
42 |
43 | ///
44 | /// 空変数であるかチェック。
45 | /// 非同期実行中に使用されるので可能な限り高速に処理を戻すこと。
46 | ///
47 | IsEmptyVar,
48 |
49 | ///
50 | /// 非同期結果格納バッファ初期化。
51 | ///
52 | AsyncResultVarInitialize,
53 |
54 | ///
55 | /// 非同期操作。
56 | ///
57 | AsyncOperation,
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/ExplicitAppVar.cs:
--------------------------------------------------------------------------------
1 | namespace Codeer.Friendly
2 | {
3 | #if ENG
4 | ///
5 | /// Explicit AppVar.
6 | /// If you use dynamic to argument, return value becomes dynamic.
7 | /// This class prevents it.
8 | ///
9 | #else
10 | ///
11 | /// アプリケーション内部の変数を明示するときに使用する
12 | /// dynamicを引数に使うとメソッドの戻り値もdynamicになるのでそれを防ぐ
13 | ///
14 | #endif
15 | public class ExplicitAppVar : IAppVarOwner
16 | {
17 | #if ENG
18 | ///
19 | /// Variable in the application.
20 | ///
21 | #else
22 | ///
23 | /// 内部的に保持する対象アプリケーション内変数。
24 | ///
25 | #endif
26 | public AppVar AppVar { get; private set; }
27 |
28 | #if ENG
29 | ///
30 | /// Constractor.
31 | ///
32 | /// Variable in the application.
33 | #else
34 | ///
35 | /// コンストラクタ
36 | ///
37 | /// アプリケーション内部の変数
38 | #endif
39 | public ExplicitAppVar(AppVar appVar)
40 | {
41 | AppVar = appVar;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly.Dynamic/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("Codeer.Friendly.Dynamic")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Codeer.Friendly.Dynamic")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
18 | // 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
23 | [assembly: Guid("b51cd959-57c7-4df6-ba7b-26ea21bdc0e8")]
24 |
25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
33 | // 既定値にすることができます:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("2.7.0.0")]
36 | [assembly: AssemblyFileVersion("2.7.0.0")]
37 | [assembly: System.CLSCompliant(true)]
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("Codeer.Friendly")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Codeer.Friendly")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
18 | // 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
23 | [assembly: Guid("0691e3ff-b712-4b4b-b34e-9b58ab8e505b")]
24 |
25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
33 | // 既定値にすることができます:
34 | [assembly: AssemblyVersion("2.7.0.0")]
35 | [assembly: AssemblyFileVersion("2.7.0.0")]
36 | [assembly: Codeer.Friendly.Inside.FriendlyInfoAttribute("invisible")]
37 | [assembly: System.CLSCompliant(true)]
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/AsyncFriendlyOperationOwner.cs:
--------------------------------------------------------------------------------
1 | namespace Codeer.Friendly.Inside
2 | {
3 | ///
4 | /// 非同期操作保持クラス。
5 | ///
6 | internal class AsyncFriendlyOperationOwner
7 | {
8 | Async _async;
9 | string _operation;
10 | OperationTypeInfo _operationTypeInfo;
11 |
12 | ///
13 | /// コンストラクタ。
14 | ///
15 | /// 非同期実行クラス。
16 | /// 操作タイプ情報。(オーバーロードの解決等に使用します。)
17 | /// 操作名称。
18 | internal AsyncFriendlyOperationOwner(Async async, OperationTypeInfo operationTypeInfo, string operation)
19 | {
20 | _async = async;
21 | _operationTypeInfo = operationTypeInfo;
22 | _operation = operation;
23 | }
24 |
25 | ///
26 | /// 操作呼び出し。
27 | ///
28 | /// 引数。
29 | /// 戻り値。
30 | internal AppVar FriendlyOperation(params object[] args)
31 | {
32 | if (args == null)
33 | {
34 | args = new object[] { null };
35 | }
36 | return _async.Invoke(_operationTypeInfo, _operation, args);
37 | }
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/OperationTalker.cs:
--------------------------------------------------------------------------------
1 | using Codeer.Friendly.Inside.Protocol;
2 |
3 | namespace Codeer.Friendly.Inside
4 | {
5 | ///
6 | /// 操作通信
7 | ///
8 | public abstract class OperationTalker
9 | {
10 | ///
11 | /// アプリケーションとの接続者。
12 | ///
13 | internal abstract IFriendlyConnector FriendlyConnector { get; }
14 |
15 | ///
16 | /// 戻り値をAppVarで取得する通信。
17 | ///
18 | /// 通信タイプ。
19 | /// 操作タイプ情報。
20 | /// 操作名称。
21 | /// 引数。
22 | /// 変数。
23 | internal abstract AppVar SendAndReceive(ProtocolType protocolType, OperationTypeInfo operationTypeInfo, string operation, object[] arguments);
24 |
25 | ///
26 | /// 戻り値を値で取得する通信処理。
27 | ///
28 | /// 通信タイプ。
29 | /// 操作タイプ情報。
30 | /// 操作名称。
31 | /// 引数。
32 | /// 値。
33 | internal abstract object SendAndValueReceive(ProtocolType protocolType, OperationTypeInfo operationTypeInfo, string operation, object[] arguments);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/FriendlyOperationOwner.cs:
--------------------------------------------------------------------------------
1 | using Codeer.Friendly.Inside.Protocol;
2 |
3 | namespace Codeer.Friendly.Inside
4 | {
5 | ///
6 | /// 操作保持クラス。
7 | ///
8 | class FriendlyOperationOwner
9 | {
10 | OperationTalker _operationTalker;
11 | OperationTypeInfo _operationTypeInfo;
12 | string _operation;
13 |
14 | ///
15 | /// コンストラクタ。
16 | ///
17 | /// 操作通信社
18 | /// 操作タイプ情報。
19 | /// 操作名称。
20 | internal FriendlyOperationOwner(OperationTalker talker, OperationTypeInfo operationTypeInfo, string operation)
21 | {
22 | _operationTalker = talker;
23 | _operationTypeInfo = operationTypeInfo;
24 | _operation = operation;
25 | }
26 |
27 | ///
28 | /// 操作実行。
29 | ///
30 | /// 引数。
31 | /// 戻り値。
32 | internal AppVar FriendlyOperation(params object[] arguments)
33 | {
34 | if (arguments == null)
35 | {
36 | arguments = new object[] { null };
37 | }
38 | return _operationTalker.SendAndReceive(ProtocolType.Operation, _operationTypeInfo, _operation, arguments);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly.Dynamic/AppVarExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace Codeer.Friendly.Dynamic
2 | {
3 | #if ENG
4 | ///
5 | /// AppVar extension methods to provide dynamic functionality.
6 | ///
7 | #else
8 | ///
9 | /// AppVarを拡張します。
10 | ///
11 | #endif
12 | public static class AppVarExtensions
13 | {
14 | #if ENG
15 | ///
16 | /// Helper method to convert an AppVar to a DynamicAppVar and convert it into a dynamic type.
17 | ///
18 | /// AppVar.
19 | /// DynamicAppVar.
20 | #else
21 | ///
22 | /// AppVarをDynamicAppVarに変換し、dynamic型に入れるためのヘルパメソッドです。
23 | ///
24 | /// AppVar型変数。
25 | /// DynamicAppVar。
26 | #endif
27 | public static dynamic Dynamic(this AppVar src)
28 | {
29 | return new DynamicAppVar(src);
30 | }
31 |
32 | #if ENG
33 | ///
34 | /// Helper method to convert an AppVar to a DynamicAppVar and convert it into a dynamic type.
35 | ///
36 | /// AppVar Owner.
37 | /// DynamicAppVar.
38 | #else
39 | ///
40 | /// IAppVarOwnerClearlyをDynamicAppVarに変換し、dynamic型に入れるためのヘルパメソッドです。
41 | ///
42 | /// AppVar保持クラス。
43 | /// DynamicAppVar。
44 | #endif
45 | public static dynamic Dynamic(this IAppVarOwner src)
46 | {
47 | return new DynamicAppVar(src.AppVar);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/InformationException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.Security.Permissions;
4 |
5 | namespace Codeer.Friendly.Inside
6 | {
7 | ///
8 | /// 情報通知用例外。
9 | ///
10 | [Serializable]
11 | public class InformationException : Exception
12 | {
13 | ///
14 | /// コンストラクタ。
15 | ///
16 | public InformationException(){}
17 |
18 | ///
19 | /// コンストラクタ。
20 | ///
21 | /// メッセージ。
22 | public InformationException(string message) : base(message) { }
23 |
24 | ///
25 | /// コンストラクタ。
26 | ///
27 | /// メッセージ。
28 | /// 内部例外。
29 | public InformationException(string message, Exception innerException) : base(message, innerException) { }
30 |
31 | ///
32 | /// コンストラクタ。
33 | ///
34 | /// シリアライズ情報。
35 | /// コンテキスト。
36 | protected InformationException(SerializationInfo info, StreamingContext context)
37 | : base(info, context) { }
38 |
39 | ///
40 | /// シリアライズ。
41 | ///
42 | /// シリアライズ情報。
43 | /// コンテキスト。
44 | [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
45 | public override void GetObjectData(SerializationInfo info, StreamingContext context)
46 | {
47 | base.GetObjectData(info, context);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/InternalException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Codeer.Friendly.Properties;
3 | using System.Security.Permissions;
4 | using System.Runtime.Serialization;
5 |
6 | namespace Codeer.Friendly.Inside
7 | {
8 | ///
9 | /// 内部例外。
10 | ///
11 | [Serializable]
12 | public class InternalException : Exception
13 | {
14 | ///
15 | /// コンストラクタ。
16 | ///
17 | public InternalException(){}
18 |
19 | ///
20 | /// コンストラクタ。
21 | ///
22 | /// メッセージ。
23 | public InternalException(string message) : base(message) { }
24 |
25 | ///
26 | /// コンストラクタ。
27 | ///
28 | /// メッセージ。
29 | /// 内部例外。
30 | public InternalException(string message, Exception innerException) : base(message, innerException) { }
31 |
32 | ///
33 | /// コンストラクタ。
34 | ///
35 | /// シリアライズ情報。
36 | /// コンテキスト。
37 | protected InternalException(SerializationInfo info, StreamingContext context)
38 | : base(info, context) { }
39 |
40 | ///
41 | /// シリアライズ。
42 | ///
43 | /// シリアライズ情報。
44 | /// コンテキスト。
45 | [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
46 | public override void GetObjectData(SerializationInfo info, StreamingContext context)
47 | {
48 | base.GetObjectData(info, context);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/Protocol/ProtocolInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Codeer.Friendly.Inside.Protocol
4 | {
5 | ///
6 | /// 通信情報。
7 | ///
8 | [Serializable]
9 | public class ProtocolInfo
10 | {
11 | ///
12 | /// 通信タイプ。
13 | ///
14 | public ProtocolType ProtocolType { get; set; }
15 |
16 | ///
17 | /// 操作タイプ情報。
18 | ///
19 | public OperationTypeInfo OperationTypeInfo { get; set; }
20 |
21 | ///
22 | /// 変数アドレス。
23 | ///
24 | public VarAddress VarAddress { get; set; }
25 |
26 | ///
27 | /// タイプフルネーム。
28 | ///
29 | public string TypeFullName { get; set; }
30 |
31 | ///
32 | /// 操作名称。
33 | ///
34 | public string Operation { get; set; }
35 |
36 | ///
37 | /// 引数。
38 | ///
39 | public object[] Arguments { get; set; }
40 |
41 | ///
42 | /// コンストラクタ
43 | ///
44 | public ProtocolInfo() { }
45 |
46 | ///
47 | /// コンストラクタ。
48 | ///
49 | /// 通信タイプ。
50 | /// 操作タイプ情報。
51 | /// 変数アドレス。
52 | /// タイプフルネーム。
53 | /// 操作名称。
54 | /// 引数。
55 | public ProtocolInfo(ProtocolType protocolType, OperationTypeInfo operationTypeInfo, VarAddress varAddress, string typeFullName, string operation, object[] arguments)
56 | {
57 | ProtocolType = protocolType;
58 | OperationTypeInfo = operationTypeInfo;
59 | VarAddress = varAddress;
60 | TypeFullName = typeFullName;
61 | Operation = operation;
62 | Arguments = arguments;
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/Project/Nuget/Friendly.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Codeer.Friendly
5 | 2.7.0
6 | Friendly
7 | Codeer
8 | Codeer
9 | https://github.com/Codeer-Software/Friendly/blob/master/LICENSE
10 | https://github.com/Codeer-Software/Friendly
11 | https://raw.githubusercontent.com/Codeer-Software/Friendly/master/FriendlyNuget128.png
12 | false
13 | Friendly Common Interfaces. You can access the target application using the interface defined by this.
14 | Friendly Testing Windows WPF WinForms Win32 Automation
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/AppVarHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Codeer.Friendly
4 | {
5 | #if ENG
6 | ///
7 | /// Helper methos of AppVar.
8 | ///
9 | #else
10 | ///
11 | /// AppVarのヘルパメソッドです。
12 | ///
13 | #endif
14 | public static class AppVarHelper
15 | {
16 | #if ENG
17 | ///
18 | /// Determines whether the specified Object instances in target application are the same instance.
19 | ///
20 | /// The first object to compare.
21 | /// The second object to compare.
22 | /// is same.
23 | #else
24 | ///
25 | /// 対象プロセス内のインスタンスが同一であるかを判断します。
26 | ///
27 | /// 比較対象1。
28 | /// 比較対象2。
29 | /// インスタンスが同一であるか。
30 | #endif
31 | public static bool ReferenceEquals(AppVar lhs, AppVar rhs)
32 | {
33 | if (lhs == null)
34 | {
35 | throw new ArgumentNullException("lhs");
36 | }
37 | if (rhs == null)
38 | {
39 | throw new ArgumentNullException("rhs");
40 | }
41 | return (bool)lhs.App[typeof(object), "ReferenceEquals"](lhs, rhs).Core;
42 | }
43 |
44 | #if ENG
45 | ///
46 | /// Get that variables in the target application is null.
47 | ///
48 | /// Variable in the target application.
49 | /// is null.
50 | #else
51 | ///
52 | /// アプリケーション内変数がnullであるかを取得します。
53 | ///
54 | /// アプリケーション内変数。
55 | /// nullであるか。
56 | #endif
57 | public static bool IsNull(AppVar appVar)
58 | {
59 | if (appVar == null)
60 | {
61 | throw new ArgumentNullException("appVar");
62 | }
63 | return appVar.IsNull;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/Protocol/ExceptionInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Codeer.Friendly.Inside.Protocol
4 | {
5 | ///
6 | /// 例外情報。
7 | /// 例外クラスは場合によっては、シリアライズ不可能なので、必要なデータのみ抜粋し、保持する。
8 | ///
9 | [Serializable]
10 | public class ExceptionInfo
11 | {
12 | ///
13 | /// 例外のタイプ文字列。
14 | ///
15 | public string ExceptionType { get; set; }
16 |
17 | ///
18 | /// 例外に関連付けられているヘルプ ファイルへのリンク。
19 | ///
20 | public string HelpLink { get; set; }
21 |
22 | ///
23 | /// 現在の例外を説明するメッセージ。
24 | ///
25 | public string Message { get; set; }
26 |
27 | ///
28 | /// エラーの原因となったアプリケーションまたはオブジェクトの名前。
29 | ///
30 | public string Source { get; set; }
31 |
32 | ///
33 | /// 現在の例外がスローされたときにコール スタック。
34 | ///
35 | public string StackTrace { get; set; }
36 |
37 | ///
38 | /// コンストラクタ。
39 | ///
40 | public ExceptionInfo() { }
41 |
42 | ///
43 | /// コンストラクタ。
44 | ///
45 | /// 例外。
46 | public ExceptionInfo(Exception exception)
47 | {
48 | if (exception == null)
49 | {
50 | return;
51 | }
52 |
53 | //アプリ内部でFriendly系の処理によって発生した想定内の例外はメッセージのみ返す。
54 | if (exception is InformationException)
55 | {
56 | Message = exception.Message;
57 | return;
58 | }
59 |
60 | //InternalErrorがあれば、それを利用する
61 | while (exception.InnerException != null)
62 | {
63 | exception = exception.InnerException;
64 | }
65 | Message = exception.Message;
66 | ExceptionType = exception.GetType().FullName;
67 | HelpLink = exception.HelpLink;
68 | Source = exception.Source;
69 | StackTrace = exception.StackTrace;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly.Dynamic/Inside/TypeChahe.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Codeer.Friendly.Dynamic.Inside
4 | {
5 | ///
6 | /// タイプキャッシュ。
7 | ///
8 | class TypeChahe
9 | {
10 | AppVar _typeFinder;
11 | internal Dictionary NameSpace { get; private set; }
12 | internal Dictionary Type { get; private set; }
13 |
14 | ///
15 | /// コンストラクタ
16 | ///
17 | /// アプリケーション操作クラス
18 | internal TypeChahe(AppFriend app)
19 | {
20 | _typeFinder = app.Dim(new NewInfo("Codeer.Friendly.DotNetExecutor.TypeFinder"));
21 | NameSpace = new Dictionary();
22 | Type = new Dictionary();
23 | }
24 |
25 | ///
26 | /// タイプ名称か。
27 | ///
28 | /// アプリケーション操作クラス。
29 | /// 名前。
30 | /// タイプ名称でなくてもキャッシュするか。
31 | /// タイプ名称か。
32 | internal bool IsTypeName(AppFriend app, string name, bool cacheNotType)
33 | {
34 | if (NameSpace.ContainsKey(name))
35 | {
36 | return false;
37 | }
38 | bool isType = false;
39 | if (Type.TryGetValue(name, out isType))
40 | {
41 | return isType;
42 | }
43 | if ((bool)app[typeof(object), "ReferenceEquals"](_typeFinder["GetType"](name), null).Core)
44 | {
45 | if (cacheNotType)
46 | {
47 | Type.Add(name, false);
48 | }
49 | return false;
50 | }
51 | Type.Add(name, true);
52 | int index = name.LastIndexOf('.');
53 | if (index != -1)
54 | {
55 | string nameSpace = name.Substring(0, index);
56 | NameSpace.Remove(nameSpace);
57 | NameSpace.Add(nameSpace, true);
58 | }
59 | return true;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | [Bb]in/
3 | [Oo]bj/
4 |
5 | # mstest test results
6 | TestResults
7 |
8 | ## Ignore Visual Studio temporary files, build results, and
9 | ## files generated by popular Visual Studio add-ons.
10 |
11 | # User-specific files
12 | *.suo
13 | *.user
14 | *.sln.docstates
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Rr]elease/
19 | x64/
20 | *_i.c
21 | *_p.c
22 | *.ilk
23 | *.meta
24 | *.obj
25 | *.pch
26 | *.pdb
27 | *.pgc
28 | *.pgd
29 | *.rsp
30 | *.sbr
31 | *.tlb
32 | *.tli
33 | *.tlh
34 | *.tmp
35 | *.log
36 | *.vspscc
37 | *.vssscc
38 | .builds
39 |
40 | # Visual C++ cache files
41 | ipch/
42 | *.aps
43 | *.ncb
44 | *.opensdf
45 | *.sdf
46 |
47 | # Visual Studio profiler
48 | *.psess
49 | *.vsp
50 | *.vspx
51 |
52 | # Guidance Automation Toolkit
53 | *.gpState
54 |
55 | # ReSharper is a .NET coding add-in
56 | _ReSharper*
57 |
58 | # NCrunch
59 | *.ncrunch*
60 | .*crunch*.local.xml
61 |
62 | # Installshield output folder
63 | [Ee]xpress
64 |
65 | # DocProject is a documentation generator add-in
66 | DocProject/buildhelp/
67 | DocProject/Help/*.HxT
68 | DocProject/Help/*.HxC
69 | DocProject/Help/*.hhc
70 | DocProject/Help/*.hhk
71 | DocProject/Help/*.hhp
72 | DocProject/Help/Html2
73 | DocProject/Help/html
74 |
75 | # Click-Once directory
76 | publish
77 |
78 | # Publish Web Output
79 | *.Publish.xml
80 |
81 | # NuGet Packages Directory
82 | packages
83 |
84 | # Windows Azure Build Output
85 | csx
86 | *.build.csdef
87 |
88 | # Windows Store app package directory
89 | AppPackages/
90 |
91 | # Others
92 | [Bb]in
93 | [Oo]bj
94 | sql
95 | TestResults
96 | [Tt]est[Rr]esult*
97 | *.Cache
98 | ClientBin
99 | [Ss]tyle[Cc]op.*
100 | ~$*
101 | *.dbmdl
102 | Generated_Code #added for RIA/Silverlight projects
103 |
104 | # Backup & report files from converting an old project file to a newer
105 | # Visual Studio version. Backup files are not needed, because we have git ;-)
106 | _UpgradeReport_Files/
107 | Backup*/
108 | UpgradeLog*.XML
109 |
110 | *.nupkg
111 | ReleaseBinary/
112 | TestResults/
113 | .vs/
--------------------------------------------------------------------------------
/CustomSerializer.jp.md:
--------------------------------------------------------------------------------
1 | # FriendlyCustomSerializerSample
2 | Friendlyでカスタマイズされたシリアライザを利用するときのサンプルです。
3 | EnableUnsafeBinaryFormatterSerializationをfalseにしたアプリをFriedlyで操作したい場合に利用します。
4 | 背景としてFriendlyではプロセス間通信にBinaryFormatterを利用しているのでそれが使えなくなります。
5 |
6 | ## 利用方法
7 | ```csharp
8 | WindowsAppFriend.SetCustomSerializer();
9 | ```
10 | を呼び出すことでシリアライザを登録できます。
11 | 注意点としては登録したシリアライザは操作対象プロセスでも使われるため定義しているアセンブリをdllインジェクションします。
12 | 操作対象プロセスで動作することを前提としたアセンブリで実装してください。
13 |
14 | ```csharp
15 | public void Test()
16 | {
17 | //カスタムシリアライザの設定
18 | //最初に一回呼び出す
19 | WindowsAppFriend.SetCustomSerializer();
20 |
21 | //WindowsAppFriendを生成
22 | var app = new WindowsAppFriend(Process.Start(info));
23 |
24 | //通常のFriendlyの操作
25 | var formControls = app.AttachFormControls();
26 | formControls.button.EmulateClick();
27 | formControls.checkBox.EmulateCheck(CheckState.Checked);
28 | formControls.comboBox.EmulateChangeText("Item-3");
29 | formControls.comboBox.EmulateChangeSelect(2);
30 | formControls.radioButton1.EmulateCheck();
31 | formControls.radioButton1.EmulateCheck();
32 | }
33 | ```
34 |
35 | ## カスタムシリアライザ
36 | ICustomSerializerを実装します。
37 | 実装方法は任意ですが、本サンプルでは[MessagePack](https://www.nuget.org/packages/MessagePack)を利用しています。
38 |
39 | ```csharp
40 | public class IntPtrFormatter : IMessagePackFormatter
41 | {
42 | public void Serialize(ref MessagePackWriter writer, IntPtr value, MessagePackSerializerOptions options)
43 | => writer.Write(value.ToInt64());
44 |
45 | public IntPtr Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
46 | => new IntPtr(reader.ReadInt64());
47 | }
48 |
49 | public class CustomSerializer : ICustomSerializer
50 | {
51 | MessagePackSerializerOptions customOptions = MessagePackSerializerOptions
52 | .Standard
53 | .WithResolver(
54 | CompositeResolver.Create(
55 | new IMessagePackFormatter[] { new IntPtrFormatter() },
56 | new IFormatterResolver[] { TypelessContractlessStandardResolver.Instance }
57 | )
58 | );
59 |
60 | public object Deserialize(byte[] bin)
61 | => MessagePackSerializer.Typeless.Deserialize(bin, customOptions);
62 |
63 | public Assembly[] GetRequiredAssemblies() => [GetType().Assembly, typeof(MessagePackSerializer).Assembly];
64 |
65 | public byte[] Serialize(object obj)
66 | => MessagePackSerializer.Typeless.Serialize(obj, customOptions);
67 | }
68 | ```
69 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Enumerate.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Collections;
3 | using Codeer.Friendly.Inside.Protocol;
4 |
5 | namespace Codeer.Friendly
6 | {
7 | #if ENG
8 | ///
9 | /// When the variable in application corresponds to repetition processing, repetitive processing by foreach can be executed. (in .Net, when IEnumerator is inherited).
10 | ///
11 | #else
12 | ///
13 | /// アプリケーション内の変数が繰り返し処理に対応している場合(.NetならIEnumeratorを継承している場合)foreachによる反復処理を実行できます。
14 | ///
15 | #endif
16 | public class Enumerate : IEnumerable
17 | {
18 | AppVar _enumerable;
19 |
20 | #if ENG
21 | ///
22 | /// Constractor.
23 | ///
24 | /// An enumerable variable in the application.
25 | #else
26 | ///
27 | /// コンストラクタ。
28 | ///
29 | /// 反復処理可能なアプリケーション内変数。
30 | #endif
31 | public Enumerate(AppVar enumerable)
32 | {
33 | _enumerable = enumerable;
34 | }
35 |
36 | #if ENG
37 | ///
38 | /// Produces an enumerator for the provided variable.
39 | ///
40 | /// An enumerator that allows iterative processing on the variable.
41 | #else
42 | ///
43 | /// コレクションを反復処理する列挙子を返します。
44 | ///
45 | /// コレクションを反復処理するために使用できる列挙子。
46 | #endif
47 | public IEnumerator GetEnumerator()
48 | {
49 | VarAddress[] core = (VarAddress[])_enumerable.SendAndValueReceive(ProtocolType.GetElements, null, string.Empty, new object[0]);
50 | List elements = new List();
51 | for (int i = 0; i < core.Length; i++)
52 | {
53 | elements.Add(new AppVar(_enumerable.FriendlyConnector, core[i]));
54 | }
55 | return elements.GetEnumerator();
56 | }
57 |
58 | #if ENG
59 | ///
60 | /// Produces an enumerator for the provided variable.
61 | ///
62 | /// An enumerator that allows iterative processing on the variable.
63 | #else
64 | ///
65 | /// コレクションを反復処理する列挙子を返します。
66 | ///
67 | /// コレクションを反復処理するために使用できる列挙子。
68 | #endif
69 | IEnumerator IEnumerable.GetEnumerator()
70 | {
71 | return GetEnumerator();
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/CustomSerializer.md:
--------------------------------------------------------------------------------
1 | # Friendly Custom Serializer Sample
2 |
3 | This sample shows how to use a customized serializer with Friendly.
4 | Use it when you want to control an app with Friendly that has `EnableUnsafeBinaryFormatterSerialization` set to `false`.
5 |
6 | **Background:** Friendly uses `BinaryFormatter` for inter process communication, so when `BinaryFormatter` cannot be used, you need to provide an alternative serializer.
7 |
8 | ## Usage
9 |
10 | ```csharp
11 | WindowsAppFriend.SetCustomSerializer();
12 | ```
13 | Call this to register the serializer.
14 |
15 | **Note:** The registered serializer will also be used inside the target process, so the assembly that defines it will be injected (DLL injection). Implement it as an assembly that is safe to run in the target process.
16 |
17 | ```csharp
18 | public void Test()
19 | {
20 | // Configure the custom serializer (call once at startup)
21 | WindowsAppFriend.SetCustomSerializer();
22 |
23 | // Create WindowsAppFriend
24 | var app = new WindowsAppFriend(Process.Start(info));
25 |
26 | // Typical Friendly operations
27 | var formControls = app.AttachFormControls();
28 | formControls.button.EmulateClick();
29 | formControls.checkBox.EmulateCheck(CheckState.Checked);
30 | formControls.comboBox.EmulateChangeText("Item-3");
31 | formControls.comboBox.EmulateChangeSelect(2);
32 | formControls.radioButton1.EmulateCheck();
33 | formControls.radioButton1.EmulateCheck();
34 | }
35 | ```
36 |
37 | ## Custom serializer
38 |
39 | Implement `ICustomSerializer`.
40 | Any implementation style is fine; this sample uses [MessagePack](https://www.nuget.org/packages/MessagePack).
41 |
42 | ```csharp
43 | public class IntPtrFormatter : IMessagePackFormatter
44 | {
45 | public void Serialize(ref MessagePackWriter writer, IntPtr value, MessagePackSerializerOptions options)
46 | => writer.Write(value.ToInt64());
47 |
48 | public IntPtr Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
49 | => new IntPtr(reader.ReadInt64());
50 | }
51 |
52 | public class CustomSerializer : ICustomSerializer
53 | {
54 | MessagePackSerializerOptions customOptions = MessagePackSerializerOptions
55 | .Standard
56 | .WithResolver(
57 | CompositeResolver.Create(
58 | new IMessagePackFormatter[] { new IntPtrFormatter() },
59 | new IFormatterResolver[] { TypelessContractlessStandardResolver.Instance }
60 | )
61 | );
62 |
63 | public object Deserialize(byte[] bin)
64 | => MessagePackSerializer.Typeless.Deserialize(bin, customOptions);
65 |
66 | public Assembly[] GetRequiredAssemblies() => [GetType().Assembly, typeof(MessagePackSerializer).Assembly];
67 |
68 | public byte[] Serialize(object obj)
69 | => MessagePackSerializer.Typeless.Serialize(obj, customOptions);
70 | }
71 | ```
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/OperationTypeInfo.cs:
--------------------------------------------------------------------------------
1 | #define CODE_ANALYSIS
2 | using System;
3 | using System.Diagnostics.CodeAnalysis;
4 |
5 | namespace Codeer.Friendly
6 | {
7 | #if ENG
8 | ///
9 | /// Used to specify parameters for a FriendlyOperation when there is a need to resolve overloads or call an operation on a parent class.
10 | /// Please refer to samples.
11 | ///
12 | #else
13 | ///
14 | /// FriendlyOperationの型を確定させるための情報です。
15 | /// オーバーロードの解決と、親クラスの操作呼び出しに使用します。
16 | ///
17 | #endif
18 | [Serializable]
19 | public class OperationTypeInfo
20 | {
21 | #if ENG
22 | ///
23 | /// Returns the full class name of the target type for the target operation.
24 | ///
25 | #else
26 | ///
27 | /// 操作を保持する型フルネームです。
28 | ///
29 | #endif
30 | public string Target { get; set; }
31 |
32 | #if ENG
33 | ///
34 | /// Returns an array of the full class names of the target operation's parameters.
35 | ///
36 | #else
37 | ///
38 | /// 引数の型のフルネーム配列。
39 | ///
40 | #endif
41 | public string[] Arguments { get; set; }
42 |
43 | #if ENG
44 | ///
45 | /// Constructor.
46 | ///
47 | #else
48 | ///
49 | /// コンストラクタ。
50 | ///
51 | #endif
52 | public OperationTypeInfo() { }
53 |
54 | #if ENG
55 | ///
56 | /// Constructor.
57 | ///
58 | /// The full class name of the target type for the target operation.
59 | /// The full class names of the the target operation's parameters.
60 | #else
61 | ///
62 | /// コンストラクタ。
63 | ///
64 | /// 操作を保持する型フルネームです。
65 | /// 引数の型のフルネーム配列。
66 | #endif
67 | [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String)")]
68 | public OperationTypeInfo(string target, params string[] arguments)
69 | {
70 | //引数チェック
71 | if (string.IsNullOrEmpty(target))
72 | {
73 | throw new ArgumentNullException("target");
74 | }
75 | if (arguments == null)
76 | {
77 | throw new ArgumentNullException("arguments");
78 | }
79 | for (int i = 0; i < arguments.Length; i++)
80 | {
81 | if (string.IsNullOrEmpty(arguments[i]))
82 | {
83 | throw new ArgumentException("arguments is invalid");
84 | }
85 | }
86 | Target = target;
87 | Arguments = arguments;
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/Inside/StaticOperationTalker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Codeer.Friendly.Inside.Protocol;
3 | using Codeer.Friendly.Properties;
4 |
5 | namespace Codeer.Friendly.Inside
6 | {
7 | ///
8 | /// Static操作通信
9 | ///
10 | class StaticOperationTalker : OperationTalker
11 | {
12 | readonly IFriendlyConnector _friendlyConnector;
13 | readonly string _staticOperationTypeFullName;
14 |
15 | ///
16 | /// アプリケーションとの接続者。
17 | ///
18 | internal override IFriendlyConnector FriendlyConnector { get { return _friendlyConnector; } }
19 |
20 | ///
21 | /// コンストラクタ。
22 | ///
23 | /// 操作送信者。
24 | /// タイプフルネーム。
25 | internal StaticOperationTalker(IFriendlyConnector friendlyConnector, string typeFullName)
26 | {
27 | _friendlyConnector = friendlyConnector;
28 | _staticOperationTypeFullName = typeFullName;
29 | }
30 |
31 | ///
32 | /// 操作取得。
33 | ///
34 | /// 操作名称。
35 | /// 操作タイプ情報。
36 | /// 非同期実行オブジェクト。
37 | /// 操作
38 | internal FriendlyOperation this[string operation, OperationTypeInfo operationTypeInfo, Async async]
39 | {
40 | get
41 | {
42 | if (async == null)
43 | {
44 | return new FriendlyOperationOwner(this, operationTypeInfo, operation).FriendlyOperation;
45 | }
46 | else
47 | {
48 | async.Initialize(this);
49 | return new AsyncFriendlyOperationOwner(async, operationTypeInfo, operation).FriendlyOperation;
50 | }
51 | }
52 | }
53 |
54 | ///
55 | /// 戻り値をAppVarで取得する通信。
56 | ///
57 | /// 通信タイプ。
58 | /// 操作タイプ情報。
59 | /// 操作名称。
60 | /// 引数。
61 | /// 変数。
62 | internal override AppVar SendAndReceive(ProtocolType protocolType, OperationTypeInfo operationTypeInfo, string operation, object[] arguments)
63 | {
64 | return FriendlyTalker.SendAndVarReceive(this, _friendlyConnector, protocolType, operationTypeInfo, null, _staticOperationTypeFullName, operation, arguments);
65 | }
66 |
67 | ///
68 | /// 戻り値を値で取得する通信処理。
69 | ///
70 | /// 通信タイプ。
71 | /// 操作タイプ情報。
72 | /// 操作名称。
73 | /// 引数。
74 | /// 値。
75 | internal override object SendAndValueReceive(ProtocolType protocolType, OperationTypeInfo operationTypeInfo, string operation, object[] arguments)
76 | {
77 | return FriendlyTalker.SendAndValueReceive(this, _friendlyConnector, protocolType, operationTypeInfo, null, _staticOperationTypeFullName, operation, arguments);
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly/NewInfo.cs:
--------------------------------------------------------------------------------
1 | #define CODE_ANALYSIS
2 | using System;
3 | using System.Diagnostics.CodeAnalysis;
4 |
5 | namespace Codeer.Friendly
6 | {
7 | #if ENG
8 | ///
9 | /// Used to provide information when instantiating an object in an application.
10 | /// Stores generation information and constructor parameters.
11 | ///
12 | #else
13 | ///
14 | /// アプリケーション内部でオブジェクトを生成するための情報を表すクラスです。
15 | /// 生成する型情報とコンストラクタ引数を保持します。
16 | ///
17 | #endif
18 | public class NewInfo
19 | {
20 | string _typeFullName;
21 | object[] _arguments;
22 |
23 | #if ENG
24 | ///
25 | /// Returns the type's full name.
26 | ///
27 | #else
28 | ///
29 | /// タイプフルネーム。
30 | ///
31 | #endif
32 | public string TypeFullName { get { return _typeFullName; } }
33 |
34 | #if ENG
35 | ///
36 | /// Returns the set of constructor parameters.
37 | ///
38 | #else
39 | ///
40 | /// 引数。
41 | ///
42 | #endif
43 | public object[] Arguments { get { return _arguments; } }
44 |
45 | #if ENG
46 | ///
47 | /// Constructor.
48 | ///
49 | /// Fully qualified type name of the generated object.
50 | ///
51 | /// Arguments to be passed to the object's constructor.
52 | /// Can be AppVars or serializable objects.
53 | ///
54 | #else
55 | ///
56 | /// コンストラクタ。
57 | ///
58 | /// 生成する型のタイプフルネーム。
59 | /// 生成引数。
60 | #endif
61 | public NewInfo(string typeFullName, params object[] arguments)
62 | {
63 | _typeFullName = typeFullName;
64 | _arguments = arguments;
65 | if (_arguments == null)
66 | {
67 | _arguments = new object[] { null };
68 | }
69 | }
70 |
71 | #if ENG
72 | ///
73 | /// Constractor.
74 | ///
75 | /// The type of the object to create.
76 | ///
77 | /// Arguments to be passed to the object's constructor.
78 | /// Can be AppVars or serializable objects.
79 | ///
80 | #else
81 | ///
82 | /// コンストラクタ。
83 | ///
84 | /// タイプ。
85 | /// 生成引数。
86 | #endif
87 | [SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
88 | public NewInfo(Type type, params object[] args) : this(type.FullName, args) { }
89 | }
90 |
91 | #if ENG
92 | ///
93 | /// Used to provide information when instantiating an object in an application.
94 | /// Stores generation information and constructor parameters.
95 | ///
96 | #else
97 | ///
98 | /// アプリケーション内部でオブジェクトを生成するための情報を表すクラスです。
99 | /// 生成する型情報とコンストラクタ引数を保持します。
100 | ///
101 | #endif
102 | public class NewInfo : NewInfo
103 | {
104 | #if ENG
105 | ///
106 | /// Constructor for NewInfo<T>, not NewInfo.
107 | /// Provides one way of indicating the desired type.
108 | ///
109 | ///
110 | /// Arguments to be passed to the object's constructor.
111 | /// Can be AppVars or serializable objects.
112 | ///
113 | #else
114 | ///
115 | /// コンストラクタ。
116 | ///
117 | /// 生成引数。
118 | #endif
119 | public NewInfo(params object[] args) : base(typeof(T), args) { }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly.Dynamic/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // このコードはツールによって生成されました。
4 | // ランタイム バージョン:4.0.30319.18052
5 | //
6 | // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7 | // コードが再生成されるときに損失したりします。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Codeer.Friendly.Dynamic.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。
17 | ///
18 | // このクラスは StronglyTypedResourceBuilder クラスが ResGen
19 | // または Visual Studio のようなツールを使用して自動生成されました。
20 | // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に
21 | // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Codeer.Friendly.Dynamic.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、
51 | /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Multiple Async arguments were found. Only one Async argument can be specified per call. に類似しているローカライズされた文字列を検索します。
65 | ///
66 | internal static string ErrorAsyncArgument {
67 | get {
68 | return ResourceManager.GetString("ErrorAsyncArgument", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Async cannot be used when instantiating an object. に類似しているローカライズされた文字列を検索します。
74 | ///
75 | internal static string ErrorInstanceCreateCantUseAsync {
76 | get {
77 | return ResourceManager.GetString("ErrorInstanceCreateCantUseAsync", resourceCulture);
78 | }
79 | }
80 |
81 | ///
82 | /// Multiple OperationTypeInfo arguments were found. Only one OperationTypeInfo argument can be specified per call. に類似しているローカライズされた文字列を検索します。
83 | ///
84 | internal static string ErrorOperationTypeInfoArgument {
85 | get {
86 | return ResourceManager.GetString("ErrorOperationTypeInfoArgument", resourceCulture);
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/Project/Codeer.Friendly.Dynamic/Inside/DynamicFriendlyOperationUtility.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Codeer.Friendly.Dynamic.Properties;
4 |
5 | namespace Codeer.Friendly.Dynamic.Inside
6 | {
7 | ///
8 | /// DynamicでFriendlyOperationを実行するためのユーティリティー。
9 | ///
10 | static class DynamicFriendlyOperationUtility
11 | {
12 | ///
13 | /// FriendlyOperationを取得。
14 | ///
15 | /// 対象。
16 | /// 操作名称。
17 | /// 非同期実行オブジェクト。
18 | /// 操作タイプ情報。
19 | /// FriendlyOperation。
20 | internal static FriendlyOperation GetFriendlyOperation(AppVar target, string name, Async async, OperationTypeInfo typeInfo)
21 | {
22 | if (async != null && typeInfo != null)
23 | {
24 | return target[name, typeInfo, async];
25 | }
26 | else if (async != null)
27 | {
28 | return target[name, async];
29 | }
30 | else if (typeInfo != null)
31 | {
32 | return target[name, typeInfo];
33 | }
34 | return target[name];
35 | }
36 |
37 | ///
38 | /// FriendlyOperationを取得。
39 | ///
40 | /// 対象。
41 | /// 操作名称。
42 | /// 非同期実行オブジェクト。
43 | /// 操作タイプ情報。
44 | /// FriendlyOperation。
45 | internal static FriendlyOperation GetFriendlyOperation(AppFriend target, string name, Async async, OperationTypeInfo typeInfo)
46 | {
47 | if (async != null && typeInfo != null)
48 | {
49 | return target[name, typeInfo, async];
50 | }
51 | else if (async != null)
52 | {
53 | return target[name, async];
54 | }
55 | else if (typeInfo != null)
56 | {
57 | return target[name, typeInfo];
58 | }
59 | return target[name];
60 | }
61 |
62 | ///
63 | /// 引数を解決する。
64 | ///
65 | /// 元引数。
66 | /// 非同期実行オブジェクト。
67 | /// 操作タイプ情報。
68 | /// 解決した後の引数。
69 | internal static object[] ResolveArguments(object[] srcArgs, out Async async, out OperationTypeInfo typeInfo)
70 | {
71 | return ResolveAsyncAndTypeInfo(srcArgs, out async, out typeInfo);
72 | }
73 |
74 | ///
75 | /// setter時に引数に値を加える。
76 | ///
77 | /// 元引数。
78 | /// setする値。
79 | /// 加えた後の引数。
80 | internal static object[] AddSetterValue(object[] argsSrc, object value)
81 | {
82 | object[] args = new object[argsSrc.Length + 1];
83 | Array.Copy(argsSrc, args, argsSrc.Length);
84 | args[argsSrc.Length] = value;
85 | return args;
86 | }
87 |
88 | ///
89 | /// 非同期実行オブジェクトと操作タイプ情報に関して引数を解決する。
90 | ///
91 | /// 元引数。
92 | /// 非同期実行オブジェクト。
93 | /// 操作タイプ情報。
94 | /// 解決した後の引数。
95 | private static object[] ResolveAsyncAndTypeInfo(object[] srcArgs, out Async async, out OperationTypeInfo typeInfo)
96 | {
97 | List