/// <summary> /// Register a <see cref="CustomEffect"/> factory. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="effectFactory"></param> /// <param name="effectId"></param> public void RegisterEffect <T>(Func <T> effectFactory, Guid effectId) where T : CustomEffect { CustomEffectFactory factory; lock (registeredEffects) { if (registeredEffects.ContainsKey(effectId)) { throw new ArgumentException("An effect is already registered with this GUID", "effectFactory"); } factory = new CustomEffectFactory(() => effectFactory(), typeof(T), effectId); registeredEffects.Add(effectId, factory); } RegisterEffectFromString(effectId, factory.ToXml(), factory.Bindings, factory.Bindings.Length, factory.NativePointer); }
/// <summary> /// Register a <see cref="CustomEffect"/>. /// </summary> /// <typeparam name="T">Type of </typeparam> public void RegisterEffect <T>() where T : CustomEffect, new() { CustomEffectFactory factory; var guid = Utilities.GetGuidFromType(typeof(T)); lock (registeredEffects) { if (registeredEffects.ContainsKey(guid)) { throw new ArgumentException("An effect is already registered with this GUID", "effectFactory"); } factory = new CustomEffectFactory(() => new T(), typeof(T)); registeredEffects.Add(guid, factory); } RegisterEffectFromString(guid, factory.ToXml(), factory.Bindings, factory.Bindings.Length, factory.NativePointer); }