Microsoft.Protocols.TestSuites.MS_OXWSMSG.TestSuiteBase.ConstructFindItemRequest C# (CSharp) Method

ConstructFindItemRequest() protected method

The operation construct a request for FindItem operation.
protected ConstructFindItemRequest ( string folderName, string value, string field ) : FindItemType
folderName string A string that specifies the folder to search.
value string A string that specifies the value for a search restriction.
field string A string that specifies the type of referenced field URI.
return Microsoft.Protocols.TestSuites.Common.FindItemType
        protected FindItemType ConstructFindItemRequest(string folderName, string value, string field)
        {
            FindItemType findRequest = new FindItemType();
            findRequest.ItemShape = new ItemResponseShapeType();
            findRequest.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;

            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            DistinguishedFolderIdNameType folderIdName;
            if (Enum.TryParse<DistinguishedFolderIdNameType>(folderName, out folderIdName))
            {
                folderId.Id = folderIdName;
            }
            else
            {
                Site.Assert.Fail("The value of the first argument (foldIdNameType) of FindItem operation is invalid.");
            }

            findRequest.ParentFolderIds = new BaseFolderIdType[1];
            findRequest.ParentFolderIds[0] = folderId;

            PathToUnindexedFieldType itemClass = new PathToUnindexedFieldType();
            UnindexedFieldURIType fieldURI;
            if (Enum.TryParse<UnindexedFieldURIType>(field, out fieldURI))
            {
                // set search field.
                itemClass.FieldURI = fieldURI;
            }
            else
            {
                Site.Assert.Fail("The value of the second argument (fieldURIType) of FindItem operation is invalid.");
            }

            ContainsExpressionType expressionType = new ContainsExpressionType();
            expressionType.Item = itemClass;
            expressionType.ContainmentMode = ContainmentModeType.Substring;
            expressionType.ContainmentModeSpecified = true;
            expressionType.ContainmentComparison = ContainmentComparisonType.IgnoreCaseAndNonSpacingCharacters;
            expressionType.ContainmentComparisonSpecified = true;
            expressionType.Constant = new ConstantValueType();
            expressionType.Constant.Value = value;

            RestrictionType restriction = new RestrictionType();
            restriction.Item = expressionType;

            if (!string.IsNullOrEmpty(value))
            {
                findRequest.Restriction = restriction;
            }

            return findRequest;
        }
        #endregion