예제 #1
0
        public override IConnection Connect(IInputPlug inputPlug)
        {
            if (IsCompatible(inputPlug))
            {
                if (property.CurrentValue == null)
                {
                    InterfacePlug plug = (InterfacePlug)inputPlug;

                    property.CurrentValue = plug.Owner.QueryInterface(plug.InterfaceType);

                    PropertyInterfaceConnection connection = new PropertyInterfaceConnection(this, inputPlug);

                    if (!inputPlug.OnConnection(connection))
                    {
                        connection.Dispose();
                        return(null);
                    }

                    this.connections.Add(connection);
                    return(connection);
                }
            }

            return(null);
        }
예제 #2
0
        public override bool IsCompatible(IInputPlug inputPlug)
        {
            InterfacePlug plug = inputPlug as InterfacePlug;

            if (plug != null)
            {
                if (plug.InterfaceType.Equals(Property.Type))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public static InterfacePlug[] Enumerate(IActor owner)
        {
            List <InterfacePlug> list = new List <InterfacePlug>();

            foreach (Type t in owner.Interfaces)
            {
                InterfacePlug newPlug = Create(t, owner);
                if (newPlug != null)
                {
                    list.Add(newPlug);
                }
            }

            return(list.ToArray());
        }