Exemplo n.º 1
0
        // tableRef
        private void DeparseHanaTableReferenceNode(ScriptWriter writer, HanaTableReferenceNode node, QsiScript script)
        {
            // tableName
            writer.Write(node.Identifier);

            if (!node.Behavior.IsEmpty)
            {
                writer.WriteSpace();
                DeparseTreeNode(writer, node.Behavior.Value, script);
            }

            // partitionRestriction?
            if (!node.Partition.IsEmpty)
            {
                writer.WriteSpace();
                writer.Write(node.Partition.Value.Text);
            }

            // tableSampleClause?
            if (!node.Sampling.IsEmpty)
            {
                writer.WriteSpace();
                writer.Write(node.Sampling.Value.Text);
            }
        }
Exemplo n.º 2
0
        protected override void DeparseOrderExpressionNode(ScriptWriter writer, IQsiOrderExpressionNode node, QsiScript script)
        {
            if (node is HanaOrderByExpressionNode hanaOrderBy)
            {
                DeparseTreeNode(writer, node.Expression, script);

                if (!hanaOrderBy.Collate.IsEmpty)
                {
                    writer.WriteSpace();
                    DeparseTreeNode(writer, hanaOrderBy.Collate.Value, script);
                }

                writer.WriteSpace();
                writer.Write(node.Order == QsiSortOrder.Ascending ? "ASC" : "DESC");

                if (hanaOrderBy.NullBehavior.HasValue)
                {
                    var first = hanaOrderBy.NullBehavior == HanaOrderByNullBehavior.NullsFirst;

                    writer.WriteSpace();
                    writer.Write(first ? "NULLS FIRST" : "NULLS LAST");
                }

                return;
            }

            base.DeparseOrderExpressionNode(writer, node, script);
        }
Exemplo n.º 3
0
        protected override void DeparseDerivedTableNode(ScriptWriter writer, IQsiDerivedTableNode node, QsiScript script)
        {
            base.DeparseDerivedTableNode(writer, node, script);

            if (node is not MySqlDerivedTableNode mysqlNode)
            {
                return;
            }

            if (!mysqlNode.ProcedureAnalyse.IsEmpty)
            {
                var procedureAnalyse = mysqlNode.ProcedureAnalyse.Value;

                writer.WriteSpace();
                writer.Write("PROCEDURE ANALYSE (");
                writer.Write(procedureAnalyse.MaxElements);

                if (procedureAnalyse.MaxMemory.HasValue)
                {
                    writer.Write(", ");
                    writer.Write(procedureAnalyse.MaxMemory.Value);
                }

                writer.Write(')');
            }

            if (mysqlNode.Lockings?.Count > 0)
            {
                writer.WriteSpace();
                writer.WriteJoin(" ", mysqlNode.Lockings, DeparseLockingNode);
            }
        }
Exemplo n.º 4
0
        private void DeparseLockingNode(ScriptWriter writer, MySqlLockingNode node)
        {
            if (node.TableLockType == MySqlTableLockType.ShareMode)
            {
                writer.Write("LOCK IN SHARE MODE");
            }
            else
            {
                writer.Write("FOR ");
                writer.Write(node.TableLockType == MySqlTableLockType.Update ? "UPDATE" : "SHARE");

                if (!ListUtility.IsNullOrEmpty(node.Tables))
                {
                    writer.WriteSpace();
                    writer.Write("OF ");
                    writer.WriteJoin(", ", node.Tables);
                }

                if (node.RowLockType.HasValue)
                {
                    writer.WriteSpace();
                    writer.Write(node.RowLockType == MySqlRowLockType.SkipLocked ? "SKIP LOCKED" : "NOWAIT");
                }
            }
        }
Exemplo n.º 5
0
        private void DeparseImpalaGroupingExpressionNode(ScriptWriter writer, ImpalaGroupingExpressionNode node, QsiScript script)
        {
            writer.Write("GROUP BY ");

            bool parens = false;

            switch (node.GroupingSetsType)
            {
            case ImpalaGroupingSetsType.Sets:
                writer.Write("GROUPING SETS(");
                parens = true;
                break;

            case ImpalaGroupingSetsType.Cube:
                writer.Write("CUBE(");
                parens = true;
                break;

            case ImpalaGroupingSetsType.Rollup:
                writer.Write("ROLLUP(");
                parens = true;
                break;
            }

            writer.WriteJoin(", ", node.Items, (_, item) => DeparseTreeNode(writer, item, script));

            if (parens)
            {
                writer.Write(')');
            }
        }
Exemplo n.º 6
0
        private void DeparseHanaDerivedTableNode(ScriptWriter writer, IHanaDerivedTableNode node, QsiScript script)
        {
            if (IsAliasedTableReferenceNode(node))
            {
                DeparseTreeNode(writer, node.Source, script);
                writer.WriteSpace();
                DeparseTreeNode(writer, node.Alias, script);

                if (node.Sampling != null)
                {
                    writer.WriteSpace();
                    writer.Write(node.Sampling.Text);
                }

                return;
            }

            if (node.Directives != null)
            {
                DeparseTreeNode(writer, node.Directives, script);
                writer.WriteSpace();
            }

            writer.Write("SELECT ");

            if (node.Top != null)
            {
                writer.Write("TOP ");
                DeparseTreeNode(writer, node.Top, script);
            }

            if (node.Operation.HasValue)
            {
                writer.Write(node.Operation == HanaResultSetOperation.All ? "ALL " : "DISTINCT ");
            }

            if (node.Columns != null)
            {
                DeparseTreeNode(writer, node.Columns, script);
            }

            if (node.Source != null)
            {
                writer.WriteSpace().Write("FROM ");

                if (node.Source is IQsiDerivedTableNode leftSource && !IsAliasedTableReferenceNode(leftSource) ||
                    node.Source is IQsiCompositeTableNode)
                {
                    DeparseTreeNodeWithParenthesis(writer, node.Source, script);
                }
                else
                {
                    DeparseTreeNode(writer, node.Source, script);
                }
            }
        protected override void OnRender(ScriptWriter writer, bool multiLine, bool startOnNewLine)
        {
            if (multiLine && startOnNewLine)
                writer.WriteNewLineAndIndent();

            string quote = this.DoubleQuotes ? "\"" : "'";
            if (Text == null)
                writer.Write(quote + quote);

			writer.Write(quote + JsScriptWriter.JsConvert(Text).ToString().Replace(quote, @"\" + quote) + quote);
        }
Exemplo n.º 8
0
        private void DeparseImpalaWhereExpressionNode(ScriptWriter writer, ImpalaWhereExpressionNode node, QsiScript script)
        {
            writer.Write("WHERE ");

            if (!string.IsNullOrWhiteSpace(node.PlanHints))
            {
                writer.Write(node.PlanHints);
                writer.WriteSpace();
            }

            DeparseTreeNode(writer, node.Expression.Value, script);
        }
Exemplo n.º 9
0
        private void DeparseImpalaOrderExpressionNode(ScriptWriter writer, ImpalaOrderExpressionNode node, QsiScript script)
        {
            DeparseTreeNode(writer, node.Expression.Value, script);

            writer.WriteSpace();
            writer.Write(node.Order == QsiSortOrder.Ascending ? "ASC" : "DESC");

            if (node.NullsOrder.HasValue)
            {
                writer.WriteSpace();
                writer.Write("NULLS ");
                writer.Write(node.NullsOrder == ImpalaNullsOrder.First ? "FIRST" : "LAST");
            }
        }
Exemplo n.º 10
0
        private void Write(ScriptWriter writer)
        {
            // write namespace
            if (!string.IsNullOrEmpty(Namespace))
            {
                writer.WriteFullLineFormat("namespace {0}", Namespace);
                writer.BeginScope();
            }

            // write class definition
            writer.BeginWrite();
            writer.Write("public ");
            if (IsStatic)
            {
                writer.Write("static ");
            }
            if (IsPartial)
            {
                writer.Write("partial ");
            }
            writer.Write("class " + Name);
            writer.EndWrite();

            writer.BeginScope();

            // write fields and properties
            for (int x = 0; x < fields.Count; x++)
            {
                fields[x].Write(writer);
            }

            for (int x = 0; x < properties.Count; x++)
            {
                properties[x].Write(writer);
            }

            // write methods
            for (int x = 0; x < methods.Count; x++)
            {
                methods[x].Write(writer);
            }

            // write child classes
            for (int x = 0; x < classes.Count; x++)
            {
                classes[x].Write(writer);
            }

            writer.EndScope();
        }
        protected override void OnRender(ScriptWriter writer, bool multiLine, bool startOnNewLine)
        {
            if (multiLine && startOnNewLine)
                writer.WriteNewLineAndIndent();

            writer.Write("function(");
            Parameters.Render(writer, 1);
            writer.Write(") {");
            Commands.Render(writer, 1);

            if (Commands.MultiLine && !Commands.IsNothing())
                writer.WriteNewLineAndIndent();

            writer.Write("}");
        }
		protected override void WriteSeperator(ScriptWriter writer)
		{
			if (writer is JsScriptWriter && ((JsScriptWriter)writer).Condensed && this.SeperatorCondensed != null)
				writer.Write(this.SeperatorCondensed);
			else
				base.WriteSeperator(writer);
		}
Exemplo n.º 13
0
        private void DeparseImpalaTableReferenceNode(ScriptWriter writer, ImpalaTableReferenceNode node, QsiScript script)
        {
            DeparseTableReferenceNode(writer, node, script);

            if (!string.IsNullOrWhiteSpace(node.TableSample))
            {
                writer.WriteSpace();
                writer.Write(node.TableSample);
            }

            if (!string.IsNullOrWhiteSpace(node.PlanHints))
            {
                writer.WriteSpace();
                writer.Write(node.PlanHints);
            }
        }
Exemplo n.º 14
0
        private void DeparseImpalaValuesTableNode(ScriptWriter writer, ImpalaValuesTableNode node, QsiScript script)
        {
            writer.Write("VALUES ");

            writer.WriteJoin(", ", node.Rows, (w, row) =>
            {
                DeparseTreeNode(w, row, script);
            });

            if (!node.Order.IsEmpty)
            {
                writer.WriteSpace();
                DeparseTreeNode(writer, node.Order.Value, script);
            }

            if (!node.Order.IsEmpty)
            {
                writer.WriteSpace();
                DeparseTreeNode(writer, node.Order.Value, script);
            }

            if (!node.Limit.IsEmpty)
            {
                writer.WriteSpace();
                DeparseTreeNode(writer, node.Limit.Value, script);
            }
        }
Exemplo n.º 15
0
        private void DeparseHanaAssociationTableNode(ScriptWriter writer, HanaAssociationTableNode node, QsiScript script)
        {
            // tableName
            writer.Write(node.Identifier);

            // [condition]
            if (!node.Condition.IsEmpty)
            {
                writer.Write('[');
                DeparseTreeNode(writer, node.Condition.Value, script);
                writer.Write(']');
            }

            writer.Write(':');

            DeparseTreeNode(writer, node.Expression.Value, script);
        }
Exemplo n.º 16
0
        protected override void OnRender(ScriptWriter writer, bool multiLine, bool startOnNewLine)
        {
            if (multiLine && startOnNewLine)
                writer.WriteNewLineAndIndent();

            if (New)
                writer.Write("new ");

            writer.Write(Function);
            writer.Write("(");
            Parameters.Render(writer, 1);

            if (multiLine && !Parameters.IsNothing())
                writer.WriteNewLineAndIndent();

            writer.Write(")");
        }
Exemplo n.º 17
0
        protected override void DeparseLimitExpressionNode(ScriptWriter writer, IQsiLimitExpressionNode node, QsiScript script)
        {
            if (node.Limit is not null)
            {
                writer.Write("LIMIT ");
                DeparseTreeNode(writer, node.Limit, script);
            }

            if (node.Offset is not null)
            {
                if (node.Limit is not null)
                {
                    writer.WriteSpace();
                }

                writer.Write("OFFSET ");
                DeparseTreeNode(writer, node.Offset, script);
            }
        }
Exemplo n.º 18
0
        private void DeparseHanaAssociationReferenceNode(ScriptWriter writer, HanaAssociationReferenceNode node, QsiScript script)
        {
            writer.Write(node.Identifier);

            if (node.Condition != null)
            {
                writer.Write("[");

                DeparseTreeNode(writer, node.Condition.Value, script);

                if (!string.IsNullOrEmpty(node.Cardinality))
                {
                    writer.WriteSpace();
                    writer.Write(node.Cardinality);
                }

                writer.Write("]");
            }
        }
Exemplo n.º 19
0
        protected override void DeparseTreeNode(ScriptWriter writer, IQsiTreeNode node, QsiScript script)
        {
            var range = CqlTree.Span[node];

            if (Equals(range, default(Range)))
            {
                base.DeparseTreeNode(writer, node, script);
            }

            writer.Write(script.Script[range]);
        }
Exemplo n.º 20
0
        private void DeparseImpalaJoinedTableNode(ScriptWriter writer, ImpalaJoinedTableNode node, QsiScript script)
        {
            string joinType = node.IsComma ? ", " : $" {node.JoinType?.Trim()} ";

            DeparseTreeNode(writer, node.Left.Value, script);
            writer.Write(joinType);

            if (!string.IsNullOrWhiteSpace(node.PlanHints))
            {
                writer.Write(node.PlanHints).WriteSpace();
            }

            DeparseTreeNode(writer, node.Right.Value, script);

            if (node.PivotColumns is not null)
            {
                writer.Write(" USING ");
                DeparseTreeNodeWithParenthesis(writer, node.PivotColumns.Value, script);
            }
        }
        protected override void OnRender(ScriptWriter writer, bool multiLine, bool startOnNewLine)
        {
            if (multiLine && startOnNewLine)
                writer.WriteNewLineAndIndent();

            writer.Write(Name + ": ");

            if (Value is IScriptItem)
            {
                if (!((IScriptItem)Value).IsNothing())
                {
                    ((IScriptItem)Value).Render(writer);
                }
            }
            else
            {
				writer.Write(Value);
            }

        }
Exemplo n.º 22
0
        /// <summary>
        /// Saves the document at the given URI</summary>
        /// <param name="document">Document to save</param>
        /// <param name="uri">New document URI</param>
        public void Save(IDocument document, Uri uri)
        {
            ScriptDocument circuitDocument = (ScriptDocument)document;
            string         filePath        = uri.LocalPath;
            FileMode       fileMode        = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate;

            using (FileStream stream = new FileStream(filePath, fileMode))
            {
                var writer = new ScriptWriter(m_schemaLoader.TypeCollection);
                writer.Write(circuitDocument.DomNode, stream, uri);
            }
        }
Exemplo n.º 23
0
        protected override void DeparseTreeNode(ScriptWriter writer, IQsiTreeNode node, QsiScript script)
        {
            var range = SqlServerTree.GetSpan(node);

            if (Equals(range, default(Range)))
            {
                base.DeparseTreeNode(writer, node, script);
                return;
            }

            writer.Write(script.Script[range]);
        }
Exemplo n.º 24
0
        protected override void DeparseTreeNode(ScriptWriter writer, IQsiTreeNode node, QsiScript script)
        {
            var rawNode = PTree.RawNode[node];

            if (rawNode == null)
            {
                base.DeparseTreeNode(writer, node, script);
                return;
            }

            writer.Write(global::PhoenixSql.PhoenixSqlDeparser.Deparse(rawNode));
        }
Exemplo n.º 25
0
        private void DeparseHanaTableUpdateBehaviorNode(ScriptWriter writer, HanaTableUpdateBehaviorNode node, QsiScript script)
        {
            writer.Write("FOR UPDATE");

            if (!node.Columns.IsEmpty)
            {
                writer.Write(" (");
                DeparseTreeNode(writer, node.Columns.Value, script);
                writer.Write(')');
            }

            if (node.WaitTime.IsEmpty)
            {
                writer.WriteSpace();

                if (node.WaitTime.IsEmpty)
                {
                    writer.Write("NOWAIT");
                }
                else
                {
                    writer.Write("WAIT ");
                    DeparseTreeNode(writer, node.WaitTime.Value, script);
                }
            }

            if (node.IgnoreLocked)
            {
                writer.Write(" IGNORE LOCKED");
            }
        }
Exemplo n.º 26
0
        protected override void DeparseJoinedTableNode(ScriptWriter writer, IQsiJoinedTableNode node, QsiScript script)
        {
            base.DeparseJoinedTableNode(writer, node, script);

            if (node is SqlServerJoinedTableNode sqlServerJoinedTableNode)
            {
                if (!sqlServerJoinedTableNode.Expression.IsEmpty)
                {
                    writer.Write(" ON ");
                    DeparseTreeNode(writer, sqlServerJoinedTableNode.Expression.Value, script);
                }
            }
        }
Exemplo n.º 27
0
        private void DeparseHanaTableSerializeBehaviorNode(ScriptWriter writer, HanaTableSerializeBehaviorNode node, QsiScript script)
        {
            writer.Write("FOR ").Write(node.Type == HanaTableSerializeType.Json ? "JSON" : "XML");

            if (node.Options.Count > 0)
            {
                writer.Write(" (");

                writer.WriteJoin(", ", node.Options, (w, n) =>
                {
                    w.Write(IdentifierUtility.Escape(n.Key, EscapeQuotes.Single, EscapeBehavior.TwoTime));
                    w.Write('=');
                    w.Write(IdentifierUtility.Escape(n.Value, EscapeQuotes.Single, EscapeBehavior.TwoTime));
                });

                writer.Write(')');
            }

            if (!string.IsNullOrEmpty(node.ReturnType))
            {
                writer.Write(" RETURNS ").Write(node.ReturnType);
            }
        }
Exemplo n.º 28
0
        protected override void DeparseLimitExpressionNode(ScriptWriter writer, IQsiLimitExpressionNode node, QsiScript script)
        {
            if (node is HanaLimitExpressionNode hanaLimit)
            {
                writer.Write("LIMIT ");
                DeparseTreeNode(writer, node.Limit, script);

                if (node.Offset != null)
                {
                    writer.WriteSpace();
                    DeparseTreeNode(writer, node.Offset, script);
                }

                if (hanaLimit.TotalRowCount)
                {
                    writer.WriteSpace();
                    writer.Write("TOTAL ROWCOUNT");
                }

                return;
            }

            base.DeparseLimitExpressionNode(writer, node, script);
        }
Exemplo n.º 29
0
        protected override void DeparseTreeNode(ScriptWriter writer, IQsiTreeNode node, QsiScript script)
        {
            var range = HanaTree.Span[node];

            if (Equals(range, default(Range)))
            {
                switch (node)
                {
                case HanaTableShareLockBehaviorNode shareLock:
                    DeparseHanaTableShareLockBehaviorNode(writer, shareLock, script);
                    break;

                case HanaTableUpdateBehaviorNode update:
                    DeparseHanaTableUpdateBehaviorNode(writer, update, script);
                    break;

                case HanaTableSerializeBehaviorNode serialize:
                    DeparseHanaTableSerializeBehaviorNode(writer, serialize, script);
                    break;

                case HanaTableSystemTimeBehaviorNode systemTime:
                    DeparseHanaTableSystemTimeBehaviorNode(writer, systemTime, script);
                    break;

                case HanaTableApplicationTimeBehaviorNode applicationTime:
                    DeparseHanaTableApplicationTimeBehaviorNode(writer, applicationTime, script);
                    break;

                case HanaViewDefinitionNode viewDefinition:
                    DeparseHanaViewDefinitionNode(writer, viewDefinition, script);
                    break;

                default:
                    base.DeparseTreeNode(writer, node, script);
                    break;
                }

                return;
            }

            writer.Write(script.Script[range]);
        }
Exemplo n.º 30
0
		/// <summary>
		/// Renders the text content after encoding it
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

			IScriptWriter writer = e.Writer;


			if (this.Layout == ScriptLayout.Block && this.HasRenderContent)
				writer.WriteNewLineAndIndent();

            // as we have to process the contents we will have to render it seperately
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, e.Writer); // use same format provider

            sw.Write(this.Text);

            string text = tw.ToString();

            writer.Write(Encode(text));
		}
Exemplo n.º 31
0
        protected override void DeparseCompositeTableNode(ScriptWriter writer, IQsiCompositeTableNode node, QsiScript script)
        {
            switch (node)
            {
            case SqlServerBinaryTableNode sqlServerBinaryTableNode:
            {
                string binaryTableType;

                switch (sqlServerBinaryTableNode.BinaryTableType)
                {
                case SqlServerBinaryTableType.Except:
                    binaryTableType = " EXCEPT ";
                    break;

                case SqlServerBinaryTableType.Intersect:
                    binaryTableType = " INTERSECT ";
                    break;

                case SqlServerBinaryTableType.Union:
                    binaryTableType = " UNION ";
                    break;

                default:
                    throw new NotSupportedException(sqlServerBinaryTableNode.BinaryTableType.ToString());
                }

                DeparseTreeNode(writer, sqlServerBinaryTableNode.Left.Value, script);
                writer.Write(binaryTableType);
                DeparseTreeNode(writer, sqlServerBinaryTableNode.Right.Value, script);
                break;
            }

            default:
                base.DeparseCompositeTableNode(writer, node, script);
                break;
            }
        }
Exemplo n.º 32
0
		/// <summary>
		/// Renders the cdata section
		/// Special handing is done to cope if the data contains the illegal closing cdata character sequence (which I can't use here!)
		/// </summary>
		/// <param name="e">includes the script writer to render content to</param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

			IScriptWriter writer = e.Writer;

			if (this.Layout == ScriptLayout.Block && this.HasRenderContent)
				writer.WriteNewLineAndIndent();

            // as we have to process the contents we will have to render it seperately
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, e.Writer); // use same format provider

            sw.Write(this.Data);

            string text = tw.ToString();


            text = text.Replace("]]>", "]]>]]&gt;<![CDATA["); // resolve embedded ]]> by changing to two cdatas with a text node

			writer.Write("<![CDATA[");
            writer.Write(text);
			writer.Write("]]>");
		}
        public void Write(ScriptWriter writer)
        {
            // method signature
            {
                writer.BeginWrite();

                writer.Write("public ");

                if (IsStatic)
                {
                    writer.Write("static ");
                }

                if (!IsConstructor)
                {
                    writer.WriteFormat("{0} ", ReturnType);
                }

                writer.Write(Name);

                // write parameters
                writer.Write("(");
                for (int x = 0; x < parameters.Count; x++)
                {
                    writer.WriteFormat("{0} {1}", parameters[x].TypeName, parameters[x].Name);

                    if (x + 1 < parameters.Count)
                    {
                        writer.Write(", ");
                    }
                }
                writer.Write(")");
                writer.EndWrite();
            }

            // write method definition
            instructions.Write(writer);

            writer.WriteFullLine(string.Empty);
        }
Exemplo n.º 34
0
		/// <summary>
		/// render the class
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

            // work out the class name
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, e.Writer); // use same format provider

            sw.Write(this.ClassName);

            string className = tw.ToString();

            Script script = Sb.Script();

            string nameSpace = ExtJs.GetNamespace(className);

			Script constructor = Sb.Script();

			if (!String.IsNullOrEmpty(nameSpace))
                script.Add(Js.Statement(Js.Call("Ext.ns", Js.Q(nameSpace)))); // register namespace

            script.AddRange(
                Js.Statement(ClassName, " = ",
					Js.Function(ScriptLayout.InlineBlock,
						Parameters,
						Constructor
					)
				),
				Js.Statement(Js.Call("Ext.extend",ClassName,BaseClass)) // make it inherit from base class
			
            );

            e.Writer.Write(script);
		}
		/// <summary>
		/// Adds the attribute to the supplied element
		/// </summary>
		/// <param name="parentElement"></param>
		public void Render(XmlElement parentElement)
		{
            // as we have to process the contents we will have to render it seperately
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw); // use same format provider

            sw.Write(this.Value);

            string text = tw.ToString();

            parentElement.SetAttribute(this.Name, text);
		}
Exemplo n.º 36
0
		/// <summary>
		/// Add a CData section to the supplied element
		/// Special handing is done to cope if the data contains the illegal closing cdata character sequence
		/// </summary>
		/// <param name="parentElement"></param>
		public void Render(XmlElement parentElement)
		{
			XmlDocument doc = parentElement.OwnerDocument;

            // as we have to process the contents we will have to render it seperately
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw); // use same format provider

            sw.Write(this.Data);

            string text = tw.ToString();


            while (text.Contains("]]>"))
			{
                string subData = text.Substring(0, text.IndexOf("]]>"));
                text = text.Substring(text.IndexOf("]]>") + 3);

				XmlCDataSection subCdata = doc.CreateCDataSection(subData);
				parentElement.AppendChild(subCdata);

				XmlText textNode = doc.CreateTextNode("]]>");
				parentElement.AppendChild(textNode);
			}

            if (!String.IsNullOrEmpty(text))
			{
                XmlCDataSection cdata = doc.CreateCDataSection(text);

				parentElement.AppendChild(cdata);
			}


		}
Exemplo n.º 37
0
        /// <summary>
        /// Provide a string representation of the object
        /// using a javascript format provider
        /// </summary>
        /// <param name="o"></param>
        /// <param name="indentations">number of indentations to start with</param>
        /// <returns></returns>
        public static string Render(object o, int indentations)
        {
            if (o == null)
                return String.Empty;

            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, JsFormatProvider.Instance);
            sw.CurrentIndentLevel = indentations;
            sw.Write(o);

            return tw.ToString();
        }
Exemplo n.º 38
0
 private void DeparseHanaCollateExpressionNode(ScriptWriter writer, HanaCollateExpressionNode node, QsiScript script)
 {
     writer.Write(node.Name);
 }
		/// <summary>
		/// renders the component
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

            Script script = Sb.Script();

            // work out the component name
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, e.Writer); // use same format provider

            sw.Write(this.ComponentName);

            string componentName = tw.ToString();


            string nameSpace = ExtJs.GetNamespace(componentName);

			// namespace script
			if (!String.IsNullOrEmpty(nameSpace))
                script.Add(Js.Statement(Js.Call("Ext.ns", Js.Q(nameSpace)))); // register namespace

			// component script
            script.Add(
                Js.Statement(ComponentName, " = ",
                    Js.Call(ScriptLayout.InlineBlock,"Ext.extend",
                        Js.List(
                            this.BaseComponent,
							Js.Object(ScriptLayout.InlineBlock,
								this.Object
							)
                        )
                    )
                )
			);

			// register script
            if (!String.IsNullOrEmpty(this.RegistryName))
                script.Add(Js.Statement(Js.Call("Ext.reg", Js.Q(this.RegistryName), this.ComponentName))); // register xtype

            e.Writer.Write(script);

		}
Exemplo n.º 40
0
 private void DeparseHanaTableShareLockBehaviorNode(ScriptWriter writer, HanaTableShareLockBehaviorNode node, QsiScript script)
 {
     writer.Write("FOR SHARE LOCK");
 }
Exemplo n.º 41
0
		/// <summary>
		/// Wraps the quotes around the rendering of the text object
		/// escapes internal quotes and new lines
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
        {
			base.OnRender(e);

			IScriptWriter writer = e.Writer;


			if (this.Layout == ScriptLayout.Block)
                writer.WriteNewLineAndIndent();

            string quote = this.DoubleQuotes ? "\"" : "'";
            if (Text == null)
                writer.Write(quote + quote);

            // as we have to process the contents we will have to render it seperately
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, e.Writer); // use same format provider
            
            sw.Write(this.Text);

            string text = tw.ToString();

            // now process it
			text = text.Replace(quote, @"\" + quote);

			text = text.Replace(Environment.NewLine, "\\n\\r");

			writer.Write(quote + text + quote);
		}
Exemplo n.º 42
0
		/// <summary>
		/// Adds a text node to the parent element which contains the supplied text
		/// </summary>
		/// <param name="parentElement"></param>
		public void Render(XmlElement parentElement)
		{
			XmlDocument doc = parentElement.OwnerDocument;

            // as we have to process the contents we will have to render it seperately
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw); // use same format provider

            sw.Write(this.Text);

            string text = tw.ToString();


            XmlText textNode = doc.CreateTextNode(text);

			parentElement.AppendChild(textNode);


		}
Exemplo n.º 43
0
        private void DeparseHanaViewDefinitionNode(ScriptWriter writer, HanaViewDefinitionNode node, QsiScript script)
        {
            writer.Write("CREATE VIEW ").Write(node.Identifier);

            if (!string.IsNullOrEmpty(node.Comment))
            {
                writer.Write(" COMMENT ");
                writer.Write(IdentifierUtility.Escape(node.Comment, EscapeQuotes.Single, EscapeBehavior.TwoTime));
            }

            if (!node.Columns.IsEmpty)
            {
                writer.WriteSpace();
                writer.Write('(');
                DeparseTreeNode(writer, node.Columns.Value, script);
                writer.Write(')');
            }

            if (!node.Parameters.IsEmpty)
            {
                writer.WriteSpace().Write(node.Parameters.Value.Text);
            }

            writer.Write(" AS ");
            DeparseTreeNode(writer, node.Source.Value, script);

            if (!node.Associations.IsEmpty)
            {
                writer.WriteSpace().Write(node.Associations.Value.Text);
            }

            if (!node.Masks.IsEmpty)
            {
                writer.WriteSpace().Write(node.Masks.Value.Text);
            }

            if (!node.ExpressionMacros.IsEmpty)
            {
                writer.WriteSpace().Write(node.ExpressionMacros.Value.Text);
            }

            if (!node.Annotation.IsEmpty)
            {
                writer.WriteSpace().Write(node.Annotation.Value.Text);
            }

            if (node.StructuredPrivilegeCheck)
            {
                writer.WriteSpace().Write("WITH STRUCTURED PRIVILEGE CHECK");
            }

            if (!node.Cache.IsEmpty)
            {
                writer.WriteSpace().Write(node.Cache.Value.Text);
            }

            if (!node.Force)
            {
                writer.WriteSpace().Write("FORCE");
            }

            if (!node.CheckOption)
            {
                writer.WriteSpace().Write("WITH CHECK OPTION");
            }

            if (!node.DdlOnly)
            {
                writer.WriteSpace().Write("WITH DDL ONLY");
            }

            if (!node.ReadOnly)
            {
                writer.WriteSpace().Write("WITH READ ONLY");
            }

            if (!node.Anonymization.IsEmpty)
            {
                writer.WriteSpace().Write(node.Anonymization.Value.Text);
            }
        }
Exemplo n.º 44
0
 private void DeparseHanaTableApplicationTimeBehaviorNode(ScriptWriter writer, HanaTableApplicationTimeBehaviorNode node, QsiScript script)
 {
     writer.Write("FOR APPLICATION_TIME AS OF ");
     writer.Write(IdentifierUtility.Escape(node.Time, EscapeQuotes.Single, EscapeBehavior.TwoTime));
 }