예제 #1
0
파일: Case.cs 프로젝트: uvbs/M_Y_P_F_P_R_O
 /// <summary>
 /// 更新案例信息。
 /// </summary>
 /// <returns>成功返回true;否则返回false。</returns>
 public Boolean Update()
 {
     ThrowExceptionIfNotExisted();
     _configuration.SetCaseInfo(CaseInfo);
     if (_configuration.Save(ProjectFile))
     {
         CaseInfo.Commit();
         Updated?.Invoke(this, EventArgs.Empty);
         return(true);
     }
     return(false);
 }
예제 #2
0
파일: Case.cs 프로젝트: uvbs/M_Y_P_F_P_R_O
        /// <summary>
        /// 创建新的案例。
        /// </summary>
        /// <param name="caseInfo">案例信息。</param>
        /// <param name="projectFileNameWithoutExtension">不包含扩展名的项目文件名称。</param>
        /// <returns>新的案例。</returns>
        public static Case New(CaseInfo caseInfo, String projectFileNameWithoutExtension = null)
        {
            if (caseInfo == null)
            {
                throw new ArgumentNullException("caseInfo");
            }
            CPConfiguration configuration = CPConfiguration.Create(caseInfo);

            if (configuration == null)
            {
                return(null);
            }
            String file = System.IO.Path.Combine(caseInfo.Path, caseInfo.GetDirectoryName(), $"{projectFileNameWithoutExtension ?? DefaultProjectFile}.cp");

            if (!configuration.Save(file))
            {
                return(null);
            }
            RestrictedCaseInfo rci = configuration.GetCaseInfo(System.IO.Path.GetDirectoryName(file));

            return(new Case(rci, configuration, file));
        }
예제 #3
0
        /// <summary>
        /// 创建新的案例。
        /// </summary>
        /// <param name="caseInfo">案例信息。</param>
        /// <returns>新的案例。</returns>
        public static Case New(CaseInfo caseInfo)
        {
            if (caseInfo == null)
            {
                throw new ArgumentNullException("caseInfo");
            }
            CPConfiguration configuration = CPConfiguration.Create(caseInfo);

            if (configuration == null)
            {
                return(null);
            }
            if (!configuration.Save())
            {
                return(null);
            }
            RestrictedCaseInfo rci = configuration.GetCaseInfo();

            return(new Case(rci, configuration)
            {
                Existed = true
            });
        }