Пример #1
0
        /// <summary>
        /// Creates a new code safe flag name that is unique in the current code scope and adds it to the fields list.
        /// </summary>
        /// <param name="fieldName">Name of the flag.</param>
        /// <returns>The new code safe representation of the flag name.</returns>
        public string CreateCodeSafeFlagName(string fieldName)
        {
            // Convert the flag name to a code safe representation.
            string newFlagName = MutationCodeFormatter.CreateCodeSafeFieldName(fieldName);

            // Make sure the new flag name is unique in the code scope.
            if (this.Fields.Contains(newFlagName) == true)
            {
                string tempFlagName = "";

                // Loop and append an integer until the flag name becomes unique.
                int uniqueInt = 1;
                do
                {
                    // Append an integer to the flag name to try and make it unique.
                    tempFlagName = String.Format("{0}{1}", tempFlagName, uniqueInt++);
                }while (this.Fields.Contains(tempFlagName) == true);

                // Save the new field name.
                newFlagName = tempFlagName;
            }

            // Add the new flag name to the fields list.
            this.Fields.Add(newFlagName);

            // Return the new flag name.
            return(newFlagName);
        }
Пример #2
0
 public void WriteToFile(string folder)
 {
     // Check if the definition is a tag group or tag block and write it to the correct location.
     if (this.TagBlockDefinition.IsTagGroup == true)
     {
         // Write the tag group to file.
         this.CodeCreator.WriteToFile(string.Format("{0}\\{1}.cs", folder,
                                                    MutationCodeFormatter.CreateCodeSafeFieldName(this.TagBlockDefinition.s_tag_block_definition.Name)));
     }
     else
     {
         // Write the block definition to file.
         this.CodeCreator.WriteToFile(string.Format("{0}\\BlockDefinitions\\{1}.cs", folder,
                                                    MutationCodeFormatter.CreateCodeSafeFieldName(this.TagBlockDefinition.s_tag_block_definition.Name)));
     }
 }