public void NullReturned()
        {
            WixDocument doc = new WixDocument();
            IWixPropertyValueProvider provider = (IWixPropertyValueProvider)doc;

            Assert.IsNull(provider.GetValue("test"));
        }
Пример #2
0
        /// <summary>
        /// Expands the Wix property values using the IWixPropertyValueProvider
        /// </summary>
        public static string Parse(string input, IWixPropertyValueProvider valueProvider)
        {
            StringBuilder output = new StringBuilder();

            int currentPos = 0;

            do
            {
                // Find property.
                int endIndex   = -1;
                int startIndex = input.IndexOf(PropertyStart, currentPos);
                if (startIndex != -1)
                {
                    endIndex = input.IndexOf(PropertyEnd, startIndex);
                }

                // Did we find a property?
                if (endIndex == -1)
                {
                    if (currentPos == 0)
                    {
                        return(input);
                    }
                    else
                    {
                        output.Append(input.Substring(currentPos));
                        return(output.ToString());
                    }
                }

                // Get the property name
                int    propertyNameStart  = startIndex + PropertyStart.Length;
                int    propertyNameLength = endIndex - propertyNameStart;
                string propertyName       = input.Substring(propertyNameStart, propertyNameLength);
                if (propertyName.StartsWith(PropertyPrefix))
                {
                    propertyName = propertyName.Substring(PropertyPrefix.Length);
                }

                // Get the property value.
                string propertyValue = valueProvider.GetValue(propertyName);
                if (propertyValue != null)
                {
                    output.Append(String.Concat(input.Substring(currentPos, startIndex - currentPos), propertyValue));
                }
                else
                {
                    output.Append(input.Substring(currentPos, endIndex - currentPos));
                }
                currentPos = endIndex + 1;
            } while (currentPos < input.Length);

            return(output.ToString());
        }
Пример #3
0
		public static string Parse(string input, IWixPropertyValueProvider valueProvider)
		{
			StringBuilder output = new StringBuilder();
			
			int currentPos = 0;
			do {
				// Find property.
				int endIndex = -1;
				int startIndex = input.IndexOf(PropertyStart, currentPos);
				if (startIndex != -1) {
					endIndex = input.IndexOf(PropertyEnd, startIndex);
				}
				
				// Did we find a property?
				if (endIndex == -1) {
					if (currentPos == 0) {
						return input;
					} else {
						output.Append(input.Substring(currentPos));
						return output.ToString();
					}
				}
									
				// Get the property name
				int propertyNameStart = startIndex + PropertyStart.Length;
				int propertyNameLength = endIndex - propertyNameStart;
				string propertyName = input.Substring(propertyNameStart, propertyNameLength);
				if (propertyName.StartsWith(PropertyPrefix)) {
					propertyName = propertyName.Substring(PropertyPrefix.Length);
				}
				
				// Get the property value.
				string propertyValue = valueProvider.GetValue(propertyName);
				if (propertyValue != null) {
					output.Append(String.Concat(input.Substring(currentPos, startIndex - currentPos), propertyValue));
				} else {
					output.Append(input.Substring(currentPos, endIndex - currentPos));
				}
				currentPos = endIndex + 1;
			} while (currentPos < input.Length);
			
			return output.ToString();
		}
Пример #4
0
        public void UnknownProperty()
        {
            IWixPropertyValueProvider provider = (IWixPropertyValueProvider)project;

            Assert.IsNull(provider.GetValue("UnknownMSBuildProperty"));
        }