コード例 #1
0
        private bool TryGetDefinitionFromFileSystem(FileInfo file, out RelationDefinition definition, out DateTime lastWrite)
        {
            if (file.Exists)
            {
                lastWrite = file.LastWriteTimeUtc;
                using (var reader = new StreamReader(file.FullName, Encoding.UTF8))
                    definition = RelationDefinition.FromJson(reader.ReadToEnd());
                return(true);
            }

            lastWrite  = DateTime.MinValue;
            definition = null;
            return(false);
        }
コード例 #2
0
 private static RelationDefinition ReadDefinition(ZipFile zip, string entry, out DateTime lastModified)
 {
     if (zip.ContainsEntry(entry))
     {
         var zipEntry = zip[entry];
         lastModified = zipEntry.LastModified.ToUniversalTime();
         using (var s = zipEntry.OpenReader()) {
             using (var r = new StreamReader(s, ZipEncoding))
                 return(RelationDefinition.FromJson(r.ReadToEnd()));
         }
     }
     else
     {
         var oldEntry = Path.ChangeExtension(entry, "yaml");
         var zipEntry = zip[oldEntry];
         lastModified = zipEntry.LastModified.ToUniversalTime();
         using (var s = zipEntry.OpenReader()) {
             using (var r = new StreamReader(s, ZipEncoding))
                 return(RelationDefinition.Deserialize(r));
         }
     }
 }