Exemplo n.º 1
0
        /// <summary>
        /// Fetches the property tokens of the specified resource type.
        /// </summary>
        /// <param name="resourceTypeFullName">Full name of resource type.</param>
        /// <param name="context"><see cref="ZentityContext" /> instance to fetch data with.</param>
        /// <returns>Property tokens.</returns>
        private static IEnumerable <ScalarProperty> FetchPropertyTokens(string resourceTypeFullName,
                                                                        ZentityContext context)
        {
            ResourceType type = ResourceTypeHelper.FetchResourceType(resourceTypeFullName, context);

            return(FetchPropertyTokens(type, context));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fetches the implicit properties.
        /// </summary>
        /// <param name="resourceTypeFullName">Full name of resource type.</param>
        /// <param name="context"><see cref="ZentityContext" /> instance to fetch data with.</param>
        /// <returns>Implicit scalar properties.</returns>
        public static IEnumerable <ScalarProperty> FetchImplicitProperties(string resourceTypeFullName,
                                                                           ZentityContext context)
        {
            if (String.IsNullOrEmpty(resourceTypeFullName))
            {
                throw new ArgumentNullException("resourceTypeFullName");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            XDocument implicitPropertiesDocument =
                Utility.ReadXmlConfigurationFile(Resources.SEARCH_IMPLICITPROPERTIES_FILENAME);

            if (implicitPropertiesDocument == null)
            {
                return(Utility.CreateEmptyEnumerable <ScalarProperty>());
            }

            ResourceType type = ResourceTypeHelper.FetchResourceType(resourceTypeFullName, context);

            if (type == null)
            {
                throw new ArgumentException(
                          String.Format(CultureInfo.CurrentCulture,
                                        Resources.SEARCH_INVALID_RESOURCETYPE, resourceTypeFullName));
            }
            return(FetchImplicitProperties(implicitPropertiesDocument, type, context));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Fetches special tokens.
        /// </summary>
        /// <param name="resourceTypeFullName">Full name of resource type.</param>
        /// <param name="context"><see cref="ZentityContext" /> instance to fetch data with.</param>
        /// <returns>Special tokens.</returns>
        private static IEnumerable <SpecialToken> FetchTokens(string resourceTypeFullName, ZentityContext context)
        {
            if (String.IsNullOrEmpty(resourceTypeFullName))
            {
                throw new ArgumentNullException("resourceTypeFullName");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            List <SpecialToken> specialTokens = new List <SpecialToken>();

            XDocument specialTokensDocument =
                Utility.ReadXmlConfigurationFile(Resources.SEARCH_SPECIALTOKENS_FILENAME);

            if (specialTokensDocument == null)
            {
                return(Utility.CreateEmptyEnumerable <SpecialToken>());
            }

            IEnumerable <XElement> xmlTokens =
                specialTokensDocument.Root
                .Elements(XName.Get(SearchConstants.XML_TOKEN, SearchConstants.XMLNS_NAMESPACE));

            ResourceType type =
                ResourceTypeHelper.FetchResourceType(resourceTypeFullName, context);

            if (type == null)
            {
                throw new ArgumentException(
                          String.Format(CultureInfo.CurrentCulture,
                                        Resources.SEARCH_INVALID_RESOURCETYPE, resourceTypeFullName));
            }

            foreach (XElement xmlToken in xmlTokens)
            {
                SpecialToken specialToken = new SpecialToken();
                specialToken.Token    = xmlToken.Attribute(SearchConstants.XML_NAME).Value;
                specialToken.DataType =
                    (DataTypes)Enum.Parse(
                        typeof(DataTypes), xmlToken.Attribute(SearchConstants.XML_DATATYPE).Value);

                specialToken.Properties = FetchProperties(xmlToken, type, context);
                specialTokens.Add(specialToken);
            }

            return(specialTokens);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Fetches the specified resource type.
 /// </summary>
 /// <param name="resourceTypeFullName">Full name of resource type.</param>
 /// <returns>Resource type.</returns>
 public ResourceType FetchResourceType(string resourceTypeFullName)
 {
     return(ResourceTypeHelper.FetchResourceType(resourceTypeFullName, context));
 }