示例#1
0
        /// <summary>
        /// Convert from a semicolon separated string to a list of preprocessor definitions.
        /// </summary>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            string stringValue = value as string;

            if (stringValue != null)
            {
                ICollection <PreprocessorDefinition> result = new List <PreprocessorDefinition>();
                string[] items = stringValue.Split(';');

                foreach (var i in items)
                {
                    string item = i.Trim();
                    if (item.Length == 0)
                    {
                        continue;
                    }

                    PreprocessorDefinition pd = ConvertStringItemToObject(i);
                    result.Add(pd);
                }
                return(result);
            }
            else
            {
                return(base.ConvertFrom(context, culture, value));
            }
        }
示例#2
0
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="that">The parameter to copy.</param>
        public ScriptParameter(ScriptParameter that)
            : this()
        {
            this.Name                 = that.Name;
            this.Verbosity            = that.Verbosity;
            this.maxResultColumnWidth = that.maxResultColumnWidth;

            this.IncludeDirectories.Clear();
            this.IncludeDirectories.AddRange(that.IncludeDirectories);

            this.preprocessorDefinitions.Clear();
            foreach (PreprocessorDefinition def in that.PreprocessorDefinitions)
            {
                PreprocessorDefinition defCopy = new PreprocessorDefinition(def);
                this.preprocessorDefinitions.Add(defCopy);
            }

            this.AdvancedPreprocessorParameter = that.AdvancedPreprocessorParameter;
            this.OutputFile             = that.OutputFile;
            this.IsOutputFileEnabled    = that.IsOutputFileEnabled;
            this.IsPreprocessorEnabled  = that.IsPreprocessorEnabled;
            this.IsBreakOnErrorEnabled  = that.IsBreakOnErrorEnabled;
            this.TemporaryFile          = that.TemporaryFile;
            this.IsTemporaryFileEnabled = that.IsTemporaryFileEnabled;
        }
示例#3
0
        private static PreprocessorDefinition ConvertStringItemToObject(string item)
        {
            string[] nameValue = item.Split('=');
            bool     enabled   = false;
            string   name      = null;
            string   value     = null;

            if (nameValue.Length == 0)
            {
                return(null);
            }

            name = nameValue[0].Trim();
            if (nameValue.Length > 1)
            {
                value = nameValue[1].Trim();
            }

            if (name.StartsWith("!"))
            {
                enabled = false;
                name    = name.TrimStart('!').Trim();
            }
            else
            {
                enabled = true;
            }

            PreprocessorDefinition result = new PreprocessorDefinition();

            result.IsEnabled = enabled;
            result.Name      = name;
            result.Value     = value;


            return(result);
        }
示例#4
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 public PreprocessorDefinition(PreprocessorDefinition preprocessorDefinition)
 {
     this.IsEnabled = preprocessorDefinition.IsEnabled;
     this.Name      = preprocessorDefinition.Name;
     this.Value     = preprocessorDefinition.Value;
 }