示例#1
0
        public IPackageInstallResult Do(IPackage package, IFilePathResolver target){
            foreach (var file in TargetFile.split()){
                if (target.Exists(file)){
                    var oldcontent = target.Read(file).asXPathNavigable();
                    var writer = new StringWriter();
                    // var args = XsltStandardExtension.PrepareArgs();
                    Transformation.Transform(oldcontent, new XsltArgumentList(), writer);
                    writer.Flush();
                    target.Write(file, writer.ToString());
                }
            }

            return new DefaultPackageInstallResult{State = ResultState.OK};
        }
示例#2
0
 private bool GetProceed(IFilePathResolver target, string targetFileName, DefaultPackageInstallResult result){
     var proceed = true;
     if (!target.Exists(targetFileName)){
         if (TreatFileNotExistedAsError){
             result.State = ResultState.Error;
             result.SubMessages.Add("ERROR/NOFILE:" + targetFileName);
             proceed = false;
         }
         else{
             result.SubMessages.Add("NOFILE:" + targetFileName);
             proceed = false;
         }
     }
     return proceed;
 }
示例#3
0
        public override IPackageInstallResult Do(IPackage package, IFilePathResolver target){
            var result = new DefaultPackageInstallResult{Message = ToString()};
            package.PathResolver.ResolveAll("")
                .Where(s => !(GetBehaviour(s) == CopyBehaviour.Skip))
                .Select(s =>{
                            target.Resolve("~/" + s, false);
                            return s;
                        })
                .ToList();
            foreach (var file in package.PathResolver.ResolveAll("")){
                var behaviour = GetBehaviour(file);
                switch (behaviour){
                    case CopyBehaviour.Skip:
                        result.SubMessages.Add(string.Format("SKIP:{0}", file));
                        //   Console.WriteLine(string.Format("SKIP:{0}", file));
                        break;

                    case CopyBehaviour.None:
                        goto default;

                    case CopyBehaviour.OverWrite:
                        goto default;

                    case CopyBehaviour.NewOnly:
                        if (!target.Exists(file)){
                            goto default;
                        }
                        result.SubMessages.Add(string.Format("EXISTS:{0}", file));
                        Console.WriteLine(string.Format("EXISTS:{0}", file));
                        break;

                    default:
                        target.Write(file, package.PathResolver.ReadBinary(file));
                        result.SubMessages.Add(string.Format("COPY:{0}", file));
                        // Console.WriteLine(string.Format("COPY:{0}", file));
                        break;
                }
            }
            return result;
        }
示例#4
0
 public IPackageInstallResult Do(IPackage package, IFilePathResolver target){
     if (Overwrite || !target.Exists(TargetPath)){
         target.Write(TargetPath, Content);
     }
     return DefaultPackageInstallResult.Ok("файл установлен");
 }