Example #1
0
        /// <summary>Gets the value for named property for the result.</summary>
        /// <param name="name">Name of property for which to get enumerable results.</param>
        /// <returns>The value for the named property of the result.</returns>
        /// <remarks>
        /// If the element returned in turn has properties which are expanded out-of-band
        /// of the object model, then the result will also be of type <see cref="IExpandedResult"/>,
        /// and the value will be available through <see cref="ExpandedElement"/>.
        /// A special case is the handling of $skiptoken property. In case the $skiptoken property does not
        /// exist on the current wrapper object, instead of throw-ing we return null which will
        /// be an indication to the caller that the property does not exist.
        /// </remarks>
        public object GetExpandedPropertyValue(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (this.propertyNames == null)
            {
                throw new InvalidOperationException(Strings.BasicExpandProvider_ExpandedPropertiesNotInitialized);
            }

            int nameIndex = -1;

            for (int i = 0; i < this.propertyNames.Length; i++)
            {
                if (this.propertyNames[i] == name)
                {
                    nameIndex = i;
                    break;
                }
            }

            if (nameIndex == -1 && name == XmlConstants.HttpQueryStringSkipToken)
            {
                return(null);
            }

            object resource = this.InternalGetExpandedPropertyValue(nameIndex);

            resource = ProjectedWrapper.ProcessResultInstance(resource);
            return(ProjectedWrapper.ProcessResultEnumeration(resource));
        }
Example #2
0
        internal static object ProcessResultInstance(object resource)
        {
            ProjectedWrapper wrapper = resource as ProjectedWrapper;

            if ((wrapper != null) && string.IsNullOrEmpty(wrapper.resourceTypeName))
            {
                return(null);
            }
            return(resource);
        }
Example #3
0
        public object GetExpandedPropertyValue(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (this.propertyNames == null)
            {
                throw new InvalidOperationException(Strings.BasicExpandProvider_ExpandedPropertiesNotInitialized);
            }
            int nameIndex = -1;

            for (int i = 0; i < this.propertyNames.Length; i++)
            {
                if (this.propertyNames[i] == name)
                {
                    nameIndex = i;
                    break;
                }
            }
            bool flag = false;

            if (this.referencePropertyNames != null)
            {
                for (int j = 0; j < this.referencePropertyNames.Length; j++)
                {
                    if (this.referencePropertyNames[j] == name)
                    {
                        flag = true;
                        break;
                    }
                }
            }
            if ((nameIndex == -1) && (name == "$skiptoken"))
            {
                return(null);
            }
            object resource = ProjectedWrapper.ProcessResultInstance(this.InternalGetExpandedPropertyValue(nameIndex));

            if (!flag)
            {
                return(ProjectedWrapper.ProcessResultEnumeration(resource));
            }
            return(resource);
        }