Exemplo n.º 1
0
        private async void GetResourcesCommand()
        {
            _logService.Write(this, "Loading reaction with ID " + _reactionId, "debug");
            OutputMessages.Add(new OutputMessage()
            {
                Message = "Loading reaction...", Level = "debug"
            });
            _reaction = await _dbService.GetReactionAsync(_reactionId);

            var tmpsm = await _dbService.GetStartingMaterial(_reactionId);

            var tmpr = await _dbService.GetReagents(_reactionId);

            var tmps = await _dbService.GetSolvents(_reactionId);

            var tmpp = await _dbService.GetProducts(_reactionId);

            var tmpobs = await _dbService.GetObsImgs(_reactionId);

            _logService.Write(this, "Loaded " + _reactionId, "debug");

            OutputMessages.Add(new OutputMessage()
            {
                Message = "Loaded", Level = "debug"
            });
            StartingMaterial.Add(tmpsm);
            foreach (var item in tmpr)
            {
                Reagents.Add(item);
            }
            _logService.Write(this, Reagents.Count + " reagents loaded for this reaction", "debug");
            foreach (var item in tmps)
            {
                Solvents.Add(item);
            }
            _logService.Write(this, Solvents.Count + " solvents loaded for this reaction", "debug");
            foreach (var item in tmpp)
            {
                Products.Add(item);
            }
            _logService.Write(this, Products.Count + " products loaded for this reaction", "debug");
            foreach (var item in tmpobs)
            {
                ObservationImgsByteArray.Add(item);
            }
            _logService.Write(this, ObservationImgsByteArray.Count + " observable imgs loaded for this reaction", "debug");
            ConfigureReactionParameter();
        }
Exemplo n.º 2
0
        public Recipe(string l)
        {
            Regex r = new Regex(@"(?:(?<reagent>(\d+) ([A-Z]+))(?:, )?)+ => (?<productAmount>\d+) (?<product>[A-Z]+)");
            Match m = r.Match(l);

            if (!m.Success)
            {
                throw new Exception("Could not match regex to line " + l);
            }
            Product = new Element(int.Parse(m.Groups["productAmount"].Value), m.Groups["product"].Value);
            for (int i = 0; i < m.Groups["reagent"].Captures.Count; i++)
            {
                string[] capt = m.Groups["reagent"].Captures[i].Value.Split(" ");
                Reagents.Add(new Element(int.Parse(capt[0]), capt[1]));
            }
        }