internal PluginAssemblyInfo FindOrCreate(Runner.PluginAssemblyInfo assembly) { Debug.Assert(assembly != null); PluginAssemblyInfo f; if (!_dicAssemblies.TryGetValue(assembly.AssemblyFileName, out f)) { f = new PluginAssemblyInfo(_discoverer); _dicAssemblies.Add(assembly.AssemblyFileName, f); _hasBeenDiscovered.Add(f); f.Initialize(this, assembly); _newAssemblies.Add(f); if (assembly.HasPluginsOrServices) { _discoverer._pluginOrServiceAssemblies.Add(f); } } else { Debug.Assert(f != null && (_hasBeenDiscovered.Contains(f) || (f.LastChangedVersion != _discoverer.CurrentVersion))); if (f.LastChangedVersion != _discoverer.CurrentVersion && !_hasBeenDiscovered.Contains(f)) { _hasBeenDiscovered.Add(f); if (f.Merge(this, assembly)) { _changedAssemblies.Add(f); } } } return(f); }
public IServiceInfo FindService(string serviceAssemblyQualifiedName) { ServiceInfo f; if (_servicesByAssemblyQualifiedName.TryGetValue(serviceAssemblyQualifiedName, out f)) { return(f); } // Second chance: find the assembly (without Version, Culture and PulicKeyToken). string assemblyFullName, fullTypeName; if (SimpleTypeFinder.SplitAssemblyQualifiedName(serviceAssemblyQualifiedName, out fullTypeName, out assemblyFullName)) { PluginAssemblyInfo a = FindAssembly(assemblyFullName); if (a != null) { foreach (var s in a.Services) { if (s.ServiceFullName == fullTypeName) { return(s); } } } } return(null); }
internal void Initialize(PluginDiscoverer.Merger merger, Runner.ServiceInfo r) { _assemblyQualifiedName = r.AssemblyQualifiedName; _serviceFullName = r.ServiceFullName; _isDynamicService = r.IsDynamicService; Debug.Assert(!_isDynamicService || (r.HasError || r.AssemblyInfo != null), "If we are a DynamicService, we must have an assembly or be in error."); if (r.AssemblyInfo != null) { _assembly = merger.FindOrCreate(r.AssemblyInfo); } base.Initialize(r); _implCollection = new List <PluginInfo>(); foreach (Runner.PluginInfo plugin in r.Implementations) { _implCollection.Add(merger.FindOrCreate(plugin)); } _impl = new ReadOnlyListOnIList <PluginInfo>(_implCollection); _propertiesInfoCollection = new List <SimplePropertyInfo>(); foreach (Runner.SimplePropertyInfo rP in r.PropertiesInfoCollection) { SimplePropertyInfo p = new SimplePropertyInfo(); p.Initialize(rP); _propertiesInfoCollection.Add(p); } _propertiesInfoCollectionEx = new ReadOnlyListOnIList <SimplePropertyInfo>(_propertiesInfoCollection); _methodsInfoCollection = new List <SimpleMethodInfo>(); foreach (Runner.SimpleMethodInfo rM in r.MethodsInfoCollection) { SimpleMethodInfo m = new SimpleMethodInfo(); m.Initialize(rM); _methodsInfoCollection.Add(m); } _methodsInfoCollectionEx = new ReadOnlyListOnIList <SimpleMethodInfo>(_methodsInfoCollection); _eventsInfoCollection = new List <SimpleEventInfo>(); foreach (Runner.SimpleEventInfo rE in r.EventsInfoCollection) { SimpleEventInfo e = new SimpleEventInfo(); e.Initialize(rE); _eventsInfoCollection.Add(e); } _eventsInfoCollectionEx = new ReadOnlyListOnIList <SimpleEventInfo>(_eventsInfoCollection); }
internal bool Merge(PluginDiscoverer.Merger merger, Runner.ServiceInfo r) { bool hasChanged = false; if (_assemblyQualifiedName != r.AssemblyQualifiedName) { _assemblyQualifiedName = r.AssemblyQualifiedName; hasChanged = true; } if (_serviceFullName != r.ServiceFullName) { _serviceFullName = r.ServiceFullName; hasChanged = true; } if (_isDynamicService != r.IsDynamicService) { _isDynamicService = r.IsDynamicService; hasChanged = true; } PluginAssemblyInfo newAI = r.AssemblyInfo != null?merger.FindOrCreate(r.AssemblyInfo) : null; if (_assembly != newAI) { _assembly = newAI; hasChanged = true; } if (PluginDiscoverer.Merger.GenericMergeLists(_implCollection, r.Implementations, merger.FindOrCreate, null)) { hasChanged = true; } if (PluginDiscoverer.Merger.GenericMergeLists(_methodsInfoCollection, r.MethodsInfoCollection, FindOrCreate, null)) { hasChanged = true; } if (PluginDiscoverer.Merger.GenericMergeLists(_eventsInfoCollection, r.EventsInfoCollection, FindOrCreate, null)) { hasChanged = true; } if (PluginDiscoverer.Merger.GenericMergeLists(_propertiesInfoCollection, r.PropertiesInfoCollection, FindOrCreate, null)) { hasChanged = true; } return(Merge(r, hasChanged)); }
internal void Initialize( PluginDiscoverer.Merger merger, Runner.PluginInfo r ) { base.Initialize( r ); _pluginId = r.PluginId; _name = r.PublicName; _pluginFullName = r.PluginFullName; _desc = r.Description; _url = r.RefUrl; _version = r.Version; _iconUri = r.IconUri; _isOldVersion = r.IsOldVersion; _assemblyInfo = merger.FindOrCreate( r.AssemblyInfo ); Debug.Assert( r.Categories != null ); _categoriesCollection = r.Categories; _categories = new ReadOnlyListOnIList<string>( _categoriesCollection ); if( r.EditorsInfo != null ) { _editorsCollection = new List<PluginConfigAccessorInfo>(); foreach( Runner.PluginConfigAccessorInfo editor in r.EditorsInfo ) _editorsCollection.Add( merger.FindOrCreate( editor ) ); } _servicesReferencesCollection = new List<ServiceReferenceInfo>(); _dicServiceReferences = new Dictionary<Runner.ServiceReferenceInfo, ServiceReferenceInfo>(); foreach( Runner.ServiceReferenceInfo service in r.ServiceReferences ) _servicesReferencesCollection.Add( FindOrCreate( merger, service ) ); if( r.Service != null ) { _service = merger.FindOrCreate( r.Service ); } _editableByCollection = new List<PluginConfigAccessorInfo>(); foreach( Runner.PluginConfigAccessorInfo editor in r.EditableBy ) _editableByCollection.Add( merger.FindOrCreate( editor ) ); _serviceReferences = new ReadOnlyListOnIList<ServiceReferenceInfo>( _dicServiceReferences.Values.ToList() ); _editorsInfo = new ReadOnlyListOnIList<PluginConfigAccessorInfo>( _editorsCollection ); _editableBy = new ReadOnlyListOnIList<PluginConfigAccessorInfo>( _editableByCollection ); _serviceReferences = new ReadOnlyListOnIList<ServiceReferenceInfo>( _dicServiceReferences.Values.ToList() ); _editorsInfo = new ReadOnlyListOnIList<PluginConfigAccessorInfo>( _editorsCollection ); }
internal bool Merge( PluginDiscoverer.Merger merger, Runner.PluginInfo r ) { bool hasChanged = false; if( _pluginId != r.PluginId ) { _pluginId = r.PluginId; hasChanged = true; } if( _name != r.PublicName ) { _name = r.PublicName; hasChanged = true; } if( _pluginFullName != r.PluginFullName ) { _pluginFullName = r.PluginFullName; hasChanged = true; } if( _desc != r.Description ) { _desc = r.Description; hasChanged = true; } if( _url != r.RefUrl ) { _url = r.RefUrl; hasChanged = true; } if( _version != r.Version ) { _version = r.Version; hasChanged = true; } if( _iconUri != r.IconUri ) { _iconUri = r.IconUri; hasChanged = true; } if( _isOldVersion != r.IsOldVersion ) { _isOldVersion = r.IsOldVersion; hasChanged = true; } Debug.Assert( _categories != null && r.Categories != null, "Already initialized." ); if( !_categories.SequenceEqual( r.Categories, StringComparer.Ordinal ) ) { _categoriesCollection = r.Categories; _categories = new ReadOnlyListOnIList<string>( _categoriesCollection ); hasChanged = true; } PluginAssemblyInfo newAI = merger.FindOrCreate( r.AssemblyInfo ); if( _assemblyInfo != newAI ) { _assemblyInfo = newAI; hasChanged = true; } if( PluginDiscoverer.Merger.GenericMergeLists( _servicesReferencesCollection, r.ServiceReferences, ( s ) => { return FindOrCreate( merger, s ); }, null ) ) { hasChanged = true; } // r.Service can be null, some checks have to be made: if( r.Service == null ) { if( _service != null ) { _service = null; hasChanged = true; } } else { ServiceInfo s = merger.FindOrCreate( r.Service ); if( _service != s ) { _service = s; hasChanged = true; } } if ( PluginDiscoverer.Merger.GenericMergeLists( _editorsCollection, r.EditorsInfo, merger.FindOrCreate, null ) ) { hasChanged = true; } if( PluginDiscoverer.Merger.GenericMergeLists( _editableByCollection, r.EditableBy, merger.FindOrCreate, null ) ) { hasChanged = true; } return Merge( r, hasChanged ); }