Beispiel #1
0
 public UiPlugin(IUiPluginContext context)
 {
     Context = context;
     _menu   = new UiMenuItem(this)
     {
         Header = "Export selected rundown as XML"
     };
     Debug.WriteLine(this, "Plugin created");
     context.PropertyChanged += Context_PropertyChanged;
 }
Beispiel #2
0
 public UiPlugin(IUiPluginContext context)
 {
     Context = context;
     _menu   = new UiMenuItem(this)
     {
         Header = "Play"
     };
     Debug.WriteLine(this, "Plugin created");
     context.PropertyChanged += Context_PropertyChanged;
 }
Beispiel #3
0
 internal bool SetContext(IUiPluginContext context)
 {
     if (Context != null)
     {
         return(false);
     }
     Context = context;
     context.Engine.PropertyChanged   += Engine_PropertyChanged;
     DeviceEnumerator.DeviceConnected += DeviceEnumeratorOnDeviceConnected;
     SetBacklight(context.Engine);
     return(true);
 }
        public object[] Create(IUiPluginContext context)
        {
            var result = _plugins?.Where(xk => string.Equals(xk.EngineName, context.Engine.EngineName, StringComparison.OrdinalIgnoreCase)).ToArray();

            foreach (var plugin in result)
            {
                if (!plugin.SetContext(context))
                {
                    throw new ApplicationException($"The {Type.FullName} plugin cannot be re-used");
                }
            }
            return(result);
        }
        public object CreateNew(IUiPluginContext context)
        {
            var result = _plugins?.FirstOrDefault(xk => string.Equals(xk.EngineName, context.Engine.EngineName, StringComparison.OrdinalIgnoreCase));

            if (result != null)
            {
                if (!result.SetContext(context))
                {
                    throw new ApplicationException($"The {Type.FullName} plugin cannot be re-used");
                }
            }
            return(result);
        }
Beispiel #6
0
 public static T ComposePart <T>(IUiPluginContext context) where T : class
 {
     try
     {
         if (Factories != null)
         {
             return(Factories
                    .Where(f => typeof(T).IsAssignableFrom(f.Type))
                    .SelectMany(f => f.Create(context))
                    .FirstOrDefault() as T);
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
     return(null);
 }
Beispiel #7
0
 public static IUiPlugin[] ComposeUiParts(IUiPluginContext context)
 {
     try
     {
         if (Factories != null)
         {
             return(Factories
                    .Where(f => typeof(IUiPlugin).IsAssignableFrom(f.Type))
                    .SelectMany(f => f.Create(context))
                    .Cast <IUiPlugin>().ToArray());
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
     return(new IUiPlugin[0]);
 }
Beispiel #8
0
 public static T ComposePart <T>(IUiPluginContext context)
 {
     try
     {
         if (Factories != null)
         {
             return(Factories
                    .Where(f => typeof(T).IsAssignableFrom(f.Type))
                    .Select(f => (T)f.CreateNew(context))
                    .FirstOrDefault(p => p != null));
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
     return(default(T));
 }
Beispiel #9
0
 public static T[] ComposeParts <T>(IUiPluginContext context) where T : IUiPlugin
 {
     try
     {
         if (Factories != null)
         {
             return(Factories
                    .Where(f => typeof(T).IsAssignableFrom(f.Type))
                    .Select(f => (T)f.CreateNew(context))
                    .Where(p => p != null)
                    .ToArray());
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
     return(new T[0]);
 }
Beispiel #10
0
 public object CreateNew(IUiPluginContext context)
 {
     return(new UiPlugin(context));
 }
Beispiel #11
0
 public object[] Create(IUiPluginContext context)
 {
     return(new object[] { new UiPlugin(context) });
 }
Beispiel #12
0
 public object CreateNew(IUiPluginContext context)
 {
     return(new VideoPreviewViewmodel());
 }
Beispiel #13
0
 object[] IUiPluginFactory.Create(IUiPluginContext context)
 {
     return(new object[] { new VideoPreviewViewmodel() });
 }