internal DeclareNode(ValueProviderBase valueProvider, Action<bool, string> addError)
            {
                if (!valueProvider.Variable.HasText())
                    addError(true, "declare[{0}] should end with 'as $someVariable'".FormatWith(valueProvider.ToString()));

                this.ValueProvider = valueProvider;
            }
Esempio n. 2
0
        protected internal override void RenderTemplate(ScopedDictionary <string, ValueProviderBase> variables)
        {
            string str = "@declare" + ValueProvider.ToString(variables, null);

            this.ReplaceBy(this.NodeProvider.NewRun((OpenXmlCompositeElement?)this.RunProperties?.CloneNode(true), str));

            ValueProvider.Declare(variables);
        }
Esempio n. 3
0
        public override void WriteTo(System.Xml.XmlWriter xmlWriter)
        {
            var tempText = this.NodeProvider.NewText(ValueProvider?.ToString() ?? "Error!");

            this.AppendChild(tempText);
            base.WriteTo(xmlWriter);
            this.RemoveChild(tempText);
        }
            public override void ToString(StringBuilder sb, ScopedDictionary <string, ValueProviderBase> variables)
            {
                sb.Append("@declare");

                ValueProvider.ToString(sb, variables, null);

                ValueProvider.Declare(variables);
            }
 public override void ToString(StringBuilder sb, ScopedDictionary <string, ValueProviderBase> variables)
 {
     sb.Append("@foreach");
     ValueProvider.ToString(sb, variables, null);
     {
         var newVars = new ScopedDictionary <string, ValueProviderBase>(variables);
         ValueProvider.Declare(newVars);
         Block.ToString(sb, newVars);
     }
     sb.Append("@endforeach");
 }
            public override void ToString(StringBuilder sb, ScopedDictionary <string, ValueProviderBase> variables)
            {
                sb.Append("@");
                if (IsRaw)
                {
                    sb.Append("raw");
                }

                ValueProvider.ToString(sb, variables,
                                       Format.HasText() ? (":" + TemplateUtils.ScapeColon(Format)) : null);
            }
            public override void ToString(StringBuilder sb, ScopedDictionary <string, ValueProviderBase> variables)
            {
                sb.Append("@if");
                ValueProvider.ToString(sb, variables, Operation == null ? null : FilterValueConverter.ToStringOperation(Operation.Value) + Value);
                {
                    var newVars = new ScopedDictionary <string, ValueProviderBase>(variables);
                    ValueProvider.Declare(newVars);
                    IfBlock.ToString(sb, newVars);
                }

                if (ElseBlock != null)
                {
                    sb.Append("@else");
                    var newVars = new ScopedDictionary <string, ValueProviderBase>(variables);
                    ValueProvider.Declare(newVars);
                    ElseBlock.ToString(sb, newVars);
                }

                sb.Append("@endif");
            }
Esempio n. 8
0
        internal DeclareNode(INodeProvider nodeProvider, ValueProviderBase valueProvider, Action <bool, string> addError) : base(nodeProvider)
        {
            if (!valueProvider.Variable.HasText())
            {
                addError(true, "declare{0} should end with 'as $someVariable'".FormatWith(valueProvider.ToString()));
            }

            this.ValueProvider = valueProvider;
        }