/// <summary>
 /// Matches the specified config object with this search value.
 /// </summary>
 /// <param name="configObject">Configuration object to match.</param>
 /// <returns>
 /// Value between 0 and 1, with 1 representing an exact match, 0 representing no match.
 /// </returns>
 public float CalculateMatchQuality(ConfigBase configObject)
 {
   CultureInfo culture = ServiceRegistration.Get<ILocalization>().CurrentCulture;
   IEnumerable<string> searchTexts = configObject.GetSearchTexts();
   double result = 0;
   int count = 0;
   foreach (string text in searchTexts)
   {
     string searchText = text.ToLower(culture);
     if (searchText == _searchText)
       result++;
     else if (text.Contains(_searchText))
       result += 0.5;
     count++;
   }
   return (float)(result / count);
 }
Exemplo n.º 2
0
 public void UnregisterConfiguration(ConfigBase configItem)
 {
   _configItems.Remove(configItem);
 }
Exemplo n.º 3
0
 public void RegisterConfiguration(ConfigBase configItem)
 {
   IServerConnectionManager scm = ServiceRegistration.Get<IServerConnectionManager>();
   IContentDirectory cd = scm.ContentDirectory;
   // Set initial "Enabled" value, depending on current connection state.
   configItem.Enabled = cd != null;
   // Set initial "Visible" value, depending on attachment state.
   configItem.Visible = scm.HomeServerSystemId != null;
   _configItems.Add(configItem);
 }
Exemplo n.º 4
0
 /// <summary>
 /// [Internal Constructor] Initializes a new instance of the ConfigurationNode class.
 /// </summary>
 /// <param name="configObj">Setting to link to the node.</param>
 /// <param name="parent">Parent node of the node.</param>
 public ConfigurationNode(ConfigBase configObj, ConfigurationNode parent)
 {
   _configObj = configObj;
   _parent = parent;
   _childNodes = new List<ConfigurationNode>();
 }
Exemplo n.º 5
0
 protected void AddChildNode(ConfigBase childObj)
 {
   _childNodes.Add(new ConfigurationNode(childObj, this));
 }