Exemple #1
0
        public async Task <CoreByLevelsOutputs> Handler(CoreByLevelsInputs 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 <CoreByLevelsInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <CoreByLevelsInputs, CoreByLevelsOutputs>(store, CoreByLevels.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
        /// <summary>
        /// Creates a building service core including stair enclosures, lift shafts, a mechanical shaft, and restrooms with reference to the quantity and area of the building levels.
        /// </summary>
        /// <param name="model">The input model.</param>
        /// <param name="input">The arguments to the execution.</param>
        /// <returns>A CoreByLevelsOutputs instance containing computed results and the model with any new elements.</returns>
        public static CoreByLevelsOutputs Execute(Dictionary <string, Model> inputModels, CoreByLevelsInputs input)
        {
            var levels = new List <LevelPerimeter>();

            inputModels.TryGetValue("Levels", out var model);
            if (model == null || model.AllElementsOfType <LevelPerimeter>().Count() == 0)
            {
                throw new ArgumentException("No LevelPerimeters found.");
            }
            levels.AddRange(model.AllElementsOfType <LevelPerimeter>());
            var coreMaker = new CoreMaker(levels, input.Setback, input.Rotation);
            var outputs   = new CoreByLevelsOutputs(coreMaker.Restrooms.Count(), coreMaker.LiftQuantity);

            outputs.Model.AddElement(new Exclusion(coreMaker.Perimeter, coreMaker.Elevation, Guid.NewGuid(), "Core Exclusion"));
            foreach (var room in coreMaker.Restrooms)
            {
                outputs.Model.AddElement(room);
            }
            foreach (var mech in coreMaker.Mechanicals)
            {
                outputs.Model.AddElement(mech);
            }
            foreach (var stair in coreMaker.Stairs)
            {
                outputs.Model.AddElement(stair);
            }
            foreach (var lift in coreMaker.Lifts)
            {
                outputs.Model.AddElement(lift);
            }
            return(outputs);
        }