예제 #1
0
 /// <summary>
 /// 戻り値をAppVarで取得する通信。
 /// </summary>
 /// <param name="invoker">呼び出し元。</param>
 /// <param name="friendlyConnector">アプリケーションとの接続者。</param>
 /// <param name="protocolType">通信タイプ。</param>
 /// <param name="operationTypeInfo">操作タイプ情報。</param>
 /// <param name="varAddress">変数アドレス。</param>
 /// <param name="typeFullName">タイプフルネーム。</param>
 /// <param name="operation">操作名称。</param>
 /// <param name="arguments">引数。</param>
 /// <returns>変数。</returns>
 internal static AppVar SendAndVarReceive(object invoker, IFriendlyConnector friendlyConnector, ProtocolType protocolType,
     OperationTypeInfo operationTypeInfo, VarAddress varAddress, string typeFullName, string operation, object[] arguments)
 {
     object value = SendAndValueReceive(invoker, friendlyConnector, protocolType, operationTypeInfo, varAddress, typeFullName, operation, arguments);
     VarAddress retHandle = value as VarAddress;
     return (retHandle == null) ? (null) : (new AppVar(friendlyConnector, retHandle));
 }
예제 #2
0
        /// <summary>
        /// 戻り値をAppVarで取得する通信。
        /// </summary>
        /// <param name="invoker">呼び出し元。</param>
        /// <param name="friendlyConnector">アプリケーションとの接続者。</param>
        /// <param name="protocolType">通信タイプ。</param>
        /// <param name="operationTypeInfo">操作タイプ情報。</param>
        /// <param name="varAddress">変数アドレス。</param>
        /// <param name="typeFullName">タイプフルネーム。</param>
        /// <param name="operation">操作名称。</param>
        /// <param name="arguments">引数。</param>
        /// <returns>変数。</returns>
        internal static AppVar SendAndVarReceive(object invoker, IFriendlyConnector friendlyConnector, ProtocolType protocolType,
                                                 OperationTypeInfo operationTypeInfo, VarAddress varAddress, string typeFullName, string operation, object[] arguments)
        {
            object     value     = SendAndValueReceive(invoker, friendlyConnector, protocolType, operationTypeInfo, varAddress, typeFullName, operation, arguments);
            VarAddress retHandle = value as VarAddress;

            return((retHandle == null) ? (null) : (new AppVar(friendlyConnector, retHandle)));
        }
예제 #3
0
 /// <summary>
 /// AppVarがあれば、Varハンドルに変換。
 /// </summary>
 /// <param name="friendlyConnector">アプリケーションとの接続者。</param>
 /// <param name="arguments">引数。</param>
 /// <returns>変換結果。</returns>
 static object[] ConvertAppVar(IFriendlyConnector friendlyConnector, object[] arguments)
 {
     object[] argsTmp = new object[arguments.Length];
     for (int i = 0; i < arguments.Length; i++)
     {
         argsTmp[i] = ConvertAppVar(friendlyConnector, arguments[i], i);
     }
     return(argsTmp);
 }
예제 #4
0
        /// <summary>
        /// 戻り値を値で取得する通信処理。
        /// 通信基本形。
        /// </summary>
        /// <param name="invoker">呼び出し元。</param>
        /// <param name="friendlyConnector">アプリケーションとの接続者。</param>
        /// <param name="protocolType">通信タイプ。</param>
        /// <param name="operationTypeInfo">操作タイプ情報。</param>
        /// <param name="varAddress">変数アドレス。</param>
        /// <param name="typeFullName">タイプフルネーム。</param>
        /// <param name="operation">操作名称。</param>
        /// <param name="arguments">引数。</param>
        /// <returns>値。</returns>
        internal static object SendAndValueReceive(object invoker, IFriendlyConnector friendlyConnector, ProtocolType protocolType,
            OperationTypeInfo operationTypeInfo, VarAddress varAddress, string typeFullName, string operation, object[] arguments)
        {
            //配列の場合の調整
            arguments = AdjustArrayArgs(arguments);

            ReturnInfo ret = friendlyConnector.SendAndReceive(new ProtocolInfo(protocolType, operationTypeInfo, varAddress, typeFullName, operation, ConvertAppVar(friendlyConnector, arguments)));
            GC.KeepAlive(invoker);
            GC.KeepAlive(friendlyConnector);
            for (int i = 0; i < arguments.Length; i++)
            {
                if (arguments[i] != null)
                {
                    GC.KeepAlive(arguments[i]);
                }
            }
            if (ret.Exception != null)
            {
                throw new FriendlyOperationException(ret.Exception);
            }
            return ret.ReturnValue;
        }
예제 #5
0
        /// <summary>
        /// AppVarであれば、Varハンドルに変換。
        /// </summary>
        /// <param name="friendlyConnector">アプリケーションとの接続者。</param>
        /// <param name="index">引数のインデックス。</param>
        /// <param name="arg">引数。</param>
        /// <returns>変換結果。</returns>
        static object ConvertAppVar(IFriendlyConnector friendlyConnector, object arg, int index)
        {
            AppVar appVar = null;

            {
                IAppVarSelf selft = arg as IAppVarSelf;
                if (selft != null)
                {
                    appVar = selft.CodeerFriendlyAppVar;
                }
            }
            if (appVar == null)
            {
                IAppVarOwner owner = arg as IAppVarOwner;
                if (owner != null)
                {
                    appVar = owner.AppVar;
                }
            }
            if (appVar == null)
            {
                appVar = arg as AppVar;
            }
            if (appVar == null)
            {
                if ((arg as IDefinition) != null)
                {
                    throw new FriendlyOperationException(string.Format(CultureInfo.CurrentCulture, Resources.ErrorDefinitionArgument, index + 1));
                }
                return(arg);
            }

            //違う変数プールに属する変数は使用できない
            if (!object.ReferenceEquals(friendlyConnector.Identity, appVar.FriendlyConnector.Identity))
            {
                throw new FriendlyOperationException(string.Format(CultureInfo.CurrentCulture, Resources.ErrorDifferentAppFriendVar, index + 1));
            }
            return(appVar.VarAddress);
        }
예제 #6
0
        /// <summary>
        /// 戻り値を値で取得する通信処理。
        /// 通信基本形。
        /// </summary>
        /// <param name="invoker">呼び出し元。</param>
        /// <param name="friendlyConnector">アプリケーションとの接続者。</param>
        /// <param name="protocolType">通信タイプ。</param>
        /// <param name="operationTypeInfo">操作タイプ情報。</param>
        /// <param name="varAddress">変数アドレス。</param>
        /// <param name="typeFullName">タイプフルネーム。</param>
        /// <param name="operation">操作名称。</param>
        /// <param name="arguments">引数。</param>
        /// <returns>値。</returns>
        internal static object SendAndValueReceive(object invoker, IFriendlyConnector friendlyConnector, ProtocolType protocolType,
                                                   OperationTypeInfo operationTypeInfo, VarAddress varAddress, string typeFullName, string operation, object[] arguments)
        {
            //配列の場合の調整
            arguments = AdjustArrayArgs(arguments);

            ReturnInfo ret = friendlyConnector.SendAndReceive(new ProtocolInfo(protocolType, operationTypeInfo, varAddress, typeFullName, operation, ConvertAppVar(friendlyConnector, arguments)));

            GC.KeepAlive(invoker);
            GC.KeepAlive(friendlyConnector);
            for (int i = 0; i < arguments.Length; i++)
            {
                if (arguments[i] != null)
                {
                    GC.KeepAlive(arguments[i]);
                }
            }
            if (ret.Exception != null)
            {
                throw new FriendlyOperationException(ret.Exception);
            }
            return(ret.ReturnValue);
        }
예제 #7
0
 /// <summary>
 /// AppVarがあれば、Varハンドルに変換。
 /// </summary>
 /// <param name="friendlyConnector">アプリケーションとの接続者。</param>
 /// <param name="arguments">引数。</param>
 /// <returns>変換結果。</returns>
 static object[] ConvertAppVar(IFriendlyConnector friendlyConnector, object[] arguments)
 {
     object[] argsTmp = new object[arguments.Length];
     for (int i = 0; i < arguments.Length; i++)
     {
         argsTmp[i] = ConvertAppVar(friendlyConnector, arguments[i], i);
     }
     return argsTmp;
 }
예제 #8
0
        /// <summary>
        /// AppVarであれば、Varハンドルに変換。
        /// </summary>
        /// <param name="friendlyConnector">アプリケーションとの接続者。</param>
        /// <param name="index">引数のインデックス。</param>
        /// <param name="arg">引数。</param>
        /// <returns>変換結果。</returns>
        static object ConvertAppVar(IFriendlyConnector friendlyConnector, object arg, int index)
        {
            AppVar appVar = null;
            {
                IAppVarSelf selft = arg as IAppVarSelf;
                if (selft != null)
                {
                    appVar = selft.CodeerFriendlyAppVar;
                }
            }
            if (appVar == null)
            {
                IAppVarOwner owner = arg as IAppVarOwner;
                if (owner != null)
                {
                    appVar = owner.AppVar;
                }
            }
            if (appVar == null)
            {
                appVar = arg as AppVar;
            }
            if (appVar == null)
            {
                if ((arg as IDefinition) != null)
                {
                    throw new FriendlyOperationException(string.Format(CultureInfo.CurrentCulture, Resources.ErrorDefinitionArgument, index + 1));
                }
                return arg;
            }

            //違う変数プールに属する変数は使用できない
            if (!object.ReferenceEquals(friendlyConnector.Identity, appVar.FriendlyConnector.Identity))
            {
                throw new FriendlyOperationException(string.Format(CultureInfo.CurrentCulture, Resources.ErrorDifferentAppFriendVar, index + 1));
            }
            return appVar.VarAddress;
        }
예제 #9
0
 /// <summary>
 /// コンストラクタ。
 /// </summary>
 /// <param name="friendlyConnector">操作送信者。</param>
 /// <param name="typeFullName">タイプフルネーム。</param>
 internal StaticOperationTalker(IFriendlyConnector friendlyConnector, string typeFullName)
 {
     _friendlyConnector           = friendlyConnector;
     _staticOperationTypeFullName = typeFullName;
 }
예제 #10
0
파일: AppVar.cs 프로젝트: bangush/Friendly
 /// <summary>
 /// コンストラクタ。
 /// </summary>
 /// <param name="friendlyConnector">アプリケーションとの接続クラス。</param>
 /// <param name="varAddress">変数アドレス</param>
 internal AppVar(IFriendlyConnector friendlyConnector, VarAddress varAddress)
 {
     _friendlyConnector = friendlyConnector;
     _varAddress        = varAddress;
 }
 /// <summary>
 /// コンストラクタ。
 /// </summary>
 /// <param name="friendlyConnector">操作送信者。</param>
 /// <param name="typeFullName">タイプフルネーム。</param>
 internal StaticOperationTalker(IFriendlyConnector friendlyConnector, string typeFullName)
 {
     _friendlyConnector = friendlyConnector;
     _staticOperationTypeFullName = typeFullName;
 }
예제 #12
0
		/// <summary>
        /// コンストラクタ。
		/// </summary>
        /// <param name="friendlyConnector">アプリケーションとの接続クラス。</param>
        /// <param name="varAddress">変数アドレス</param>
        internal AppVar(IFriendlyConnector friendlyConnector, VarAddress varAddress)
		{
            _friendlyConnector = friendlyConnector;
            _varAddress = varAddress;
		}