mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Merge branch 'master' into RGB.NET_update
This commit is contained in:
commit
da90c0d3a1
94 files changed
+1525
-1007
No files matched your search
@@ -4,7 +4,7 @@ namespace Artemis.Storage.Entities.Profile.DataBindings
|
||||
{
|
||||
public class DataBindingEntity
|
||||
{
|
||||
public string TargetExpression { get; set; }
|
||||
public string Identifier { get; set; }
|
||||
public TimeSpan EasingTime { get; set; }
|
||||
public int EasingFunction { get; set; }
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using Artemis.Storage.Migrations.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Migrations
|
||||
{
|
||||
public class M10BetterDataBindings : IStorageMigration
|
||||
{
|
||||
private void Migrate(BsonValue bsonValue)
|
||||
{
|
||||
if (!bsonValue.IsDocument || !bsonValue.AsDocument.TryGetValue("PropertyEntities", out BsonValue propertyEntities))
|
||||
return;
|
||||
|
||||
foreach (BsonValue propertyEntity in propertyEntities.AsArray)
|
||||
{
|
||||
if (!propertyEntity.AsDocument.TryGetValue("DataBindingEntities", out BsonValue dataBindingEntities))
|
||||
continue;
|
||||
foreach (BsonValue dataBindingEntity in dataBindingEntities.AsArray)
|
||||
{
|
||||
if (!dataBindingEntity.AsDocument.TryGetValue("TargetExpression", out BsonValue targetExpression))
|
||||
continue;
|
||||
string value = targetExpression.AsString;
|
||||
if (value == "value => value" || value == "b => b")
|
||||
{
|
||||
dataBindingEntity.AsDocument["Identifier"] = "Value";
|
||||
}
|
||||
else
|
||||
{
|
||||
string selector = value.Split("=>")[1];
|
||||
string property = selector.Split(".")[1];
|
||||
dataBindingEntity.AsDocument["Identifier"] = property;
|
||||
}
|
||||
|
||||
dataBindingEntity.AsDocument.Remove("TargetExpression");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int UserVersion => 10;
|
||||
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
ILiteCollection<BsonDocument> collection = repository.Database.GetCollection("ProfileEntity");
|
||||
foreach (BsonDocument bsonDocument in collection.FindAll())
|
||||
{
|
||||
foreach (BsonValue bsonLayer in bsonDocument["Layers"].AsArray)
|
||||
Migrate(bsonLayer);
|
||||
|
||||
foreach (BsonValue bsonLayer in bsonDocument["Folders"].AsArray)
|
||||
Migrate(bsonLayer);
|
||||
|
||||
collection.Update(bsonDocument);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user