Пример #1
0
        /// check if all placeholders have been replaced in the template; ignore IFDEF
        public Boolean CheckTemplateCompletion(StringBuilder s)
        {
            int    posPlaceholder = s.IndexOf("{#");
            string remainingTemplatePlaceholders = "";

            while (posPlaceholder > -1)
            {
                string latestPlaceholder = s.Substring(posPlaceholder + 2, s.IndexOf("}", posPlaceholder) - posPlaceholder - 2);
                remainingTemplatePlaceholders +=
                    latestPlaceholder + Environment.NewLine;
                posPlaceholder = s.IndexOf("{#", posPlaceholder + 2);
            }

            if (remainingTemplatePlaceholders.Length > 0)
            {
                if (FDestinationFile.Length > 0)
                {
                    StreamWriter FWriter;
                    FWriter = File.CreateText(FDestinationFile + ".error");
                    FWriter.Write(s.ToString());
                    FWriter.Close();

                    throw new Exception("The template has not completely been filled in. " +
                                        Environment.NewLine + "You are missing: " + Environment.NewLine +
                                        remainingTemplatePlaceholders + Environment.NewLine +
                                        "Check file " + FDestinationFile + ".error");
                }
                else
                {
                    TLogging.Log("Failure in this code: ");
                    TLogging.Log(s.ToString());

                    throw new Exception("The template has not completely been filled in. " +
                                        Environment.NewLine + "You are missing: " + Environment.NewLine +
                                        remainingTemplatePlaceholders);
                }
            }

            return(true);
        }