Example #1
0
        /// <summary>
        /// Updates the code attribute argument.
        /// </summary>
        /// <param name="codeAttribute">The code attribute.</param>
        /// <param name="argumentName">Name of the argument.</param>
        /// <param name="argumentValue">The argument value.</param>
        /// <param name="createIfNew">if set to <c>true</c> [create if new].</param>
        /// <returns></returns>
        public static bool UpdateCodeAttributeArgument(
            CodeAttribute codeAttribute,
            string argumentName,
            string argumentValue,
            bool createIfNew)
        {
            Guard.ArgumentNotNull(codeAttribute, "codeAttribute");
            Guard.ArgumentNotNullOrEmptyString(argumentName, "argumentName");

            bool result = false;

            EnvDTE80.CodeAttribute2        attribute2    = (EnvDTE80.CodeAttribute2)codeAttribute;
            EnvDTE80.CodeAttributeArgument argumentMatch = null;
            foreach (EnvDTE80.CodeAttributeArgument argument in attribute2.Arguments)
            {
                if (argument.Name.Equals(argumentName, StringComparison.InvariantCultureIgnoreCase))
                {
                    argumentMatch = argument;
                    break;
                }
            }
            if (argumentMatch != null)
            {
                argumentMatch.Value = argumentValue;
                result = true;
            }
            else if (createIfNew)
            {
                attribute2.AddArgument(argumentValue, argumentName, attribute2.Arguments.Count);
                result = true;
            }

            return(result);
        }
 /// <summary>
 /// 
 /// </summary>
 public AttributeArgumentInfo(EnvDTE80.CodeAttributeArgument item)
 {
     this.item = item;
     this.Name = this.item.Name;
     this.Value = this.item.Value;
 }