当前位置: 首页>>代码示例>>C#>>正文


C# Package.Remove方法代码示例

本文整理汇总了C#中Package.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Package.Remove方法的具体用法?C# Package.Remove怎么用?C# Package.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Package的用法示例。


在下文中一共展示了Package.Remove方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Transform

 public override void Transform(Engine engine, Package package)
 {
     Initialize(engine, package);
     Component comp = GetComponent();
     if (IsPageTemplate() || comp == null)
     {
         Logger.Error("No Component found (is this a Page Template?)");
         return;
     }
     Item outputItem = package.GetByName(Package.OutputName);
     if (outputItem == null)
     {
         Logger.Error("No Output package item found (is this TBB placed at the end?)");
         return;
     }
     _metaFieldNames = (package.GetValue("multimediaLinkAttributes") ?? String.Empty).Split(',').Select(s => s.Trim()).ToList();
     // resolve rich text fields
     XmlDocument doc = new XmlDocument();
     string output = outputItem.GetAsString();
     doc.LoadXml(output);
     var fields = doc.SelectNodes("//Field[@FieldType='Xhtml']/Values/string");
     foreach (XmlElement field in fields)
     {
         field.InnerXml = ResolveXhtml(field.InnerXml);
     }
     package.Remove(outputItem);
     package.PushItem(Package.OutputName, package.CreateXmlDocumentItem(ContentType.Xml, doc));
 }
开发者ID:MrSnowflake,项目名称:tri,代码行数:28,代码来源:ResolveRichText.cs

示例2: Transform

        public void Transform(Engine engine, Package package)
        {
            this.package = package;
            this.engine = engine;

            if (engine.PublishingContext.RenderContext != null && engine.PublishingContext.RenderContext.ContextVariables.Contains(BasePageTemplate.VariableNameCalledFromDynamicDelivery))
            {
                if (engine.PublishingContext.RenderContext.ContextVariables[BasePageTemplate.VariableNameCalledFromDynamicDelivery].Equals(BasePageTemplate.VariableValueCalledFromDynamicDelivery))
                {
                    log.Debug("template is rendered by a DynamicDelivery page template, will not convert from XML to java");
                    return;
                }
            }

            Item outputItem = package.GetByName("Output");
            String inputValue = package.GetValue("Output");

            if (inputValue == null || inputValue.Length == 0)
            {
                log.Warning("Could not find 'Output' in the package, nothing to transform");
                return;
            }

            String minimizeSettings = package.GetValue("MinimizeSettings");


            string outputValue = XmlMinimizer.Convert(inputValue, minimizeSettings);

            // replace the Output item in the package
            package.Remove(outputItem);
            outputItem.SetAsString(outputValue);
            package.PushItem("Output", outputItem);
        }
开发者ID:flaithbheartaigh,项目名称:dynamic-delivery-4-tridion,代码行数:33,代码来源:MinimizeXML.cs

示例3: Transform

      public void Transform(Engine engine, Package package)
      {
         this.package = package;
         this.engine = engine;

         if (engine.PublishingContext.RenderContext != null && engine.PublishingContext.RenderContext.ContextVariables.Contains(BasePageTemplate.VariableNameCalledFromDynamicDelivery))
         {
            if (engine.PublishingContext.RenderContext.ContextVariables[BasePageTemplate.VariableNameCalledFromDynamicDelivery].Equals(BasePageTemplate.VariableValueCalledFromDynamicDelivery))
            {
               log.Debug("template is rendered by a DynamicDelivery page template, will not convert from XML to java");
               return;
            }
         }

         Item outputItem = package.GetByName("Output");
         String inputValue = package.GetValue("Output");

         if (inputValue == null || inputValue.Length == 0)
         {
            log.Warning("Could not find 'Output' in the package, nothing to transform");
            return;
         }

         // Combine the 'to lower' and 'to java' functions, since there is no reason to have one without the other.
         // Note: it is still possible (for backwards compatibility) to have a separate ToLower TBB in your templates.
         // In that case, the first letter of each element will be converted into lower case twice, which doesn't do any harm.
         string outputValue = LowerCaseConverter.Convert(inputValue);
         outputValue = XmlToJavaConverter.Convert(outputValue);
        // outputValue = XmlMinimizer.Convert(outputValue);

         // replace the Output item in the package
         package.Remove(outputItem);
         outputItem.SetAsString(outputValue);
         package.PushItem("Output", outputItem);
      }
开发者ID:flaithbheartaigh,项目名称:dynamic-delivery-4-tridion,代码行数:35,代码来源:ConvertXmlToJava.cs

示例4: Transform

		public void Transform(Engine engine, Package package) {
			this.package = package;
			this.engine = engine;

         if (engine.PublishingContext.RenderContext != null && engine.PublishingContext.RenderContext.ContextVariables.Contains(BasePageTemplate.VariableNameCalledFromDynamicDelivery))
         {
            if (engine.PublishingContext.RenderContext.ContextVariables[BasePageTemplate.VariableNameCalledFromDynamicDelivery].Equals(BasePageTemplate.VariableValueCalledFromDynamicDelivery))
            {
               log.Debug("template is rendered by a DynamicDelivery page template, will not convert to lower case");
               return;
            }
         }

			Item outputItem = package.GetByName("Output");
			String inputValue = package.GetValue("Output");
			if (inputValue == null || inputValue.Length == 0) {
				log.Error("Could not find 'Output' in the package. Exiting template.");
				return;
			}

            string convertedValue = LowerCaseConverter.Convert(inputValue);

			package.Remove(outputItem);
			outputItem.SetAsString(convertedValue);
			package.PushItem("Output", outputItem);
		}
开发者ID:flaithbheartaigh,项目名称:dynamic-delivery-4-tridion,代码行数:26,代码来源:ConvertToLowerCase.cs

示例5: Transform

        public override void Transform(Engine engine, Package package)
        {
            Initialize(engine, package);
            Component comp = GetComponent();
            if (IsPageTemplate() || comp == null)
            {
                Logger.Error("No Component found (is this a Page Template?)");
                return;
            }
            Item outputItem = package.GetByName(Package.OutputName);
            if (outputItem == null)
            {
                Logger.Error("No Output package item found (is this TBB placed at the end?)");
                return;
            }
            _metaFieldNames = (package.GetValue("multimediaLinkAttributes") ?? String.Empty).Split(',').Select(s => s.Trim()).ToList();

            // resolve rich text fields
            string output = outputItem.GetAsString();
            package.Remove(outputItem);
            if (output.StartsWith("<"))
            {
                Logger.Debug("Content is XML");
                //XML - only for backwards compatibility
                package.PushItem(Package.OutputName, package.CreateXmlDocumentItem(ContentType.Xml, ResolveXmlContent(output)));
            }
            else
            {
                Logger.Debug("Content is JSON");
                //JSON
                package.PushItem(Package.OutputName, package.CreateStringItem(ContentType.Text, ResolveJsonContent(output)));
            }
        }
开发者ID:NiclasCedermalm,项目名称:dxa-content-management,代码行数:33,代码来源:ResolveRichText.cs

示例6: Transform

        public void Transform(Engine engine, Package package)
        {
            TemplatingLogger log = TemplatingLogger.GetLogger(GetType());
            if (package.GetByName(Package.OutputName) == null)
            {
                log.Error("Could not find \"Output\" item in Package. This template building block should be the last TBB in your template.");
                return;
            }
            Item output = package.GetByName(Package.OutputName);

            string outputText = output.GetAsString();

            bool outputchanged = false;
            foreach (Match m in TcmUriRegEx.Matches(outputText))
            {
                log.Debug("Found " + m.Value);
                TcmUri uri = new TcmUri(m.Value);
                if(uri.GetVersionlessUri().ToString().Equals(m.Value)) continue;
                log.Debug("Found version information on uri " + m.Value + ". Removing.");
                outputText = outputText.Replace(m.Value, uri.GetVersionlessUri().ToString());
                outputchanged = true;
            }
            if (outputchanged)
            {
                output.SetAsString(outputText);
                package.Remove(output);
                package.PushItem(Package.OutputName, output);
            }
        }
开发者ID:mhassan26,项目名称:SDL-Tridion-Template-Tools,代码行数:29,代码来源:RemoveDynamicVersionFromUri.cs

示例7: Transform

        public void Transform(Engine engine, Package package)
        {

            // do NOT execute this logic when we are actually publishing! (similair for fast track publishing)
            if (engine.RenderMode == RenderMode.Publish || (engine.PublishingContext.PublicationTarget != null && !Tcm.TcmUri.IsNullOrUriNull(engine.PublishingContext.PublicationTarget.Id)))
            {
                return;
            }

            Item outputItem = package.GetByName("Output");
            String inputValue = package.GetValue("Output");

            if (string.IsNullOrEmpty(inputValue))
            {
                log.Warning("Could not find 'Output' in the package, nothing to preview");
                return;
            }

            // read staging url from configuration
            string stagingUrl = TridionConfigurationManager.GetInstance(engine, package).AppSettings["StagingUrl"];
            string outputValue = HttpPost(stagingUrl, inputValue);
            if (string.IsNullOrEmpty(outputValue))
            {
                outputValue = "<h2>There was an error while generating the preview.</h2>";
            }

            // replace the Output item in the package
            package.Remove(outputItem);
            package.PushItem("Output", package.CreateStringItem(ContentType.Html, outputValue));
        }
开发者ID:jhorsman,项目名称:DD4T.TridionTemplates,代码行数:30,代码来源:PreviewPage.cs

示例8: Transform

        public override void Transform(Engine engine, Package package)
        {
            Initialize(engine, package);

            //The core configuration component should be the one being processed by the template
            Component coreConfigComponent = GetComponent();
            StructureGroup sg = GetSystemStructureGroup("config");
            _moduleRoot = GetModulesRoot(coreConfigComponent);

            //Get all the active modules
            Dictionary<string, Component> moduleComponents = GetActiveModules(coreConfigComponent);
            List<string> filesCreated = new List<string>();

            //For each active module, publish the config and add the filename(s) to the bootstrap list
            foreach (KeyValuePair<string, Component> module in moduleComponents)
            {
                filesCreated.Add(ProcessModule(module.Key, module.Value, sg));
            }
            filesCreated.AddRange(PublishJsonData(ReadSchemaData(), coreConfigComponent, "schemas", sg));
            filesCreated.AddRange(PublishJsonData(ReadTemplateData(), coreConfigComponent, "templates", sg));
            filesCreated.AddRange(PublishJsonData(ReadTaxonomiesData(), coreConfigComponent, "taxonomies", sg));

            //Publish the boostrap list, this is used by the web application to load in all other configuration files
            PublishBootstrapJson(filesCreated, coreConfigComponent, sg, "config-", BuildAdditionalData());

            StringBuilder publishedFiles = new StringBuilder();
            foreach (string file in filesCreated)
            {
                if (!String.IsNullOrEmpty(file))
                {
                    publishedFiles.AppendCommaSeparated(file);
                    Logger.Info("Published " + file);
                }
            }

            // append json result to output
            string json = String.Format(JsonOutputFormat, publishedFiles);
            Item outputItem = package.GetByName(Package.OutputName);
            if (outputItem != null)
            {
                package.Remove(outputItem);
                string output = outputItem.GetAsString();
                if (output.StartsWith("["))
                {
                    // insert new json object
                    json = String.Format("{0},{1}{2}]", output.TrimEnd(']'), Environment.NewLine, json);
                }
                else
                {
                    // append new json object
                    json = String.Format("[{0},{1}{2}]", output, Environment.NewLine, json);
                }
            }
            package.PushItem(Package.OutputName, package.CreateStringItem(ContentType.Text, json));
        }
开发者ID:NiclasCedermalm,项目名称:dxa-content-management,代码行数:55,代码来源:PublishConfiguration.cs

示例9: Transform

        public void Transform(Engine engine, Package package)
        {
            Item outputItem = package.GetByName(Package.OutputName);
            string outputText = outputItem.GetAsString();

            Match match = JstlRegex.Match(outputText);
            while (match.Success)
            {
                String replaceJstl = match.Value.Replace("[", "{");
                replaceJstl = replaceJstl.Replace("]", "}");
                outputText = outputText.Replace(match.Value, replaceJstl);
                match = match.NextMatch();
            }
            outputItem.SetAsString(outputText);
            package.Remove(outputItem);
            package.PushItem(Package.OutputName, outputItem);
        }
开发者ID:mhassan26,项目名称:SDL-Tridion-Template-Tools,代码行数:17,代码来源:EnableJSTL.cs

示例10: Transform

        public override void Transform(Engine engine, Package package)
        {
            Initialize(engine, package);

            Item outputItem = package.GetByName(Package.OutputName);
            if (outputItem == null)
            {
                Logger.Error("No Output item found in package. Ensure this TBB is executed at the end of the modular templating pipeline.");
                return;
            }

            string multimediaLinkAttributesParam = package.GetValue("multimediaLinkAttributes") ?? string.Empty;
            Logger.Debug("Using multimediaLinkAttributes: " + multimediaLinkAttributesParam);
            _dataFieldNames = multimediaLinkAttributesParam.Split(',').Select(s => s.Trim()).ToList();

            string output = outputItem.GetAsString();
            package.Remove(outputItem);
            package.PushItem(Package.OutputName, package.CreateStringItem(ContentType.Text, PreProcessRichTextContent(output)));
        }
开发者ID:sdl,项目名称:dxa-content-management,代码行数:19,代码来源:ResolveRichText.cs

示例11: Transform

        public void Transform(Engine engine, Package package)
        {
            this.package = package;
            this.engine = engine;

             if (engine.PublishingContext.RenderContext != null && engine.PublishingContext.RenderContext.ContextVariables.Contains(PageTemplateBase.VariableNameCalledFromDynamicDelivery))
             {
            if (engine.PublishingContext.RenderContext.ContextVariables[PageTemplateBase.VariableNameCalledFromDynamicDelivery].Equals(PageTemplateBase.VariableValueCalledFromDynamicDelivery))
            {
               log.Debug("template is rendered by a DynamicDelivery page template, will not convert to lower case");
               return;
            }
             }

            Item outputItem = package.GetByName("Output");
            String inputValue = package.GetValue("Output");
            if (inputValue == null || inputValue.Length == 0) {
                log.Error("Could not find 'Output' in the package. Exiting template.");
                return;
            }

            StringReader srXml = new StringReader(inputValue);
            XmlReader readerXml = new XmlTextReader(srXml);

            // Load the style sheet.
             XslCompiledTransform xslTransformer = new XslCompiledTransform();

             //load the Xsl from the assembly
             Stream xslStream = IOUtils.LoadResourceAsStream("Tridion.Extensions.DynamicDelivery.Templates.Resources.ConvertFirstCharToLowerCase.xslt");
             xslTransformer.Load(XmlReader.Create(xslStream));

            // Execute the transform and output the results to a file.
            StringWriter sw = new StringWriter();
            XmlWriter writer = new XmlTextWriter(sw);
             xslTransformer.Transform(readerXml, writer);
            writer.Close();
            sw.Close();

            package.Remove(outputItem);
            outputItem.SetAsString(sw.ToString());
            package.PushItem("Output", outputItem);
        }
开发者ID:rainmaker2k,项目名称:TridionMVCDotNet,代码行数:42,代码来源:ConvertToLowerCase.cs

示例12: Transform

        //private string _moduleRoot = String.Empty;
        public override void Transform(Engine engine, Package package)
        {
            Initialize(engine, package);

            //The core configuration component should be the one being processed by the template
            Component coreConfigComponent = GetComponent();
            StructureGroup sg = GetSystemStructureGroup();

            //Publish the boostrap list, this is used by the web application to load in all other static files
            List<string> files = GetBootstrapFiles();
            PublishBootstrapJson(files, coreConfigComponent, sg, "statics-");

            StringBuilder publishedFiles = new StringBuilder();
            foreach (string file in files)
            {
                publishedFiles.AppendCommaSeparated(file);
                Logger.Info("Published " + file);
            }

            // append json result to output
            string json = String.Format(JsonOutputFormat, publishedFiles);
            Item outputItem = package.GetByName(Package.OutputName);
            if (outputItem != null)
            {
                package.Remove(outputItem);
                string output = outputItem.GetAsString();
                if (output.StartsWith("["))
                {
                    // insert new json object
                    json = String.Format("{0},{1}{2}]", output.TrimEnd(']'), Environment.NewLine, json);
                }
                else
                {
                    // append new json object
                    json = String.Format("[{0},{1}{2}]", output, Environment.NewLine, json);
                }
            }
            package.PushItem(Package.OutputName, package.CreateStringItem(ContentType.Text, json));
        }
开发者ID:NiclasCedermalm,项目名称:dxa-content-management,代码行数:40,代码来源:PublishStaticBootstrap.cs

示例13: Transform

        public override void Transform(Engine engine, Package package)
        {
            this.Package = package;
            this.Engine = engine;
            XmlSerializer serializer;

            Dynamic.Component component;
            bool hasOutput = HasPackageValue(package, "Output");
            if (hasOutput)
            {
                GeneralUtils.TimedLog("start retrieving previous Output from package");
                String inputValue = package.GetValue("Output");
                GeneralUtils.TimedLog("start deserializing");
                TextReader tr = new StringReader(inputValue);
                GeneralUtils.TimedLog("start creating serializer");
                serializer = new XmlSerializerFactory().CreateSerializer(typeof(Dynamic.Component));
                GeneralUtils.TimedLog("finished creating serializer");
                component = (Dynamic.Component)serializer.Deserialize(tr);
                GeneralUtils.TimedLog("finished deserializing from package");
            }
            else
            {
                GeneralUtils.ResetLogTimer();
                GeneralUtils.TimedLog("Could not find 'Output' in the package");
                GeneralUtils.TimedLog("Start creating dynamic component from current component in the package");
                GeneralUtils.TimedLog("start creating serializer");
                serializer = new XmlSerializerFactory().CreateSerializer(typeof(Dynamic.Component));
                GeneralUtils.TimedLog("finished creating serializer");
                component = GetDynamicComponent(manager);
                GeneralUtils.TimedLog("Finished creating dynamic component with title " + component.Title);
            }

            try
            {
                GeneralUtils.TimedLog("starting transformComponent");
                TransformComponent(component);
                GeneralUtils.TimedLog("finished transformComponent");
            }
            catch (StopChainException)
            {
                GeneralUtils.TimedLog("caught stopchainexception, will not write current component back to the package");
                return;
            }
            var sw = new StringWriter();
            var ms = new MemoryStream();
            XmlWriter writer = new XmlTextWriterFormattedNoDeclaration(ms, Encoding.UTF8);
            string outputValue;
            //Create our own namespaces for the output
            var ns = new XmlSerializerNamespaces();

            //Add an empty namespace and empty value
            ns.Add("", "");

            serializer.Serialize(writer, component, ns);
            outputValue = Encoding.UTF8.GetString(ms.ToArray());

            // for some reason, the .NET serializer leaves an invalid character at the start of the string
            // we will remove everything up to the first < so that the XML can be deserialized later!
            Regex re = new Regex("^[^<]+");
            outputValue = re.Replace(outputValue, "");

            if (hasOutput)
            {
                Item outputItem = package.GetByName("Output");
                package.Remove(outputItem);
                outputItem.SetAsString(outputValue);
                package.PushItem("Output", outputItem);
            }
            else
            {
                package.PushItem(Package.OutputName, package.CreateStringItem(ContentType.Text, outputValue));
            }

            GeneralUtils.TimedLog("finished Transform");
        }
开发者ID:rainmaker2k,项目名称:TridionMVCDotNet,代码行数:75,代码来源:BaseComponentTemplate.cs

示例14: Transform

        public void Transform(Engine engine, Package package)
        {
            _log = TemplatingLogger.GetLogger(GetType());
            _engine = engine;

            string itemName = string.Empty;
            if (package.GetByName(Package.ComponentName) != null) itemName = Package.ComponentName;
            if (package.GetByName(Package.PageName) != null) itemName = Package.PageName;

            if (string.IsNullOrEmpty(itemName))
            {
                _log.Debug("Could not determine template type, exiting");
                return;
            }

            VersionedItem item = (VersionedItem)engine.GetObject(package.GetByName(itemName));
            if (item.LockType.HasFlag(LockType.InWorkflow))
            {
                CurrentMode mode = GetCurrentMode();
                VersionedItem w = item.GetVersion(0);
                switch (mode)
                {
                    case CurrentMode.CmePreview:
                    case CurrentMode.TemplateBuilder:
                    case CurrentMode.SessionPreview:
                        // return workflow object without comparing to Publication Target Minimum Approval Status
                        package.Remove(package.GetByName(itemName));
                        if (itemName.Equals(Package.ComponentName))
                        {
                            package.PushItem(Package.ComponentName, package.CreateTridionItem(ContentType.Component, w));
                        }
                        else if (itemName.Equals(Package.PageName))
                        {
                            package.PushItem(Package.PageName, package.CreateTridionItem(ContentType.Page, w));
                        }
                        break;

                    case CurrentMode.Publish:
                        PublicationTarget target = _engine.PublishingContext.PublicationTarget;
                        ApprovalStatus targetStatus = target.MinApprovalStatus;
                        ApprovalStatus contentStatus = null;
                        if (w is Component)
                        {
                            contentStatus = ((Component)w).ApprovalStatus;
                        }
                        else if (w is Page)
                        {
                            contentStatus = ((Page)w).ApprovalStatus;
                        }
                        if (contentStatus == null)
                        {
                            _log.Debug("Could not determine approval status of content. Exiting.");
                            return;
                        }
                        bool mustUpdate = false;
                        if (targetStatus == null)
                            mustUpdate = true;
                        else
                        {
                            if (contentStatus.Position > targetStatus.Position)
                                mustUpdate = true;
                        }

                        if (mustUpdate)
                        {
                            package.Remove(package.GetByName(itemName));
                            if (itemName.Equals(Package.ComponentName))
                            {
                                package.PushItem(Package.ComponentName, package.CreateTridionItem(ContentType.Component, w));
                            }
                            else if (itemName.Equals(Package.PageName))
                            {
                                package.PushItem(Package.PageName, package.CreateTridionItem(ContentType.Page, w));
                            }
                        }
                        break;
                }
            }
        }
开发者ID:mhassan26,项目名称:SDL-Tridion-Template-Tools,代码行数:79,代码来源:GetItemInWorkflow.cs


注:本文中的Package.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。