Example #1
0
 public CommandPresenter(ICommandActivity commandActivity, IScreenDrawer screenDrawer, string mode)
 {
     baseDirectory        = Android.App.Application.Context.GetString(Resource.String.JSONObjectsDirectory);
     this.commandActivity = commandActivity;
     this.screenDrawer    = screenDrawer;
     this.socket          = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     SetAverageSelection();
 }
        /// <summary>
        /// Gets the <see cref="CommandValue"/>  from the activity.
        /// </summary>
        /// <param name="activity">The command activity.</param>
        /// <typeparam name="T">The underlying value type for the <see cref="CommandValue"/>.</typeparam>
        /// <returns>The <see cref="CommandValue"/> from the activity.</returns>
        public static CommandValue <T> GetCommandValue <T>(this ICommandActivity activity)
        {
            object value = activity?.Value;

            if (value == null)
            {
                return(null);
            }
            else if (value is CommandValue <T> commandValue)
            {
                return(commandValue);
            }
            else
            {
                return(((JObject)value).ToObject <CommandValue <T> >());
            }
        }