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

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

            Layer = layer;
            Index = index;
        }
Exemplo 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));
            }
        }
Exemplo 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;
        }
Exemplo n.º 5
0
 public void AddOneWayToSource(Layer item)
 {
     Add(item, FlowDirection.OneWayToSource);
 }
Exemplo n.º 6
0
 public void AddTwoWay(Layer item)
 {
     Add(item, FlowDirection.TwoWay);
 }
Exemplo n.º 7
0
 public void AddOneWay(Layer item)
 {
     Add(item, FlowDirection.OneWay);
 }
Exemplo 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;
         }
     }
 }