Changeset 11423
- Timestamp:
- 10/08/14 03:27:24 (10 years ago)
- Location:
- branches/OptimizationNetworks
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab 3.3.sln
r11069 r11423 1 1 2 2 Microsoft Visual Studio Solution File, Format Version 12.00 3 # Visual Studio 2012 3 # Visual Studio 2013 4 VisualStudioVersion = 12.0.21005.1 5 MinimumVisualStudioVersion = 10.0.40219.1 4 6 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{96396439-A764-4022-A8D2-BE021449B8D1}" 5 7 ProjectSection(SolutionItems) = preProject … … 1942 1944 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 1943 1945 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 1944 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x64.ActiveCfg = Debug|Any CPU 1945 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x86.ActiveCfg = Debug|Any CPU 1946 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x64.ActiveCfg = Debug|x64 1947 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x64.Build.0 = Debug|x64 1948 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x86.ActiveCfg = Debug|x86 1949 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x86.Build.0 = Debug|x86 1946 1950 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 1947 1951 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|Any CPU.Build.0 = Release|Any CPU 1948 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x64.ActiveCfg = Release|Any CPU 1949 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x86.ActiveCfg = Release|Any CPU 1952 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x64.ActiveCfg = Release|x64 1953 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x64.Build.0 = Release|x64 1954 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x86.ActiveCfg = Release|x86 1955 {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x86.Build.0 = Release|x86 1950 1956 {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 1951 1957 {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU 1952 {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x64.ActiveCfg = Debug|Any CPU 1953 {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x86.ActiveCfg = Debug|Any CPU 1958 {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x64.ActiveCfg = Debug|x64 1959 {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x64.Build.0 = Debug|x64 1960 {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x86.ActiveCfg = Debug|x86 1961 {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x86.Build.0 = Debug|x86 1954 1962 {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU 1955 1963 {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|Any CPU.Build.0 = Release|Any CPU 1956 {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x64.ActiveCfg = Release|Any CPU 1957 {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x86.ActiveCfg = Release|Any CPU 1964 {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x64.ActiveCfg = Release|x64 1965 {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x64.Build.0 = Release|x64 1966 {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x86.ActiveCfg = Release|x86 1967 {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x86.Build.0 = Release|x86 1958 1968 {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 1959 1969 {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|Any CPU.Build.0 = Debug|Any CPU 1960 {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x64.ActiveCfg = Debug|Any CPU 1961 {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x86.ActiveCfg = Debug|Any CPU 1970 {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x64.ActiveCfg = Debug|x64 1971 {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x64.Build.0 = Debug|x64 1972 {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x86.ActiveCfg = Debug|x86 1973 {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x86.Build.0 = Debug|x86 1962 1974 {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|Any CPU.ActiveCfg = Release|Any CPU 1963 1975 {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|Any CPU.Build.0 = Release|Any CPU 1964 {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x64.ActiveCfg = Release|Any CPU 1965 {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x86.ActiveCfg = Release|Any CPU 1976 {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x64.ActiveCfg = Release|x64 1977 {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x64.Build.0 = Release|x64 1978 {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x86.ActiveCfg = Release|x86 1979 {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x86.Build.0 = Release|x86 1966 1980 EndGlobalSection 1967 1981 GlobalSection(SolutionProperties) = preSolution -
branches/OptimizationNetworks/HeuristicLab.Modeler/3.3/HeuristicLab.Modeler-3.3.csproj
r11063 r11423 36 36 <PropertyGroup> 37 37 <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile> 38 </PropertyGroup> 39 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> 40 <DebugSymbols>true</DebugSymbols> 41 <OutputPath>bin\x64\Debug\</OutputPath> 42 <DefineConstants>DEBUG;TRACE</DefineConstants> 43 <DebugType>full</DebugType> 44 <PlatformTarget>x64</PlatformTarget> 45 <ErrorReport>prompt</ErrorReport> 46 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 47 </PropertyGroup> 48 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> 49 <OutputPath>bin\x64\Release\</OutputPath> 50 <DefineConstants>TRACE</DefineConstants> 51 <Optimize>true</Optimize> 52 <DebugType>pdbonly</DebugType> 53 <PlatformTarget>x64</PlatformTarget> 54 <ErrorReport>prompt</ErrorReport> 55 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 56 </PropertyGroup> 57 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> 58 <DebugSymbols>true</DebugSymbols> 59 <OutputPath>bin\x86\Debug\</OutputPath> 60 <DefineConstants>DEBUG;TRACE</DefineConstants> 61 <DebugType>full</DebugType> 62 <PlatformTarget>x86</PlatformTarget> 63 <ErrorReport>prompt</ErrorReport> 64 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 65 </PropertyGroup> 66 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> 67 <OutputPath>bin\x86\Release\</OutputPath> 68 <DefineConstants>TRACE</DefineConstants> 69 <Optimize>true</Optimize> 70 <DebugType>pdbonly</DebugType> 71 <PlatformTarget>x86</PlatformTarget> 72 <ErrorReport>prompt</ErrorReport> 73 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 38 74 </PropertyGroup> 39 75 <ItemGroup> -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HeuristicLab.Optimization.Networks.Views-3.3.csproj
r11421 r11423 37 37 <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile> 38 38 </PropertyGroup> 39 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> 40 <DebugSymbols>true</DebugSymbols> 41 <OutputPath>bin\x64\Debug\</OutputPath> 42 <DefineConstants>DEBUG;TRACE</DefineConstants> 43 <DebugType>full</DebugType> 44 <PlatformTarget>x64</PlatformTarget> 45 <ErrorReport>prompt</ErrorReport> 46 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 47 </PropertyGroup> 48 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> 49 <OutputPath>bin\x64\Release\</OutputPath> 50 <DefineConstants>TRACE</DefineConstants> 51 <Optimize>true</Optimize> 52 <DebugType>pdbonly</DebugType> 53 <PlatformTarget>x64</PlatformTarget> 54 <ErrorReport>prompt</ErrorReport> 55 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 56 </PropertyGroup> 57 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> 58 <DebugSymbols>true</DebugSymbols> 59 <OutputPath>bin\x86\Debug\</OutputPath> 60 <DefineConstants>DEBUG;TRACE</DefineConstants> 61 <DebugType>full</DebugType> 62 <PlatformTarget>x86</PlatformTarget> 63 <ErrorReport>prompt</ErrorReport> 64 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 65 </PropertyGroup> 66 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> 67 <OutputPath>bin\x86\Release\</OutputPath> 68 <DefineConstants>TRACE</DefineConstants> 69 <Optimize>true</Optimize> 70 <DebugType>pdbonly</DebugType> 71 <PlatformTarget>x86</PlatformTarget> 72 <ErrorReport>prompt</ErrorReport> 73 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 74 </PropertyGroup> 39 75 <ItemGroup> 40 76 <Reference Include="System" /> -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/InputPortView.cs
r11421 r11423 51 51 protected override void OnContentChanged() { 52 52 base.OnContentChanged(); 53 outputPortTextBox.Text = ((Content == null) || (Content.OutputPort == null)) ? string.Empty : Content.OutputPort. Name;53 outputPortTextBox.Text = ((Content == null) || (Content.OutputPort == null)) ? string.Empty : Content.OutputPort.ToString(); 54 54 } 55 55 … … 62 62 Invoke(new EventHandler(Content_OutputPortChanged), sender, e); 63 63 else { 64 outputPortTextBox.Text = Content.OutputPort == null ? string.Empty : Content.OutputPort. Name;64 outputPortTextBox.Text = Content.OutputPort == null ? string.Empty : Content.OutputPort.ToString(); 65 65 } 66 66 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/AlgorithmNode.cs
r11412 r11423 116 116 117 117 #region Ports Events 118 private void RegisterPortsEvents() { 119 Ports.ItemsAdded += Ports_ItemsAdded; 120 Ports.ItemsRemoved += Ports_ItemsRemoved; 121 Ports.ItemsReplaced += Ports_ItemsReplaced; 122 Ports.CollectionReset += Ports_CollectionReset; 118 protected override void RegisterPortsEvents() { 119 base.RegisterPortsEvents(); 123 120 foreach (var p in Ports) 124 121 RegisterPortEvents(p); 125 122 } 126 void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 127 foreach (var p in e.Items) 128 RegisterPortEvents(p); 129 } 130 void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 123 protected override void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 124 base.Ports_ItemsAdded(sender, e); 125 foreach (var p in e.Items) 126 RegisterPortEvents(p); 127 } 128 protected override void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 129 base.Ports_ItemsRemoved(sender, e); 131 130 foreach (var p in e.Items) 132 131 DeregisterPortEvents(p); 133 132 } 134 void Ports_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 133 protected override void Ports_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 134 base.Ports_ItemsReplaced(sender, e); 135 135 foreach (var p in e.OldItems) 136 136 DeregisterPortEvents(p); … … 138 138 RegisterPortEvents(p); 139 139 } 140 void Ports_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 140 protected override void Ports_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 141 base.Ports_CollectionReset(sender, e); 141 142 foreach (var p in e.OldItems) 142 143 DeregisterPortEvents(p); -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj
r11421 r11423 36 36 <PropertyGroup> 37 37 <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile> 38 </PropertyGroup> 39 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> 40 <DebugSymbols>true</DebugSymbols> 41 <OutputPath>bin\x64\Debug\</OutputPath> 42 <DefineConstants>DEBUG;TRACE</DefineConstants> 43 <DebugType>full</DebugType> 44 <PlatformTarget>x64</PlatformTarget> 45 <ErrorReport>prompt</ErrorReport> 46 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 47 </PropertyGroup> 48 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> 49 <OutputPath>bin\x64\Release\</OutputPath> 50 <DefineConstants>TRACE</DefineConstants> 51 <Optimize>true</Optimize> 52 <DebugType>pdbonly</DebugType> 53 <PlatformTarget>x64</PlatformTarget> 54 <ErrorReport>prompt</ErrorReport> 55 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 56 </PropertyGroup> 57 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> 58 <DebugSymbols>true</DebugSymbols> 59 <OutputPath>bin\x86\Debug\</OutputPath> 60 <DefineConstants>DEBUG;TRACE</DefineConstants> 61 <DebugType>full</DebugType> 62 <PlatformTarget>x86</PlatformTarget> 63 <ErrorReport>prompt</ErrorReport> 64 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 65 </PropertyGroup> 66 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> 67 <OutputPath>bin\x86\Release\</OutputPath> 68 <DefineConstants>TRACE</DefineConstants> 69 <Optimize>true</Optimize> 70 <DebugType>pdbonly</DebugType> 71 <PlatformTarget>x86</PlatformTarget> 72 <ErrorReport>prompt</ErrorReport> 73 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 38 74 </PropertyGroup> 39 75 <ItemGroup> -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IPort.cs
r11421 r11423 24 24 namespace HeuristicLab.Optimization.Networks { 25 25 public interface IPort : INamedItem { 26 INode Node{ get; set; }26 INode Parent { get; set; } 27 27 } 28 28 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs
r11421 r11423 88 88 if (outputPort != null) { 89 89 outputPort.ValueChanged += OutputPort_ValueChanged; 90 outputPort.ToStringChanged += OutputPort_ToStringChanged; 90 91 } 91 92 } … … 93 94 if (outputPort != null) { 94 95 outputPort.ValueChanged -= OutputPort_ValueChanged; 96 outputPort.ToStringChanged -= OutputPort_ToStringChanged; 95 97 } 96 98 } … … 100 102 //DISCUSS: switch threads to decouple value propagation and to make communication asynchronous -> should be done in Node? 101 103 } 104 protected void OutputPort_ToStringChanged(object sender, EventArgs e) { 105 OnOutputPortChanged(); 106 } 102 107 } 103 108 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Node.cs
r11421 r11423 52 52 : base(original, cloner) { 53 53 ports = cloner.Clone(original.ports); 54 foreach (var p in Ports) 55 p.Parent = this; 54 56 readOnlyPorts = null; 57 RegisterPortsEvents(); 55 58 } 56 59 public Node() 57 60 : base("Node") { 58 ports = new PortCollection( this);61 ports = new PortCollection(); 59 62 readOnlyPorts = null; 63 RegisterPortsEvents(); 60 64 } 61 65 public Node(string name) 62 66 : base(name) { 63 ports = new PortCollection( this);67 ports = new PortCollection(); 64 68 readOnlyPorts = null; 69 RegisterPortsEvents(); 65 70 } 66 71 public Node(string name, string description) 67 72 : base(name, description) { 68 ports = new PortCollection( this);73 ports = new PortCollection(); 69 74 readOnlyPorts = null; 75 RegisterPortsEvents(); 76 } 77 78 [StorableHook(HookType.AfterDeserialization)] 79 private void AfterDeserialization() { 80 foreach (var p in Ports) 81 p.Parent = this; 82 RegisterPortsEvents(); 70 83 } 71 84 … … 73 86 return new Node(this, cloner); 74 87 } 88 89 #region Ports Events 90 protected virtual void RegisterPortsEvents() { 91 ports.ItemsAdded += Ports_ItemsAdded; 92 ports.ItemsRemoved += Ports_ItemsRemoved; 93 ports.ItemsReplaced += Ports_ItemsReplaced; 94 ports.CollectionReset += Ports_CollectionReset; 95 } 96 protected virtual void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 97 foreach (var p in e.Items) 98 p.Parent = this; 99 } 100 protected virtual void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 101 foreach (var p in e.Items) 102 p.Parent = null; 103 } 104 protected virtual void Ports_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 105 foreach (var p in e.OldItems) 106 p.Parent = null; 107 foreach (var p in e.Items) 108 p.Parent = this; 109 } 110 protected virtual void Ports_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 111 foreach (var p in e.OldItems) 112 p.Parent = null; 113 foreach (var p in e.Items) 114 p.Parent = this; 115 } 116 #endregion 75 117 } 76 118 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Port.cs
r11421 r11423 34 34 } 35 35 36 [Storable] 37 private INode node; 38 public INode Node { 39 get { return node; } 36 private INode parent; 37 public INode Parent { 38 get { return parent; } 40 39 set { 41 if ((value != null) && !value.Ports.Contains(this)) 42 throw new InvalidOperationException("Port is not contained in port collection of node."); 43 if ((value == null) && node.Ports.Contains(this)) 44 throw new InvalidOperationException("Port is still contained in port collection of node."); 45 node = value; 40 if (value != parent) { 41 // NOTE: never call setter directly as the Parent property is set by the node which contains the port 42 if ((value != null) && !value.Ports.Contains(this)) 43 throw new InvalidOperationException("Port is not contained in port collection of node."); 44 if ((value == null) && parent.Ports.Contains(this)) 45 throw new InvalidOperationException("Port is still contained in port collection of node."); 46 DeregisterParentEvents(); 47 parent = value; 48 RegisterParentEvents(); 49 OnToStringChanged(); 50 } 46 51 } 47 52 } … … 49 54 [StorableConstructor] 50 55 protected Port(bool deserializing) : base(deserializing) { } 51 protected Port(Port original, Cloner cloner) 52 : base(original, cloner) { 53 node = (INode)cloner.GetClone(original.node); // NOTE: original node is NOT automatically cloned 54 } 56 protected Port(Port original, Cloner cloner) : base(original, cloner) { } 55 57 protected Port() : base("Port") { } 56 58 protected Port(string name) : base(name) { } 57 59 protected Port(string name, string description) : base(name, description) { } 60 61 public override string ToString() { 62 if (parent != null) { 63 return string.Concat(parent.ToString(), " -> ", base.ToString()); 64 } 65 return base.ToString(); 66 } 67 68 #region Parent Events 69 protected virtual void RegisterParentEvents() { 70 if (parent != null) { 71 parent.ToStringChanged += Parent_ToStringChanged; 72 } 73 } 74 protected virtual void DeregisterParentEvents() { 75 if (parent != null) { 76 parent.ToStringChanged -= Parent_ToStringChanged; 77 } 78 } 79 void Parent_ToStringChanged(object sender, EventArgs e) { 80 OnToStringChanged(); 81 } 82 #endregion 58 83 } 59 84 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/PortCollection.cs
r11421 r11423 30 30 [Item("PortCollection", "Represents a collection of ports in an optimization network node.")] 31 31 public class PortCollection : NamedItemCollection<IPort> { 32 [Storable]33 private INode node;34 public INode Node {35 get { return node; }36 }37 38 32 [StorableConstructor] 39 33 protected PortCollection(bool deserializing) : base(deserializing) { } 40 protected PortCollection(PortCollection original, Cloner cloner) 41 : base(original, cloner) { 42 if (!cloner.ClonedObjectRegistered(original.node)) 43 // NOTE: cannot clone port collection alone if referenced node is not cloned 44 throw new InvalidOperationException("Node of port collection is not cloned."); 45 node = cloner.Clone(original.node); 46 } 47 public PortCollection(INode node) 48 : base() { 49 this.node = node; 50 } 51 public PortCollection(INode node, int capacity) 52 : base(capacity) { 53 this.node = node; 54 } 55 public PortCollection(INode node, IEnumerable<IPort> collection) 56 : base(collection) { 57 this.node = node; 58 } 34 protected PortCollection(PortCollection original, Cloner cloner) : base(original, cloner) { } 35 public PortCollection() : base() { } 36 public PortCollection(INode node, int capacity) : base(capacity) { } 37 public PortCollection(INode node, IEnumerable<IPort> collection) : base(collection) { } 59 38 60 39 public override IDeepCloneable Clone(Cloner cloner) { return new PortCollection(this, cloner); } 61 62 protected override void OnItemsAdded(IEnumerable<IPort> items) {63 foreach (var p in items)64 p.Node = node;65 base.OnItemsAdded(items);66 }67 protected override void OnItemsRemoved(IEnumerable<IPort> items) {68 foreach (var p in items)69 p.Node = null;70 base.OnItemsRemoved(items);71 }72 protected override void OnItemsReplaced(IEnumerable<IPort> items, IEnumerable<IPort> oldItems) {73 foreach (var p in oldItems)74 p.Node = null;75 foreach (var p in items)76 p.Node = node;77 base.OnItemsReplaced(items, oldItems);78 }79 protected override void OnCollectionReset(IEnumerable<IPort> items, IEnumerable<IPort> oldItems) {80 foreach (var p in oldItems)81 p.Node = null;82 foreach (var p in items)83 p.Node = node;84 base.OnCollectionReset(items, oldItems);85 }86 40 } 87 41 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/VariablesNode.cs
r11412 r11423 101 101 102 102 #region Ports Events 103 private void RegisterPortsEvents() { 104 Ports.ItemsAdded += Ports_ItemsAdded; 105 Ports.ItemsRemoved += Ports_ItemsRemoved; 106 Ports.ItemsReplaced += Ports_ItemsReplaced; 107 Ports.CollectionReset += Ports_CollectionReset; 103 protected override void RegisterPortsEvents() { 104 base.RegisterPortsEvents(); 108 105 foreach (var p in Ports) 109 106 RegisterPortEvents(p); 110 107 } 111 void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 112 foreach (var p in e.Items) 113 RegisterPortEvents(p); 114 } 115 void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 108 protected override void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 109 base.Ports_ItemsAdded(sender, e); 110 foreach (var p in e.Items) 111 RegisterPortEvents(p); 112 } 113 protected override void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 114 base.Ports_ItemsRemoved(sender, e); 116 115 foreach (var p in e.Items) 117 116 DeregisterPortEvents(p); 118 117 } 119 void Ports_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 118 protected override void Ports_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 119 base.Ports_ItemsReplaced(sender, e); 120 120 foreach (var p in e.OldItems) 121 121 DeregisterPortEvents(p); … … 123 123 RegisterPortEvents(p); 124 124 } 125 void Ports_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 125 protected override void Ports_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { 126 base.Ports_CollectionReset(sender, e); 126 127 foreach (var p in e.OldItems) 127 128 DeregisterPortEvents(p);
Note: See TracChangeset
for help on using the changeset viewer.