public void CreateNewPrefix(string name, string symbol, ScalarFloat factor, bool inverted, string definition)
 {
     UnitService.AddPrefix(name, symbol, "user", factor, inverted);
     PrefixDefinitionRepository.AddPrefixDefinition(new PrefixDefinition {
         Name = name, Symbol = symbol, Definition = definition, Factor = factor.Value, Inverted = inverted
     });
 }
        public void Init()
        {
            DataAccessService.Init();
            PrefixDefinitionRepository.Init();
            UnitDefinitionRepository.Init();

            var nullScalar = new ScalarFloat();

            foreach (var prefixDefinition in PrefixDefinitionRepository.GetPrefixDefinitions())
            {
                try
                {
                    UnitService.AddPrefix(prefixDefinition.Name, prefixDefinition.Symbol, "user", nullScalar.GetNewFromFloat(prefixDefinition.Factor) as ScalarFloat, prefixDefinition.Inverted);
                }
                catch
                {
                }
            }
            foreach (var unitDefinition in UnitDefinitionRepository.GetUnitDefinitions())
            {
                try
                {
                    var unit = UnitService.Parse(unitDefinition.Definition);
                    UnitService.AddUnit(unit, unitDefinition.Name, unitDefinition.Symbol, "user");
                }
                catch
                {
                }
            }
        }