33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
|
|
using LiteDB;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.IO;
|
|||
|
|
|
|||
|
|
namespace CaeKnowledge.View
|
|||
|
|
{
|
|||
|
|
public class ElasticWithDensityConverter : StringConverter
|
|||
|
|
{
|
|||
|
|
public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true;
|
|||
|
|
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => true;
|
|||
|
|
|
|||
|
|
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
|||
|
|
{
|
|||
|
|
var items = new List<string>();
|
|||
|
|
|
|||
|
|
var fullPath = CaeGlobals.Tools.GetLiteDatabase();
|
|||
|
|
|
|||
|
|
if (fullPath == null || !File.Exists(fullPath))
|
|||
|
|
{
|
|||
|
|
return new StandardValuesCollection(items);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
using(var db = new LiteDatabase(fullPath))
|
|||
|
|
{
|
|||
|
|
var col = db.GetCollection<ViewElasticWithDensity>("elastic_with_densities");
|
|||
|
|
items.AddRange(col.Query().Select(x => x.Name).ToEnumerable());
|
|||
|
|
|
|||
|
|
return new StandardValuesCollection(items);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|