Microsoft.Protocols.TestSuites.MS_COPYS.TestSuiteBase.SelectFieldBySpecifiedAtrribute C# (CSharp) Method

SelectFieldBySpecifiedAtrribute() protected method

A method used to select a field by specified field attribute value. The "DisplayName" is not a unique identifier for a field, so the method return the first match item when using "DisplayName" attribute value. If there are no any fields are found, this method will raise an InvalidOperationException.
protected SelectFieldBySpecifiedAtrribute ( FieldInformation fields, string expectedAttributeValue, FieldAttributeType usedAttribute ) : FieldInformation
fields FieldInformation A parameter represents the fields array.
expectedAttributeValue string A parameter represents the expected attribute value which is used to match field item.
usedAttribute FieldAttributeType A parameter represents the attribute type which is used to compare with the expected attribute value.
return FieldInformation
        protected FieldInformation SelectFieldBySpecifiedAtrribute(FieldInformation[] fields, string expectedAttributeValue, FieldAttributeType usedAttribute)
        {
            FieldInformation selectedField = this.FindOutTheField(fields, expectedAttributeValue, usedAttribute);
            if (null == selectedField)
            {
               string errorMsg = string.Format(
                        "Could not find the expected field by specified value:[{0}] of [{1}] attribute.",
                        expectedAttributeValue,
                        usedAttribute);

               throw new InvalidOperationException(errorMsg);
            }

            return selectedField;
        }