Example #1
0
        /// <summary>
        /// Is used by static constructor, or during testing to reset schemas and units engine to default state.
        /// </summary>
        internal static void Initialize()
        {
            var assemblyFilePath = Assembly.GetExecutingAssembly().Location;

            var    config = ConfigurationManager.OpenExeConfiguration(assemblyFilePath);
            var    key    = config.AppSettings.Settings["schemaPath"];
            string path   = null;

            if (key != null)
            {
                path = key.Value;
            }

            if (!string.IsNullOrEmpty(path) && Directory.Exists(path))
            {
                SchemaDirectory = path;
            }

            try
            {
                unitsEngine = new ForgeUnitsCLR.UnitsEngine();
                SchemasCLR.SchemaUtility.addDefinitionsFromFolder(SchemaDirectory, unitsEngine);
                unitsEngine.resolveSchemas();
            }
            catch
            {
                unitsEngine = null;
                //There was an issue initializing the schemas at the specified path.
            }
        }
Example #2
0
 /// <summary>
 /// only use this method during tests - allows setting a different schema location without
 /// worrying about distributing a test configuration file.
 /// </summary>
 internal static void SetTestEngine(string testSchemaDir)
 {
     try
     {
         unitsEngine = new ForgeUnitsCLR.UnitsEngine();
         SchemasCLR.SchemaUtility.addDefinitionsFromFolder(testSchemaDir, unitsEngine);
         unitsEngine.resolveSchemas();
     }
     catch
     {
         unitsEngine = null;
         //There was an issue initializing the schemas at the specified path.
     }
 }