Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / Core / Castle.Core / Internal / GraphNode.cs
bloba2ce48e023895c97a60676fe1db4f64e7706e286
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;
20 [Serializable]
21 public class GraphNode : MarshalByRefObject, IVertex
23 private ArrayList incoming;
24 private ArrayList outgoing;
26 public GraphNode()
30 // /// <summary>
31 // /// Kind of copy constructor
32 // /// </summary>
33 // /// <param name="copy"></param>
34 // public GraphNode(GraphNode copy)
35 // {
36 // incoming = new ArrayList(Incoming);
37 // outgoing = new ArrayList(Outgoing);
38 // }
40 #region IVertex Members
42 public IVertex[] Adjacencies
44 get { return Dependents; }
47 #endregion
49 public void AddDependent(GraphNode node)
51 Outgoing.Add(node);
52 node.Incoming.Add(this);
55 private ArrayList Incoming
57 get
59 if (incoming == null) incoming = new ArrayList();
60 return incoming;
64 private ArrayList Outgoing
66 get
68 if (outgoing == null) outgoing = new ArrayList();
69 return outgoing;
73 /// <summary>
74 /// The nodes that dependes on this node
75 /// </summary>
76 public GraphNode[] Dependers
78 get
80 if (incoming == null) return new GraphNode[0];
81 return (GraphNode[]) incoming.ToArray(typeof(GraphNode));
85 /// <summary>
86 /// The nodes that this node depends
87 /// </summary>
88 public GraphNode[] Dependents
90 get
92 if (outgoing == null) return new GraphNode[0];
93 return (GraphNode[]) outgoing.ToArray(typeof(GraphNode));
97 public void RemoveDepender(GraphNode depender)
99 Incoming.Remove(depender);
100 depender.RemoveDependent(this);
103 private void RemoveDependent(GraphNode graphNode)
105 Outgoing.Remove(graphNode);