public static async Task<Tuple<DateTime?, DateTime?>> ReadCommitMetadata(CatalogWriterBase writer, CancellationToken cancellationToken)
        {
            DateTime? lastCreated = null;
            DateTime? lastEdited = null;

            string json = await writer.Storage.LoadString(writer.RootUri, cancellationToken);

            if (json != null)
            {
                JObject obj;

                using (JsonReader jsonReader = new JsonTextReader(new StringReader(json)))
                {
                    jsonReader.DateParseHandling = DateParseHandling.None;
                    obj = JObject.Load(jsonReader);
                }

                JToken t1;
                if (obj.TryGetValue("nuget:lastCreated", out t1))
                {
                    lastCreated = DateTime.Parse(t1.ToString(), null, DateTimeStyles.RoundtripKind);
                }

                JToken t2;
                if (obj.TryGetValue("nuget:lastEdited", out t2))
                {
                    lastEdited = DateTime.Parse(t2.ToString(), null, DateTimeStyles.RoundtripKind);
                }
            }

            return Tuple.Create(lastCreated, lastEdited);
        }
Beispiel #2
0
        public static async Task <Tuple <DateTime?, DateTime?> > ReadCommitMetadata(CatalogWriterBase writer)
        {
            DateTime?lastCreated = null;
            DateTime?lastEdited  = null;

            string json = await writer.Storage.LoadString(writer.RootUri);

            if (json != null)
            {
                JObject obj;

                using (JsonReader jsonReader = new JsonTextReader(new StringReader(json)))
                {
                    jsonReader.DateParseHandling = DateParseHandling.None;
                    obj = JObject.Load(jsonReader);
                }

                JToken t1;
                if (obj.TryGetValue("nuget:lastCreated", out t1))
                {
                    lastCreated = DateTime.Parse(t1.ToString(), null, DateTimeStyles.RoundtripKind);
                }

                JToken t2;
                if (obj.TryGetValue("nuget:lastEdited", out t2))
                {
                    lastEdited = DateTime.Parse(t2.ToString(), null, DateTimeStyles.RoundtripKind);
                }
            }

            return(Tuple.Create(lastCreated, lastEdited));
        }
Beispiel #3
0
        public static async Task <CommitMetadata> ReadCommitMetadata(CatalogWriterBase writer, CancellationToken cancellationToken)
        {
            CommitMetadata commitMetadata = new CommitMetadata();

            string json = await writer.Storage.LoadStringAsync(writer.RootUri, cancellationToken);

            if (json != null)
            {
                JObject obj;

                using (JsonReader jsonReader = new JsonTextReader(new StringReader(json)))
                {
                    jsonReader.DateParseHandling = DateParseHandling.None;
                    obj = JObject.Load(jsonReader);
                }

                commitMetadata.LastCreated = TryGetDateTimeFromJObject(obj, "nuget:lastCreated");
                commitMetadata.LastEdited  = TryGetDateTimeFromJObject(obj, "nuget:lastEdited");
                commitMetadata.LastDeleted = TryGetDateTimeFromJObject(obj, "nuget:lastDeleted");
            }

            return(commitMetadata);
        }
        public static async Task<CommitMetadata> ReadCommitMetadata(CatalogWriterBase writer, CancellationToken cancellationToken)
        {
            CommitMetadata commitMetadata = new CommitMetadata();

            string json = await writer.Storage.LoadString(writer.RootUri, cancellationToken);

            if (json != null)
            {
                JObject obj;

                using (JsonReader jsonReader = new JsonTextReader(new StringReader(json)))
                {
                    jsonReader.DateParseHandling = DateParseHandling.None;
                    obj = JObject.Load(jsonReader);
                }

                commitMetadata.LastCreated = TryGetDateTimeFromJObject(obj, "nuget:lastCreated");
                commitMetadata.LastEdited = TryGetDateTimeFromJObject(obj, "nuget:lastEdited");
                commitMetadata.LastDeleted = TryGetDateTimeFromJObject(obj, "nuget:lastDeleted");
            }

            return commitMetadata;
        }