Write() public method

public Write ( bool value ) : void
value bool
return void
Beispiel #1
0
 /// <summary>
 /// </summary>
 /// <param name="type">
 /// </param>
 /// <param name="writer">
 /// </param>
 public static void WriteRttiPointerClassInfo(this IType type, IndentedTextWriter writer)
 {
     writer.Write("@\"{0}\" = linkonce_odr unnamed_addr constant ", type.GetRttiPointerInfoName());
     type.WriteRttiPointerClassInfoDeclaration(writer);
     writer.Write(' ');
     type.WriteRttiPointerClassInfoDefinition(writer);
 }
Beispiel #2
0
        public override void AppendDDL(IndentedTextWriter textWriter)
        {
            if (!string.IsNullOrEmpty(Note))
            {
                textWriter.WriteLine("/*");
                textWriter.Write("  ");
                textWriter.WriteLine(Note);
                textWriter.WriteLine("*/");
            }

            textWriter.WriteLine($"IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{ForeignKey.QuotedForeignKeyName}'))");

            textWriter.Indent++;
            textWriter.WriteLine($"ALTER TABLE {ForeignKey.ParentObjectIdentifier}");
            textWriter.Indent++;
            textWriter.Write("ADD ");
            textWriter.Indent++;
            ForeignKey.AppendDDL(textWriter);
            textWriter.WriteLine(";");
            textWriter.Indent--;
            textWriter.Indent--;
            textWriter.Indent--;

            textWriter.WriteLine("GO");
        }
Beispiel #3
0
    private void WriteCallIfElse(IndentedTextWriter writer, MethodBase[] methods)
    {
      for (int i = 0; i < methods.Length; i++)
      {
        ParameterInfo[] parameters = methods[i].GetParameters();

        if (i > 0)
          writer.Write("else ");

        writer.Write("if (");
        if (parameters.Length > 0)
        {
          writer.Write("OnlyContains(arguments");
          foreach (ParameterInfo parameter in parameters)
          {
            writer.Write(", \"");
            writer.Write(parameter.Name);
            writer.Write("\"");
          }
          writer.Write(")");
        }
        else
        {
          writer.Write("arguments.Count == 0");
        }

        writer.WriteLine(")");
        writer.Indent++;
        WriteHashtableCall(writer, methods[i], parameters);
        writer.Indent--;
      }
    }
 protected override void WriteCase(IndentedTextWriter writer, string name)
 {
   writer.Write("return Create");
   writer.Write(name[0].ToString().ToUpperInvariant());
   writer.Write(name.Substring(1));
   writer.WriteLine("(element);");
 }
        private static void WriteProductions(Grammar grammar, IndentedTextWriter output)
        {
            output.WriteLine("// Production rules:");
            output.WriteLine();

            foreach (var prod in grammar.Productions)
            {
                output.WriteLine("// {0}:", prod.Index);
                output.Write("{0} :", prod.Outcome.Name);
                if (prod.Pattern.Length == 0)
                {
                    output.Write(" /*empty*/");
                }
                else
                {
                    foreach (var symb in prod.Pattern)
                    {
                        output.Write(' ');
                        output.Write(symb.Name);
                    }
                }

                output.WriteLine(";");
                output.WriteLine();
            }
        }
Beispiel #6
0
 public void Dump(IndentedTextWriter w)
 {
     w.Write("Bitmap Fill id_" + this.CharacterId + " type: ");
     w.Write(Enum.GetName(typeof(FillType), this.FillType));
     w.Write(" ");
     Matrix.Dump(w);
 }
        public void Generate(Context context, IndentedTextWriter writer)
        {
            foreach (Contract contract in context.Contracts)
            {
                writer.WriteLine();
                writer.WriteLine("[GeneratedCode(\"MessagesGenerator\", \"1.0.0.0\")]");
                writer.Write("public sealed class {0}", contract.Name);
                var interfaces = new List<string>();

                if ((contract.Modifier & ContractModifier.CommandInterface) == ContractModifier.CommandInterface)
                {
                    interfaces.Add(String.Format(CultureInfo.InvariantCulture, _commandBaseType, contract.Members.First().Type));
                }

                if ((contract.Modifier & ContractModifier.EventInterface) == ContractModifier.EventInterface)
                {
                    interfaces.Add(String.Format(CultureInfo.InvariantCulture, _eventBaseType, contract.Members.First().Type));
                }

                if (interfaces.Any())
                {
                    writer.Write(" : {0}", string.Join(", ", interfaces.ToArray()));
                }
                writer.WriteLine();
                writer.WriteLine("{");
                writer.Indent++;

                WriteConstructor(writer, contract);
                writer.WriteLine();
                WriteMembers(contract, writer);

                writer.Indent--;
                writer.WriteLine("}");
            }
        }
Beispiel #8
0
        internal override IndentedTextWriter WriteDiffs(IndentedTextWriter writer, HashSet<ValueDiff> written)
        {
            if (!written.Add(this.ValueDiff))
            {
                writer.Write("...");
                return writer;
            }

            if (this.Diffs.Count == 0)
            {
                writer.Write($"[{this.Index}] x: {this.X.ToInvariantOrNullString()} y: {this.Y.ToInvariantOrNullString()}");
                return writer;
            }

            writer.Write($"[{this.Index}]");
            writer.Indent++;
            foreach (var diff in this.Diffs)
            {
                writer.WriteLine();
                diff.WriteDiffs(writer, written);
            }

            writer.Indent--;
            return writer;
        }
		//===========================================================================================
		protected override void WriteSet(IndentedTextWriter writer, PropertyInfo property)
		{
			writer.Write("image->");
			writer.Write(property.Name);
			writer.Write(" = ");
			WriteGetValue(writer, property);
		}
		//===========================================================================================
		protected override void WriteHashtableCall(IndentedTextWriter writer, MethodBase method, ParameterInfo[] parameters)
		{
			writer.Write("image->");
			writer.Write(method.Name);
			writer.Write("(");
			WriteHashtableParameters(writer, parameters);
			writer.WriteLine(");");
		}
		//===========================================================================================
		public override void WriteHeader(IndentedTextWriter writer)
		{
			writer.Write("static ");
			writer.Write(TypeName);
			writer.Write(" Create");
			writer.Write(ClassName);
			writer.WriteLine("(XmlElement^ element);");
		}
 protected override void WriteCall(IndentedTextWriter writer, MethodBase method, ParameterInfo[] parameters)
 {
   writer.Write("drawables.Add(new ");
   writer.Write(method.DeclaringType.Name);
   writer.Write("(");
   WriteParameters(writer, parameters);
   writer.WriteLine("));");
 }
		//===========================================================================================
		private static void WriteMember(IndentedTextWriter writer, Type type, string suffix)
		{
			writer.Write("private static Type _");
			if (!string.IsNullOrEmpty(suffix))
				writer.Write(suffix);
			WriteType(writer, type);
			writer.WriteLine(";");
		}
		//===========================================================================================
		protected override void WriteHashtableCall(IndentedTextWriter writer, MethodBase method, ParameterInfo[] parameters)
		{
			writer.Write("return ");
			writer.Write(method.DeclaringType.Name);
			writer.Write("(");
			WriteHashtableParameters(writer, parameters);
			writer.WriteLine(");");
		}
Beispiel #15
0
 public void AppendDDL(IndentedTextWriter textWriter)
 {
     if (!IsSystemNamed)
     {
         textWriter.Write($"CONSTRAINT [{ConstraintName}] ");
     }
     textWriter.Write($"UNIQUE {(IsNonClustered ? "NONCLUSTERED" : "CLUSTERED")} ({string.Join(",", Columns)})");
 }
Beispiel #16
0
        public static void Run(Expression<Action<Spec>> action)
        {
            var output = new IndentedTextWriter(Output ?? Console.Out);

            try
            {
                var callingMethod = new StackFrame(1).GetMethod().Name;
                output.WriteLine(callingMethod);
                output.Indent++;
            }
            catch{}

            var parser = new SpecExpressionParser();
            var steps = parser.Parse(action);
            Exception exception = null;
            foreach (var step in steps)
            {
                if (step.Expression == null)
                {
                    output.Write(step);
                }
                else
                {
                    output.Write("{0,-50} => ", step);
                    try
                    {
                        Expression<Action> stepAction = step.Expression.NodeType == ExpressionType.Lambda
                            ? (Expression<Action>) step.Expression
                            : Expression.Lambda<Action>(step.Expression);
                        var compiledAction = stepAction.Compile();
                        compiledAction();
                        output.Write("Passed");
                    }
                    catch(Exception ex)
                    {
                        if (exception == null)
                        {
                            exception = ex;
                        }
                        output.Write("Failed");
                        output.WriteLine();
                        output.WriteLine();
                        output.WriteLine(ex.Message);
                    }
                    output.WriteLine();
                }

                if (step.StepType == StepType.AsA)
                {
                    output.Indent++;
                }

                if (exception != null)
                {
                    throw exception;
                }
            }
        }
 public void AppendDDL(IndentedTextWriter textWriter)
 {
     if (!IsSystemNamed)
     {
         textWriter.Write($"CONSTRAINT {ConstraintName} ");
     }
     textWriter.Write("CHECK ");
     textWriter.Write(Definition);
 }
        public void WriteText(IndentedTextWriter writer)
        {
            writer.WriteLine(Name);
            writer.WriteLine("{");
            writer.Indent++;

            foreach (KeyValuePair<string, NTROValue> entry in Contents)
            {
                var array = entry.Value as NTROArray;

                if (entry.Value.Pointer)
                {
                    writer.Write("{0} {1}* = (ptr) ->", ValveDataType(entry.Value.Type), entry.Key);
                    entry.Value.WriteText(writer);
                }
                else if (array != null)
                {
                    // TODO: This is matching Valve's incosistency
                    if (array.Type == DataType.Byte && array.IsIndirection)
                    {
                        writer.WriteLine("{0}[{2}] {1} =", ValveDataType(array.Type), entry.Key, array.Count);
                    }
                    else
                    {
                        writer.WriteLine("{0} {1}[{2}] =", ValveDataType(array.Type), entry.Key, array.Count);
                    }

                    writer.WriteLine("[");
                    writer.Indent++;

                    foreach (var innerEntry in array)
                    {
                        if (array.Type == DataType.Byte && array.IsIndirection)
                        {
                            writer.WriteLine("{0:X2}", (innerEntry as NTROValue<byte>).Value);
                        }
                        else
                        {
                            innerEntry.WriteText(writer);
                        }
                    }

                    writer.Indent--;
                    writer.WriteLine("]");
                }
                else // Can either be NTROArray or NTROValue so...
                {
                    writer.Write("{0} {1} = ", ValveDataType(entry.Value.Type), entry.Key);
                    entry.Value.WriteText(writer);
                }
            }

            writer.Indent--;
            writer.WriteLine("}");
        }
		//===========================================================================================
		private static void WritePropertyEnd(IndentedTextWriter writer, Type type, string suffix)
		{
			writer.Indent--;
			writer.Write("return _");
			if (!string.IsNullOrEmpty(suffix))
				writer.Write(suffix);
			WriteType(writer, type);
			writer.WriteLine(";");
			WriteEndColon(writer);
			WriteEndColon(writer);
		}
		//===========================================================================================
		public override void WriteIncludes(IndentedTextWriter writer)
		{
			base.WriteIncludes(writer);

			foreach (string pathBase in from constructor in Methods
												 select constructor.First().DeclaringType.Name)
			{
				writer.Write(@"#include ""..\..\Drawables\Paths\");
				writer.Write(pathBase);
				writer.WriteLine(@".h""");
			}
		}
Beispiel #21
0
 public void ToFlashAsm(IndentedTextWriter w)
 {
     if (ActionRecords.CurrentConstantPool != null && ActionRecords.CurrentConstantPool.Constants.Length > Constant16Value)
     {
         string s = ActionRecords.CurrentConstantPool.Constants[Constant16Value];
         w.Write("'" + PrimitiveString.EscapeString(s) + "'");
     }
     else
     {
         w.Write("cp: " + Constant16Value);
     }
 }
Beispiel #22
0
 public virtual void Dump(IndentedTextWriter w)
 {
     w.Write("PlaceObject ");
     w.Write("id:" + Character);
     w.Write(" dp:" + Depth);
     w.Write(" ");
     Matrix.Dump(w);
     if (HasColorTransform)
     {
         //ColorTransform.Dump(w);
     }
     w.WriteLine();
 }
		//===========================================================================================
		private void WriteSwitch(IndentedTextWriter writer, IEnumerable<string> names, int level)
		{
			IEnumerable<char> chars = (from name in names
												where name.Length > level
												select name[level]).Distinct();


			if (chars.Count() == 1 && names.Count() > 1)
			{
				WriteLengthCheck(writer, names, level);
				WriteSwitch(writer, names, ++level);
			}
			else
			{
				WriteLengthCheck(writer, names, level);

				if (chars.Count() > 1)
				{
					writer.Write("switch(element->Name[");
					writer.Write(level);
					writer.WriteLine("])");
					WriteStartColon(writer);
				}

				foreach (char c in chars)
				{
					writer.Write("case '");
					writer.Write(c);
					writer.WriteLine("':");
					WriteStartColon(writer);

					IEnumerable<string> children = from name in names
															 where name.Length > level && name[level] == c
															 select name;

					if (children.Count() == 1)
						WriteExecute(writer, children.First());
					else
						WriteSwitch(writer, children, level + 1);

					WriteEndColon(writer);
				}

				if (chars.Count() > 1)
				{
					WriteEndColon(writer);
					if (level != 0)
						writer.WriteLine("break;");
				}
			}
		}
		//===========================================================================================
		protected override void WriteCall(IndentedTextWriter writer, MethodBase method, ParameterInfo[] parameters)
		{
			if (ReturnsImage(method))
				writer.Write("return ");

			writer.Write("collection->");
			writer.Write(method.Name);
			writer.Write("(");
			WriteParameters(writer, parameters);
			writer.WriteLine(");");

			if (!ReturnsImage(method))
				writer.WriteLine("return nullptr;");
		}
    private void WriteLengthCheck(IndentedTextWriter writer, IEnumerable<string> names, int level)
    {
      string shortName = (from name in names
                          where name.Length == level
                          select name).FirstOrDefault();
      if (shortName == null)
        return;

      writer.Write("if (element.Name.Length == ");
      writer.Write(level);
      writer.WriteLine(")");
      WriteStartColon(writer);
      WriteCase(writer, shortName);
      WriteEndColon(writer);
    }
            public void WriteText(IndentedTextWriter writer)
            {
                writer.WriteLine("ResourceEditStringData_t");
                writer.WriteLine("{");
                writer.Indent++;
                writer.WriteLine("CResourceString m_Name = \"{0}\"", Name);

                var lines = Value.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);

                if (lines.Length > 1)
                {
                    writer.Indent++;

                    writer.Write("CResourceString m_String = \"");

                    foreach (var line in lines)
                    {
                        writer.WriteLine(line);
                    }

                    writer.WriteLine("\"");

                    writer.Indent--;
                }
                else
                {
                    writer.WriteLine("CResourceString m_String = \"{0}\"", Value);
                }

                writer.Indent--;
                writer.WriteLine("}");
            }
Beispiel #27
0
 public void Dump(IndentedTextWriter w)
 {
     w.Write("Line [");
     w.Write("dx: " + this.DeltaX + ", ");
     w.Write("dy: " + this.DeltaY);
     w.Write("]");
 }
Beispiel #28
0
        public override void AppendDDL(IndentedTextWriter textWriter)
        {
            if (Note.Length > 0)
            {
                textWriter.WriteLine("/*");
                textWriter.Write("  ");
                textWriter.WriteLine(Note);
                textWriter.WriteLine("*/");
            }

            textWriter.WriteLine($"IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{ObjectIdentifier}'))");

            textWriter.WriteLine($"CREATE TABLE {ObjectIdentifier} (");

            textWriter.Indent++;
            foreach (var column in Columns)
            {
                column.AppendDDL(textWriter, includeConstraints: true);
                textWriter.WriteLine(",");
            }
            foreach (var constraint in Constraints)
            {
                constraint.AppendDDL(textWriter);
                textWriter.WriteLine(",");
            }
            textWriter.Indent--;

            textWriter.WriteLine(");");
            textWriter.WriteLine("GO");
        }
        /// <summary>
        /// </summary>
        /// <param name="type">
        /// </param>
        /// <param name="writer">
        /// </param>
        public static void WriteRttiClassInfoDeclaration(IType type, IndentedTextWriter writer)
        {
            writer.Write("{ i8*, i8*, i32, i32");

            if (type.BaseType != null)
            {
                writer.Write(", i8*, i32");
            }

            foreach (var @interface in type.GetInterfaces())
            {
                writer.Write(", i8*, i32");
            }

            writer.Write(" }");
        }
 private void WriteCode(IndentedTextWriter writer, string className)
 {
   WriteSeparator(writer);
   writer.Write("private ");
   writer.Write(className);
   writer.Write(" Create");
   writer.Write(className);
   writer.WriteLine("(XmlElement parent)");
   WriteStartColon(writer);
   CheckNull(writer, "parent");
   writer.WriteLine("XmlElement element = (XmlElement)parent.FirstChild;");
   CheckNull(writer, "element");
   WriteSwitch(writer, from type in Types.GetInterfaceTypes(className)
                       select MagickTypes.GetXsdName(type));
   WriteEndColon(writer);
 }