Beispiel #1
0
        public static BindingHandle CreateBinding <A, B>(BindPoint source, Arrow <A, B> arrow, BindPoint destination)
        {
            /*
             * Creates a one-to-one binding from a source, an arrow and a destination. Infers
             * whether it should be bidirectional from the type of the supplied arrow.
             */

            if (LinkWouldCauseConflict(source, destination))
            {
                throw new BindingConflictException();
            }

            Binding <A, B> result;

            if (arrow is InvertibleArrow <A, B> )
            {
                result = new TwoWayBinding <A, B>(source, (InvertibleArrow <A, B>)arrow, destination);
                UpdateBindingGraphBothWays(source, destination);
            }
            else
            {
                result = new Binding <A, B>(source, arrow, destination);
                UpdateBindingGraph(source, destination);
            }

            BindingHandle handle = new BindingHandle(result);

            bindings.Add(handle, result);

            return(handle);
        }
Beispiel #2
0
        public static BindingHandle CreateBinding <A, B>(BindPoint source, Arrow <A, B> arrow, BindPoint destination)
        {
            // TODO: Check for cycles here

            Binding <A, B> result;

            if (arrow is InvertibleArrow <A, B> )
            {
                result = new TwoWayBinding <A, B>(source, (InvertibleArrow <A, B>)arrow, destination);
            }
            else
            {
                result = new Binding <A, B>(source, arrow, destination);
            }

            return(new BindingHandle(result));
        }