Example #1
0
        /// <summary>
        /// Generates a detailed error message
        /// </summary>
        /// <param name="sassСompilationException">Sass compilation exception</param>
        /// <returns>Detailed error message</returns>
        public static string Format(SassСompilationException sassСompilationException)
        {
            string message = sassСompilationException.Text;
            string filePath = sassСompilationException.File;
            int lineNumber = sassСompilationException.LineNumber;
            int columnNumber = sassСompilationException.ColumnNumber;
            string sourceCode = sassСompilationException.Source;
            string sourceFragment = SourceCodeNavigator.GetSourceFragment(sourceCode,
                new SourceCodeNodeCoordinates(lineNumber, columnNumber));

            var errorMessage = new StringBuilder();
            errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Message, message);
            if (!string.IsNullOrWhiteSpace(filePath))
            {
                errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_File, filePath);
            }
            if (lineNumber > 0)
            {
                errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_LineNumber,
                    lineNumber.ToString(CultureInfo.InvariantCulture));
            }
            if (columnNumber > 0)
            {
                errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ColumnNumber,
                    columnNumber.ToString(CultureInfo.InvariantCulture));
            }
            if (!string.IsNullOrWhiteSpace(sourceFragment))
            {
                errorMessage.AppendFormatLine("{1}:{0}{0}{2}", Environment.NewLine,
                    Strings.ErrorDetails_SourceFragment,
                    sourceFragment);
            }

            return errorMessage.ToString();
        }
Example #2
0
 public override string ToString()
 {
     var builder = new StringBuilder();
     builder.AppendFormatLine("First name: {0}", FirstName);
     builder.AppendFormatLine("Last name: {0}", LastName);
     builder.AppendFormatLine("Address: {0}", Address);
     return builder.ToString();
 }
        public string WriteToString(ServerSettings serverSettings)
        {
            var sb = new StringBuilder();

            sb.AppendFormatLine(@"server:{0}", serverSettings.ServerIp);
            sb.AppendFormatLine(@"port:{0}", serverSettings.Port);
            sb.AppendLine(";Timeout in seconds");
            sb.AppendFormatLine(@"timeout:{0}", serverSettings.TimeoutInSeconds);

            return sb.ToString();
        }
        /// <summary>
        /// Generates a detailed error message
        /// </summary>
        /// <param name="jsEngineLoadException">JavaScript engine load exception</param>
        /// <returns>Detailed error message</returns>
        public static string Format(JsEngineLoadException jsEngineLoadException)
        {
            var errorMessage = new StringBuilder();
            errorMessage.AppendFormatLine("{0}: {1}", CommonStrings.ErrorDetails_Message,
                jsEngineLoadException.Message);
            if (!string.IsNullOrWhiteSpace(jsEngineLoadException.EngineMode))
            {
                errorMessage.AppendFormatLine("{0}: {1}", CommonStrings.ErrorDetails_EngineMode,
                    jsEngineLoadException.EngineMode);
            }

            return errorMessage.ToString();
        }
		protected override string CombineAssetContent(IList<IAsset> assets)
		{
			var contentBuilder = new StringBuilder();
			int assetCount = assets.Count;
			int lastAssetIndex = assetCount - 1;

			for (int assetIndex = 0; assetIndex < assetCount; assetIndex++)
			{
				IAsset asset = assets[assetIndex];
				string assetContent = asset.Content.TrimEnd();

				if (EnableTracing)
				{
					contentBuilder.AppendFormatLine("//#region URL: {0}", asset.Url);
				}
				contentBuilder.Append(assetContent);
				if (!assetContent.EndsWith(";"))
				{
					contentBuilder.Append(";");
				}
				if (EnableTracing)
				{
					contentBuilder.AppendLine();
					contentBuilder.AppendLine("//#endregion");
				}

				if (assetIndex != lastAssetIndex)
				{
					contentBuilder.AppendLine();
				}
			}

			return contentBuilder.ToString();
		}
Example #6
0
 public override void ToString(StringBuilder builder)
 {
     builder.AppendFormatLine("Seed: 0x{0:X8}  Count: {1}", Seed, Count);
     builder.Append("Client Seed: ");
     ClientSeed.ToHexString(builder);
     builder.AppendLine();
     builder.Append("Server Seed: ");
     ServerSeed.ToHexString(builder);
     builder.AppendLine();
 }
        /// <summary>
        /// Logs a information about the error
        /// </summary>
        /// <param name="category">Error category</param>
        /// <param name="message">Error message</param>
        /// <param name="filePath">File path</param>
        /// <param name="lineNumber">Line number on which the error occurred</param>
        /// <param name="columnNumber">Column number on which the error occurred</param>
        /// <param name="sourceFragment">Fragment of source code</param>
        public override void Error(string category, string message, string filePath = "",
			int lineNumber = 0, int columnNumber = 0, string sourceFragment = "")
        {
            var errorMessage = new StringBuilder();
            errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Category, category);
            errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Message, message);

            if (!string.IsNullOrWhiteSpace(filePath))
            {
                errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_File, filePath);
            }

            if (lineNumber > 0)
            {
                errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_LineNumber, lineNumber);
            }

            if (columnNumber > 0)
            {
                errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ColumnNumber, columnNumber);
            }

            if (!string.IsNullOrWhiteSpace(sourceFragment))
            {
                errorMessage.AppendFormatLine("{1}:{0}{0}{2}", Environment.NewLine,
                    Strings.ErrorDetails_SourceFragment, sourceFragment);
            }

            throw new MarkupMinificationException(errorMessage.ToString());
        }
Example #8
0
		private void Output(String msg, Boolean error = false)
		{
			var sb = new StringBuilder();
			var start = txtOutput.TextLength;

			sb.AppendFormatLine("> {0}", msg);
			txtOutput.AppendText(sb.ToString());

			txtOutput.Select(start, txtOutput.TextLength - 1);
			txtOutput.SelectionColor = error ? Color.DarkRed : Color.Black;

			txtOutput.DeselectAll();

			txtOutput.Refresh();
		}
		/// <summary>
		/// Generates a detailed error message
		/// </summary>
		/// <param name="jsRuntimeException">JavaScript runtime exception</param>
		/// <returns>Detailed error message</returns>
		public static string Format(JsRuntimeException jsRuntimeException)
		{
			var errorMessage = new StringBuilder();
			errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Message,
				jsRuntimeException.Message);
			if (!string.IsNullOrWhiteSpace(jsRuntimeException.EngineName))
			{
				errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_EngineName,
					jsRuntimeException.EngineName);
			}
			if (!string.IsNullOrWhiteSpace(jsRuntimeException.EngineVersion))
			{
				errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_EngineVersion,
					jsRuntimeException.EngineVersion);
			}
			if (!string.IsNullOrWhiteSpace(jsRuntimeException.ErrorCode))
			{
				errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ErrorCode,
					jsRuntimeException.ErrorCode);
			}
			if (!string.IsNullOrWhiteSpace(jsRuntimeException.Category))
			{
				errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Category,
					jsRuntimeException.Category);
			}
			if (jsRuntimeException.LineNumber > 0)
			{
				errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_LineNumber,
					jsRuntimeException.LineNumber.ToString(CultureInfo.InvariantCulture));
			}
			if (jsRuntimeException.ColumnNumber > 0)
			{
				errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ColumnNumber,
					jsRuntimeException.ColumnNumber.ToString(CultureInfo.InvariantCulture));
			}
			if (!string.IsNullOrWhiteSpace(jsRuntimeException.SourceFragment))
			{
				errorMessage.AppendFormatLine("{1}:{0}{0}{2}", Environment.NewLine,
					Strings.ErrorDetails_SourceFragment,
					jsRuntimeException.SourceFragment);
			}

			return errorMessage.ToString();
		}
		protected override string CombineAssetContent(IList<IAsset> assets)
		{
			var contentBuilder = new StringBuilder();
			string topCharset = string.Empty;
			var imports = new List<string>();

			int assetCount = assets.Count;
			int lastAssetIndex = assetCount - 1;

			for (int assetIndex = 0; assetIndex < assetCount; assetIndex++)
			{
				IAsset asset = assets[assetIndex];

				if (EnableTracing)
				{
					contentBuilder.AppendFormatLine("/*#region URL: {0} */", asset.Url);
				}
				contentBuilder.Append(EjectCssCharsetAndImports(asset.Content, ref topCharset, imports));
				if (EnableTracing)
				{
					contentBuilder.AppendLine();
					contentBuilder.AppendLine("/*#endregion*/");
				}

				if (assetIndex != lastAssetIndex)
				{
					contentBuilder.AppendLine();
				}
			}

			if (imports.Count > 0)
			{
				string importsTemplate = EnableTracing ?
					"/*#region CSS Imports */{0}{1}{0}/*#endregion*/{0}{0}" : "{1}{0}";

				contentBuilder.Insert(0, string.Format(importsTemplate, Environment.NewLine,
					string.Join(Environment.NewLine, imports)));
			}

			if (!string.IsNullOrWhiteSpace(topCharset))
			{
				contentBuilder.Insert(0, topCharset + Environment.NewLine);
			}

			return contentBuilder.ToString();
		}
Example #11
0
        public static void ShowError(FrameworkElement owner, Exception exception, string formatMessage = null, params object[] args)
        {
            Log.Error(exception, formatMessage, args);

            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(formatMessage))
                sb.AppendFormatLine(formatMessage, args);
            if (exception != null)
                sb.Append(exception);

            if (owner == null)
            {
                MessageBox.Show(sb.ToString(), "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                Window window = (Window)owner.GetRootElement();
                MessageBox.Show(window, sb.ToString(), "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #12
0
    /// <summary>
    /// Constructs exception composing details from response, method specific error description and actual inner exception
    /// </summary>
    /// <param name="response">Response of failed request</param>
    /// <param name="stripeErrorMessage">Method specific error description</param>
    /// <param name="inner">Actual inner exception</param>
    /// <returns>Composed exception</returns>
    public static TaxException Compose(HttpWebResponse response, string stripeErrorMessage, Exception inner)
    {
      int statusCode = (int)response.StatusCode;

      string responseErrMsg = string.Empty;
      try
      {
        using(var reponseStream  = response.GetResponseStream())
        {
          using (var responseReader = new System.IO.StreamReader(reponseStream))
          {
            string responseStr = responseReader.ReadToEnd();
            dynamic responseObj = responseStr.JSONToDynamic();
            var sb = new StringBuilder();
            foreach (var item in ((JSONDataMap)responseObj.Data))
            {
              sb.AppendFormatLine("{0}: {1}", item.Key, item.Value);
            }
            responseErrMsg = sb.ToString();
          }
        }
      }
      catch (Exception)
      {
        // dlatushkin 2014/04/07:
        // there is no way to test some cases (50X errors for example)
        // so try/catch is used to swallow exception
      }

      string specificError = System.Environment.NewLine;
      if (responseErrMsg.IsNotNullOrWhiteSpace())
        specificError += StringConsts.PAYMENT_STRIPE_ERR_MSG_ERROR.Args( responseErrMsg) + System.Environment.NewLine;

      specificError += stripeErrorMessage;

      TaxException ex = new TaxException(specificError, inner);

      return ex;
    }
Example #13
0
        private static string GetHeader(IEnumerable<string> assemblyPaths, bool forceDueToSpecialType)
        {
            if (!forceDueToSpecialType && !assemblyPaths.Any())
            {
                return "";
            }

            if (!assemblyPaths.All(File.Exists))
            {
                return "";
            }

            var sb = new StringBuilder();
            sb.AppendFormatLine("//****************************************************************");
            sb.AppendFormatLine("//  Generated by:  ToTypeScriptD");
            sb.AppendFormatLine("//  Website:       http://github.com/ToTypeScriptD/ToTypeScriptD");
            sb.AppendFormatLine("//  Version:       {0}", System.Diagnostics.FileVersionInfo.GetVersionInfo(typeof(Render).Assembly.Location).ProductVersion);
            sb.AppendFormatLine("//  Date:          {0}", DateTime.Now);
            if (assemblyPaths.Any())
            {
                sb.AppendFormatLine("//");
                sb.AppendFormatLine("//  Assemblies:");
                assemblyPaths
                    .Select(System.IO.Path.GetFileName)
                    .Distinct()
                    .OrderBy(s => s)
                    .Each(path =>
                    {
                        sb.AppendFormatLine("//    {0}", System.IO.Path.GetFileName(path));
                    });
                sb.AppendFormatLine("//");
            }
            sb.AppendFormatLine("//****************************************************************");
            sb.AppendFormatLine();
            sb.AppendFormatLine();
            sb.AppendFormatLine();
            return sb.ToString();
        }
		/// <summary>
		/// Generates a detailed error message
		/// </summary>
		/// <param name="errorDetails">Error details</param>
		/// <param name="sourceCode">Source code</param>
		/// <param name="currentFilePath">Path to current LESS-file</param>
		/// <param name="dependencies">List of dependencies</param>
		/// <returns>Detailed error message</returns>
		private static string FormatErrorDetails(JToken errorDetails, string sourceCode, string currentFilePath,
			DependencyCollection dependencies)
		{
			var type = errorDetails.Value<string>("type");
			var message = errorDetails.Value<string>("message");
			var filePath = errorDetails.Value<string>("fileName");
			if (string.IsNullOrWhiteSpace(filePath))
			{
				filePath = currentFilePath;
			}
			var lineNumber = errorDetails.Value<int>("lineNumber");
			var columnNumber = errorDetails.Value<int>("columnNumber");

			string newSourceCode = string.Empty;
			if (string.Equals(filePath, currentFilePath, StringComparison.OrdinalIgnoreCase))
			{
				newSourceCode = sourceCode;
			}
			else
			{
				var dependency = dependencies.GetByUrl(filePath);
				if (dependency != null)
				{
					newSourceCode = dependency.Content;
				}
			}

			string sourceFragment = SourceCodeNavigator.GetSourceFragment(newSourceCode,
				new SourceCodeNodeCoordinates(lineNumber, columnNumber));

			var errorMessage = new StringBuilder();
			if (!string.IsNullOrWhiteSpace(type))
			{
				errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_ErrorType, type);
			}
			errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_Message, message);
			if (!string.IsNullOrWhiteSpace(filePath))
			{
				errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_File, filePath);
			}
			if (lineNumber > 0)
			{
				errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_LineNumber,
					lineNumber.ToString(CultureInfo.InvariantCulture));
			}
			if (columnNumber > 0)
			{
				errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_ColumnNumber,
					columnNumber.ToString(CultureInfo.InvariantCulture));
			}
			if (!string.IsNullOrWhiteSpace(sourceFragment))
			{
				errorMessage.AppendFormatLine("{1}:{0}{0}{2}", Environment.NewLine,
					CoreStrings.ErrorDetails_SourceError, sourceFragment);
			}

			return errorMessage.ToString();
		}
Example #15
0
 private void WriteAsyncPromiseMethods(StringBuilder sb)
 {
     string genericTypeArgName;
     if (IsTypeAsync(out genericTypeArgName))
     {
         sb.AppendLine();
         Indent(sb); Indent(sb); sb.AppendFormatLine("// Promise Extension");
         Indent(sb); Indent(sb); sb.AppendFormatLine("then<U>(success?: (value: {0}) => ToTypeScriptD.WinRT.IPromise<U>, error?: (error: any) => ToTypeScriptD.WinRT.IPromise<U>, progress?: (progress: any) => void): ToTypeScriptD.WinRT.IPromise<U>;", genericTypeArgName);
         Indent(sb); Indent(sb); sb.AppendFormatLine("then<U>(success?: (value: {0}) => ToTypeScriptD.WinRT.IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): ToTypeScriptD.WinRT.IPromise<U>;", genericTypeArgName);
         Indent(sb); Indent(sb); sb.AppendFormatLine("then<U>(success?: (value: {0}) => U, error?: (error: any) => ToTypeScriptD.WinRT.IPromise<U>, progress?: (progress: any) => void): ToTypeScriptD.WinRT.IPromise<U>;", genericTypeArgName);
         Indent(sb); Indent(sb); sb.AppendFormatLine("then<U>(success?: (value: {0}) => U, error?: (error: any) => U, progress?: (progress: any) => void): ToTypeScriptD.WinRT.IPromise<U>;", genericTypeArgName);
         Indent(sb); Indent(sb); sb.AppendFormatLine("done<U>(success?: (value: {0}) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;", genericTypeArgName);
     }
 }
Example #16
0
        private void CreateAIScript_Click(object sender, EventArgs e)
        {
            err = false;
            rtbScriptOut.Clear();
            rtbScriptOut.ForeColor = Color.Blue;

            ScriptAI script             = new ScriptAI();
            script.ID                   = _tbScriptID.Text.ToInt32();
            script.NpcEntry             = _tbEntryNpc.Text.ToInt32();
            script.EventType            = _cbEventType.GetIntValue();
            script.Phase                = _clbPhase.GetFlagsValue();
            script.Chance               = _tbShance.Text.ToInt32();
            script.Flags                = _clbEventFlag.GetFlagsValue();

            script.EventParam[0]        = _cbEventParametr1.GetIntValue();
            script.EventParam[1]        = _cbEventParametr2.GetIntValue();
            script.EventParam[2]        = _cbEventParametr3.GetIntValue();
            script.EventParam[3]        = _cbEventParametr4.GetIntValue();

            script.ActionType[0]        = _cbActionType1.GetIntValue();
            script.ActionParam[0, 0]    = _cbActionParam1_1.GetIntValue();
            script.ActionParam[0, 1]    = _cbActionParam1_2.GetIntValue();
            script.ActionParam[0, 2]    = _cbActionParam1_3.GetIntValue();

            script.ActionType[1]        = _cbActionType2.GetIntValue();
            script.ActionParam[1, 0]    = _cbActionParam2_1.GetIntValue();
            script.ActionParam[1, 1]    = _cbActionParam2_2.GetIntValue();
            script.ActionParam[1, 2]    = _cbActionParam2_3.GetIntValue();

            script.ActionType[2]        = _cbActionType3.GetIntValue();
            script.ActionParam[2, 0]    = _cbActionParam3_1.GetIntValue();
            script.ActionParam[2, 1]    = _cbActionParam3_2.GetIntValue();
            script.ActionParam[2, 2]    = _cbActionParam3_3.GetIntValue();

            script.Comment              = _tbComment.Text;

            #region Проверки

            if (script.ID < 1)
                LogOut("Номен скрипта должен быть больше 0!");

            if (script.Chance == 0 || script.Chance > 100)
                LogOut("Шанс срабатывания должен быть 0 и не больше 100%!");

            switch ((EventType)script.EventType)
            {
                case EventType.ПО_ТАЙМЕРУ_В_БОЮ:
                case EventType.ПО_ТАЙМЕРУ_ВНЕ_БОЯ:
                    if (script.EventParam[0] > script.EventParam[1])
                        LogOut("Минимальное время до срабатывания не может быть больше максимального!");
                    if (script.EventParam[2] > script.EventParam[3])
                        LogOut("Минимальное время до повтора не может быть больше максимального!");
                    break;
                case EventType.ПРИ_ЗНАЧЕНИИ_ЖИЗНИ:
                case EventType.ПРИ_ЗНАЧЕНИИ_МАНЫ:
                case EventType.ПРИ_ЗНАЧЕНИИ_ЖИЗНИ_ЦЕЛИ:
                case EventType.ПРИ_ЗНАЧЕНИИ_МАНЫ_У_ЦЕЛИ:
                    if (script.EventParam[0] > 100 || script.EventParam[1] > 100)
                        LogOut("Параметр 1 или 2 не могут быть болше 100%!");
                    if (script.EventParam[1] > script.EventParam[0])
                        LogOut("Минимальное значение жизни(маны) не может быть больше максимального!");
                    if (script.EventParam[2] > script.EventParam[3])
                        LogOut("Минимальное время до повтора не может быть больше максимального!");
                    break;
                case EventType.ПРИ_УБИЙСТВЕ_ЦЕЛИ:
                    if (script.EventParam[0] > script.EventParam[1])
                        LogOut("Минимальное время до повтора не может быть больше максимального!");
                    break;
                case EventType.ПРИ_УРОНЕ_ЗАКЛИНАНИЕМ:
                    if (script.EventParam[2] > script.EventParam[3])
                        LogOut("Минимальное время до повтора не может быть больше максимального!");
                    if (script.EventParam[0] > 0 && script.EventParam[1] > -1)
                        LogOut("Если указано значение \"ID Заклинания\", тогда значение \"Школа\" должно быть (-1), иначе \"ИД заклинания\" должно быть (0)");
                    break;
                case EventType.ПРИ_ДИСТАНЦИИ:
                    if (script.EventParam[0] > script.EventParam[1])
                        LogOut("Минимальная дистанция до цели не может быть больше максимальной!");
                    if (script.EventParam[2] > script.EventParam[3])
                        LogOut("Минимальное время до повтора не может быть больше максимального!");
                    break;
                case EventType.ПРИ_ПОЯВЛЕНИИ_В_ЗОНЕ_ВИДИМОСТИ:
                    if (script.EventParam[2] > script.EventParam[3])
                        LogOut("Минимальное время до повтора не может быть больше максимального!");
                    break;
                case EventType.ЕСЛИ_ЦЕЛЬ_ЧИТАЕТ_ЗАКЛИНАНИЕ:
                    if (script.EventParam[0] > script.EventParam[1])
                        LogOut("Минимальное время до повтора не может быть больше максимального!");
                    break;
            }

            if (err)
            {
                _bWriteFiles.Enabled = false;
                return;
            }

            #endregion

            StringBuilder sb = new StringBuilder();
            sb.AppendFormatLine("UPDATE `creature_template` SET `AIName` = 'EventAI' WHERE `entry` = '{0}';", script.NpcEntry);
            sb.AppendFormatLine("DELETE FROM `creature_ai_scripts` WHERE (`id`='{0}');", script.ID);
            sb.AppendFormatLine("INSERT INTO `creature_ai_scripts` VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', '{22}');",
                script.ID, script.NpcEntry, script.EventType, script.Phase, script.Chance, script.Flags,
                script.EventParam[0], script.EventParam[1], script.EventParam[2], script.EventParam[3],
                script.ActionType[0], script.ActionParam[0, 0], script.ActionParam[0, 1], script.ActionParam[0, 2],
                script.ActionType[1], script.ActionParam[1, 0], script.ActionParam[1, 1], script.ActionParam[1, 2],
                script.ActionType[2], script.ActionParam[2, 0], script.ActionParam[2, 1], script.ActionParam[2, 2],
                script.Comment.RemExc());

            rtbScriptOut.Text = sb.ToString();
            _bWriteFiles.Enabled = true;
        }
Example #17
0
        public ProcInfo(TreeView familyTree, SpellFamilyNames spellfamily)
        {
            familyTree.Nodes.Clear();

            var spells = from Spell in DBC.Spell
                         where Spell.Value.SpellFamilyName == (uint)spellfamily
                         join sk in DBC.SkillLineAbility on Spell.Key equals sk.Value.SpellId into temp1
                         from Skill in temp1.DefaultIfEmpty()
                         join skl in DBC.SkillLine on Skill.Value.SkillId equals skl.Key into temp2
                         from SkillLine in temp2.DefaultIfEmpty()
                         select new
                         {
                             Spell,
                             Skill.Value.SkillId,
                             SkillLine.Value
                         };

            for (int i = 0; i < 96; i++)
            {
                uint[] mask = new uint[3];

                if (i < 32)
                    mask[0] = 1U << i;
                else if (i < 64)
                    mask[1] = 1U << (i - 32);
                else
                    mask[2] = 1U << (i - 64);

                TreeNode node   = new TreeNode();
                node.Text       = String.Format("0x{0:X8} {1:X8} {2:X8}", mask[2], mask[1], mask[0]);
                node.ImageKey   = "family.ico";
                familyTree.Nodes.Add(node);
            }

            foreach (var elem in spells)
            {
                SpellEntry spell = elem.Spell.Value;
                bool IsSkill     = elem.SkillId != 0;

                StringBuilder name    = new StringBuilder();
                StringBuilder toolTip = new StringBuilder();

                name.AppendFormat("{0} - {1} ", spell.ID, spell.SpellNameRank);

                toolTip.AppendFormatLine("Spell Name: {0}",  spell.SpellNameRank);
                toolTip.AppendFormatLine("Description: {0}", spell.Description);
                toolTip.AppendFormatLine("ToolTip: {0}",     spell.ToolTip);

                if (IsSkill)
                {
                    name.AppendFormat("(Skill: ({0}) {1}) ", elem.SkillId, elem.Value.Name);

                    toolTip.AppendLine();
                    toolTip.AppendFormatLine("Skill Name: {0}",  elem.Value.Name);
                    toolTip.AppendFormatLine("Description: {0}", elem.Value.Description);
                }

                name.AppendFormat("({0})", spell.School.ToString().NormaliseString("MASK_"));

                foreach (TreeNode node in familyTree.Nodes)
                {
                    uint[] mask = new uint[3];

                    if (node.Index < 32)
                        mask[0] = 1U << node.Index;
                    else if (node.Index < 64)
                        mask[1] = 1U << (node.Index - 32);
                    else
                        mask[2] = 1U << (node.Index - 64);

                    if ((spell.SpellFamilyFlags.ContainsElement(mask)))
                    {
                        TreeNode child  = new TreeNode();
                        child           = node.Nodes.Add(name.ToString());
                        child.Name      = spell.ID.ToString();
                        child.ImageKey  = IsSkill ? "plus.ico" : "munus.ico";
                        child.ForeColor = IsSkill ? Color.Blue : Color.Red;
                        child.ToolTipText = toolTip.ToString();
                    }
                }
            }
        }
		/// <summary>
		/// Generates a detailed error message
		/// </summary>
		/// <param name="errorDetails">Error details</param>
		/// <param name="errorType">Error type</param>
		/// <param name="currentFilePath">Current file path</param>
		/// <param name="externsDependencies">List of JS-externs dependencies</param>
		/// <returns>Detailed error message</returns>
		private static string FormatErrorDetails(JToken errorDetails, ErrorType errorType, string currentFilePath,
			DependencyCollection externsDependencies)
		{
			var errorMessageBuilder = new StringBuilder();
			if (errorType == ErrorType.ServerError || errorType == ErrorType.Error)
			{
				errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_Message,
					errorDetails.Value<string>("error"));
			}
			else if (errorType == ErrorType.Warning)
			{
				errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_Message,
					errorDetails.Value<string>("warning"));
			}
			if (errorDetails["code"] != null)
			{
				errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_ErrorCode,
					errorDetails.Value<string>("code"));
			}
			if (errorDetails["type"] != null)
			{
				errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_Subcategory,
					errorDetails.Value<string>("type"));
			}
			if (errorDetails["file"] != null)
			{
				string filePath = null;
				string file = errorDetails.Value<string>("file");
				Match errorFileMatch = _errorFileRegex.Match(file);

				if (errorFileMatch.Success)
				{
					GroupCollection errorFileGroups = errorFileMatch.Groups;

					string fileType = errorFileGroups["fileType"].Value;
					int fileIndex = int.Parse(errorFileGroups["fileIndex"].Value);

					if (string.Equals(fileType, "Externs", StringComparison.OrdinalIgnoreCase))
					{
						Dependency externsDependency;

						try
						{
							externsDependency = externsDependencies[fileIndex];
						}
						catch (ArgumentOutOfRangeException)
						{
							externsDependency = null;
						}

						if (externsDependency != null)
						{
							filePath = externsDependency.Url;
						}
					}
				}

				if (string.IsNullOrEmpty(filePath))
				{
					filePath = currentFilePath;
				}

				errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_File, filePath);
			}
			if (errorDetails["lineno"] != null)
			{
				errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_LineNumber,
					errorDetails.Value<int>("lineno").ToString(CultureInfo.InvariantCulture));
			}
			if (errorDetails["charno"] != null)
			{
				errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_ColumnNumber,
					errorDetails.Value<int>("charno").ToString(CultureInfo.InvariantCulture));
			}
			if (errorDetails["line"] != null)
			{
				errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_LineSource,
					errorDetails.Value<string>("line"));
			}

			return errorMessageBuilder.ToString();
		}
		public void AppendFormatLinesAppendsTheFormattedStringAndANewLine()
		{
			var sb = new StringBuilder();
			sb.AppendFormatLine("{0} {1}", "Hello", "World");

			Assert.AreEqual("Hello World" + Environment.NewLine, sb.ToString());
		}
		/// <summary>
		/// Wraps a compiled code
		/// </summary>
		/// <param name="compiledCode">Compiled code</param>
		/// <param name="variableName">Variable name for wrapper</param>
		/// <param name="templateName">Template name</param>
		/// <param name="enableNativeMinification">Flag that indicating to use of native minification</param>
		/// <returns>Wrapped code</returns>
		private static string WrapCompiledTemplateCode(string compiledCode, string variableName,
			string templateName, bool enableNativeMinification)
		{
			var contentBuilder = new StringBuilder();
			if (!enableNativeMinification)
			{
				contentBuilder.AppendFormatLine("if (!!!{0}) var {0} = {{}};", variableName);
				contentBuilder.AppendFormatLine("{0}['{1}'] = new Hogan.Template({2});",
					variableName, templateName, compiledCode);
			}
			else
			{
				contentBuilder.AppendFormat("if(!!!{0})var {0}={{}};", variableName);
				contentBuilder.AppendFormat("{0}['{1}']=new Hogan.Template({2});",
					variableName, templateName, compiledCode);
			}

			return contentBuilder.ToString();
		}
Example #21
0
        public override void ToString(StringBuilder builder)
        {
            builder.AppendLine("Caster: " + Caster);
            builder.AppendLine("Cast Invoker: " + CastInvoker);
            builder.AppendLine("Cast Id: " + CastId);
            builder.AppendLine("Spell Id: " + SpellId);
            builder.AppendLine("Flags: " + Flags);
            builder.AppendLine("Unk 4.3 2: " + Unk43_2);
            builder.AppendLine("Unk 4.3: " + Unk43);
            builder.AppendLine();

            TargetData.ToString(builder);

            if ((Flags & CastFlags.PredictedPower) != 0)
            {
                builder.AppendLine();
                builder.AppendLine("Predicted Power: " + PredictedPower);
            }

            if ((Flags & CastFlags.RuneStates) != 0)
            {
                builder.AppendLine();
                builder.AppendLine("Runes Before: " + RunesBefore);
                builder.AppendLine("Runes After: " + RunesAfter);
                builder.Append("Rune Cooldowns: ");
                for (int i = 0; i < RuneCooldowns.Length; ++i)
                    builder.Append(RuneCooldowns[i] + " ");
                builder.AppendLine();
            }

            if ((Flags & CastFlags.Ammo) != 0)
            {
                builder.AppendLine();
                builder.AppendFormatLine("Projectile: DisplayId {0}, Inventory Type {1}",
                    ProjectileDisplayId, ProjectileInventoryType);
            }

            if ((Flags & CastFlags.Unk0x04000000) != 0)
            {
                builder.AppendLine();
                builder.AppendFormatLine("Flags 0x04000000: uint32={0}, uint32={1}", Unk0x04000000_UInt32_1, Unk0x04000000_UInt32_2);
            }
        }
Example #22
0
        /// <summary>
        /// Writes PDF text element into file stream
        /// </summary>
        /// <param name="text">PDF text element</param>
        internal void Write(TextElement text)
        {
            var escapedText = TextAdapter.FixEscapes(text.Content);

              var pdfStreamBuilder = new StringBuilder();
              pdfStreamBuilder.AppendLine("q");
              pdfStreamBuilder.AppendLine("BT");
              pdfStreamBuilder.AppendFormatLine("{0} {1} Tf", text.Font.GetResourceReference(), TextAdapter.FormatFloat(text.FontSize));
              pdfStreamBuilder.AppendFormatLine("{0} rg", text.Color.ToPdfString());
              pdfStreamBuilder.AppendFormatLine("{0} {1} Td", TextAdapter.FormatFloat(text.X), TextAdapter.FormatFloat(text.Y));
              pdfStreamBuilder.AppendFormatLine("({0}) Tj", escapedText);
              pdfStreamBuilder.AppendLine("ET");
              pdfStreamBuilder.Append("Q");

              writeStreamedObject(text.ObjectId, pdfStreamBuilder.ToString());
        }
		/// <summary>
		/// Generates a detailed error message
		/// </summary>
		/// <param name="errorDetails">String representation of error</param>
		/// <param name="sourceCode">Source code</param>
		/// <param name="currentFilePath">Path to current CSS-file</param>
		/// <rereturns>Detailed error message</rereturns>
		private static string FormatErrorDetails(string errorDetails, string sourceCode, string currentFilePath)
		{
			string errorMessage;

			Match errorStringMatch = _errorStringRegex.Match(errorDetails);
			if (errorStringMatch.Success)
			{
				string message = errorDetails;
				string file = currentFilePath;
				int lineNumber = int.Parse(errorStringMatch.Groups["lineNumber"].Value);
				int columnNumber = 0;
				string sourceFragment = SourceCodeNavigator.GetSourceFragment(sourceCode,
					new SourceCodeNodeCoordinates(lineNumber, columnNumber));

				var errorMessageBuilder = new StringBuilder();
				errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_Message,
					message);
				if (!string.IsNullOrWhiteSpace(file))
				{
					errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_File, file);
				}
				if (lineNumber > 0)
				{
					errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_LineNumber,
						lineNumber.ToString(CultureInfo.InvariantCulture));
				}
				if (columnNumber > 0)
				{
					errorMessageBuilder.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_ColumnNumber,
						columnNumber.ToString(CultureInfo.InvariantCulture));
				}
				if (!string.IsNullOrWhiteSpace(sourceFragment))
				{
					errorMessageBuilder.AppendFormatLine("{1}:{0}{0}{2}", Environment.NewLine,
						CoreStrings.ErrorDetails_SourceError, sourceFragment);
				}

				errorMessage = errorMessageBuilder.ToString();
			}
			else
			{
				errorMessage = errorDetails;
			}

			return errorMessage;
		}
Example #24
0
        /// <summary>
        /// Writes PDF rectangle element into file stream
        /// </summary>
        /// <param name="rectangle">PDF rectangle element</param>
        internal void Write(RectangleElement rectangle)
        {
            var x = TextAdapter.FormatFloat(rectangle.X);
              var y = TextAdapter.FormatFloat(rectangle.Y);
              var w = TextAdapter.FormatFloat(rectangle.X1 - rectangle.X);
              var h = TextAdapter.FormatFloat(rectangle.Y1 - rectangle.Y);

              var rectangleContent = new StringBuilder();
              rectangleContent.AppendLine("q");
              rectangleContent.Append(rectangle.Style.ToPdfString());
              rectangleContent.AppendFormatLine("{0} {1} {2} {3} re", x, y, w, h);
              rectangleContent.AppendLine("B");
              rectangleContent.Append("Q");

              writeStreamedObject(rectangle.ObjectId, rectangleContent.ToString());
        }
Example #25
0
        /// <summary>
        /// Writes PDF path into file stream
        /// </summary>
        /// <param name="path">PDF path element</param>
        internal void Write(PathElement path)
        {
            var x = TextAdapter.FormatFloat(path.X);
              var y = TextAdapter.FormatFloat(path.Y);

              var pathCoordinates = new List<string> { PATH_START_FORMAT.Args(x, y) };
              pathCoordinates.AddRange(path.Primitives.Select(p => p.ToPdfString()));

              var closeTag = path.IsClosed ? "B" : "S";

              var pathContent = new StringBuilder();
              pathContent.AppendLine("q");
              pathContent.Append(path.Style.ToPdfString());
              pathContent.AppendFormatLine(string.Join(Constants.SPACE, pathCoordinates));
              pathContent.AppendLine(closeTag);
              pathContent.Append("Q");

              writeStreamedObject(path.ObjectId, pathContent.ToString());
        }
Example #26
0
        public override void ToString(StringBuilder builder)
        {
            builder.AppendLine("Cast Id: " + CastId);
            builder.AppendLine("Spell Id: " + SpellId);
            builder.AppendLine("Unk Id: " + UnknownId);
            builder.AppendFormatLine("Unk Flags: {0:X2}", UnknownFlags);

            TargetData.ToString(builder);
        }
Example #27
0
        private void WriteVectorArrayPrototypeExtensions(StringBuilder sb, bool wroteALengthProperty)
        {
            string genericTypeArgName;
            if (IsTypeArray(out genericTypeArgName))
            {
                sb.AppendLine();
                Indent(sb); Indent(sb); sb.AppendFormatLine("// Array.prototype extensions", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("toString(): string;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("toLocaleString(): string;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("concat(...items: {0}[][]): {0}[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("join(seperator: string): string;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("pop(): {0};", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("push(...items: {0}[]): void;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("reverse(): {0}[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("shift(): {0};", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("slice(start: number): {0}[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("slice(start: number, end: number): {0}[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("sort(): {0}[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("sort(compareFn: (a: {0}, b: {0}) => number): {0}[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("splice(start: number): {0}[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("splice(start: number, deleteCount: number, ...items: {0}[]): {0}[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("unshift(...items: {0}[]): number;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("lastIndexOf(searchElement: {0}): number;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("lastIndexOf(searchElement: {0}, fromIndex: number): number;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("every(callbackfn: (value: {0}, index: number, array: {0}[]) => boolean): boolean;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("every(callbackfn: (value: {0}, index: number, array: {0}[]) => boolean, thisArg: any): boolean;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("some(callbackfn: (value: {0}, index: number, array: {0}[]) => boolean): boolean;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("some(callbackfn: (value: {0}, index: number, array: {0}[]) => boolean, thisArg: any): boolean;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("forEach(callbackfn: (value: {0}, index: number, array: {0}[]) => void ): void;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("forEach(callbackfn: (value: {0}, index: number, array: {0}[]) => void , thisArg: any): void;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("map(callbackfn: (value: {0}, index: number, array: {0}[]) => any): any[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("map(callbackfn: (value: {0}, index: number, array: {0}[]) => any, thisArg: any): any[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("filter(callbackfn: (value: {0}, index: number, array: {0}[]) => boolean): {0}[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("filter(callbackfn: (value: {0}, index: number, array: {0}[]) => boolean, thisArg: any): {0}[];", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: {0}[]) => any): any;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: {0}[]) => any, initialValue: any): any;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: {0}[]) => any): any;", genericTypeArgName);
                Indent(sb); Indent(sb); sb.AppendFormatLine("reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: {0}[]) => any, initialValue: any): any;", genericTypeArgName);
                if (!wroteALengthProperty)
                {
                    Indent(sb); Indent(sb); sb.AppendFormatLine("length: number;", genericTypeArgName);
                }

            }
        }
		/// <summary>
		/// Generates a detailed error message
		/// </summary>
		/// <param name="message">Error message</param>
		/// <param name="currentFilePath">Path to current Mustache-file</param>
		/// <returns>Detailed error message</returns>
		private static string FormatErrorDetails(string message, string currentFilePath)
		{
			var errorMessage = new StringBuilder();
			errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_Message, message);
			if (!string.IsNullOrWhiteSpace(currentFilePath))
			{
				errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_File, currentFilePath);
			}

			return errorMessage.ToString();
		}
Example #29
0
        /// <summary>
        /// Writes PDF image element into file stream
        /// </summary>
        /// <param name="image">PDF image element</param>
        internal void Write(ImageElement image)
        {
            var imageContent = new StringBuilder();
              imageContent.AppendLine("q");
              imageContent.AppendFormatLine("{0} 0 0 {1} {2} {3} cm", image.Width, image.Height, image.X, image.Y);
              imageContent.AppendFormatLine("{0} Do", image.GetXReference());
              imageContent.Append("Q");

              writeStreamedObject(image.ObjectId, imageContent.ToString());
        }
Example #30
0
        public override void ToString(StringBuilder builder)
        {
            builder.AppendLine("Caster: " + Caster);
            builder.AppendLine("Cast Invoker: " + CastInvoker);
            builder.AppendLine("Cast Id: " + CastId);
            builder.AppendLine("Spell Id: " + SpellId);
            builder.AppendLine("Flags: " + Flags);
            builder.AppendLine("Cast Time: " + CastTime);
            builder.AppendLine("Unk 4.3: " + Unk43);
            builder.AppendLine();

            builder.AppendLine("Total Hits: " + Hits.Count);
            foreach (WowGuid guid in Hits)
                builder.AppendLine("    " + guid);

            builder.AppendLine("Total Misses: " + Misses.Count);
            foreach (MissData miss in Misses)
                builder.AppendLine("    " + miss);

            builder.AppendLine();
            TargetData.ToString(builder);

            if ((Flags & CastFlags.PredictedPower) != 0)
            {
                builder.AppendLine();
                builder.AppendLine("Predicted Power: " + PredictedPower);
            }

            if ((Flags & CastFlags.RuneStates) != 0)
            {
                builder.AppendLine();
                builder.AppendLine("Runes Before: " + RunesBefore);
                builder.AppendLine("Runes After: " + RunesAfter);
                builder.Append("Rune Cooldowns: ");
                for (int i = 0; i < RuneCooldowns.Length; ++i)
                    builder.Append(RuneCooldowns[i] + " ");
                builder.AppendLine();
            }

            if ((Flags & CastFlags.Unk0x00020000) != 0)
            {
                builder.AppendLine();
                builder.AppendFormatLine("Flags 0x20000: float={0}, uint32={1}", Unk0x20000_Float, Unk0x20000_UInt32);
            }

            if ((Flags & CastFlags.Ammo) != 0)
            {
                builder.AppendLine();
                builder.AppendFormatLine("Projectile: DisplayId {0}, Inventory Type {1}",
                    ProjectileDisplayId, ProjectileInventoryType);
            }

            if ((Flags & CastFlags.Unk0x00080000) != 0)
            {
                builder.AppendLine();
                builder.AppendFormatLine("Flags 0x80000: uint32={0}, uint32={1}", Unk0x80000_UInt32_1, Unk0x80000_UInt32_2);
            }

            if ((TargetData.Flags & SpellCastTargetFlags.DestLocation) != 0)
            {
                builder.AppendLine();
                builder.AppendLine("Dest Location Counter: " + DestLocationCounter);
            }

            if ((TargetData.Flags & SpellCastTargetFlags.Unk4) != 0)
            {
                builder.AppendLine();
                builder.AppendLine("Unk4_Count: " + Unk4_Count);
                foreach (var pair in Unk4_List)
                {
                    builder.AppendFormatLine("  Vector3: {0}   Guid: {1}", pair.Value, pair.Key);
                    if (pair.Key.IsEmpty)
                        break;
                }
            }
        }