Castle.MonoRail.Framework.Helpers.FormHelper.IsPresent C# (CSharp) Method

IsPresent() protected static method

Determines whether the present value matches the value on the initialSetValue (which can be a single value or a set)
protected static IsPresent ( object value, object initialSetValue, ValueGetter propertyOnInitialSet, bool isMultiple ) : bool
value object Value from the datasource
initialSetValue object Value from the initial selection set
propertyOnInitialSet ValueGetter Optional. Property to obtain the value from
isMultiple bool true if the initial selection is a set
return bool
		protected internal static bool IsPresent(object value, object initialSetValue, 
												 ValueGetter propertyOnInitialSet, bool isMultiple)
		{
			if (!isMultiple)
			{
				object valueToCompare = initialSetValue;
				
				if (propertyOnInitialSet != null)
				{
					// propertyOnInitialSet.GetValue(initialSetValue, null);
					valueToCompare = propertyOnInitialSet.GetValue(initialSetValue); 
				}
				
				return AreEqual(value, valueToCompare);
			}
			else
			{
				foreach(object item in (IEnumerable) initialSetValue)
				{
					object valueToCompare = item;

					if (propertyOnInitialSet != null)
					{
						// valueToCompare = propertyOnInitialSet.GetValue(item, null);
						valueToCompare = propertyOnInitialSet.GetValue(item); 
					}

					if (AreEqual(value, valueToCompare))
					{
						return true;
					}
				}
			}
			
			return false;
		}