public bool TryRead <T>(string filepath, out T model, out string message) where T : class, new()
        {
            bool b = false;

            model   = null;
            message = string.Empty;
            try
            {
                if (File.Exists(filepath))
                {
                    //string filecontents = File.ReadAllText(filepath);
                    //if (!string.IsNullOrWhiteSpace(filecontents))
                    //{
                    //    model = JsonConvert.DeserializeObject<T>(filecontents);
                    //    b = true;
                    //}
                    model = GenericObjectManager.ReadGenericItem <T>(filepath);
                    b     = true;
                }
            }
            catch (Exception ex)
            {
                message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
            }

            return(b);
        }
        private void UploadStateMachine()
        {
            bool b = false;

            if (DataService.TryLocateFile(out FileInfo info))
            {
                try
                {
                    if (info.Extension.Equals(".xml", StringComparison.OrdinalIgnoreCase))
                    {
                        Machine = GenericObjectManager.ReadGenericItem <StateMachine>(info.FullName);
                        b       = true;
                    }
                    else if (info.Extension.Equals(".json", StringComparison.OrdinalIgnoreCase))
                    {
                        string text = File.ReadAllText(info.FullName);
                        Machine = JsonConvert.DeserializeObject <StateMachine>(text);
                        b       = true;
                    }
                    if (b)
                    {
                        //Machine.SetState();
                        //Workflow = new WorkflowViewModel(Machine);
                    }
                }
                catch (Exception ex)
                {
                    string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                    MessageBox.Show(message);
                }
            }
        }