/// <summary> Determines whether the given property (both name and value) are valid /// according to this validator's policy. /// /// </summary> /// <param name="name">the name of the property /// </param> /// <param name="lu">the value of the property /// </param> /// <returns> true if this property name/value is valid; false otherwise /// </returns> public virtual bool isValidProperty(string name, LexicalUnit lu) { bool isValid = false; Property property = null; if (name != null) { property = policy.getPropertyByName(name.ToLower()); } // if we were able to find the property by name, validate the value if (property != null) { // validate all values attached to this property isValid = true; while (lu != null) { System.String value_Renamed = lexicalValueToString(lu); if (value_Renamed == null || !validateValue(property, value_Renamed)) { isValid = false; break; } lu = lu.getNextLexicalUnit(); } } return(isValid); }
/// <summary> Determines whether the given property value is valid according to this /// validator's policy. /// /// </summary> /// <param name="property">the object representation of the property and its associated /// policy /// </param> /// <param name="value">the string representation of the value /// </param> /// <returns> true if the property is valid; false otherwise /// </returns> private bool validateValue(Property property, System.String value_Renamed) { bool isValid = false; // normalize the value to lowercase value_Renamed = value_Renamed.ToLower(); // check if the value matches any of the allowed literal values System.Collections.IEnumerator allowedValues = property.AllowedValues.GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (allowedValues.MoveNext() && !isValid) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" System.String allowedValue = (System.String)allowedValues.Current; if (allowedValue != null && allowedValue.Equals(value_Renamed)) { isValid = true; } } // check if the value matches any of the allowed regular expressions System.Collections.IEnumerator allowedRegexps = property.AllowedRegExp.GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (allowedRegexps.MoveNext() && !isValid) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" //Pattern pattern = (Pattern)allowedRegexps.Current; //if (pattern != null && pattern.matcher(value_Renamed).matches()) //{ // isValid = true; //} } // check if the value matches any of the allowed shorthands IEnumerator shorthandRefs = property.ShorthandRefs.GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (shorthandRefs.MoveNext() && !isValid) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" string shorthandRef = (string)shorthandRefs.Current; Property shorthand = policy.getPropertyByName(shorthandRef); if (shorthand != null) { isValid = validateValue(shorthand, value_Renamed); } } return(isValid); }
/// <summary> Determines whether the given property value is valid according to this /// validator's policy. /// /// </summary> /// <param name="property">the object representation of the property and its associated /// policy /// </param> /// <param name="value">the string representation of the value /// </param> /// <returns> true if the property is valid; false otherwise /// </returns> private bool validateValue(Property property, System.String value_Renamed) { bool isValid = false; // normalize the value to lowercase value_Renamed = value_Renamed.ToLower(); // check if the value matches any of the allowed literal values System.Collections.IEnumerator allowedValues = property.AllowedValues.GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (allowedValues.MoveNext() && !isValid) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" System.String allowedValue = (System.String)allowedValues.Current; if (allowedValue != null && allowedValue.Equals(value_Renamed)) { isValid = true; } } // check if the value matches any of the allowed regular expressions System.Collections.IEnumerator allowedRegexps = property.AllowedRegExp.GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (allowedRegexps.MoveNext() && !isValid) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" //Pattern pattern = (Pattern)allowedRegexps.Current; //if (pattern != null && pattern.matcher(value_Renamed).matches()) //{ // isValid = true; //} } // check if the value matches any of the allowed shorthands IEnumerator shorthandRefs = property.ShorthandRefs.GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (shorthandRefs.MoveNext() && !isValid) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" string shorthandRef = (string)shorthandRefs.Current; Property shorthand = policy.getPropertyByName(shorthandRef); if (shorthand != null) { isValid = validateValue(shorthand, value_Renamed); } } return isValid; }