Example #1
0
        public void Process(SitecoreResourceManagerArgs args)
        {
            if (args.TargetControllerPath != null)
            {
                var controllerContent = File.ReadAllText(args.TargetControllerPath);
                args["_CONTROLLERNAMESPACE_"] = Regex.Match(controllerContent, NamespaceRegex).Groups[1].Value;
                args["_LAYER_"]             = GetLayer(args.TargetControllerPath);
                args["_PARENTPROJECTNAME_"] = Path.GetFileName(args.TargetControllerPath).Split(new [] { "Controller" }, StringSplitOptions.RemoveEmptyEntries)[0];
            }

            if (args.TargetCsProjPath != null)
            {
                var         csProjContent = File.ReadAllText(args.TargetCsProjPath);
                XmlDocument doc           = new XmlDocument();
                doc.LoadXml(csProjContent);
                XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(doc.NameTable);
                xmlnsManager.AddNamespace("def", doc.DocumentElement.NamespaceURI);
                doc.LoadXml(csProjContent);
                args["_ASSEMBLYNAME_"]         = doc.SelectSingleNode("//def:AssemblyName", xmlnsManager)?.InnerText;
                args["_PROJECTROOTNAMESPACE_"] = doc.SelectSingleNode("//def:RootNamespace", xmlnsManager)?.InnerText;
                args["_OVERLAYTARGET_"]        = Path.GetDirectoryName(args.TargetCsProjPath);
                if (args.TargetControllerPath == null)
                {
                    args["_LAYER_"]             = GetLayer(args.TargetCsProjPath);
                    args["_PARENTPROJECTNAME_"] = args.TargetCsProjPath.Split('.')[2];
                }
            }
        }
 public void Process(SitecoreResourceManagerArgs args)
 {
     for (int i = 0; i < 4; i++)
     {
         foreach (var prop in args.GetAllProperties())
         {
             args[prop.Key] = ReplaceAllTokens.ReplaceTokens(prop.Value, args, prop.Key);
         }
     }
 }
        public ActionResult Execute(ExecuteModel model)
        {
            var collectors         = _scanner.ScanForImplementsInterface <IPropertyCollector>().ToDictionary(x => x.Processor);
            var propertiesWrapper  = _registration.GetScsRegistration <ScsSitecoreResourceManagerRegistration>().GetPropertiesWrapper(model.Template);
            var propertyDictionary = model.Properties.ToDictionary(x => x.Id);

            foreach (var prop in model.Properties)
            {
                if (propertyDictionary[prop.Id].Value == null)
                {
                    continue;
                }
                if (!string.IsNullOrWhiteSpace(prop.Processor) && !collectors[prop.Processor].Validate(prop.Value))
                {
                    return(Content(prop.Name));
                }
                propertyDictionary[prop.Id].Value = ReplaceAllTokens.ReplaceTokens(propertyDictionary[prop.Id].Value, propertyDictionary.ContainsKey, x => propertyDictionary[x].Value);
                if (propertiesWrapper.Targets[model.Target].ContainsKey(prop.Id) && propertiesWrapper.Targets[model.Target][prop.Id] == "???")
                {
                    _savedProps[$"{model.Target}.{prop.Id}", model.Template] = prop.Value;
                }
                if (propertiesWrapper.Properties.ContainsKey(prop.Id) && propertiesWrapper.Properties[prop.Id].Remember)
                {
                    _savedProps[$"{model.Target}.{prop.Id}", model.Template] = prop.Value;
                }
            }
            var args     = new SitecoreResourceManagerArgs(propertyDictionary, propertiesWrapper);
            var pipeline = CorePipelineFactory.GetPipeline("propertyProcessorPreCompiled", string.Empty);

            pipeline.Run(args);
            foreach (string compilePropertyKey in propertiesWrapper.CompiledProperties.Keys)
            {
                args[compilePropertyKey] = ReplaceAllTokens.ReplaceTokens(propertiesWrapper.CompiledProperties[compilePropertyKey], propertyDictionary.ContainsKey, x => propertyDictionary[x].Value);
            }
            pipeline = CorePipelineFactory.GetPipeline("propertyProcessorPostCompiled", string.Empty);
            pipeline.Run(args);
            pipeline = CorePipelineFactory.GetPipeline("SitecoreResourceManager", string.Empty);
            pipeline.Run(args);
            return(ScsJson(args.Output));
        }
Example #4
0
 public void Process(SitecoreResourceManagerArgs args)
 {
     args["_DEFAULTUNICORNDEPENDENCIES_"] = (args.Layer == "Feature" ? $"{args.Prefix}.Foundation.*" : (args.Layer == "Project") ? $"{args.Prefix}.Foundation.*,{args.Prefix}.Feature.*" : "");
 }