拼ui 一些业务逻辑x实现
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace EasyChart
|
||||
{
|
||||
public static class SerieSettingsRegistry
|
||||
{
|
||||
private static readonly Dictionary<SerieType, Func<BaseSerieSettings>> s_factories = new Dictionary<SerieType, Func<BaseSerieSettings>>();
|
||||
|
||||
public static void Register(SerieType type, Func<BaseSerieSettings> factory)
|
||||
{
|
||||
if (factory == null) return;
|
||||
s_factories[type] = factory;
|
||||
}
|
||||
|
||||
public static bool TryCreate(SerieType type, out BaseSerieSettings settings)
|
||||
{
|
||||
settings = null;
|
||||
if (s_factories.TryGetValue(type, out var f) && f != null)
|
||||
{
|
||||
settings = f();
|
||||
return settings != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool HasFactory(SerieType type)
|
||||
{
|
||||
return s_factories.ContainsKey(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user