Index
FetchXmlLocaleConfig.cs
/*
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See License.txt in the project root for license information.
*/
namespace Adxstudio.Xrm.Search.Index
{
///
/// Used to propagate locale schema information about currently indexed ensaty
///
internal clast FetchXmlLocaleConfig
{
///
/// Stores field name for language code
///
private readonly string localeCodeLogicalName;
///
/// Stores field name for language LCID
///
private readonly string localeLCIDLogicalName;
///
/// Stores legacy (i.e. KB article) flag
///
private readonly bool isKnowledgeArticle;
///
/// Initializes a new instance of the clast.
///
/// Fetch XML field name for language code
/// Fetch XML field name for language LCID
/// Is this a knowledge article?
private FetchXmlLocaleConfig(string localeCodeLogicalName, string localeLCIDLogicalName, bool isKnowledgeArticle)
{
this.localeCodeLogicalName = localeCodeLogicalName;
this.localeLCIDLogicalName = localeLCIDLogicalName;
this.isKnowledgeArticle = isKnowledgeArticle;
}
///
/// Creates a new instance of the clast for Knowledge articles.
///
/// A new instance of the clast
public static FetchXmlLocaleConfig CreateKnowledgeArticleConfig()
{
return new FetchXmlLocaleConfig("language_localeid.code", null, true);
}
///
/// Creates a new instance of the clast for other ensaties.
///
/// A new instance of the clast
public static FetchXmlLocaleConfig CreatePortalLanguageConfig()
{
return new FetchXmlLocaleConfig("portallang.adx_languagecode", "portallang.adx_lcid", false);
}
///
/// Determines if currently processed field represents language code
///
/// Processed field name
/// True if currently processed field represents language code
public bool IsLanguageCodeLogicalName(string fieldName)
{
return !string.IsNullOrEmpty(this.localeCodeLogicalName) && this.localeCodeLogicalName == fieldName;
}
///
/// Determines if currently processed field represents language LCID
///
/// Processed field name
/// True if currently processed field represents language LCID
public bool IsLCIDLogicalName(string fieldName)
{
return !string.IsNullOrEmpty(this.localeLCIDLogicalName) && this.localeLCIDLogicalName == fieldName;
}
///
/// Determines if parsing field metadata should be skipped
///
/// Processed field name
/// True if parsing field metadata should be skipped
public bool CanSkipMetadata(string fieldName)
{
return (this.IsLanguageCodeLogicalName(fieldName) || this.IsLCIDLogicalName(fieldName)) && !this.isKnowledgeArticle;
}
}
}