/// <summary>
        /// Adds a Restriction to a Product's Measurement.
        /// </summary>
        /// <param name="addRestrictionToProductMeasurementMV">AddRestrictionToProductMeasurementModelView with the Product's and Measurement's persistence identifiers
        /// as well as the Restriction's data.</param>
        /// <returns>GetProductModelView with updated Product information.</returns>
        /// <exception cref="ResourceNotFoundException">Thrown when either the Product or the Measurement could not be found.</exception>
        public GetProductModelView addRestrictionToProductMeasurement(AddMeasurementRestrictionModelView addRestrictionToProductMeasurementMV)
        {
            ProductRepository productRepository = PersistenceContext.repositories().createProductRepository();

            Product product = productRepository.find(addRestrictionToProductMeasurementMV.productId);

            if (product == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_PRODUCT_BY_ID, addRestrictionToProductMeasurementMV.productId));
            }

            Measurement measurement = product.productMeasurements
                                      .Where(pm => pm.measurementId == addRestrictionToProductMeasurementMV.measurementId).Select(pm => pm.measurement).SingleOrDefault();

            if (measurement == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_MEASUREMENT_BY_ID, addRestrictionToProductMeasurementMV.measurementId));
            }

            Algorithm algorithm = new AlgorithmFactory().createAlgorithm(addRestrictionToProductMeasurementMV.restriction.algorithmId);

            if (addRestrictionToProductMeasurementMV.restriction.inputValues != null)
            {
                algorithm.setInputValues(InputValueModelViewService.toDictionary(addRestrictionToProductMeasurementMV.restriction.inputValues));
            }
            algorithm.ready();
            Restriction restriction = new Restriction(addRestrictionToProductMeasurementMV.restriction.description, algorithm);

            product.addMeasurementRestriction(measurement, restriction);

            product = productRepository.update(product);

            return(ProductModelViewService.fromEntity(product));
        }
Example #2
0
        public static bool Calc(SensorGroup gp, IList <SensorAcqResult> acqs)
        {
            var alv = gp.GetVirtualItems();

            if (alv.Any())
            {
                foreach (var groupItem in alv)
                {
                    if (groupItem.VirtualGroup.GroupType == GroupType.VirtualSensor)
                    {
                        AlgorithmFactory.CreateAlgorithm(groupItem.VirtualGroup).CalcData(acqs);

                        groupItem.Value = (from acq in acqs
                                           where acq.Sensor.SensorID == groupItem.VirtualGroup.VirtualSensor.SensorID
                                           select acq).FirstOrDefault();
                    }
                }

                return(AlgorithmFactory.CreateAlgorithm(gp).CalcData(acqs));
            }
            else
            {
                return(AlgorithmFactory.CreateAlgorithm(gp).CalcData(acqs));
            }
        }
        static void Main(string[] args)
        {
            //test funkcnosti iteratoru pres algoritmy
            foreach (var item in AlgorithmFactory.Algorithms)
            {
                item.AssignCase();
            }
            //test funkcnosti iteratoru pres popisy algoritmu
            foreach (var item in AlgorithmFactory.Descriptions)
            {
                Console.WriteLine(item);
            }
            try
            {
                AlgorithmFactory.GetSelectionAlgorithm(1).AssignCase();
                AlgorithmFactory.GetSelectionAlgorithm(10).AssignCase();
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine("Exception OK: {0}", e.Message);
            }


            Console.ReadKey();
        }
Example #4
0
        // FIXME: This method keeps submitting the last entered values from the form
        // each time the page is refreshed.
        public void OnPostGenerate(int rows, int columns, Algorithm algorithm, Format format)
        {
            Grid       grid             = new Grid(new Point(columns, rows));
            IAlgorithm linkingAlgorithm = AlgorithmFactory.GetAlgorithm(algorithm, grid);

            linkingAlgorithm.Apply();

            DisplayFormat = format;

            switch (format)
            {
            case Format.Ascii:
                Maze += grid.ToString();
                break;

            case Format.Png:
                grid.ToPng();
                // FIXME: Need an expert on serving static files in ASP.NET Core to help me get this image source to work.
                ImageSource = @"~/StaticFiles/maze.png";
                break;

            default:
                // REVIEW: What would be better here is displaying a flash message at the GUI.
                throw new ArgumentException("Given format does not match a known enum.");
            }
        }
 public ApiBootstrapper(ComputeServer computeServer, WorkerPool workerPool, AlgorithmFactory algoFactory)
 {
     this.computeServer = computeServer;
     this.workerPool = workerPool;
     this.algoFactory = algoFactory;
     serverType = ServerTypes.Compute;
 }
        /// <summary>
        /// Adds a Restriction to a Product's complementary Product.
        /// </summary>
        /// <param name="addRestrictionToProductComponentMV">AddRestrictionToProductComponentModelView containing the data of the Restriction instance being added.</param>
        /// <returns>GetProductModelView with updated Product information.</returns>
        /// <exception cref="ResourceNotFoundException">Thrown when either of the Products could not be found.</exception>
        public GetProductModelView addRestrictionToProductComponent(AddComponentRestrictionModelView addRestrictionToProductComponentMV)
        {
            ProductRepository productRepository = PersistenceContext.repositories().createProductRepository();
            Product           parentProduct     = productRepository.find(addRestrictionToProductComponentMV.fatherProductId);

            if (parentProduct == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_PRODUCT_BY_ID, addRestrictionToProductComponentMV.fatherProductId));
            }

            //filter product's components rather than accessing the repository
            Product childProduct = parentProduct.components
                                   .Where(component => component.complementaryProduct.Id == addRestrictionToProductComponentMV.childProductId)
                                   .Select(component => component.complementaryProduct).SingleOrDefault();

            if (childProduct == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_PRODUCT_BY_ID, addRestrictionToProductComponentMV.childProductId));
            }

            Algorithm algorithm = new AlgorithmFactory().createAlgorithm(addRestrictionToProductComponentMV.restriction.algorithmId);

            if (addRestrictionToProductComponentMV.restriction.inputValues != null)
            {
                algorithm.setInputValues(InputValueModelViewService.toDictionary(addRestrictionToProductComponentMV.restriction.inputValues));
            }
            algorithm.ready();
            Restriction restriction = new Restriction(addRestrictionToProductComponentMV.restriction.description, algorithm);

            parentProduct.addComplementaryProductRestriction(childProduct, restriction);
            parentProduct = productRepository.update(parentProduct);
            return(ProductModelViewService.fromEntity(parentProduct));
        }
Example #7
0
        /// <summary>
        /// Returns an instance of GetAlgorithmModelView representing the instance of Algorithm.
        /// </summary>
        /// <param name="restrictionAlgorithm">RestrictionAlgorithm that matches the corresponding Algorithm.</param>
        /// <returns>GetAlgorithmModelView representing the instance of Algorithm.</returns>
        public GetAlgorithmModelView getAlgorithm(RestrictionAlgorithm restrictionAlgorithm)
        {
            //this throws ArgumentOutOfRangeException if the element is not recognized by the factory
            Algorithm algorithm = new AlgorithmFactory().createAlgorithm(restrictionAlgorithm);

            return(AlgorithmModelViewService.fromEntity(algorithm));
        }
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            Console.WriteLine("Reading configuration");

            string algorithmConfigurationFileName = "configuration.json";
            string algorithmConfigurationFilePath = Path.Combine(Directory.GetCurrentDirectory(), algorithmConfigurationFileName);

            if (File.Exists(algorithmConfigurationFilePath) == false)
            {
                throw new FileNotFoundException($"{algorithmConfigurationFileName} not found at {Directory.GetCurrentDirectory()}");
            }

            string outputDirectory = "Output";

            if (Directory.Exists(outputDirectory))
            {
                Directory.Delete(outputDirectory, true);
            }

            var algorithm = AlgorithmFactory.Create(algorithmConfigurationFilePath);

            Console.WriteLine($"{algorithm.Name} algorithm is running....");
            outputDirectory = algorithm.Run();
            Console.WriteLine("Algorithm has completed");

            WaitKeyPress();

            Process.Start(Path.Combine(Directory.GetCurrentDirectory(), outputDirectory));
        }
        /// <summary>
        /// Adds a Restriction to a Product's Material.
        /// </summary>
        /// <param name="addRestrictionModelView">AddRestrictionToProductMaterialModelView containing the data of the Restriction instance being added.</param>
        /// <returns>GetProductModelView with updated Product information.</returns>
        /// <exception cref="ResourceNotFoundException">Thrown when the Product or the Material could not be found.</exception>
        public GetProductModelView addRestrictionToProductMaterial(AddProductMaterialRestrictionModelView addRestrictionModelView)
        {
            ProductRepository productRepository = PersistenceContext.repositories().createProductRepository();
            Product           product           = productRepository.find(addRestrictionModelView.productId);

            if (product == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_PRODUCT_BY_ID, addRestrictionModelView.productId));
            }

            //filter product's materials rather than accessing the repository
            Material material = product.productMaterials
                                .Where(productMaterial => productMaterial.materialId == addRestrictionModelView.materialId)
                                .Select(productMaterial => productMaterial.material).SingleOrDefault();

            if (material == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_MATERIAL_BY_ID, addRestrictionModelView.materialId));
            }

            Algorithm algorithm = new AlgorithmFactory().createAlgorithm(addRestrictionModelView.restriction.algorithmId);

            if (addRestrictionModelView.restriction.inputValues != null)
            {
                algorithm.setInputValues(InputValueModelViewService.toDictionary(addRestrictionModelView.restriction.inputValues));
            }
            algorithm.ready();
            Restriction restriction = new Restriction(addRestrictionModelView.restriction.description, algorithm);

            product.addMaterialRestriction(material, restriction);
            product = productRepository.update(product);
            return(ProductModelViewService.fromEntity(product));
        }
Example #10
0
        public void ensureGetRequiredInputsReturnsEmptyList()
        {
            Console.WriteLine("ensureGetRequiredInputsReturnsNull");
            Algorithm alg = new AlgorithmFactory().createAlgorithm(RestrictionAlgorithm.SAME_MATERIAL_AND_FINISH_ALGORITHM);

            Assert.Empty(alg.getRequiredInputs());
        }
        /// <summary>
        /// In case for some some crazed reason you want a client to validate the specified token rather than just letting the creator be authoritative.
        /// </summary>
        /// <returns>Validated?</returns>
        /// <param name="token">The token to be validated.</param>
        public static bool Validate(string token, string secret = null)
        {
            byte[]           secretBytes      = EncodingHelper.GetBytes(secret);
            AlgorithmFactory algorithmFactory = new AlgorithmFactory();

            var tokenDecoded = DecodeToken(token);

            bool secretValid     = string.IsNullOrEmpty(secret);
            bool expirationValid = JsonConvert.DeserializeObject <JwtExpiration>(tokenDecoded.Payload).Expiration == null;

            // actually check the secret
            if (secret != null)
            {
                var alg = algorithmFactory.Create(tokenDecoded.Header.Algorithm);

                var bytesToSign = EncodingHelper.GetBytes(String.Concat(JsonConvert.SerializeObject(tokenDecoded.Header), ".", tokenDecoded.Payload));

                var testSignature        = alg.Sign(secretBytes, bytesToSign);
                var decodedTestSignature = Convert.ToBase64String(testSignature);

                secretValid = decodedTestSignature == tokenDecoded.Verification;
            }

            //actually check the expiration
            var expiration = JsonConvert.DeserializeObject <JwtExpiration>(tokenDecoded.Payload).Expiration;

            if (expiration != null)
            {
                expirationValid = DateTimeHelpers.FromUnixTime((long)expiration) < DateTime.Now;
            }

            return(secretValid && expirationValid);
        }
Example #12
0
        public double ResultAlgorithm(int numberOfAlg)
        {
            AlgorithmFactory fuctory   = new AlgorithmFactory(numberOfAlg, CompliteCodeMain, CompliteCodeChild);
            IAlgorithm       algorithm = fuctory.Create();

            algorithm?.CompareRes();
            return(algorithm.Result);
        }
Example #13
0
        public void ensureSetInputValueFails()
        {
            Algorithm alg    = new AlgorithmFactory().createAlgorithm(RestrictionAlgorithm.SAME_MATERIAL_AND_FINISH_ALGORITHM);
            Input     input  = Input.valueOf("one", "number 1");
            Action    action = () => alg.setInputValue(input, "1");

            Assert.Throws <ArgumentException>(action);
        }
Example #14
0
        public Main(Algorithm algorithmName, Form1 basicform)
        {
            InitializeComponent();
            observer  = new UIExecuteObserver(this, basicform);
            algorithm = AlgorithmFactory.getAlorithm(algorithmName, observer);

            InitializeValues();
        }
Example #15
0
        public void ensureWidthPercentageAlgorithmIsCreated()
        {
            Console.WriteLine("ensureWidthPercentageAlgorithmIsCreated");
            AlgorithmFactory factory   = new AlgorithmFactory();
            Algorithm        algorithm = factory.createAlgorithm(RestrictionAlgorithm.WIDTH_PERCENTAGE_ALGORITHM);

            Assert.True(algorithm.GetType().ToString() == "core.domain.WidthPercentageAlgorithm");
        }
Example #16
0
        public void ensureCreateAlgorithmFailsIfAlgorithmDoesNotExistd()
        {
            Console.WriteLine("ensureCreateAlgorithmFailsIfAlgorithmDoesNotExistd");
            AlgorithmFactory factory = new AlgorithmFactory();
            Action           create  = () => factory.createAlgorithm(0);

            Assert.Throws <ArgumentOutOfRangeException>(create);
        }
Example #17
0
        /// <summary>
        /// Decodes secred data from Image
        /// </summary>
        /// <param name="algorithm">Algorithm used in decoding</param>
        /// <exception cref="System.NullReferenceException">Thrown if the <paramref name="algorithm"/> is is not known algorithm type.</exception>
        /// <exception cref="System.InvalidOperationException">TThrown if the <paramref name="algorithm"/> does not inherit from StegoAlgorithm.</exception>
        /// <exception cref="StegoCore.Exceptions.DecodeException">Thrown if error while decoding occurs</exception>
        /// <returns>Bytes of decoded secred data</returns>
        public byte[] Decode(AlgorithmEnum algorithm)
        {
            if (this.image == null)
            {
                throw new System.NullReferenceException("Image cannot be null");
            }
            var alg = AlgorithmFactory.Create(algorithm);

            return(alg.Decode(this.image, this.settings));
        }
Example #18
0
        public void LSB_Embed_And_Decode_SecretDataLength()
        {
            var lsb = AlgorithmFactory.Create(AlgorithmEnum.Lsb);

            byte[] secretDataBytes = System.IO.File.ReadAllBytes(FileHelper.GetPathToSecretData());
            var    secretData      = new SecretData(secretDataBytes);
            var    imageWithSecret = lsb.Embed(Image.Load(FileHelper.GetPathToImage()), secretData, null);
            int    readedLength    = lsb.ReadSecretLength(imageWithSecret, null);

            Assert.Equal(secretDataBytes.Length, readedLength);
        }
Example #19
0
 public GameManager(HttpClient client)
 {
     this.client      = client;
     lobby            = new Lobby(client);
     algorithmFactory = new AlgorithmFactory();
     player           = new Player();
     factory          = new FactionFactory();
     standart         = algorithmFactory.GetDefault("Standart");
     hopper           = algorithmFactory.GetDefault("Hopper");
     tower            = algorithmFactory.GetDefault("Tower");
     teleport         = algorithmFactory.GetDefault("Teleport");
 }
Example #20
0
 public void InitAlgorithm(string algoName, double h_trg)
 {
     //アルゴリズムをセット
     if (env != null && env.Network != null && env.Network.Nodes != null && env.Network.Nodes.Count() > 0)
     {
         //foreach (AATBasedAgentIO aat in env.Network.Nodes)
         foreach (AgentIO aat in env.Network.Nodes)
         {
             aat.Algorithm = (AlgorithmFactory.CreateAlgorithm(algoName, h_trg));
         }
     }
 }
Example #21
0
        /// <summary>
        /// Returns an instance of GetAllInputsModelView representing the Algorithm's required inputs.
        /// </summary>
        /// <param name="restrictionAlgorithm">RestrictionAlgorithm that matches the corresponding Algorithm.</param>
        /// <returns>GetAllInputsModelView representing the Algorithm's required inputs. </returns>
        /// <exception cref="ResourceNotFoundException">Thrown when the Algorithm has no required inputs.</exception>
        public GetAllInputsModelView getAlgorithmRequiredInputs(RestrictionAlgorithm restrictionAlgorithm)
        {
            Algorithm algorithm = new AlgorithmFactory().createAlgorithm(restrictionAlgorithm);

            List <Input> requiredInputs = algorithm.getRequiredInputs();

            if (!requiredInputs.Any())
            {
                throw new ResourceNotFoundException(NO_REQUIRED_INPUTS);
            }

            return(InputModelViewService.fromCollection(requiredInputs));
        }
Example #22
0
        public void ensureSetInputValuesFails()
        {
            Input     input1 = Input.valueOf("one", "number 1");
            Input     input2 = Input.valueOf("two", "number 2");
            Algorithm alg    = new AlgorithmFactory().createAlgorithm(RestrictionAlgorithm.SAME_MATERIAL_AND_FINISH_ALGORITHM);
            Dictionary <Input, string> inputValues = new Dictionary <Input, string>();

            inputValues.Add(input1, "1");
            inputValues.Add(input2, "2");
            Action action = () => alg.setInputValues(inputValues);

            Assert.Throws <ArgumentException>(action);
        }
Example #23
0
        public string run(string password, string algo)
        {
            AlgorithmFactory factory   = new AlgorithmFactory(algo);
            IAlgo            algorithm = factory.create();

            if (algorithm == null)
            {
                return(null);
            }

            string newPassword = algorithm.generate(password);

            return(newPassword);
        }
Example #24
0
        public ComputeServer(SystemConfiguration systemConfig, string name, AlgorithmFactory algoFactory)
        {
            uuid = Guid.NewGuid().ToString();
            this.name = name;
            config = systemConfig.Servers[name];

            var mediatorConfig = systemConfig.Servers.First(kvp => kvp.Value.Type == ServerTypes.Mediator).Value;
            mediator = new MediatorConnector(mediatorConfig);

            workerPool = new WorkerPool(config.PoolSize, uuid, mediator);

            //bootstrapper = new ComputeBootstrapper(this, workerPool);
            bootstrapper = new ApiBootstrapper(this, workerPool, algoFactory);
        }
Example #25
0
 public IExternalOverlapRemoval <TVertex> GenerateOverlapRemovalAlgorithm(Dictionary <TVertex, Rect> rectangles = null)
 {
     if (ExternalOverlapRemovalAlgorithm == null)
     {
         //create default OR
         return(AlgorithmFactory.CreateOverlapRemovalAlgorithm(DefaultOverlapRemovalAlgorithm, null, DefaultOverlapRemovalAlgorithmParams));
     }
     else
     {
         var overlap = ExternalOverlapRemovalAlgorithm;
         overlap.Rectangles = rectangles;
         return(overlap);
     }
 }
Example #26
0
        /// <summary>
        /// Embed secret data in Image
        /// </summary>
        /// <param name="algorithm">Algorithm used in embending</param>
        /// <exception cref="System.NullReferenceException">Thrown if the <paramref name="algorithm"/> is is not known algorithm type.</exception>
        /// <exception cref="System.InvalidOperationException">TThrown if the <paramref name="algorithm"/> does not inherit from StegoAlgorithm.</exception>
        /// <exception cref="StegoCore.Exceptions.DataToBigException">Thrown if the secred data is to big for embending</exception>
        /// <returns>Image with embeded secret data</returns>
        public Image <Rgba32> Embed(AlgorithmEnum algorithm)
        {
            if (this.image == null)
            {
                throw new System.NullReferenceException("Image cannot be null");
            }
            if (this.secretData == null)
            {
                throw new System.NullReferenceException("Secret data cannot be null");
            }
            var alg = AlgorithmFactory.Create(algorithm);

            return(alg.Embed(this.image, this.secretData, this.settings));
        }
        private void Init()
        {
            _hashSHA1Generator        = AlgorithmFactory.GetHasher(EHashType.SHA_1);
            _hashSHA256Generator      = AlgorithmFactory.GetHasher(EHashType.SHA_256);
            hashSHA512Generator       = AlgorithmFactory.GetHasher(EHashType.SHA_512);
            defaultHashGenerator      = hashSHA512Generator;
            signHMACSHA1Generator     = AlgorithmFactory.GetSigner(ESignType.HMAC_SHA1);
            signHMACSHA256Generator   = AlgorithmFactory.GetSigner(ESignType.HMAC_SHA256);
            _saltGenerator            = new SecureRNGAdapter();
            _asymmetricCryptGenerator = new RSAAdapter();

            Encoder = Encoding.UTF8;
            aes128  = AlgorithmFactory.GetSymmetricTransformCrypt(ESymmetricTransformCryptType.AES_128);
            aes256  = AlgorithmFactory.GetSymmetricTransformCrypt(ESymmetricTransformCryptType.AES_256);
        }
Example #28
0
 public IExternalEdgeRouting <TVertex, TEdge> GenerateEdgeRoutingAlgorithm(Size DesiredSize)
 {
     if (ExternalEdgeRoutingAlgorithm == null && DefaultEdgeRoutingAlgorithm != EdgeRoutingAlgorithmTypeEnum.None)
     {
         return(AlgorithmFactory.CreateEdgeRoutingAlgorithm(DefaultEdgeRoutingAlgorithm, new Rect(DesiredSize), Graph, null, null, DefaultEdgeRoutingAlgorithmParams));
     }
     else if (ExternalEdgeRoutingAlgorithm != null)
     {
         return(ExternalEdgeRoutingAlgorithm);
     }
     else
     {
         return(null);
     }
 }
Example #29
0
        private void Encrypt_Decrypt(AlgorithmEnum alg, IImageFormat imageFormat, string outFileName)
        {
            Configuration.Default.AddImageFormat(imageFormat);

            var algorithm = AlgorithmFactory.Create(alg);

            byte[] secretDataBytes = System.IO.File.ReadAllBytes(FileHelper.GetPathToSecretData());

            var notSavedStego = EncryptAndSave(algorithm, secretDataBytes, outFileName);

            var stegoImage = Image.Load(outFileName);

            byte[] resultSecret = algorithm.Decode(notSavedStego, null);

            Assert.Equal(secretDataBytes, resultSecret);
        }
Example #30
0
 public IExternalLayout <TVertex> GenerateLayoutAlgorithm(Dictionary <TVertex, Size> vertexSizes)
 {
     if (ExternalLayoutAlgorithm != null)
     {
         var alg = ExternalLayoutAlgorithm;
         if (alg.NeedVertexSizes)
         {
             alg.VertexSizes = vertexSizes;
         }
         return(alg);
     }
     else
     {
         return(AlgorithmFactory.CreateLayoutAlgorithm(DefaultLayoutAlgorithm, Graph, null, vertexSizes, DefaultLayoutAlgorithmParams));
     }
 }
Example #31
0
        public void ensureApplyRemovesUnnecessaryFinishes()
        {
            Console.WriteLine("ensureApplyRemovesUnnecessaryFinishes");
            Material                  material     = new Material("#24", "K6205", "ola.jpg", new List <Color>(new[] { Color.valueOf("Epigraph of the Closed Curve: Close Epigraph", 100, 100, 100, 100) }), new List <Finish>(new[] { Finish.valueOf("der alte wurfelt nicht", 12), Finish.valueOf("schrödinger's box", 13) }));
            ProductCategory           cat          = new ProductCategory("AI");
            DiscreteDimensionInterval discrete     = new DiscreteDimensionInterval(new List <double>(new[] { 50.0, 90.0, 100.0, 150.0 }));
            Measurement               measurement  = new Measurement(discrete, discrete, discrete);
            List <Measurement>        measurements = new List <Measurement>()
            {
                measurement
            };
            Product           product   = new Product("#12", "Mother Goose of Mutual Recursion: Recursive Mother Goose", "product12.glb", cat, new List <Material>(new[] { material }), measurements);
            Product           component = new Product("#13", "Mother Goose of Diffractive Recitavo: Diffraction Mother Goose", "product13.gltf", cat, new List <Material>(new[] { material }), measurements);
            CustomizedProduct custom    = CustomizedProductBuilder.createCustomizedProduct("#8", product, CustomizedDimensions.valueOf(100, 100, 100)).withMaterial(CustomizedMaterial.valueOf(material, Color.valueOf("Epigraph of the Closed Curve: Close Epigraph", 100, 100, 100, 100), Finish.valueOf("schrödinger's box", 13))).build();
            Algorithm         algorithm = new AlgorithmFactory().createAlgorithm(RestrictionAlgorithm.SAME_MATERIAL_AND_FINISH_ALGORITHM);

            Assert.Equal("schrödinger's box", algorithm.apply(custom, component).productMaterials[0].material.Finishes[0].description);
        }
Example #32
0
        private static void RunAlgorithm()
        {
            IFigure           startingContainer;
            IAlgorithm        algorithm;
            Stopwatch         stopwatch        = new Stopwatch();
            IContainerFactory containerFactory = new ContainerFactory();
            IAlgorithmFactory factory          = new AlgorithmFactory();



            if (Properties.Dimensionality == AlgorithmDimensionality.TwoDimensional)
            {
                startingContainer = containerFactory.Create(Properties, ContainerWidth, ContainerHeight);
                algorithm         = factory.Create(Properties, startingContainer);
            }
            else
            {
                startingContainer = containerFactory.Create(Properties, ContainerWidth, ContainerHeight, ContainerDepth);
                algorithm         = factory.Create(Properties, startingContainer);
            }

            ObjectSet objectsToPack = LoadObjectSet();

            if (!CheckContainerSize(objectsToPack))
            {
                throw new InvalidContainerSizeException("Container is not big enough to contain biggest object. Enlarge the container.");
            }


            stopwatch.Reset();

            var sortedObjects = SortingHelper.Sort(objectsToPack, Ordering);

            stopwatch.Start();
            algorithm.Execute(sortedObjects);
            stopwatch.Stop();

            var endResults = algorithm.CreateResults();

            endResults.ExecutionTime = stopwatch.ElapsedMilliseconds;

            WriteResiltsToCsv(endResults, startingContainer);
        }
Example #33
0
 public ServerFactory(SystemConfiguration configuration, AlgorithmFactory algoFactory, DataSource dataSource)
 {
     SystemConfig = configuration;
     AlgorithmFactory = algoFactory;
     DataSource = dataSource;
 }