/// <summary> /// 设置案例信息。 /// </summary> /// <param name="caseInfo">案例信息。</param> public void SetCaseInfo(RestrictedCaseInfo caseInfo) { XElement propertyGroup = _doc.Root.Element("PropertyGroup"); propertyGroup.Element("Name").Value = caseInfo.Name; propertyGroup.Element("Type").Value = caseInfo.Type; propertyGroup.Element("Author").Value = caseInfo.Author; }
private Case(RestrictedCaseInfo caseInfo, CPConfiguration configuration, String projectFile) { Token = Guid.NewGuid(); _caseInfo = caseInfo; ProjectFile = projectFile; _configuration = configuration; RegisterCaseWatcher(this, Path, () => Delete(true)); }
/// <summary> /// 打开案例。 /// </summary> /// <param name="file">案列的项目文件路径。</param> /// <returns>案例。</returns> public static Case Open(String file) { CPConfiguration configuration = CPConfiguration.Open(file); if (configuration == null) { return(null); } RestrictedCaseInfo caseInfo = configuration.GetCaseInfo(System.IO.Path.GetDirectoryName(file)); return(new Case(caseInfo, configuration, file)); }
/// <summary> /// 打开案例。 /// </summary> /// <param name="path">案列所在路径。</param> /// <returns>案例。</returns> public static Case Open(String path) { CPConfiguration configuration = CPConfiguration.Open(path); if (configuration == null) { return(null); } RestrictedCaseInfo caseInfo = configuration.GetCaseInfo(); return(new Case(caseInfo, configuration) { Existed = true }); }
/// <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)); }
/// <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 }); }
private Case(RestrictedCaseInfo caseInfo, CPConfiguration configuration) { _caseInfo = caseInfo; _configuration = configuration; _watcher = CreateWatcher(configuration.Directory); }