public ModelInfo UpdateInfo(string modelName)
        {
            ModelInfo curInfo = null;
            bool      updated = false;

            if (!ModelInfos.ContainsKey(modelName))
            {
                curInfo = new ModelInfo(modelName);
                ModelInfos.Add(modelName, curInfo);
                updated = true;
            }
            else
            {
                curInfo = ModelInfos[modelName];
            }

            //Sync modelInfo with Ref

            List <Rescaler> toCreate = new List <Rescaler>();

            foreach (Rescaler scaler in RefModelInfo.Scalers)
            {
                if (!curInfo.HasScaler(scaler))
                {
                    toCreate.Add(scaler);
                }
            }

            if (toCreate.Count > 0)
            {
                curInfo.Scalers.AddRange(CreateScalers(toCreate));
                updated = true;
            }

            if (updated)
            {
                SaveModelInfo(curInfo);
            }

            return(curInfo);
        }
        public string LoadMeta()
        {
            string errors = "";

            string sRepo = GetRepository();

            if (!string.IsNullOrEmpty(sRepo))
            {
                DirectoryInfo repo = new DirectoryInfo(sRepo);
                if (!repo.Exists)
                {
                    try
                    {
                        repo.Create();
                    }
                    catch (Exception e) { errors += "Action Library : Create folder error (" + ExceptionHelper.GetMessages(e) + ")"; }
                }

                //Control Maps
                FileInfo MapsFile = new FileInfo(sRepo + "\\ControlMaps.xml");

                if (MapsFile.Exists)
                {
                    FileStream stream = null;
                    stream = MapsFile.OpenRead();
                    try
                    {
                        Maps = (ControlsMap)controlsMapSerializer.Deserialize(stream);
                    }
                    catch (Exception e) { errors += "Load xml " + ExceptionHelper.GetMessages(e); }

                    stream.Close();
                }

                if (!Maps.Initialize())
                {
                    SaveMap();
                }

                //Model infos
                ModelInfos.Clear();

                DirectoryInfo modelinfosFile = new DirectoryInfo(sRepo + "\\ModelInfos");
                if (modelinfosFile.Exists)
                {
                    FileInfo[] infos = modelinfosFile.GetFiles("*.xml");
                    if (infos.Length > 0)
                    {
                        foreach (FileInfo info in infos)
                        {
                            FileStream stream = null;
                            stream = info.OpenRead();
                            try
                            {
                                ModelInfo modelInfo = (ModelInfo)modelInfosSerializer.Deserialize(stream);
                                modelInfo.Name = info.Name.Substring(0, info.Name.Length - 4);

                                if (modelInfo.Name == "REF")
                                {
                                    RefModelInfo = modelInfo;
                                }
                                else
                                {
                                    ModelInfos.Add(modelInfo.Name, modelInfo);
                                }
                            }
                            catch (Exception e) { errors += "Load Animation Meta " + ExceptionHelper.GetMessages(e); }

                            stream.Close();
                        }
                    }
                }
                else
                {
                    try
                    {
                        modelinfosFile.Create();
                    }
                    catch (Exception e) { errors += "Action Library : Create folder error (" + ExceptionHelper.GetMessages(e) + ")"; }
                }

                if (RefModelInfo == null)
                {
                    //Create "Ref" modelInfos
                    RefModelInfo = new ModelInfo("REF");
                    Rescaler spine = new Rescaler("SpineScaler", "#SPINETOP", "#SPINEBOTTOM", 1);
                    spine.AffectedControls.Add("#SPINEIKTOP");
                    spine.AffectedControls.Add("#SPINEIKBOTTOM");
                    RefModelInfo.Scalers.Add(spine);

                    SaveModelInfo(RefModelInfo);
                }
            }

            return(errors);
        }