예제 #1
0
        internal SwDmComponentCollection(SwDmAssembly ownerAssm, ISwDmConfiguration conf)
        {
            m_OwnerAssm = ownerAssm;
            m_Conf      = conf;

            m_PathResolver = new SwDmFilePathResolver();
        }
예제 #2
0
        public static async Task <Tuple <long, long> > PCHelpEnsure(
            IServiceInstanceManager sim,
            long?ScopeId,
            IContentManager ContentManger,
            IFilePathResolver FilePathResolver,
            IDocumentManager DocManager,
            IDocumentCategoryManager CatManager
            )
        {
            var re = await DocManager.DocEnsureFromFiles(
                CatManager,
                //"pc-help",
                null,
                FilePathResolver.Resolve($"root://StaticResources/帮助文档/PC文档")
                );

            await sim.UpdateSetting <HygouSetting>(
                ScopeId,
                s =>
            {
                s.PCHelpCenterDefaultDocId = re[0].Children[0].Id;
            });

            var tail_doc_list = await ContentManger.ContentEnsure(
                "PC页面尾部文档列表",
                "PC页面尾部文档列表",
                null,
                re.Select(cat =>
                          new ContentItem {
                Title1 = cat.Name,
                Items = cat.Children.Select(doc =>
                                            new ContentItem {
                    Title1 = doc.Name, Uri = $"/help/doc/{doc.Id}"
                }
                                            ).ToArray()
            }
                          ).Take(4).ToArray()
                );

            var tail_link_list = await ContentManger.ContentEnsure(
                "PC页面尾部链接列表",
                "PC页面尾部链接列表",
                null,
                re.Last().Children.Select(doc =>
                                          new ContentItem {
                Title1 = doc.Name, Uri = $"/help/doc/{doc.Id}"
            }
                                          ).ToArray()
                );

            await sim.UpdateSetting <FriendlyContentSetting>(
                ScopeId,
                s =>
            {
                s.PCHomeTailMenuId = tail_doc_list.Id;
            });

            return(Tuple.Create(tail_doc_list.Id, tail_link_list.Id));
        }
예제 #3
0
        public void RunShouldCallXdtTransform(IXdtTransformEngine xdt, IFilePathResolver path)
        {
            var postStep = new PostStep(xdt, path);

              //act
              postStep.Run(null, null);
              xdt.Received(1).ApplyConfigTransformation(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
        }
예제 #4
0
        internal SwDmComponentCollection(SwDmAssembly parentAssm, ISwDmConfiguration conf)
        {
            m_ParentAssm = parentAssm;
            m_Conf       = conf;

            m_PathResolver    = new SwDmFilePathResolver();
            m_ComponentsCache = new Dictionary <string, SwDmComponent>(StringComparer.CurrentCultureIgnoreCase);
        }
예제 #5
0
        public void RunShouldCallXdtTransform(IXdtTransformEngine xdt, IFilePathResolver path)
        {
            var postStep = new PostStep(xdt, path);

            //act
            postStep.Run(null, null);
            xdt.Received(1).ApplyConfigTransformation(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
        }
예제 #6
0
    public void RunShouldCallXdtTransform(IXdtTransformEngine xdt, IFilePathResolver path, ITransformsProvider transform)
    {
      var postStep = new XmlTransformAction(xdt, path, transform);
      transform.GetTransformsByLayer(Arg.Any<string>()).Returns(new List<string>() {"web.config.transform"});

      //act
      postStep.Run(new NameValueCollection());
      xdt.Received().ApplyConfigTransformation(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
    }
예제 #7
0
        public void RunShouldNotCallXdtTransformIfTransformFileIsMissing(IXdtTransformEngine xdt, IFilePathResolver path)
        {
            path.MapPath(Arg.Any<string>()).Returns((string)null);
              var postStep = new PostStep(xdt, path);

              //act
              postStep.Run(null, null);
              xdt.DidNotReceive().ApplyConfigTransformation(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
        }
예제 #8
0
        internal SwComponent(IComponent2 comp, SwAssembly rootAssembly) : base(comp)
        {
            m_RootAssembly = rootAssembly;
            Component      = comp;
            Children       = new SwChildComponentsCollection(rootAssembly, comp);
            m_Features     = new Lazy <ISwFeatureManager>(() => new ComponentFeatureRepository(rootAssembly, comp));
            Bodies         = new SwComponentBodyCollection(comp, rootAssembly);

            m_FilePathResolver = m_RootAssembly.App.Services.GetService <IFilePathResolver>();
        }
예제 #9
0
        internal SwComponent(IComponent2 comp, SwAssembly parentAssembly) : base(comp)
        {
            m_ParentAssembly = parentAssembly;
            Component        = comp;
            Children         = new SwChildComponentsCollection(parentAssembly, comp);
            Features         = new ComponentFeatureRepository(parentAssembly, comp);
            Bodies           = new SwComponentBodyCollection(comp, parentAssembly);

            m_FilePathResolver = m_ParentAssembly.App.Services.GetService <IFilePathResolver>();
        }
예제 #10
0
        public CommandGroupVM(CommandGroupInfo cmdGrp, IIconsProvider[] providers, IFilePathResolver filePathResolver, Func <CommandMacroInfo, CommandMacroVM> cmdMacroFact) : base(cmdGrp, providers, filePathResolver)
        {
            m_CmdGrp = cmdGrp;

            Commands = new CommandsCollection <CommandMacroVM>(
                (cmdGrp.Commands ?? new CommandMacroInfo[0])
                .Select(c => cmdMacroFact.Invoke(c)));

            Commands.CommandsChanged += OnCommandsCollectionChanged;
        }
예제 #11
0
 public MacroRunner(IXApplication app, IMacroExecutor runner, IMessageService msgSvc, IXLogger logger,
                    IToolbarModuleProxy toolbarModuleProxy, IFilePathResolver filePathResolver)
 {
     m_App                = app;
     m_Runner             = runner;
     m_ToolbarModuleProxy = toolbarModuleProxy;
     m_MsgSvc             = msgSvc;
     m_Logger             = logger;
     m_FilePathResolver   = filePathResolver;
 }
예제 #12
0
    public void RunShouldNotCallXdtTransformIfTransformFileIsMissing(IXdtTransformEngine xdt, IFilePathResolver path, ITransformsProvider transform)
    {
      path.MapPath(Arg.Any<string>()).Returns((string)null);
      transform.GetTransformsByLayer(Arg.Any<string>()).Returns(new List<string>());
      var postStep = new XmlTransformAction(xdt, path, transform);

      //act
      postStep.Run(new NameValueCollection());
      xdt.DidNotReceive().ApplyConfigTransformation(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
    }
예제 #13
0
        internal SwDmComponent(SwDmAssembly parentAssm, ISwDMComponent comp) : base(comp)
        {
            Component          = comp;
            m_ParentAssm       = parentAssm;
            m_FilePathResolver = new SwDmFilePathResolver();

            m_PathLazy = new Lazy <string>(() =>
            {
                var rootDir = System.IO.Path.GetDirectoryName(OwnerAssembly.Path);

                return(m_FilePathResolver.ResolvePath(rootDir, CachedPath));
            });
        }
        public void RunShouldCallXdtTransform(IXdtTransformEngine xdt, IFilePathResolver path, ITransformsProvider transform)
        {
            var postStep = new XmlTransformAction(xdt, path, transform);

            transform.GetTransformsByLayer(Arg.Any <string>()).Returns(new List <string>()
            {
                "web.config.transform"
            });

            //act
            postStep.Run(new NameValueCollection());
            xdt.Received().ApplyConfigTransformation(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
        }
예제 #15
0
 public static async Task MobileHelpEnsure(
     IFilePathResolver FilePathResolver,
     IDocumentManager DocManager,
     IDocumentCategoryManager CatManager
     )
 {
     await DocManager.DocEnsureFromFiles(
         CatManager,
         null,
         FilePathResolver.Resolve($"root://StaticResources/帮助文档/手机文档"),
         null
         );
 }
예제 #16
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};
        }
예제 #17
0
        internal SwComponent(IComponent2 comp, SwAssembly rootAssembly, ISwApplication app) : base(comp, rootAssembly, app)
        {
            m_RootAssembly   = rootAssembly;
            Component        = comp;
            Children         = new SwChildComponentsCollection(rootAssembly, this);
            m_FeaturesLazy   = new Lazy <ISwFeatureManager>(() => new SwComponentFeatureManager(this, rootAssembly, app));
            m_DimensionsLazy = new Lazy <ISwDimensionsCollection>(() => new SwFeatureManagerDimensionsCollection(Features));

            m_MathUtils = app.Sw.IGetMathUtility();

            Bodies = new SwComponentBodyCollection(comp, rootAssembly);

            m_FilePathResolver = ((SwApplication)OwnerApplication).Services.GetService <IFilePathResolver>();
        }
예제 #18
0
        public SearchEngineService(IServiceProvider serviceProvider)
        {
            m_Resolver = (IFilePathResolver)serviceProvider.GetService(typeof(IFilePathResolver));

            lock (typeof(SearchEngineService))
            {
                if (!s_Initialized)
                {
                    LoadIndex(m_Resolver);

                    s_Initialized = true;
                }
            }
        }
예제 #19
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;
 }
예제 #20
0
        public CommandsManager(IXExtension addIn, IXApplication app,
                               IMacroRunner macroRunner, IMessageService msg,
                               IXLogger logger, IIconsProvider[] iconsProviders, IFilePathResolver pathResolver)
        {
            m_AddIn          = addIn;
            m_App            = app;
            m_MacroRunner    = macroRunner;
            m_Msg            = msg;
            m_Logger         = logger;
            m_IconsProviders = iconsProviders;

            m_CachedToggleStates = new Dictionary <CommandMacroInfo, bool>();
            m_StateResolvers     = new ConcurrentDictionary <CommandMacroInfo, IToggleButtonStateResolver>();
            m_PathResolver       = pathResolver;
        }
예제 #21
0
        public override IPackageInstallResult Do(IPackage package, IFilePathResolver target){
            var wasError = false;
            var result = new DefaultPackageInstallResult{Message = "applying auto xslt"};
            var allfiles = package.PathResolver.ResolveAll("", "*.*");
            var xsltTaskFiles = allfiles.Where(s => s.EndsWith(".taskinfo.xslt"));
            xsltTaskFiles.Select(
                s =>{
                    if (wasError){
                        return s;
                    }

                    var targetFileName = s.Substring(0, s.Length - ".taskinfo.xslt".Length);

                    if (GetProceed(target, targetFileName, result)){
                        var xsltSource = package.PathResolver.ReadBinary(s);
                        var targetSource = target.Read(targetFileName);
                        var sw = new StringWriter();
                        var xws = new XmlWriterSettings();
                        xws.Indent = true;
                        xws.NewLineHandling = NewLineHandling.Entitize;
                        xws.OmitXmlDeclaration = true;
                        xws.Encoding = Encoding.UTF8;
                        var xw = XmlWriter.Create(sw, xws);
                        var xsltTransform = new XslCompiledTransform();
                        var sets = new XsltSettings(true, true);

                        var doc = XmlReader.Create(new StringReader(targetSource));
                        var xslt = XmlReader.Create(new MemoryStream(xsltSource));
                        var xmlResolver = new FilePathXmlResolver(package.PathResolver);
                        xsltTransform.Load(xslt, sets, xmlResolver);
                        var args = new XsltArgumentList();
                        if (ArgPreparator != null){
                            ArgPreparator(args);
                        }
                        xsltTransform.Transform(doc, args, xw, xmlResolver);
                        target.Write(targetFileName, sw.ToString());
                    }
                    result.SubMessages.Add("PROCESSED: " + targetFileName);
                    Console.WriteLine("PROCESSED: " + targetFileName);
                    return s;
                }
                ).ToList();
            return result;
        }
예제 #22
0
 public void Execute(string scriptcode, TextWriter logwriter,IDictionary<string ,string > parameters) {
     Filesystem = Filesystem ?? myapp.files;
     var file = Filesystem.ResolveAll("~/", scriptcode + ".fs.script").FirstOrDefault();
     if(null==file) {
         throw new Exception("cannot find script with code "+scriptcode);
     }
     var script = File.ReadAllText(file);
     var xscript = parseTxt(script);
     var program = new FileSystemProgram();
     if (null != parameters) {
         foreach (var parameter in parameters) {
             program.Parameters[parameter.Key] = parameter.Value;
         }
     }
     program.Filesystem = this.Filesystem;
     program.Log = new LogHostBase {Writer = logwriter};
     program.Load(xscript);
     program.Execute();
 }
        public void GetTransformsByLayer_ShouldReturnsTransformsList([Frozen] IFilePathResolver path, [Greedy] TransformProvider provider, string layerName, string transformFileName)
        {
            var constructorTest = new TransformProvider();
            var transformsPath  = $"{Directory.GetCurrentDirectory()}\\temp\\transforms";

            path.MapPath(Arg.Any <string>()).Returns(transformsPath);
            Directory.CreateDirectory("temp");
            Directory.CreateDirectory(transformsPath);
            Directory.CreateDirectory($"{transformsPath}/{layerName}");
            var transformFilePath = $"{transformsPath}\\{layerName}\\{transformFileName}.xdt";

            File.CreateText(transformFilePath);
            var transforms = provider.GetTransformsByLayer(layerName);

            transforms.Should().Contain(new List <string>()
            {
                transformFilePath
            });
        }
예제 #24
0
        protected FileLoader(ICacheManager cacheManager, IFilePathResolver filePathResolver, string directoryName, string cacheName)
        {
            if (cacheManager == null)
            {
                throw new ArgumentNullException(nameof(cacheManager));
            }

            if (filePathResolver == null)
            {
                throw new ArgumentNullException(nameof(filePathResolver));
            }

            if (string.IsNullOrEmpty(cacheName))
            {
                throw new ArgumentNullException(nameof(cacheName));
            }

            CacheManager  = cacheManager;
            DirectoryPath = filePathResolver.GetWorkingDirectory() + "\\" + directoryName;
            CacheName     = cacheName;
        }
예제 #25
0
 public virtual IPackageInstallResult Install(IFilePathResolver targetSystem){
     var result = new DefaultPackageInstallResult();
     // Console.WriteLine("INFO : {0} start install",identity);
     foreach (var task in Tasks){
         // try{
         //  Console.WriteLine("INFO : {0}/{1} start ", identity,task);
         var subResult = task.Do(this, targetSystem);
         //   Console.WriteLine("INFO : {0}/{1} finish ", identity, task);
         result.SubResults.Add(subResult);
         if (subResult.State > ResultState.Warning){
             break;
         }
         // }
         //catch (Exception e){
         //   result.Error = e;
         //   result.State = ResultState.Error;
         //}
     }
     Console.WriteLine("INFO : {0} end install", identity);
     return result;
 }
예제 #26
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;
        }
예제 #27
0
 public IPackageInstallResult Do(IPackage package, IFilePathResolver target){
     var result = new DefaultPackageInstallResult();
     result.State = ResultState.OK;
     Connection.Open();
     Builder = new StringBuilder();
     var trans = Connection.BeginTransaction();
     try{
         var commit = true;
         foreach (var command in Commands){
             var com = Connection.CreateCommand();
             com.CommandType = CommandType.Text;
             com.CommandText = command;
             com.Transaction = trans;
             com.ExecuteNonQuery();
             if (command.Contains("//nocommit")){
                 commit = false;
             }
         }
         if (commit){
             trans.Commit();
         }
     }
     catch (Exception ex){
         trans.Rollback();
         logger.get("comdiv.core").Error("error in sql package task", ex);
         result.State = ResultState.Error;
     }
     finally{
         try{
             Connection.Close();
         }
         catch{}
         logger.get("comdiv.core").Info("sql:" + Builder);
     }
     //result.State = ResultState.Warning;
     return result;
 }
예제 #28
0
 public FilePathXmlResolver(IFilePathResolver targetSystem){
     TargetSystem = targetSystem;
 }
예제 #29
0
 public TransformProvider(IFilePathResolver path)
 {
   this.filePathResolver = path;
 }
예제 #30
0
파일: PostStep.cs 프로젝트: richeym/Habitat
 public PostStep(IXdtTransformEngine xdtTransformEngine, IFilePathResolver filePathResolver)
 {
     this.xdtTransformEngine = xdtTransformEngine;
       this.filePathResolver = filePathResolver;
 }
 public FileQuestionLoader(ICacheManager cacheManager, IFilePathResolver filePathResolver, string directoryName, string cacheName) : base(cacheManager, filePathResolver, directoryName, cacheName)
 {
 }
예제 #32
0
파일: PostStep.cs 프로젝트: zyq524/Habitat
 public PostStep(IXdtTransformEngine xdtTransformEngine, IFilePathResolver filePathResolver, ITransformsProvider transformsProvider)
 {
   this.xdtTransformEngine = xdtTransformEngine;
   this.filePathResolver = filePathResolver;
   this.transformProvider = transformsProvider;
 }
예제 #33
0
 public MongoPathsProvider(IFilePathResolver filePathResolver)
 {
   this.filePathResolver = filePathResolver;
 }
예제 #34
0
 public ReplaceReportingDbAction(IFilePathResolver filePathResolver, IDatabaseService databaseService)
 {
   this.databaseService = databaseService;
   this.reportingDbLocation = filePathResolver.MapPath("~/App_Data/Sitecore.Analytics.mdf");
 }
예제 #35
0
 public IPackageInstallResult Do(IPackage package, IFilePathResolver target){
     return __task(package, target);
 }
 public XmlTransformAction(IXdtTransformEngine xdtTransformEngine, IFilePathResolver filePathResolver, ITransformsProvider transformsProvider)
 {
     this.xdtTransformEngine = xdtTransformEngine;
     this.filePathResolver   = filePathResolver;
     this.transformProvider  = transformsProvider;
 }
예제 #37
0
        internal CommandItemInfoSpec(CommandMacroInfo info, IIconsProvider[] iconsProviders, IFilePathResolver pathResolver, string workDir) : base(info.Id)
        {
            Info = info;

            Title              = info.Title;
            Tooltip            = info.Description;
            Icon               = info.GetCommandIcon(iconsProviders, pathResolver, workDir);
            HasToolbar         = info.Location.HasFlag(Location_e.Toolbar);
            HasMenu            = info.Location.HasFlag(Location_e.Menu);
            HasRibbon          = info.Location.HasFlag(Location_e.TabBox);
            SupportedWorkspace = GetWorkspace(info.Scope);

            if (HasRibbon)
            {
                RibbonTextStyle = RibbonTabTextDisplay_e.TextBelow;
            }
        }
 public MongoPathsProvider(IFilePathResolver filePathResolver)
 {
     this.filePathResolver = filePathResolver;
 }
예제 #39
0
 public FileExistsValidationRule(IFilePathResolver filePathResolver)
 {
     m_FilePathResolver = filePathResolver;
 }
예제 #40
0
 public ConfiguredFilePathService(IConfigurationSettingService configurationSettingService,
                                  IFilePathResolver filePathResolver)
 {
     _configurationSettingService = configurationSettingService;
     _filePathResolver = filePathResolver;
 }
예제 #41
0
 public abstract IPackageInstallResult Do(IPackage package, IFilePathResolver target);
예제 #42
0
		/// <summary>
		/// creates new xmldsl loader with given folder of transformations
		/// </summary>
		/// <param name="rootdir"></param>
		/// <param name="resolver"> </param>
		public XmlDslLoader(string rootdir = "dsl", IFilePathResolver  resolver= null ) {
			Resolver = resolver ?? myapp.files;
			Rootdir = rootdir;	
		}
예제 #43
0
        internal static IXImage GetCommandIcon(this CommandItemInfo info, IIconsProvider[] iconsProviders, IFilePathResolver pathResolver, string workDir)
        {
            IXImage icon = null;

            try
            {
                if (!string.IsNullOrEmpty(info.IconPath))
                {
                    var iconPath = pathResolver.Resolve(info.IconPath, workDir);

                    var provider = iconsProviders.FirstOrDefault(p => p.Matches(iconPath));

                    if (provider != null)
                    {
                        icon = provider.GetIcon(iconPath);
                    }
                }
            }
            catch
            {
            }

            if (icon == null)
            {
                if (info is CommandMacroInfo)
                {
                    icon = new ImageEx(Resources.macro_icon_default.GetBytes(),
                                       Resources.macro_vector);
                }
                else if (info is CommandGroupInfo)
                {
                    icon = new ImageEx(Resources.group_icon_default.GetBytes(),
                                       Resources.macros_vector);
                }
            }

            return(icon);
        }
        public void GetTransformsByLayer_TransformsFolderDoesNotExists_ShouldReturnsEmptyCollection([Frozen] IFilePathResolver path, [Greedy] TransformProvider provider, string layerName, string transformFileName)
        {
            path.MapPath(Arg.Any <string>()).Returns(string.Empty);
            Directory.CreateDirectory("temp");
            var transforms = provider.GetTransformsByLayer(layerName);

            transforms.Should().BeEmpty();
        }
예제 #45
0
 public MacroEntryPointsExtractor(IXApplication app, IFilePathResolver filePathResolver)
 {
     m_App = app;
     m_FilePathResolver = filePathResolver;
 }
예제 #46
0
        private const int GROUP_ID_OFFSET = 500; //this offset is created to avoid conflicts of toolbar commands with the modules command manager

        internal CommandGroupInfoSpec(CommandGroupInfo info, IIconsProvider[] iconsProviders, IFilePathResolver pathResolver, string workDir) : base(info.Id + GROUP_ID_OFFSET)
        {
            Info = info;

            Title         = info.Title;
            Tooltip       = info.Description;
            RibbonTabName = "Toolbar+";
            Icon          = info.GetCommandIcon(iconsProviders, pathResolver, workDir);

            if (info.Commands != null)
            {
                Commands = info.Commands.Where(c => c.Triggers.HasFlag(Triggers_e.Button)).Select(
                    c => new CommandItemInfoSpec(c, iconsProviders, pathResolver, workDir)).ToArray();
            }
            else
            {
                Commands = new CommandItemInfoSpec[0];
            }
        }
예제 #47
0
 public XmlTransformAction(IXdtTransformEngine xdtTransformEngine, IFilePathResolver filePathResolver, ITransformsProvider transformsProvider)
 {
   this.xdtTransformEngine = xdtTransformEngine;
   this.filePathResolver = filePathResolver;
   this.transformProvider = transformsProvider;
 }
 private static void checkResolverIsPreparedForXmlProcessing(IFilePathResolver resolver){
     if (!resolver.Data.ContainsKey("__xml__resolver_prepared")){
         resolver.DefinePseudoFile(".default.xml", "<__ />");
         // the usefull default xslt for import - can work with cce:option element and config mode=append
         resolver.DefinePseudoFile(".default.xslt", ConfigMergeXslt);
         resolver.DefinePseudoFile(".xmerge.xslt", XmlMergeXslt);
         resolver.Data["__xml__resolver_prepared"] = true;
     }
 }
예제 #49
0
        public void RunShouldNotCallXdtTransformIfTransformFileIsMissing(IXdtTransformEngine xdt, IFilePathResolver path)
        {
            path.MapPath(Arg.Any <string>()).Returns((string)null);
            var postStep = new PostStep(xdt, path);

            //act
            postStep.Run(null, null);
            xdt.DidNotReceive().ApplyConfigTransformation(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
        }
예제 #50
0
        private static void LoadIndex(IFilePathResolver resolver)
        {
            using (Stream indexStream = new FileStream(resolver.MapPath("~/App_Data/Index.xml"), FileMode.Open, FileAccess.Read, FileShare.None))
            {
                const string ns = "http://schemas.magurany.com/search";

                XmlSchemaSet schemas = new XmlSchemaSet();
                schemas.Add(ns, resolver.MapPath("~/App_Data/Index.xsd"));

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments   = true;
                settings.IgnoreWhitespace = true;
                settings.Schemas          = schemas;

                XmlReader reader = XmlReader.Create(indexStream, settings);

                reader.ReadStartElement("Index", ns);

                reader.ReadStartElement("Words", ns);

                while (reader.IsStartElement("Word", ns))
                {
                    WordReference wordRef = new WordReference();

                    reader.MoveToAttribute("Word");
                    wordRef.Word = reader.ReadContentAsString();

                    reader.MoveToAttribute("Count");
                    wordRef.Count = reader.ReadContentAsInt();

                    reader.ReadStartElement("Word", ns);

                    while (reader.IsStartElement("File", ns))
                    {
                        reader.MoveToAttribute("Path");
                        string path = reader.ReadContentAsString();

                        reader.MoveToAttribute("Count");
                        int count = reader.ReadContentAsInt();

                        wordRef.Files.Add(path, count);

                        reader.ReadStartElement("File", ns);
                    }

                    s_Words.Add(wordRef.Word, wordRef);

                    reader.ReadEndElement();
                }

                reader.ReadEndElement();

                reader.ReadStartElement("Files", ns);

                while (reader.IsStartElement("File", ns))
                {
                    FileReference fileRef = new FileReference();

                    reader.MoveToAttribute("Path");
                    fileRef.Path = reader.ReadContentAsString();

                    reader.MoveToAttribute("Title");
                    fileRef.Title = reader.ReadContentAsString();

                    reader.MoveToAttribute("Preview");
                    fileRef.Preview = reader.ReadContentAsString();

                    s_Files.Add(fileRef.Path, fileRef);

                    reader.ReadStartElement("File", ns);
                }

                reader.ReadEndElement();

                reader.ReadEndElement();
            }
        }
예제 #51
0
 public TransformProvider(IFilePathResolver path)
 {
     this.filePathResolver = path;
 }
예제 #52
0
 public IPackageInstallResult Do(IPackage package, IFilePathResolver target){
     if (Overwrite || !target.Exists(TargetPath)){
         target.Write(TargetPath, Content);
     }
     return DefaultPackageInstallResult.Ok("файл установлен");
 }
        public void RunShouldNotCallXdtTransformIfTransformFileIsMissing(IXdtTransformEngine xdt, IFilePathResolver path, ITransformsProvider transform)
        {
            path.MapPath(Arg.Any <string>()).Returns((string)null);
            transform.GetTransformsByLayer(Arg.Any <string>()).Returns(new List <string>());
            var postStep = new XmlTransformAction(xdt, path, transform);

            //act
            postStep.Run(new NameValueCollection());
            xdt.DidNotReceive().ApplyConfigTransformation(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
        }
예제 #54
0
 public PostStep(IXdtTransformEngine xdtTransformEngine, IFilePathResolver filePathResolver)
 {
     this.xdtTransformEngine = xdtTransformEngine;
     this.filePathResolver   = filePathResolver;
 }