/// <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)); }
/// <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)); }
/// <summary> /// Fetches the property tokens of the specified resource type and base types. /// </summary> /// <param name="type">Resource type.</param> /// <param name="context"><see cref="ZentityContext" /> instance to fetch data with.</param> /// <returns>Property tokens.</returns> public static IEnumerable <ScalarProperty> FetchPropertyTokens(ResourceType type, ZentityContext context) { IEnumerable <ScalarProperty> properties = ResourceTypeHelper.FetchResourceTypes(context) .Where(resourceType => resourceType.Id == type.Id) .SelectMany(resourceType => resourceType.ScalarProperties); if (type.BaseType != null) { properties = properties.Concat(FetchPropertyTokens(type.BaseType, context)); } return(properties); }
/// <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); }
/// <summary> /// Fetches the property tokens. /// </summary> /// <param name="context"><see cref="ZentityContext" /> instance to fetch data with.</param> /// <returns>Property tokens.</returns> private static IEnumerable <ScalarProperty> FetchPropertyTokens(ZentityContext context) { return(ResourceTypeHelper.FetchResourceTypes(context) .SelectMany(resourceType => resourceType.ScalarProperties)); }
/// <summary> /// Compares two specified resource types and returns an integer that indicates /// their relationship to one another in the inheritance hierarchy. /// </summary> /// <param name="resourceTypeFullNameA">The first resource type full name.</param> /// <param name="resourceTypeFullNameB">The second resource type full name.</param> /// <returns>A 32-bit signed integer indicating the relationship between the two /// Value Condition Less than zero resourceTypeFullNameB is derived from resourceTypeFullNameA. /// Value Condition Greater than zero resourceTypeFullNameA is derived from resourceTypeFullNameB. /// Zero, resourceTypeFullNameA and resourceTypeFullNameB have no relation. /// </returns> public int CompareResourceTypes(string resourceTypeFullNameA, string resourceTypeFullNameB) { return(ResourceTypeHelper.CompareResourceTypes( resourceTypeFullNameA, resourceTypeFullNameB, context)); }
/// <summary> /// Fetches excluded resource types from an XML file. /// </summary> /// <returns>Excluded resource type full names.</returns> public static IEnumerable <string> FetchExcludedResourceTypeFullNames() { return(ResourceTypeHelper.FetchExcludedResourceTypeFullNames()); }
/// <summary> /// Fetches the derived types of the specified resource type. /// </summary> /// <param name="resourceType">Resource type.</param> /// <returns>Resource types.</returns> public IEnumerable <ResourceType> FetchResourceDerivedTypes(ResourceType resourceType) { return(ResourceTypeHelper.FetchResourceDerivedTypes(resourceType, context)); }
/// <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)); }