public Models.PluginAssembly Get(string name) { var assm = this.assmService.GetPluginAssembly(name); var result = new Models.PluginAssembly { Id = assm.PluginAssemblyId.Value, Name = assm.Name }; var types = this.typeService.ForPluginAssembly(assm.PluginAssemblyId.Value); var steps = this.stepService.ForPluginAssembly(assm.PluginAssemblyId.Value); var filters = this.stepService.FiltersForAssembly(assm.PluginAssemblyId.Value); var images = this.stepService.ImagesForPluginAssembly(assm.PluginAssemblyId.Value); result.PluginTypes = (from t in types select new Models.PluginAssembly.PluginType { Id = t.PluginTypeId.Value, Name = t.Name }).ToArray(); foreach (var type in result.PluginTypes) { type.PluginSteps = (from step in steps where step.EventHandler.Id == type.Id select new Models.PluginAssembly.PluginStep { Id = step.SdkMessageProcessingStepId.Value, Name = step.Name, Stage = step.Stage.Value, Mode = step.Mode.Value, Message = step.SdkMessageId.Name, FilteringAttributes = step.FilteringAttributes, Rank = step.Rank.Value, PrimaryEntityLogicalName = filters.Where(r => step.SdkMessageFilterId != null && r.SdkMessageFilterId == step.SdkMessageFilterId.Id).SingleOrDefault()?.PrimaryObjectTypeCode }).ToArray(); foreach (var step in type.PluginSteps) { step.Images = (from i in images where i.SdkMessageProcessingStepId.Id == step.Id select new Models.PluginAssembly.Image { Id = i.SdkMessageProcessingStepImageId.Value, Name = i.Name, Attributes1 = i.Attributes1, Description = i.Description, EntityAlias = i.EntityAlias, ImageType = i.ImageType.Value, MessagePropertyName = i.MessagePropertyName }).ToArray(); } } return(result); }
public void LoadAssembly(string assemblyPath) { if (_currentPluginAssembly != null) { // Unload the existing assembly first _currentPluginAssembly = null; } _currentPluginAssembly = new Models.PluginAssembly(assemblyPath, _distribIOC.Get<IPluginAssemblyFactory>()); _eventAggregator.GetEvent<Events.PluginAssemblyStateChangeEvent>() .Publish(Events.PluginAssemblyStateChange.AssemblyLoaded); // Now initialise the assembly _currentPluginAssembly.Init(); _eventAggregator.GetEvent<Events.PluginAssemblyStateChangeEvent>() .Publish(Events.PluginAssemblyStateChange.AssemblyInitialised); }
public void UnloadAssembly() { if (_currentPluginAssembly == null) { throw new InvalidOperationException(); } // Uninitialise if need to first if (_currentPluginAssembly.Initialised) { _currentPluginAssembly.Uninit(); _eventAggregator.GetEvent<Events.PluginAssemblyStateChangeEvent>() .Publish(Events.PluginAssemblyStateChange.AssemblyUninitialised); } // Remove reference _currentPluginAssembly = null; _eventAggregator.GetEvent<Events.PluginAssemblyStateChangeEvent>() .Publish(Events.PluginAssemblyStateChange.AssemblyUnloaded); }