Пример #1
0
        public void Load(string file)
        {
            this.File = file;

            ImageProcessed = false;
            try {
                Nodes.Clear();

                var contentTemplate = GetContentTemplate(file);

                //parse the json into a model format
                Response = FigmaApiHelper.GetFigmaResponseFromFileContent(contentTemplate);

                //proceses all the views recursively
                foreach (var item in Response.document.children)
                {
                    ProcessNodeRecursively(item, null);
                }
            } catch (System.Net.WebException ex) {
                if (!AppContext.Current.IsApiConfigured)
                {
                    Console.Error.WriteLine($"Cannot connect to Figma server: TOKEN not configured.");
                }
                else
                {
                    Console.Error.WriteLine($"Cannot connect to Figma server: wrong TOKEN?");
                }

                Console.WriteLine(ex);
            } catch (Exception ex) {
                Console.WriteLine($"Error reading remote resources. Ensure you added NewtonSoft nuget or cannot parse the to json?");
                Console.WriteLine(ex);
            }
        }
Пример #2
0
        public void LocalFileTest()
        {
            var file = Path.Combine(currentPath, fileExample);
            var data = File.ReadAllText(file);
            var doc  = FigmaApiHelper.GetFigmaResponseFromFileContent(data);

            Assert.IsNotNull(file);
        }