public void ReadProject(string path)
        {
            foreach (var tools in ToolsFactory.ToolsDic.Values)
            {
                foreach (var tool in tools)
                {
                    tool.ClearTestData();
                }
            }
            string pathWant = "";

            if (path.EndsWith(".prj"))
            {
                pathWant = path;
            }
            else
            {
                //pathWant = Environment.CurrentDirectory + "\\project\\" + path + ".prj";
                pathWant = Environment.CurrentDirectory + "\\project\\1.prj";
            }
            ProjectData project = SerializationFile.DeserializeObject(pathWant) as ProjectData; //如果是空的,反序列化时会出错,返回null

            //Dictionary<int, BindingList<ToolBase>> tools = SerializationFile.DeserializeObject(
            //    path) as Dictionary<int, BindingList<ToolBase>>;
            if (project == null)  //如果指定路径不存在文件,project即为null.
            {
                Util.Notify(Level.Err, "工程数据加载失败");
            }
            else
            {
                Instance = project;
                ToolsFactory.ToolsDic = project.ToolsDic;
                Util.Notify("工程数据加载成功");
            }
        }
Esempio n. 2
0
        public void ReadSetting()
        {
            UserSetting setting = SerializationFile.DeserializeObject(UserDataPath) as UserSetting;

            if (setting != null)
            {
                //setting = new UserSetting();
                Instance = setting;
            }
            //Instance = setting;
        }