示例#1
0
 public ApiController(IMapper mapper, TestService testService, ChromosomeService chromosomeService, GenerationService generationService)
 {
     _mapper            = mapper;
     _testService       = testService;
     _chromosomeService = chromosomeService;
     _generationService = generationService;
 }
        private void InvokeHandler(object sender, EventArgs e)
        {
            var project = GetSingleSelectedProject();

            if (project == null)
            {
                return;
            }

            var projectScope = _vsIdeScope.GetProjectScope(project);

            if (projectScope == null)
            {
                return;
            }

            if (!GenerationService.CheckSpecFlowToolsFolder(projectScope))
            {
                return;
            }

            foreach (var featureFileItem in GetFeatureFileItems(project))
            {
                var vsProjectItem = featureFileItem.Object as VSProjectItem;
                vsProjectItem?.RunCustomTool();
            }
        }
示例#3
0
文件: Program.cs 项目: marzukia/sacs
        static void Main(string[] args)
        {
            string filepath            = "target.jpg";
            double startingTemperature = 1;
            long   iterations          = (long)10e7;

            ITargetService     _targetService     = new TargetService(filepath);
            Target             _target            = _targetService.GetTarget();
            IGenerationService _generationService = new GenerationService(
                _target, startingTemperature, iterations);

            var gen = _generationService.CreateGeneration();

            for (int i = 0; i < iterations; i++)
            {
                gen = _generationService.CreateNextGeneration(gen);

                if (i % 100000 == 0)
                {
                    Console.WriteLine(gen.Loss);
                    _generationService.SaveBitMap(gen, $"output/{i}.bmp");
                }
                ;
            }
        }
示例#4
0
        public void TestEmptyDateOfBirth()
        {
            GenerationService service = new GenerationService();

            options.DateOfBirthOptions = null;

            var result = service.GeneratePatients(options);

            Assert.IsFalse(result.HasErrors);
        }
示例#5
0
        public void TestDateOfBirthRangeNoStart()
        {
            GenerationService service = new GenerationService();

            options.DateOfBirthOptions = new DateOfBirthOptions
            {
                End   = new DateTime(1990, 12, 31),
                Exact = DateTime.Now
            };

            var result = service.GeneratePatients(options);

            Assert.IsTrue(result.HasErrors);
        }
示例#6
0
        public void TestDateOfBirthRange()
        {
            GenerationService service = new GenerationService();

            options.DateOfBirthOptions = new DateOfBirthOptions
            {
                Start = new DateTime(1925, 01, 01),
                End   = new DateTime(1990, 12, 31),
            };

            var result = service.GeneratePatients(options);

            Assert.IsFalse(result.HasErrors);
        }
示例#7
0
        public void TestNullAssigningAuthorityV3()
        {
            GenerationService service = new GenerationService();

            options.Metadata.AssigningAuthority   = null;
            options.Metadata.ReceivingApplication = null;
            options.Metadata.ReceivingFacility    = null;
            options.Metadata.SendingApplication   = null;
            options.Metadata.SendingFacility      = null;
            options.Metadata.UseHL7v2             = false;

            var result = service.GeneratePatients(options);

            Assert.IsTrue(result.HasErrors);
        }
        public MatchupViewModel(IScreen screen, GenerationSettings settings, DowModLoader?modLoader = null, GenerationService?generationService = null)
            : base(screen, "matchup")
        {
            this.generationService = generationService ?? Locator.Current.GetService <GenerationService>();
            this.modLoader         = modLoader ?? Locator.Current.GetService <DowModLoader>();
            this.settings          = settings;

            GenerateMatchup = ReactiveCommand.Create(() =>
            {
                Matchup      = this.generationService.GenerateMatchup(this.settings);
                MapImagePath = this.modLoader.GetMapImagePath(Matchup.Map);
            });

            GenerateMatchup.Execute().Subscribe();

            GoBack = HostScreen.Router.NavigateBack;
        }
示例#9
0
        private void InitializeServices()
        {
            typesService = new TypesService(provider);

            var interfaceToTypeIdMapping = typesService.InitializeTypeSystem(serverContext.EntityTypes);

            var completeTypesList = interfaceToTypeIdMapping.Keys;

            generationService = new GenerationService(typesService);
            // TODO (nsabo) Optional loading of proxy types from the given assembly (we dont want always to generate on small devices, Silverlight...)
            // Note: Collection/Dictionary types are not saved in the assembly
            var interfaceToGeneratedMapping = generationService.GenerateProxyTypes(completeTypesList, Properties.Settings.Default.SaveGeneratedAssemblyToDisk, Properties.Settings.Default.GeneratedAssemblyFileName);

            proxyCreatorService = new ProxyCreatorService(completeTypesList, interfaceToTypeIdMapping, interfaceToGeneratedMapping);

            StaticProxyFacade.Initialize(typesService);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MainControlViewModel"/> class.
        /// </summary>
        /// <param name="organizationService">The organization service.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="connectionDetailOriginalUrl">The connection detail original URL.</param>
        public MainControlViewModel(IOrganizationService organizationService, Settings settings,
                                    ConnectionDetail connectionDetailOriginalUrl)
        {
            _settings                     = settings;
            _connectionDetail             = connectionDetailOriginalUrl;
            _outputLoggerService          = new OutputLoggerService(this);
            _metadataRepository           = new MetadataRepository(organizationService);
            _crmVersionRepository         = new CrmVersionRepository(organizationService);
            _earlyBoundSettingsRepository = new EarlyBoundSettingsRepository();
            _generationService            = new GenerationService(_metadataRepository);
            SettingsPath                  = settings.CurrentSettingsPath;

            CreateSettingPathIfNotExist();
            CheckVersion();
            LoadSettings();
            RefreshEntities();
        }
示例#11
0
 public TeamController(ILogger <TeamController> logger, GenerationService generationService)
 {
     _Logger            = logger;
     _generationService = generationService;
 }
示例#12
0
 public RandomTeamCreateCommandHandler(GenerationService genService)
 {
     _GenerationService = genService;
 }
示例#13
0
        private void Button_ok_Click(object sender, EventArgs e)
        {
            List <string> names = new List <string>(
                textBox_names.Text.Split(new char[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries));
            List <string> fuzzyVariableNames = new List <string>();

            if (numericUpDown_ifBlockCountFrom.Value > numericUpDown_ifBlockCountTo.Value)
            {
                MessageBox.Show("Неверно указан диапазон числа блоков в выражениях ЕСЛИ",
                                "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (numericUpDown_thenBlockCountFrom.Value > numericUpDown_thenBlockCountTo.Value)
            {
                MessageBox.Show("Неверно указан диапазон числа блоков в выражениях ТО",
                                "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (numericUpDown_elseBlockCountFrom.Value > numericUpDown_elseBlockCountTo.Value)
            {
                MessageBox.Show("Неверно указан диапазон числа блоков в выражениях ИНАЧЕ",
                                "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (names.Count == 0)
            {
                MessageBox.Show("Необходимо указать хотя бы одно имя переменной",
                                "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (comboBox_selectLV.Enabled && comboBox_selectLV.SelectedIndex == -1)
            {
                MessageBox.Show("Необходимо выбрать лингвистическую переменную или запретить их использование",
                                "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (comboBox_selectLV.Enabled && comboBox_selectLV.SelectedIndex != -1)
            {
                List <FuzzyVariable> fvs = dbConnection.Query <FuzzyVariable>("select * from LinguisticVariable lv, FuzzyVariable fv where lv.deleted = '0' and fv.deleted = '0' and fv.linguisticVariableId = ?",
                                                                              comboBox_selectLV.SelectedValue);
                foreach (var fv in fvs)
                {
                    fuzzyVariableNames.Add(fv.name);
                }
            }

            List <string> expressions = GenerationService.generateExpressions(
                names, (int)numericUpDown_count.Value, checkBox_allowReuse.Checked,
                (int)numericUpDown_ifBlockCountFrom.Value, (int)numericUpDown_ifBlockCountTo.Value,
                (int)numericUpDown_thenBlockCountFrom.Value, (int)numericUpDown_thenBlockCountTo.Value,
                (int)numericUpDown_elseBlockCountFrom.Value, (int)numericUpDown_elseBlockCountTo.Value,
                fuzzyVariableNames, checkBox_allowOnlyFuzzy.Checked);

            ImportExportResult result = GenerationService.exportGeneratedStrings(expressions);

            switch (result.status)
            {
            case ImportExportResultStatus.Success:
                MessageBox.Show(result.messageString, "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;

            case ImportExportResultStatus.Error:
                MessageBox.Show(result.messageString, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public GenerationController(GenerationService versionGroupsService, ILogger <GenerationController> logger) : base(logger)
 {
     GenerationService = versionGroupsService;
 }
示例#15
0
        private void InitializeServices(Type rootEntityType, Type[] entityTypes, UpgradeConfiguration upgradeConfiguration)
        {
            this.rootEntityType = rootEntityType;
            this.entityTypes    = entityTypes;

            typesService = new TypesService(provider);

            objectSerializationService.TypesService = typesService;

            var interfaceToTypeIdMapping = typesService.InitializeTypeSystem(entityTypes);

            var completeTypesList = interfaceToTypeIdMapping.Keys;

            generationService = new GenerationService(typesService);
            // TODO (nsabo) Optional loading of proxy types from the given assembly (we dont want always to generate on small devices, Silverlight...)
            // Note: Collection/Dictionary types are not saved in the assembly
            var interfaceToGeneratedMapping = generationService.GenerateProxyTypes(completeTypesList, Properties.Settings.Default.SaveGeneratedAssemblyToDisk, Properties.Settings.Default.GeneratedAssemblyFileName);

            proxyCreatorService = new ProxyCreatorService(completeTypesList, interfaceToTypeIdMapping, interfaceToGeneratedMapping);

            snapshotsService = new SnapshotsService(provider);

            #region Parent map provider setup
            if (Properties.Settings.Default.ParentMappingFileStorageUsed)
            {
                // Usage of file for caching parent information
                var indexedFile = new IndexedFileStorage(new FileStream(this.parentMappingFileName, FileMode.Create), Properties.Settings.Default.ParentMappingFileBlockSize, false);
                indexedFile.Serializer = this.objectSerializationService;
                disposables.Add(indexedFile);

                var parentProviderStorage = new CachedWriteNodeProviderUnsafe <Guid, object, EdgeData>(
                    new DirectNodeProviderUnsafe <Guid, object, EdgeData>(indexedFile, true),
                    new LimitedDirectNodeProviderUnsafe <Guid, object, EdgeData>(
                        new LimitedMemoryStorageUnsafe <Guid, object>(Properties.Settings.Default.ParentMappingMemoryMinimumCount, Properties.Settings.Default.ParentMappingMemoryMaximumCount), false)
                    );
                disposables.Add(parentProviderStorage);

                mutableParentProvider = new ParentMapProvider(parentProviderStorage, provider, null, true);
            }
            else
            {
                // Default parent information is stored in memory and has only the last snapshot available
                mutableParentProvider = new ParentMapProvider(new DirectNodeProviderUnsafe <Guid, object, EdgeData>(new MemoryStorageUnsafe <Guid, object>(), false), provider, null, true);
            }
            #endregion

            #region Merge rule provider setup
            IMergeRuleProvider mergeRuleProvider = null;

            if (SnapshotIsolationEnabled)
            {
                if (Properties.Settings.Default.ConcurrencyAutoOverrideResolution)
                {
                    mergeRuleProvider = new AutoOverrideMergeRuleProvider();
                }
                else
                {
                    if (Properties.Settings.Default.ConcurrencyAttributesEnabled)
                    {
                        mergeRuleProvider = new AttributeBasedMergeRuleProvider(typesService);
                    }
                    else
                    {
                        throw new ArgumentException("No selected provider for merge rules in snapshot isolation conflicts. Check configuration of merge rule providers.");
                    }
                }
            }
            #endregion

            #region Setup change set provider
            // TODO (nsabo) Provide option for change set safety when context goes offline, OfflineWorkspaces should enable commits when context is back online

            if (Properties.Settings.Default.ChangeSetHistoryFileStorageUsed)
            {
                var indexedFile = new IndexedFileStorage(new FileStream(Properties.Settings.Default.ChangeSetHistoryFileStorageFileName, FileMode.Create), 256, false);
                indexedFile.Serializer = this.objectSerializationService;
                disposables.Add(indexedFile);

                var changeSetProviderStorage = new CachedWriteNodeProviderUnsafe <Guid, object, EdgeData>(
                    new DirectNodeProviderUnsafe <Guid, object, EdgeData>(indexedFile, true),
                    new LimitedDirectNodeProviderUnsafe <Guid, object, EdgeData>(
                        new LimitedMemoryStorageUnsafe <Guid, object>(Properties.Settings.Default.ChangeSetHistoryWriteCacheMinimumCount, Properties.Settings.Default.ChangeSetHistoryWriteCacheMaximumCount), false)
                    );
                disposables.Add(changeSetProviderStorage);

                changeSetProvider = new TrackingChangeSetProvider(changeSetProviderStorage);
            }
            else
            {
                changeSetProvider = new TrackingChangeSetProvider(new DirectNodeProviderUnsafe <Guid, object, EdgeData>(new MemoryStorageUnsafe <Guid, object>(), false));
            }

            #endregion

            var immutableParentProvider = new ParentMapProvider(new DirectNodeProviderUnsafe <Guid, object, EdgeData>(new MemoryStorageUnsafe <Guid, object>(), false), provider, null, false);
            collectedNodesProvider = new CollectedNodesProvider(new DirectNodeProviderUnsafe <Guid, object, EdgeData>(new MemoryStorageUnsafe <Guid, object>(), false), provider);

            commitDataService = new CommitDataService(provider, typesService, snapshotsService, mutableParentProvider, immutableParentProvider, changeSetProvider, new NodeMergeExecutor(mergeRuleProvider, typesService), collectedNodesProvider);

            workspaceExclusiveLockProvider = new WorkspaceExclusiveLockProvider();
            disposables.Add(workspaceExclusiveLockProvider);

            trackingWorkspaceStateProvider = new TrackingWorkspaceStateProvider(workspaceExclusiveLockProvider);

            objectInstancesService = new ObjectInstancesService(provider, typesService);

            subscriptionManagerService = new SubscriptionManagerService(typesService, objectInstancesService);

            workspaceFacade = new WorkspaceFacade(commitDataService, trackingWorkspaceStateProvider, subscriptionManagerService, snapshotsService, workspaceExclusiveLockProvider);

            backupService = new BackupService();

            bool firstRun = snapshotsService.InitializeSnapshots();

            if (firstRun)
            {
                InitializeDefaultSnapshot();
            }
            else
            {
                OptimizeData();
            }

            StaticProxyFacade.Initialize(typesService);
        }
示例#16
0
        protected override void TestFex(string fileName)
        {
            //arrange
            var fileService    = new FileService();
            var lines          = fileService.ReadFile(TestHelper.GetInputFilePath(fileName));
            var fexService     = new FexService(lines);
            var fexLines       = fexService.Process();
            var contentService = new ContentService(fexLines);
            var root           = contentService.Process();
            var latexService   = new GenerationService(root.Children);
            var dict           = new Dictionary <string, string[]>
            {
                {
                    "simple.fex",
                    new []
                    {
                        @"\textbf{H2}\\",
                        @"hallo\\",
                        @"welt\\"
                    }
                },
                {
                    "advanced.fex",
                    new []
                    {
                        @"\section{H1",
                        @"\subsection{H2",
                        @"\subsubsection{text",
                        @"\textbf{because it has further"
                    }
                },
                {
                    "long.fex",
                    new []
                    {
                        @"\subsection{H3}",
                        @"H3.1\\",
                        @"\section{H4}"
                    }
                },
                {
                    "formulas.fex",
                    new []
                    {
                        @"x$^{2_{32}}$", // looks weird, but rendering checks out
                        @"x$^{2_{32}}$$_{bottom}$(a)",
                        @"$x^2$\\",
                        @"$x^{2^{32}}$\\",
                        @"$x^{2_{32}}$\\",
                        @"$K_{{ab}_{ab}}$\\",
                        @"$x^{-2t}$\\",
                        @"$n^{-1000}$\\",
                        @"$\epsilon$\\",
                        @"hello $\theta$ how are you\\",
                    }
                },
                {
                    "realworld.fex",
                    new []
                    {
                        @"some condition \textasciicircum",
                        @"${\{N\}}_{\{A\}}$\\",
                        @"S $\rightarrow$ B: M, ${\{N_A, K_{AB}\}}_{AS}$, ${\{N_B, K_{AB}\}}_{BS}$\\",
                        @"${\{N\}}_1$\\",
                        @"${\{N_A\}}_1$\\",
                        @"B $\rightarrow$ A: $g^y$, ${\{g^y, g^x, A\}}_{sk(B)}$\\",
                        @"${\{A, B\}}_{sk}$\\",
                        @"${\{A, B\}}_{sk(B)}$\\",
                        @"${p(2)\{2\}}_{20p(8)(9)asd}$ hello\\"
                    }
                },
            };

            //act
            var latex = latexService.Process();

            //assert
            foreach (var s in dict[fileName])
            {
                Assert.IsTrue(latex.Contains(s));
            }
        }