コード例 #1
0
        protected async Task LoadFromFileAsync(StorageFile file, string token, bool assignPayloadWithoutLoading)
        {
            this.Name      = file.Name;
            this.File      = file;
            this.Token     = token;
            this.IsUnsaved = false;

            var savedActivity = SaveableUserActivity.FromJson(await FileIO.ReadTextAsync(file));

            Payload    = savedActivity.Payload;
            Properties = savedActivity.Properties;

            await InitializeAsync();
        }
コード例 #2
0
        public static SaveableUserActivity FromJson(string json)
        {
            SaveableUserActivity answer;

            try
            {
                answer = JsonConvert.DeserializeObject <SaveableUserActivity>(json);
            }
            catch { answer = new SaveableUserActivity(); }
            if (answer.Properties == null)
            {
                answer.Properties = new UserActivityProperties();
            }
            if (answer.Payload == null)
            {
                answer.Payload = new UserActivityPayload();
            }
            return(answer);
        }