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
                {
                }
            }
        }
 public void ExportTo(string filename)
 {
     using (var fileGenerator = FileGeneratorService.CreateGenerator(filename))
     {
         foreach (var prefixDefinition in PrefixDefinitionRepository.GetPrefixDefinitions())
         {
             fileGenerator.AddLine("{0}~{1}{2} [{3}]".FormatWith(prefixDefinition.Symbol, prefixDefinition.Inverted ? "1/" : "", prefixDefinition.Factor, prefixDefinition.Name));
         }
         foreach (var unitDefinition in UnitDefinitionRepository.GetUnitDefinitions())
         {
             fileGenerator.AddLine("{0}={1} [{2}]".FormatWith(unitDefinition.Symbol, unitDefinition.Definition, unitDefinition.Name));
         }
     }
 }