示例#1
0
        /// <summary>
        /// Fetches special properties.
        /// </summary>
        /// <param name="xmlToken">Xml token.</param>
        /// <param name="type">Resource type.</param>
        /// <param name="context"><see cref="ZentityContext" /> instance to fetch data with.</param>
        /// <returns>Special Properties.</returns>
        private static IEnumerable <ScalarProperty> FetchProperties(
            XElement xmlToken, ResourceType type, ZentityContext context)
        {
            IEnumerable <XElement> xmlProperties = xmlToken
                                                   .Elements(XName.Get(SearchConstants.XML_MODULE, SearchConstants.XMLNS_NAMESPACE))
                                                   .Where(xmlModule => xmlModule.Attribute(SearchConstants.XML_NAMESPACE).Value == type.Parent.NameSpace)
                                                   .Elements(XName.Get(SearchConstants.XML_RESOURCETYPE, SearchConstants.XMLNS_NAMESPACE))
                                                   .Where(xmlResourceType => xmlResourceType.Attribute(SearchConstants.XML_NAME).Value == type.Name)
                                                   .Elements(XName.Get(SearchConstants.XML_PROPERTY, SearchConstants.XMLNS_NAMESPACE));

            IEnumerable <ScalarProperty> scalarProperties =
                PropertyTokens.FetchPropertyTokens(type, context);

            IEnumerable <ScalarProperty> specialProperties =
                scalarProperties.Join <ScalarProperty, XElement, string, ScalarProperty>(xmlProperties,
                                                                                         scalarProperty => scalarProperty.Name,
                                                                                         xmlProperty => xmlProperty.Value,
                                                                                         (scalarPropertyName, xmlPropertyName) => scalarPropertyName);

            if (type.BaseType != null)
            {
                specialProperties =
                    specialProperties.Concat(FetchProperties(xmlToken, type.BaseType, context));
            }

            return(specialProperties);
        }
示例#2
0
 /// <summary>
 /// Fetches the specified property token.
 /// </summary>
 /// <param name="token">The token.</param>
 /// <param name="resourceTypeFullName">Full name of resource type.</param>
 /// <returns>Property token.</returns>
 public ScalarProperty FetchPropertyToken(string token, string resourceTypeFullName)
 {
     return(PropertyTokens.FetchPropertyToken(token, resourceTypeFullName, context));
 }
示例#3
0
 /// <summary>
 /// Fetches the specified property token.
 /// </summary>
 /// <param name="token">The token.</param>
 /// <returns>Property token.</returns>
 /// <exception cref="SearchException">Thrown when an ambiguous token is passed.</exception>
 public ScalarProperty FetchPropertyToken(string token)
 {
     return(PropertyTokens.FetchPropertyToken(token, context));
 }