Esempio n. 1
0
        internal LayerConnections(ConnectionType type, Layer connectedLayer)
        {
            Debug.Assert(connectedLayer != null);

            ConnectedLayer = connectedLayer;
            Type = type;
        }
Esempio n. 2
0
        internal IndexedLayer(Layer layer, int index)
        {
            Debug.Assert(layer != null);
            Debug.Assert(index >= 0);

            Layer = layer;
            Index = index;
        }
Esempio n. 3
0
        public void Add(Layer item, FlowDirection direction)
        {
            Args.Requires(() => item, () => item != null);
            Args.Requires(() => direction, () => direction == FlowDirection.OneWay || direction == FlowDirection.OneWayToSource || direction == FlowDirection.TwoWay);

            if (!otherLayers.Any(l => l.Item2 == item))
            {
                WithOtherSideUpdateSuppressed(item, () =>
                {
                    if (Type == ConnectionType.Output)
                    {
                        item.InputConnections.Add(ConnectedLayer, direction);
                    }
                    else
                    {
                        item.OutputConnections.Add(ConnectedLayer, direction);
                    }
                });
                otherLayers.Add(Tuple.Create(direction, item));
            }
        }
Esempio n. 4
0
        public bool Remove(Layer item)
        {
            Args.Requires(() => item, () => item != null);

            var toRemove = otherLayers.FirstOrDefault(i => i.Item2 == item);
            if (toRemove != null && otherLayers.Remove(toRemove))
            {
                WithOtherSideUpdateSuppressed(item, () =>
                {
                    if (Type == ConnectionType.Output)
                    {
                        item.InputConnections.Remove(ConnectedLayer);
                    }
                    else
                    {
                        item.OutputConnections.Remove(ConnectedLayer);
                    }
                });
                return true;
            }
            return false;
        }
Esempio n. 5
0
 public void AddOneWayToSource(Layer item)
 {
     Add(item, FlowDirection.OneWayToSource);
 }
Esempio n. 6
0
 public void AddTwoWay(Layer item)
 {
     Add(item, FlowDirection.TwoWay);
 }
Esempio n. 7
0
 public void AddOneWay(Layer item)
 {
     Add(item, FlowDirection.OneWay);
 }
Esempio n. 8
0
 private void WithOtherSideUpdateSuppressed(Layer item, Action method)
 {
     if (!suppressOtherSideUpdate)
     {
         ((LayerConnections)item.InputConnections).suppressOtherSideUpdate = true;
         ((LayerConnections)item.OutputConnections).suppressOtherSideUpdate = true;
         try
         {
             method();
         }
         finally
         {
             ((LayerConnections)item.InputConnections).suppressOtherSideUpdate = false;
             ((LayerConnections)item.OutputConnections).suppressOtherSideUpdate = false;
         }
     }
 }