/**
         * <summary>
         * Wraps task result bean into a protocol message.</summary>
         *
         * <param name="bean">Task result that need to be wrapped.</param>
         * <returns>Wrapped message.</returns>
         */
        private static ProtoTaskBean WrapTaskResult(GridClientTaskResultBean bean)
        {
            ProtoTaskBean.Builder builder = ProtoTaskBean.CreateBuilder()
                                            .SetTaskId(bean.TaskId)
                                            .SetFinished(bean.IsFinished);

            if (bean.Error != null)
            {
                builder.SetError(bean.Error);
            }

            if (bean.Result != null)
            {
                builder.SetResultBean(WrapObject(bean.Result));
            }

            return(builder.Build());
        }
        /**
         * <summary>
         * Unwraps protocol message to a task result bean.</summary>
         *
         * <param name="bean">Protocol message to unwrap.</param>
         * <returns>Unwrapped message.</returns>
         */
        private static GridClientTaskResultBean WrapTaskResult(ProtoTaskBean bean)
        {
            GridClientTaskResultBean res = new GridClientTaskResultBean();

            res.TaskId     = bean.TaskId;
            res.IsFinished = bean.Finished;

            if (bean.HasError)
            {
                res.Error = bean.Error;
            }

            if (bean.HasResultBean)
            {
                res.Result = WrapObject(bean.ResultBean);
            }

            return(res);
        }