Пример #1
0
        public async Task <SVGElementTestOutputs> Handler(SVGElementTestInputs args, ILambdaContext context)
        {
            if (this.store == null)
            {
                // Preload the dependencies (if they exist),
                // so that they are available during model deserialization.
                var asmLocation = this.GetType().Assembly.Location;
                var asmDir      = Path.GetDirectoryName(asmLocation);
                var asmName     = Path.GetFileNameWithoutExtension(asmLocation);
                var depPath     = Path.Combine(asmDir, $"{asmName}.Dependencies.dll");

                if (File.Exists(depPath))
                {
                    Console.WriteLine($"Loading dependencies from assembly: {depPath}...");
                    Assembly.LoadFrom(depPath);
                    Console.WriteLine("Dependencies assembly loaded.");
                }

                this.store = new S3ModelStore <SVGElementTestInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <SVGElementTestInputs, SVGElementTestOutputs>(store, SVGElementTest.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
Пример #2
0
        /// <summary>
        /// The SVGElementTest function.
        /// </summary>
        /// <param name="model">The input model.</param>
        /// <param name="input">The arguments to the execution.</param>
        /// <returns>A SVGElementTestOutputs instance containing computed results and the model with any new elements.</returns>
        public static SVGElementTestOutputs Execute(Dictionary <string, Model> inputModels, SVGElementTestInputs input)
        {
            var outputs = new SVGElementTestOutputs();
            // var svgFile = input.SVGFile.LocalFilePath;
            // var fileName = Path.GetFileNameWithoutExtension(svgFile);
            // var svgContent = File.ReadAllText(svgFile);
            // var svgElement = new SVGGraphic(svgContent, Guid.NewGuid(), fileName);
            // outputs.Model.AddElement(svgElement);
            var rect = Polygon.Rectangle(input.Length, input.Width);
            var svg  = new SVG();

            svg.AddGeometry(Polygon.Rectangle(10, 10), new SVG.Style
            {
                EnableFill   = false,
                EnableStroke = false
            });
            svg.AddGeometry(rect, new SVG.Style
            {
                Fill        = Colors.Red,
                Stroke      = Colors.Blue,
                StrokeWidth = input.StrokeWidth
            });
            var svgElement2 = new SVGGraphic(svg.SvgString(), Guid.NewGuid(), "Rectangle");

            outputs.Model.AddElement(svgElement2);
            return(outputs);
        }