Exemplo n.º 1
0
 private Case(RestrictedCaseInfo caseInfo, CPConfiguration configuration, String projectFile)
 {
     Token          = Guid.NewGuid();
     _caseInfo      = caseInfo;
     ProjectFile    = projectFile;
     _configuration = configuration;
     RegisterCaseWatcher(this, Path, () => Delete(true));
 }
Exemplo n.º 2
0
        /// <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));
        }
Exemplo n.º 3
0
        /// <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
            });
        }
Exemplo n.º 4
0
        /// <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));
        }
Exemplo n.º 5
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
            });
        }
Exemplo n.º 6
0
 private Case(RestrictedCaseInfo caseInfo, CPConfiguration configuration)
 {
     _caseInfo      = caseInfo;
     _configuration = configuration;
     _watcher       = CreateWatcher(configuration.Directory);
 }