示例#1
0
        /// <summary>
        /// Loads a dictionary and lock the file
        /// </summary>
        /// <param name="filePath">The path of the file which holds the dictionary data</param>
        /// <param name="efsSystem">The system for which this dictionary is loaded</param>
        /// <returns></returns>
        public static Dictionary load(String filePath, EFSSystem efsSystem)
        {
            Dictionary retVal = DocumentLoader <Dictionary> .loadFile(filePath);

            if (retVal != null)
            {
                retVal.FilePath = filePath;
                efsSystem.AddDictionary(retVal);

                // Loads the dependancies for this .efs file
                LoadDepends loadDepends = new LoadDepends(retVal.BasePath);
                loadDepends.visit(retVal);

                // Updates the contents of this .efs file
                Updater updater = new Updater();
                updater.visit(retVal);
                if (retVal.Specifications != null)
                {
                    retVal.Specifications.ManageTypeSpecs();
                }
            }

            return(retVal);
        }
示例#2
0
        /// <summary>
        ///     Loads a dictionary and lock the file
        /// </summary>
        /// <param name="efsSystem">The system for which this dictionary is loaded</param>
        /// <param name="loadParams">The parameters used to load the file</param>
        /// <returns></returns>
        public static Dictionary Load(EfsSystem efsSystem, LoadParams loadParams)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Dictionary retVal;

            ObjectFactory factory = (ObjectFactory)acceptor.getFactory();

            try
            {
                factory.AutomaticallyGenerateGuid = false;
                retVal = LoadFile <Dictionary>(loadParams.FilePath, null, loadParams.LockFiles);
                if (retVal != null)
                {
                    retVal.FilePath = loadParams.FilePath;
                    if (efsSystem != null)
                    {
                        efsSystem.AddDictionary(retVal);
                    }

                    // Loads the dependancies for this .efs file
                    DontNotify(() =>
                    {
                        try
                        {
                            LoadDepends loadDepends = new LoadDepends(loadParams.LockFiles, loadParams.Errors);
                            loadDepends.visit(retVal);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                            retVal = null;
                        }
                    });
                }

                if (retVal != null)
                {
                    // Updates the contents of this .efs file
                    DontNotify(() =>
                    {
                        try
                        {
                            Updater updater = new Updater(loadParams.UpdateGuid, loadParams.ConvertObsolete);
                            updater.visit(retVal);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    });
                }
            }
            finally
            {
                factory.AutomaticallyGenerateGuid = true;
                EfsSystem.Instance.Compiler.Compile_Synchronous(true);
            }

            if (efsSystem != null)
            {
                efsSystem.Context.HandleChangeEvent(null, Context.ChangeKind.Load);
            }

            return(retVal);
        }