Esempio n. 1
0
        public async Task <EnvelopeByPolylineOutputs> Handler(EnvelopeByPolylineInputs args, ILambdaContext context)
        {
            // Preload dependencies (if they exist),
            // so that they are available during model deserialization.

            var sw          = System.Diagnostics.Stopwatch.StartNew();
            var asmLocation = this.GetType().Assembly.Location;
            var asmDir      = Path.GetDirectoryName(asmLocation);

            // Explicitly load the dependencies project, it might have types
            // that aren't used in the function but are necessary for correct
            // deserialization.
            var asmName = Path.GetFileNameWithoutExtension(asmLocation);
            var depPath = Path.Combine(asmDir, $"{asmName}.Dependencies.dll");

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

            // Load all reference assemblies.
            Console.WriteLine($"Loading all referenced assemblies.");
            foreach (var asm in this.GetType().Assembly.GetReferencedAssemblies())
            {
                try
                {
                    Assembly.Load(asm);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Failed to load {asm.FullName}");
                    Console.WriteLine(e.Message);
                }
            }
            sw.Stop();
            Console.WriteLine($"Time to load assemblies: {sw.Elapsed.TotalSeconds})");

            if (this.store == null)
            {
                this.store = new S3ModelStore <EnvelopeByPolylineInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <EnvelopeByPolylineInputs, EnvelopeByPolylineOutputs>(store, EnvelopeByPolyline.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
Esempio n. 2
0
        /// <summary>
        /// Generate a volume of a given width
        /// </summary>
        /// <param name="model">The input model.</param>
        /// <param name="input">The arguments to the execution.</param>
        /// <returns>A EnvelopeByPolylineOutputs instance containing computed results and the model with any new elements.</returns>
        public static EnvelopeByPolylineOutputs Execute(Dictionary <string, Model> inputModels, EnvelopeByPolylineInputs input)
        {
            /// Your code here.
            var height    = 1.0;
            var volume    = input.Length * input.Width * height;
            var output    = new EnvelopeByPolylineOutputs(volume);
            var rectangle = Polygon.Rectangle(input.Length, input.Width);
            var mass      = new Mass(rectangle, height);

            output.Model.AddElement(mass);
            return(output);
        }