Exemple #1
0
        internal static void TraceEvent(IndentLevel traceLevel, Func <string> message)
        {
            var lTraceSink = DebugView.traceSink;

            if (lTraceSink == null)
            {
                return;
            }

            string messageStr = null;

            try
            {
                messageStr = message() ?? String.Empty;
            }
            catch (Exception ex)
            {
                messageStr = "[Exception thrown]\n" + ex;
            }

            var formattedMessage = String.Join(Environment.NewLine, messageStr.Split('\n')
                                               .Select(line => String.Format("{0}{1}", traceLevel.AsIndent(), line.TrimEnd())).ToArray())
                                   + (traceLevel.IsLeaf() ? "" : ":");

            lTraceSink.TraceEvent(formattedMessage);

            Debug.WriteLine(formattedMessage);

            GC.KeepAlive(CurrentState);             // for coverage testing
        }
Exemple #2
0
        internal static void TraceEvent(IndentLevel traceLevel, Func <string> message)
        {
            var lTraceSink = DebugView.traceSink;

            if (lTraceSink == null)
            {
                return;
            }

            string messageStr = null;

            try
            {
                messageStr = message() ?? String.Empty;
            }
            catch (Exception ex)
            {
                messageStr = "[Exception thrown]\n" + ex;
            }

            var formattedMessage = String.Format("{0}{1}{2}",
                                                 traceLevel.AsIndent(), messageStr.Trim(), traceLevel.IsLeaf() ? "" : ":");

            lTraceSink.TraceEvent(formattedMessage);

            Debug.WriteLine(formattedMessage);

            GC.KeepAlive(CurrentState);             // for coverage testing
        }
Exemple #3
0
        private static bool IsLeaf(this IndentLevel level)
        {
            switch (level)
            {
            case IndentLevel.DispatchResult:
            case IndentLevel.Matcher:
                return(true);

            default:
                return(false);
            }
        }
        public void Write(StringBuilder builder, IndentLevel indentLevel)
        {
            if (builder == null || indentLevel == null)
            {
                return;
            }

            for (int x = 0; x < indentLevel.Level; x++)
            {
                builder.Append("\t");
            }
        }
Exemple #5
0
        public override string Write()
        {
            StringBuilder Code = new StringBuilder();

            Code.AppendLine(IndentLevel.GetIndent() + "new SimGroup(" + objname + ") {");
            IndentLevel.indentLevel++;
            foreach (var item in GroupItems)
            {
                Code.AppendLine(item.Write());
            }
            IndentLevel.indentLevel--;
            Code.AppendLine(IndentLevel.GetIndent() + "};");
            return(Code.ToString()); //End of chapter
        }
Exemple #6
0
        public override string Write()
        {
            StringBuilder Code = new StringBuilder();

            Code.AppendLine(IndentLevel.GetIndent() + "new Sun(" + objname + ") {");
            IndentLevel.indentLevel++;
            Code.AppendLine(IndentLevel.GetIndent() + "direction = \"" + Direction.ToString() + "\";");
            Code.AppendLine(IndentLevel.GetIndent() + "color = \"" + Color.ToString() + "\";");
            Code.AppendLine(IndentLevel.GetIndent() + "ambient = \"" + Ambient.ToString() + "\";");
            if (dynamicFields.Count != 0)
            {
                foreach (KeyValuePair <string, string> dynamicfield in dynamicFields) //dynamic field handling
                {
                    Code.AppendLine(IndentLevel.GetIndent() + dynamicfield.Key + " = \"" + dynamicfield.Value + "\";");
                }
            }
            IndentLevel.indentLevel--;
            Code.AppendLine(IndentLevel.GetIndent() + "};");
            return(Code.ToString());
        }
Exemple #7
0
        public override string Write()
        {
            StringBuilder Code = new StringBuilder();

            Code.AppendLine(IndentLevel.GetIndent() + "new Sky(" + objname + ") {");
            IndentLevel.indentLevel++;
            Code.AppendLine(IndentLevel.GetIndent() + "position = \"" + Position.ToString() + "\";");
            Code.AppendLine(IndentLevel.GetIndent() + "rotation = \"" + Rotation.ToString() + "\";");
            Code.AppendLine(IndentLevel.GetIndent() + "scale = \"" + Scale.ToString() + "\";");
            Code.AppendLine(IndentLevel.GetIndent() + "materialList = \"" + Skybox + "\";");
            if (dynamicFields.Count != 0)
            {
                foreach (KeyValuePair <string, string> dynamicfield in dynamicFields) //dynamic field handling
                {
                    Code.AppendLine(IndentLevel.GetIndent() + dynamicfield.Key + " = \"" + dynamicfield.Value + "\";");
                }
            }
            IndentLevel.indentLevel--;
            Code.AppendLine(IndentLevel.GetIndent() + "};");
            return(Code.ToString());
        }
        /// <summary>
        /// Translate a layer enum type to an indentation level.
        /// </summary>
        /// <param name="layer"></param>
        /// <returns></returns>
        private static string TranslateLayer(IndentLevel layer)
        {
            switch (layer)
            {
            case IndentLevel.Level1:
                return("\t");

            case IndentLevel.Level2:
                return("\t\t");

            case IndentLevel.Level3:
                return("\t\t\t");

            case IndentLevel.Level4:
                return("\t\t\t\t");

            case IndentLevel.Level5:
                return("\t\t\t\t\t");
            }
            return(string.Empty);
        }
Exemple #9
0
		internal static void TraceEvent(IndentLevel traceLevel, Func<string> message)
		{
			var lTraceSink = DebugView.traceSink;
			if (lTraceSink == null)
				return;

			string messageStr = null;
			try
			{
				messageStr = message() ?? String.Empty;
			}
			catch (Exception ex)
			{
				messageStr = "[Exception thrown]\n" + ex;
			}

			var formattedMessage = String.Join(Environment.NewLine, messageStr.Split('\n')
					.Select(line => String.Format("{0}{1}", traceLevel.AsIndent(), line.TrimEnd())).ToArray())
				+ (traceLevel.IsLeaf() ? "" : ":");
			lTraceSink.TraceEvent(formattedMessage);

			Debug.WriteLine(formattedMessage);

			GC.KeepAlive(CurrentState); // for coverage testing
		}
Exemple #10
0
 private static string AsIndent(this IndentLevel traceLevel)
 {
     return("".Join(Enumerable.Repeat("    ", (int)traceLevel)));
 }
Exemple #11
0
		internal static void TraceEvent(IndentLevel traceLevel, Func<string> message)
		{
			var lTraceSink = DebugView.traceSink;
			if (lTraceSink == null)
				return;

			string messageStr = null;
			try
			{
				messageStr = message() ?? String.Empty;
			}
			catch (Exception ex)
			{
				messageStr = "[Exception thrown]\n" + ex;
			}

			var formattedMessage = String.Format("{0}{1}{2}",
				traceLevel.AsIndent(), messageStr.Trim(), traceLevel.IsLeaf() ? "" : ":");
			lTraceSink.TraceEvent(formattedMessage);

			Debug.WriteLine(formattedMessage);

			GC.KeepAlive(CurrentState); // for coverage testing
		}
        /// <summary>
        /// Print a string message on console with a given indentation level.
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="message"></param>
        public static void PrintString(IndentLevel layer, string message)
        {
            string indentation = TranslateLayer(layer);

            Console.WriteLine($"{indentation}{message}");
        }