Exemplo n.º 1
0
        private string GetPossiblyDuplicateNameForOption(OptionSetMetadataBase metadata, IServiceProvider services, OptionMetadata option)
        {
            var defaultName = DefaultService.GetNameForOption(metadata, option, services);

            defaultName = Transliterate(option, defaultName);

            var name = GetValidCSharpName(defaultName);

            if (defaultName == string.Empty)
            {
                name = name + option.Value;
            }
            return(name);
        }
        public string GetNameForOption(OptionSetMetadataBase optionSetMetadata, OptionMetadata optionMetadata, IServiceProvider services)
        {
            var defaultName = DefaultService.GetNameForOption(optionSetMetadata, optionMetadata, services);

            defaultName = Transliterate(optionMetadata, defaultName);

            var newName = GetValidCSharpName(defaultName);

            newName = AppendValueForDuplicateOptionSetValueNames(optionSetMetadata, newName, optionMetadata.Value.GetValueOrDefault(), services);

            if (newName == defaultName)
            {
                Trace.TraceInformation("The name of this option is {0}", defaultName);
            }
            else
            {
                Trace.TraceInformation("The name of this option was {0} but has been changed to {1}", defaultName, newName);
            }

            return(newName);
        }
        /// <summary>
        /// Checks to make sure that the name does not already exist for the OptionSetto be generated.
        /// </summary>
        private Dictionary <string, bool> GetDuplicateNameValues(OptionSetMetadataBase metadata, IServiceProvider services)
        {
            var nameValueDups = new Dictionary <string, bool>();

            // Look through all options, populating the namesAndValues Collection
            foreach (var option in metadata.GetOptions())
            {
                var defaultName = DefaultService.GetNameForOption(metadata, option, services);

                defaultName = Transliterate(option, defaultName);

                var name = GetValidCSharpName(defaultName);

                nameValueDups[name] = nameValueDups.ContainsKey(name);

                if (metadata.OptionSetType == OptionSetType.Status)
                {
                    // For Statuses, also do State
                    name = AppendState(option, name);
                    nameValueDups[name] = nameValueDups.ContainsKey(name);
                }
            }
            return(nameValueDups);
        }
 public string GetNameForOption(OptionSetMetadataBase optionSetMetadata, OptionMetadata optionMetadata, IServiceProvider services)
 {
     return(DefaultService.GetNameForOption(optionSetMetadata, optionMetadata, services));
 }