public void SortedArrayKeyList_can_allow_duplicates() { var a = new CKSortedArrayKeyList<int, string>( i => i.ToString() ); a.AddRangeArray( 1, 10, 100, 100, 1000, 10000, 2, 20, 3, 30, 100, 46, 56 ); CheckList( a, 1, 10, 100, 1000, 10000, 2, 20, 3, 30, 46, 56 ); Assert.That( a.IndexOf( 1 ), Is.EqualTo( 0 ) ); Assert.That( a.IndexOf( 2 ), Is.EqualTo( 5 ) ); Assert.That( a.IndexOf( 3 ), Is.EqualTo( 7 ) ); Assert.That( a.KeyCount( "100" ), Is.EqualTo( 1 ) ); object o; o = "2"; Assert.That( a.IndexOf( o ), Is.EqualTo( 5 ) ); o = 2; Assert.That( a.IndexOf( o ), Is.EqualTo( 5 ) ); o = null; Assert.That( a.IndexOf( o ), Is.EqualTo( Int32.MinValue ) ); o = new ClassToTest( "A" ); Assert.That( a.IndexOf( o ), Is.EqualTo( Int32.MinValue ) ); o = "42"; Assert.That( a.Contains( o ), Is.False ); a.Remove( "10" ); Assert.That( a.KeyCount( "10" ), Is.EqualTo( 0 ) ); CheckList( a, 1, 100, 1000, 10000, 2, 20, 3, 30, 46, 56 ); a.Remove( "20" ); CheckList( a, 1, 100, 1000, 10000, 2, 3, 30, 46, 56 ); a.Remove( "100" ); Assert.That( a.KeyCount( "100" ), Is.EqualTo( 0 ) ); CheckList( a, 1, 1000, 10000, 2, 3, 30, 46, 56 ); Assert.That( a.Remove( "Nothing" ), Is.False ); }
public void SortedArrayKeyList_without_duplicates() { var a = new CKSortedArrayKeyList <int, string>(i => i.ToString()); a.AddRangeArray(3, 2, 1); bool exists; Assert.That(a.GetByKey("1", out exists) == 1 && exists); Assert.That(a.GetByKey("10", out exists) == 0 && !exists); Assert.That(a.GetByKey("2", out exists) == 2 && exists); Assert.That(a.Contains("2")); Assert.That(a.Contains("1")); Assert.That(!a.Contains("21")); object o; o = "2"; Assert.That(a.Contains(o), "Using the key."); o = 2; Assert.That(a.Contains(o), "Using the value itself."); o = null; Assert.That(a.Contains(o), Is.False); o = 42; Assert.That(a.Contains(o), Is.False); o = "42"; Assert.That(a.Contains(o), Is.False); Assert.That(!a.Add(3)); Assert.That(!a.Add(2)); Assert.That(!a.Add(1)); CheckList(a.GetAllByKey("2"), 2); }
public void SortedArrayKeyList_without_duplicates() { var a = new CKSortedArrayKeyList <int, string>(i => i.ToString()); a.AddRangeArray(3, 2, 1); bool exists; a.GetByKey("1", out exists).Should().Be(1); exists.Should().BeTrue(); a.GetByKey("10", out exists).Should().Be(0); exists.Should().BeFalse(); a.GetByKey("2", out exists).Should().Be(2); exists.Should().BeTrue(); a.Contains("2").Should().BeTrue(); a.Contains("1").Should().BeTrue(); a.Contains("21").Should().BeFalse(); object o; o = "2"; a.Contains(o).Should().BeTrue("Using the key."); o = 2; a.Contains(o).Should().BeTrue("Using the value itself."); o = null; a.Contains(o).Should().BeFalse(); o = 42; a.Contains(o).Should().BeFalse(); o = "42"; a.Contains(o).Should().BeFalse(); a.Add(3).Should().BeFalse(); a.Add(2).Should().BeFalse(); a.Add(1).Should().BeFalse(); CheckList(a.GetAllByKey("2"), 2); }
public VirtualFileStorage(bool handleZip, bool handleNupkg) { _handleZip = handleZip; _handleNupkg = handleNupkg; _drivers = new CKSortedArrayKeyList <VirtualFileStorageDriver, string>(v => v.RootPath, StringComparer.OrdinalIgnoreCase.Compare); _root = new VirtualFileStorageDriverRoot(this); _drivers.Add(_root); }
public void SortedArrayKeyList_does_not_accept_null_entries() { var b = new CKSortedArrayKeyList <ClassToTest, string>(i => i.ToString(), false); ClassToTest classToTest = new ClassToTest("A"); b.Add(classToTest); b.Add(new ClassToTest("B")); b.Contains(classToTest).Should().BeTrue(); b.IndexOf(classToTest).Should().Be(0); b.Invoking(sut => sut.IndexOf((ClassToTest)null)).Should().Throw <ArgumentNullException>(); }
public void SortedArrayKeyList_does_not_accept_null_entries() { var b = new CKSortedArrayKeyList <ClassToTest, string>(i => i.ToString(), false); ClassToTest classToTest = new ClassToTest("A"); b.Add(classToTest); b.Add(new ClassToTest("B")); Assert.That(b.Contains(classToTest), Is.True); Assert.That(b.IndexOf(classToTest), Is.EqualTo(0)); Assert.Throws <ArgumentNullException>(() => b.IndexOf((ClassToTest)null)); }
internal LabXmlDeserializer( LabStateManager state, XmlReader r ) { this.state = state; this.r = r; deserializedState = new PersistedLabState(); // Used to index reference links between plugins and services. pendingGeneralizations = new List<PendingGeneralization>(); pendingPluginServices = new List<PendingPluginService>(); pendingServiceReferences = new List<PendingServiceReference>(); loadedServices = new CKSortedArrayKeyList<ServiceInfo, string>( s => s.ServiceFullName, false ); loadedPlugins = new CKSortedArrayKeyList<PluginInfo, string>( p => p.PluginFullName, false ); }
internal LabXmlDeserializer(LabStateManager state, XmlReader r) { this.state = state; this.r = r; deserializedState = new PersistedLabState(); // Used to index reference links between plugins and services. pendingGeneralizations = new List <PendingGeneralization>(); pendingPluginServices = new List <PendingPluginService>(); pendingServiceReferences = new List <PendingServiceReference>(); loadedServices = new CKSortedArrayKeyList <ServiceInfo, string>(s => s.ServiceFullName, false); loadedPlugins = new CKSortedArrayKeyList <PluginInfo, string>(p => p.PluginFullName, false); }
private static void ReadPlugins(XmlReader r, DiscoveredInfo d, CKSortedArrayKeyList <ServiceInfo, string> loadedServices, CKSortedArrayKeyList <PluginInfo, string> loadedPlugins, List <PendingPluginService> pendingPluginServices, List <PendingServiceReference> pendingServiceReferences) { while (r.Read()) { if (r.IsStartElement() && r.Name == "Plugin") { ReadPlugin(r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingPluginServices, pendingServiceReferences); } } }
public void sorting_Lexicographic_integers() { var a = new CKSortedArrayKeyList<int,string>( i => i.ToString() ); a.AddRangeArray( 1, 2, 3 ); CheckList( a, 1, 2, 3 ); a.AddRangeArray( 10, 20, 30 ); CheckList( a, 1, 10, 2, 20, 3, 30 ); a.AddRangeArray( 10, 20, 30 ); CheckList( a, 1, 10, 2, 20, 3, 30 ); a.AddRangeArray( 10000, 1000, 100, 10, 1, 56 ); CheckList( a, 1, 10, 100, 1000, 10000, 2, 20, 3, 30, 56 ); a.AddRangeArray( 10000, 1000, 100, 10, 1, 46 ); CheckList( a, 1, 10, 100, 1000, 10000, 2, 20, 3, 30, 46, 56 ); }
public void sorting_Lexicographic_integers() { var a = new CKSortedArrayKeyList <int, string>(i => i.ToString()); a.AddRangeArray(1, 2, 3); CheckList(a, 1, 2, 3); a.AddRangeArray(10, 20, 30); CheckList(a, 1, 10, 2, 20, 3, 30); a.AddRangeArray(10, 20, 30); CheckList(a, 1, 10, 2, 20, 3, 30); a.AddRangeArray(10000, 1000, 100, 10, 1, 56); CheckList(a, 1, 10, 100, 1000, 10000, 2, 20, 3, 30, 56); a.AddRangeArray(10000, 1000, 100, 10, 1, 46); CheckList(a, 1, 10, 100, 1000, 10000, 2, 20, 3, 30, 46, 56); }
public static YodiiEngine CreateEngineFromXml(XmlReader r) { YodiiEngine e = new YodiiEngine(new YodiiEngineHostMock()); DiscoveredInfo d = new DiscoveredInfo(); // Used to index reference links between plugins and services. List <PendingGeneralization> pendingGeneralizations = new List <PendingGeneralization>(); List <PendingPluginService> pendingPluginServices = new List <PendingPluginService>(); List <PendingServiceReference> pendingServiceReferences = new List <PendingServiceReference>(); CKSortedArrayKeyList <PluginInfo, string> loadedPlugins; CKSortedArrayKeyList <ServiceInfo, string> loadedServices; loadedServices = new CKSortedArrayKeyList <ServiceInfo, string>(s => s.ServiceFullName, false); loadedPlugins = new CKSortedArrayKeyList <PluginInfo, string>(p => p.PluginFullName, false); while (r.Read()) { // Load services if (r.IsStartElement() && r.Name == "Services") { ReadServices(r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingGeneralizations, pendingPluginServices, pendingServiceReferences); } // Load plugins if (r.IsStartElement() && r.Name == "Plugins") { ReadPlugins(r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingPluginServices, pendingServiceReferences); } // Read configuration manager if (r.IsStartElement() && r.Name == "Configuration") { ReadConfigurationManager(e.Configuration, r.ReadSubtree()); } } e.SetDiscoveredInfo(d); return(e); }
public static YodiiEngine CreateEngineFromXml( XmlReader r ) { YodiiEngine e = new YodiiEngine( new YodiiEngineHostMock() ); DiscoveredInfo d = new DiscoveredInfo(); // Used to index reference links between plugins and services. List<PendingGeneralization> pendingGeneralizations = new List<PendingGeneralization>(); List<PendingPluginService> pendingPluginServices = new List<PendingPluginService>(); List<PendingServiceReference> pendingServiceReferences = new List<PendingServiceReference>(); CKSortedArrayKeyList<PluginInfo, string> loadedPlugins; CKSortedArrayKeyList<ServiceInfo, string> loadedServices; loadedServices = new CKSortedArrayKeyList<ServiceInfo, string>( s => s.ServiceFullName, false ); loadedPlugins = new CKSortedArrayKeyList<PluginInfo, string>( p => p.PluginFullName, false ); while( r.Read() ) { // Load services if( r.IsStartElement() && r.Name == "Services" ) { ReadServices( r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingGeneralizations, pendingPluginServices, pendingServiceReferences ); } // Load plugins if( r.IsStartElement() && r.Name == "Plugins" ) { ReadPlugins( r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingPluginServices, pendingServiceReferences ); } // Read configuration manager if( r.IsStartElement() && r.Name == "Configuration" ) { ReadConfigurationManager( e.Configuration, r.ReadSubtree() ); } } e.SetDiscoveredInfo( d ); return e; }
public void SortedArrayKeyList_can_allow_duplicates() { var a = new CKSortedArrayKeyList <int, string>(i => i.ToString()); a.AddRangeArray(1, 10, 100, 100, 1000, 10000, 2, 20, 3, 30, 100, 46, 56); CheckList(a, 1, 10, 100, 1000, 10000, 2, 20, 3, 30, 46, 56); Assert.That(a.IndexOf(1), Is.EqualTo(0)); Assert.That(a.IndexOf(2), Is.EqualTo(5)); Assert.That(a.IndexOf(3), Is.EqualTo(7)); Assert.That(a.KeyCount("100"), Is.EqualTo(1)); object o; o = "2"; Assert.That(a.IndexOf(o), Is.EqualTo(5)); o = 2; Assert.That(a.IndexOf(o), Is.EqualTo(5)); o = null; Assert.That(a.IndexOf(o), Is.EqualTo(Int32.MinValue)); o = new ClassToTest("A"); Assert.That(a.IndexOf(o), Is.EqualTo(Int32.MinValue)); o = "42"; Assert.That(a.Contains(o), Is.False); a.Remove("10"); Assert.That(a.KeyCount("10"), Is.EqualTo(0)); CheckList(a, 1, 100, 1000, 10000, 2, 20, 3, 30, 46, 56); a.Remove("20"); CheckList(a, 1, 100, 1000, 10000, 2, 3, 30, 46, 56); a.Remove("100"); Assert.That(a.KeyCount("100"), Is.EqualTo(0)); CheckList(a, 1, 1000, 10000, 2, 3, 30, 46, 56); Assert.That(a.Remove("Nothing"), Is.False); }
public void another_test_with_duplicates_in_SortedArrayKeyList() { var a = new CKSortedArrayKeyList <int, string>(i => (i % 100).ToString(), true); a.AddRangeArray(2, 1); bool exists; a.GetByKey("1", out exists).Should().Be(1); exists.Should().BeTrue(); a.GetByKey("2", out exists).Should().Be(2); exists.Should().BeTrue(); a.Add(102); a.Add(101); int v1 = a.GetByKey("1"); v1.Should().BeOneOf(new[] { 1, 101 }, "It is one or the other that is returned."); int v2 = a.GetByKey("2"); v2.Should().BeOneOf(new[] { 2, 102 }, "It is one or the other that is returned."); a.KeyCount("2").Should().Be(2); CheckList(a.GetAllByKey("2").OrderBy(Util.FuncIdentity), 2, 102); a.Add(102); a.Add(102); a.Add(102); a.Add(202); a.Add(302); a.KeyCount("2").Should().Be(7); CheckList(a.GetAllByKey("2").OrderBy(Util.FuncIdentity), 2, 102, 102, 102, 102, 202, 302); a.KeyCount("5454").Should().Be(0); a.GetAllByKey("5454").Should().BeEmpty(); }
public void another_test_with_duplicates_in_SortedArrayKeyList() { var a = new CKSortedArrayKeyList <int, string>(i => (i % 100).ToString(), true); a.AddRangeArray(2, 1); bool exists; Assert.That(a.GetByKey("1", out exists) == 1 && exists); Assert.That(a.GetByKey("2", out exists) == 2 && exists); Assert.That(a.Add(102)); Assert.That(a.Add(101)); int v1 = a.GetByKey("1"); Assert.That(v1, Is.EqualTo(1).Or.EqualTo(101), "It is one or the other that is returned."); int v2 = a.GetByKey("2"); Assert.That(v2, Is.EqualTo(2).Or.EqualTo(102), "It is one or the other that is returned."); Assert.That(a.KeyCount("2") == 2); CheckList(a.GetAllByKey("2").OrderBy(Util.FuncIdentity), 2, 102); Assert.That(a.Add(102)); Assert.That(a.Add(102)); Assert.That(a.Add(102)); Assert.That(a.Add(202)); Assert.That(a.Add(302)); Assert.That(a.KeyCount("2") == 7); CheckList(a.GetAllByKey("2").OrderBy(Util.FuncIdentity), 2, 102, 102, 102, 102, 202, 302); Assert.That(a.KeyCount("5454") == 0); Assert.That(a.GetAllByKey("5454"), Is.Empty); }
public void SortedArrayKeyList_can_allow_duplicates() { var a = new CKSortedArrayKeyList <int, string>(i => i.ToString()); a.AddRangeArray(1, 10, 100, 100, 1000, 10000, 2, 20, 3, 30, 100, 46, 56); CheckList(a, 1, 10, 100, 1000, 10000, 2, 20, 3, 30, 46, 56); a.IndexOf(1).Should().Be(0); a.IndexOf(2).Should().Be(5); a.IndexOf(3).Should().Be(7); a.KeyCount("100").Should().Be(1); object o; o = "2"; a.IndexOf(o).Should().Be(5); o = 2; a.IndexOf(o).Should().Be(5); o = null; a.IndexOf(o).Should().Be(Int32.MinValue); o = new ClassToTest("A"); a.IndexOf(o).Should().Be(Int32.MinValue); o = "42"; a.Contains(o).Should().BeFalse(); a.Remove("10"); a.KeyCount("10").Should().Be(0); CheckList(a, 1, 100, 1000, 10000, 2, 20, 3, 30, 46, 56); a.Remove("20"); CheckList(a, 1, 100, 1000, 10000, 2, 3, 30, 46, 56); a.Remove("100"); a.KeyCount("100").Should().Be(0); CheckList(a, 1, 1000, 10000, 2, 3, 30, 46, 56); a.Remove("Nothing").Should().BeFalse(); }
protected override void InternalPreCompute() { _serviceVertices = new CKSortedArrayKeyList <YodiiGraphVertex, IServiceInfo>( s => s.LabServiceInfo.ServiceInfo, (a, b) => String.Compare(a.ServiceFullName, b.ServiceFullName), false ); _pluginVertices = new CKSortedArrayKeyList <YodiiGraphVertex, IPluginInfo>( s => s.LabPluginInfo.PluginInfo, (a, b) => String.Compare(a.PluginFullName, b.PluginFullName), false ); _rootFamilies = new CKSortedArrayList <ServiceFamily>( (a, b) => String.Compare(a.RootService.ServiceFullName, b.RootService.ServiceFullName), false ); _serviceFamilies = new CKSortedArrayKeyList <ServiceFamily, IServiceInfo>( s => s.RootService, (a, b) => String.Compare(a.ServiceFullName, b.ServiceFullName), false ); _orphanPlugins = new CKSortedArrayKeyList <YodiiGraphVertex, IPluginInfo>( p => p.LabPluginInfo.PluginInfo, (a, b) => String.Compare(a.PluginFullName, b.PluginFullName), false ); _rootFamilies = new CKSortedArrayList <ServiceFamily>( (a, b) => String.Compare(a.RootService.ServiceFullName, b.RootService.ServiceFullName), false ); }
/// <summary> /// Creates a new, empty FinalConfiguration. /// </summary> public FinalConfiguration() { _items = new CKSortedArrayKeyList <FinalConfigurationItem, string>(e => e.ServiceOrPluginFullName, (x, y) => StringComparer.Ordinal.Compare(x, y)); }
public void SortedArrayKeyList_without_duplicates() { var a = new CKSortedArrayKeyList<int, string>( i => i.ToString() ); a.AddRangeArray( 3, 2, 1 ); bool exists; Assert.That( a.GetByKey( "1", out exists ) == 1 && exists ); Assert.That( a.GetByKey( "10", out exists ) == 0 && !exists ); Assert.That( a.GetByKey( "2", out exists ) == 2 && exists ); Assert.That( a.Contains( "2" ) ); Assert.That( a.Contains( "1" ) ); Assert.That( !a.Contains( "21" ) ); object o; o = "2"; Assert.That( a.Contains( o ), "Using the key." ); o = 2; Assert.That( a.Contains( o ), "Using the value itself." ); o = null; Assert.That( a.Contains( o ), Is.False ); o = 42; Assert.That( a.Contains( o ), Is.False ); o = "42"; Assert.That( a.Contains( o ), Is.False ); Assert.That( !a.Add( 3 ) ); Assert.That( !a.Add( 2 ) ); Assert.That( !a.Add( 1 ) ); CheckList( a.GetAllByKey( "2" ), 2 ); }
/// <summary> /// Creates a new, empty FinalConfiguration. /// </summary> public FinalConfiguration() { _items = new CKSortedArrayKeyList<FinalConfigurationItem, string>( e => e.ServiceOrPluginFullName, ( x, y ) => StringComparer.Ordinal.Compare( x, y ) ); }
public void another_test_with_duplicates_in_SortedArrayKeyList() { var a = new CKSortedArrayKeyList<int, string>( i => (i%100).ToString(), true ); a.AddRangeArray( 2, 1 ); bool exists; Assert.That( a.GetByKey( "1", out exists ) == 1 && exists ); Assert.That( a.GetByKey( "2", out exists ) == 2 && exists ); Assert.That( a.Add( 102 ) ); Assert.That( a.Add( 101 ) ); int v1 = a.GetByKey( "1" ); Assert.That( v1, Is.EqualTo( 1 ).Or.EqualTo( 101 ), "It is one or the other that is returned." ); int v2 = a.GetByKey( "2" ); Assert.That( v2, Is.EqualTo( 2 ).Or.EqualTo( 102 ), "It is one or the other that is returned." ); Assert.That( a.KeyCount( "2" ) == 2 ); CheckList( a.GetAllByKey( "2" ).OrderBy( Util.FuncIdentity ), 2, 102 ); Assert.That( a.Add( 102 ) ); Assert.That( a.Add( 102 ) ); Assert.That( a.Add( 102 ) ); Assert.That( a.Add( 202 ) ); Assert.That( a.Add( 302 ) ); Assert.That( a.KeyCount( "2" ) == 7 ); CheckList( a.GetAllByKey( "2" ).OrderBy( Util.FuncIdentity ), 2, 102, 102, 102, 102, 202, 302 ); Assert.That( a.KeyCount( "5454" ) == 0 ); Assert.That( a.GetAllByKey( "5454" ), Is.Empty ); }
private static void ReadPlugin(XmlReader r, DiscoveredInfo d, CKSortedArrayKeyList <ServiceInfo, string> loadedServices, CKSortedArrayKeyList <PluginInfo, string> loadedPlugins, List <PendingPluginService> pendingPluginServices, List <PendingServiceReference> pendingServiceReferences ) { r.Read(); string pluginFullName = String.Empty; string serviceFullName = null; List <Tuple <string, DependencyRequirement> > references = new List <Tuple <string, DependencyRequirement> >(); while (r.Read()) { if (r.IsStartElement() && !r.IsEmptyElement) { switch (r.Name) { case "FullName": if (r.Read()) { pluginFullName = r.Value; } break; case "Service": if (r.Read()) { serviceFullName = r.Value; } break; case "ServiceReferences": while (r.Read()) { if (r.IsStartElement() && r.Name == "ServiceReference") { string serviceFullName2 = r.GetAttribute("Service"); if (!String.IsNullOrEmpty(serviceFullName2)) { DependencyRequirement requirement = (DependencyRequirement)Enum.Parse(typeof(DependencyRequirement), r.GetAttribute("Requirement")); references.Add(Tuple.Create(serviceFullName2, requirement)); } } } break; } } } PluginInfo p = new PluginInfo(pluginFullName, d.DefaultAssembly); d.PluginInfos.Add(p); loadedPlugins.Add(p); if (!String.IsNullOrEmpty(serviceFullName)) { if (loadedServices.Contains(serviceFullName)) { var service = loadedServices.GetByKey(serviceFullName); p.Service = service; } else { pendingPluginServices.Add(new PendingPluginService(p, serviceFullName)); } } foreach (var t in references) { if (loadedServices.Contains(t.Item1)) { p.AddServiceReference(loadedServices.GetByKey(t.Item1), t.Item2); } else { pendingServiceReferences.Add(new PendingServiceReference(p, t.Item1, t.Item2)); } } }
private static void ReadService(XmlReader r, DiscoveredInfo d, CKSortedArrayKeyList <ServiceInfo, string> loadedServices, CKSortedArrayKeyList <PluginInfo, string> loadedPlugins, List <PendingGeneralization> pendingGeneralizations, List <PendingPluginService> pendingPluginServices, List <PendingServiceReference> pendingServiceReferences ) { r.Read(); string serviceFullName = r.GetAttribute("FullName"); Debug.Assert(serviceFullName != null, "FullName attribute was found in Service XML element."); var s = new ServiceInfo(serviceFullName, d.DefaultAssembly); d.ServiceInfos.Add(s); loadedServices.Add(s); ServiceInfo generalization = null; while (r.Read()) { if (r.IsStartElement() && !r.IsEmptyElement) { if (r.Name == "Generalization") { if (r.Read()) { string generalizationName = r.Value; if (!String.IsNullOrEmpty(generalizationName)) { if (loadedServices.Contains(generalizationName)) { generalization = loadedServices.GetByKey(generalizationName); s.Generalization = generalization; } else { pendingGeneralizations.Add(new PendingGeneralization(s, generalizationName)); } } } } } } // Fix pending references of this service foreach (var pg in pendingGeneralizations.Where(x => x.PendingServiceFullName == serviceFullName).ToList()) { pg.Service.Generalization = s; pendingGeneralizations.Remove(pg); } foreach (var pps in pendingPluginServices.Where(x => x.PendingServiceFullName == serviceFullName).ToList()) { pps.Plugin.Service = s; pendingPluginServices.Remove(pps); } foreach (var psr in pendingServiceReferences.Where(x => x.PendingServiceFullName == serviceFullName).ToList()) { psr.Plugin.AddServiceReference(s, psr.Requirement); pendingServiceReferences.Remove(psr); } }
private static void ReadServices( XmlReader r, DiscoveredInfo d, CKSortedArrayKeyList<ServiceInfo, string> loadedServices, CKSortedArrayKeyList<PluginInfo, string> loadedPlugins, List<PendingGeneralization> pendingGeneralizations, List<PendingPluginService> pendingPluginServices, List<PendingServiceReference> pendingServiceReferences ) { while( r.Read() ) { if( r.IsStartElement() && r.Name == "Service" ) { ReadService( r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingGeneralizations, pendingPluginServices, pendingServiceReferences ); } } }
public void SortedArrayKeyList_does_not_accept_null_entries() { var b = new CKSortedArrayKeyList<ClassToTest, string>( i => i.ToString(), false ); ClassToTest classToTest = new ClassToTest( "A" ); b.Add( classToTest ); b.Add( new ClassToTest( "B" ) ); Assert.That( b.Contains( classToTest ), Is.True ); Assert.That( b.IndexOf( classToTest ), Is.EqualTo( 0 ) ); Assert.Throws<ArgumentNullException>( () => b.IndexOf( (ClassToTest)null ) ); }
private static void ReadService( XmlReader r, DiscoveredInfo d, CKSortedArrayKeyList<ServiceInfo, string> loadedServices, CKSortedArrayKeyList<PluginInfo, string> loadedPlugins, List<PendingGeneralization> pendingGeneralizations, List<PendingPluginService> pendingPluginServices, List<PendingServiceReference> pendingServiceReferences ) { r.Read(); string serviceFullName = r.GetAttribute( "FullName" ); Debug.Assert( serviceFullName != null, "FullName attribute was found in Service XML element." ); var s = new ServiceInfo( serviceFullName, d.DefaultAssembly ); d.ServiceInfos.Add( s ); loadedServices.Add( s ); ServiceInfo generalization = null; while( r.Read() ) { if( r.IsStartElement() && !r.IsEmptyElement ) { if( r.Name == "Generalization" ) { if( r.Read() ) { string generalizationName = r.Value; if( !String.IsNullOrEmpty( generalizationName ) ) { if( loadedServices.Contains( generalizationName ) ) { generalization = loadedServices.GetByKey( generalizationName ); s.Generalization = generalization; } else { pendingGeneralizations.Add( new PendingGeneralization( s, generalizationName ) ); } } } } } } // Fix pending references of this service foreach( var pg in pendingGeneralizations.Where( x => x.PendingServiceFullName == serviceFullName ).ToList() ) { pg.Service.Generalization = s; pendingGeneralizations.Remove( pg ); } foreach( var pps in pendingPluginServices.Where( x => x.PendingServiceFullName == serviceFullName ).ToList() ) { pps.Plugin.Service = s; pendingPluginServices.Remove( pps ); } foreach( var psr in pendingServiceReferences.Where( x => x.PendingServiceFullName == serviceFullName ).ToList() ) { psr.Plugin.AddServiceReference( s, psr.Requirement ); pendingServiceReferences.Remove( psr ); } }
private static void ReadPlugin( XmlReader r, DiscoveredInfo d, CKSortedArrayKeyList<ServiceInfo, string> loadedServices, CKSortedArrayKeyList<PluginInfo, string> loadedPlugins, List<PendingPluginService> pendingPluginServices, List<PendingServiceReference> pendingServiceReferences ) { r.Read(); string pluginFullName = String.Empty; string serviceFullName = null; List<Tuple<string,DependencyRequirement>> references = new List<Tuple<string, DependencyRequirement>>(); while( r.Read() ) { if( r.IsStartElement() && !r.IsEmptyElement ) { switch( r.Name ) { case "FullName": if( r.Read() ) { pluginFullName = r.Value; } break; case "Service": if( r.Read() ) { serviceFullName = r.Value; } break; case "ServiceReferences": while( r.Read() ) { if( r.IsStartElement() && r.Name == "ServiceReference" ) { string serviceFullName2 = r.GetAttribute( "Service" ); if( !String.IsNullOrEmpty( serviceFullName2 ) ) { DependencyRequirement requirement = (DependencyRequirement)Enum.Parse( typeof( DependencyRequirement ), r.GetAttribute( "Requirement" ) ); references.Add( Tuple.Create( serviceFullName2, requirement ) ); } } } break; } } } PluginInfo p = new PluginInfo( pluginFullName, d.DefaultAssembly ); d.PluginInfos.Add( p ); loadedPlugins.Add( p ); if( !String.IsNullOrEmpty( serviceFullName ) ) { if( loadedServices.Contains( serviceFullName ) ) { var service = loadedServices.GetByKey( serviceFullName ); p.Service = service; } else { pendingPluginServices.Add( new PendingPluginService( p, serviceFullName ) ); } } foreach( var t in references ) { if( loadedServices.Contains( t.Item1 ) ) { p.AddServiceReference( loadedServices.GetByKey( t.Item1 ), t.Item2 ); } else { pendingServiceReferences.Add( new PendingServiceReference( p, t.Item1, t.Item2 ) ); } } }