public MediaListItemAction(MediaItemActionExtension extension) { Caption = extension.Caption; Sort = extension.Sort; _action = extension.Action; Restriction = _action as IUserRestriction; if (Restriction != null) { Restriction.RestrictionGroup = extension.RestrictionGroup; } Deferred = _action is IDeferredMediaItemAction; }
protected void BuildExtensions() { if (_mediaActionPluginItemStateTracker != null) { return; } _mediaActionPluginItemStateTracker = new FixedItemStateTracker("MediaItemsActionModel - Extension registration"); IPluginManager pluginManager = ServiceRegistration.Get <IPluginManager>(); foreach (PluginItemMetadata itemMetadata in pluginManager.GetAllPluginItemMetadata(MediaItemActionBuilder.MEDIA_EXTENSION_PATH)) { try { MediaItemActionExtension mediaExtension = pluginManager.RequestPluginItem <MediaItemActionExtension>( MediaItemActionBuilder.MEDIA_EXTENSION_PATH, itemMetadata.Id, _mediaActionPluginItemStateTracker); if (mediaExtension == null) { ServiceRegistration.Get <ILogger>().Warn("Could not instantiate Media extension with id '{0}'", itemMetadata.Id); } else { Type extensionClass = mediaExtension.ExtensionClass; if (extensionClass == null) { throw new PluginInvalidStateException("Could not find class type for extension {0}", mediaExtension.Caption); } IMediaItemAction action = Activator.CreateInstance(extensionClass) as IMediaItemAction; if (action == null) { throw new PluginInvalidStateException("Could not create IMediaItemAction instance of class {0}", extensionClass); } mediaExtension.Action = action; _actions.Add(mediaExtension); } } catch (PluginInvalidStateException e) { ServiceRegistration.Get <ILogger>().Warn("Cannot add Media extension with id '{0}'", e, itemMetadata.Id); } } }