public bool InjectPropertyDependencies(ISMAPlugin plugin, ISuperMemoAssistant sma, ISMAPluginManager pluginMgr, Guid sessionGuid, bool isDevelopment) { bool smaSet = false; bool mgrSet = false; bool guidSet = false; var type = plugin.GetType(); while (type != null && type != typeof(ISMAPlugin)) { var props = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (var prop in props) { if (SMAInterfaceTypes.Contains(prop.PropertyType)) { prop.SetValue(plugin, sma /*Convert.ChangeType(sma, prop.PropertyType)*/); smaSet = true; } else if (PluginMgrInterfaceTypes.Contains(prop.PropertyType)) { prop.SetValue(plugin, pluginMgr /*Convert.ChangeType(pluginMgr, prop.PropertyType)*/); mgrSet = true; } else if (prop.PropertyType == typeof(Guid)) { prop.SetValue(plugin, sessionGuid); guidSet = true; } else if (prop.PropertyType == typeof(bool) && prop.Name is "IsDevelopmentPlugin") { prop.SetValue(plugin, isDevelopment); } } type = type.BaseType; } return(smaSet && mgrSet && guidSet); }
public CollectionFSService(ISuperMemoAssistant sma) { SMA = sma; LoadDb(); }