Applied patch from Jan Limpens 'ReflectionBasedDictionaryAdapter needs to check if...
[castle.git] / Core / Castle.Core / Internal / GraphNode.cs
blob0f7da71c0032e42d1706e22b394631ad7440311b
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Core
17 using System;
18 using System.Collections;
19 using System.Collections.Generic;
21 #if SILVERLIGHT
22 public class GraphNode : IVertex
23 #else
24 [Serializable]
25 public class GraphNode : MarshalByRefObject, IVertex
26 #endif
28 private List<GraphNode> incoming;
29 private List<GraphNode> outgoing;
31 public GraphNode()
35 // /// <summary>
36 // /// Kind of copy constructor
37 // /// </summary>
38 // /// <param name="copy"></param>
39 // public GraphNode(GraphNode copy)
40 // {
41 // incoming = new ArrayList(Incoming);
42 // outgoing = new ArrayList(Outgoing);
43 // }
45 #region IVertex Members
47 public IVertex[] Adjacencies
49 get { return Dependents; }
52 #endregion
54 public void AddDependent(GraphNode node)
56 Outgoing.Add(node);
57 node.Incoming.Add(this);
60 private List<GraphNode> Incoming
62 get
64 if (incoming == null) incoming = new List<GraphNode>();
65 return incoming;
69 private List<GraphNode> Outgoing
71 get
73 if (outgoing == null) outgoing = new List<GraphNode>();
74 return outgoing;
78 /// <summary>
79 /// The nodes that dependes on this node
80 /// </summary>
81 public GraphNode[] Dependers
83 get
85 if (incoming == null) return new GraphNode[0];
86 return incoming.ToArray();
90 /// <summary>
91 /// The nodes that this node depends
92 /// </summary>
93 public GraphNode[] Dependents
95 get
97 if (outgoing == null) return new GraphNode[0];
98 return outgoing.ToArray();
102 public void RemoveDepender(GraphNode depender)
104 Incoming.Remove(depender);
105 depender.RemoveDependent(this);
108 private void RemoveDependent(GraphNode graphNode)
110 Outgoing.Remove(graphNode);