Exemple #1
0
        private static async Task <SketchMeta> LoadMetaDataAsync(ISketchArchive sketchArchive)
        {
            using (var infoStream = sketchArchive.OpenFile("meta.json"))
            {
                var json       = JObject.Parse(await infoStream.ReadToStringAsync().ConfigureAwait(false));
                var appversion = double.Parse((string)json["appVersion"], CultureInfo.InvariantCulture);
                // The first version of the open Sketch format doesn't have compatibilityVersion field.
                // ref TestProject.sketch. 2017-12-06 anette
                var compatibilityVersion = json["compatibilityVersion"] != null?int.Parse((string)json["compatibilityVersion"]) : -1;

                var version = int.Parse((string)json["version"]);
                var build   = (int)json["build"];
                var variant = (string)json["variant"];

                return(new SketchMeta()
                {
                    AppVersion = appversion,
                    CompatibilityVersion =
                        compatibilityVersion,
                    Version = version,
                    Build = build,
                    Variant = variant
                });
            }
        }
Exemple #2
0
        public static void Check(string sketchFilePath,
                                 ISketchArchive sketchArchive,
                                 ILogger log)
        {
            var meta = LoadMetaDataAsync(sketchArchive).Result;

            log.Info("You are running Sketch2Fuse compatible with Sketch format " +
                     "version " + SketchCompatibilityVersion);
            log.Info("Converting " + sketchFilePath + " created with Sketch "
                     + meta.AppVersion + " variant " + meta.Variant + " build" +
                     meta.Version);

            if (meta.CompatibilityVersion > SketchCompatibilityVersion)
            {
                log.Warning(
                    "The sketch file you are converting to UX has been created with a newer version of Sketch than the converter supports.");
            }
            else if (meta.CompatibilityVersion < SketchCompatibilityVersion)
            {
                log.Warning(
                    "The sketch file was created with an older version than Sketch2Fuse supports, please open the file in Sketch and save it as with the newer version if you experence any problems.");
            }
        }
Exemple #3
0
 private async Task <SketchDocument> ParseAsync(ISketchArchive stream)
 {
     return(await new SketchParserInternal(stream, _log).ParseDocumentAsync());
 }
Exemple #4
0
 public SketchDocument Parse(ISketchArchive stream)
 {
     return(ParseAsync(stream).Result);
 }
 public SketchParserInternal(ISketchArchive archive, ILogger log)
 {
     _archive = archive;
     _log     = log;
 }