public void Connect(Control _control, ConnectorFactory _factory)
        {
            WACControl          myContainer           = null;
            WACControlConnector myContainersConnector = null;

            try { myContainer = (WACControl)WACNamingContainer(_control); } catch (Exception) { }
            if (myContainer != null)
            {
                myContainersConnector = getConnector(myContainer, _factory);
            }
            if (myContainersConnector != null)
            {
                myContainersConnector.TryAdd((WACControl)_control);
            }
            if (ServiceFactory.IsDisconnectedControl(_control))
            {
                return;
            }
            if (ServiceFactory.IsIndependentControl(_control))
            {
                _connect(_control, _factory, null);
            }
            else
            {   // Dependent
                if (myContainersConnector != null)
                {
                    if (myContainersConnector.ViewModel == null)
                    {
                        myContainersConnector.Connect(myContainer, _factory);
                    }
                    _connect(_control, _factory, myContainersConnector.ViewModel);
                }
            }
            this.ContainedControls = getContents(_control, this);
        }
Esempio n. 2
0
        public string GetConnectedControl(WACControlConnector _connector)
        {
            var a = connectors.Where(w => w.Value.Equals(_connector)).Select(s => s.Key);

            if (a.Any())
            {
                return(a.First());
            }
            else
            {
                return(string.Empty);
            }
        }
Esempio n. 3
0
        public WACControlConnector GetConnectorForControl(Control _control)
        {
            // return registered ControlConnector if it exists otherwise, create one, register and return
            WACControlConnector ucc = null;

            if (connectors.TryGetValue(_control.ClientID, out ucc))
            {
                return(ucc);
            }
            else
            {
                ucc = CreateUserControlConnector(UserControlConnectorName(_control));
                RegisterConnector(_control, ucc);
                return(ucc);
            }
        }
        private List <WACControl> getContents(Control _control, WACControlConnector _connector)
        {
            List <WACControl> ret      = new List <WACControl>();
            List <Control>    contents = EnumerateControlsRecursive(_control).ToList <Control>();

            contents.Add(_control);
            var a = contents.Where(w => WACNamingContainer(w) == _control).Select(s => s);

            foreach (Control wc in a)
            {
                if (ServiceFactory.IsWACControl(wc))
                {
                    ret.Add((WACControl)wc);
                }
            }
            return(ret);
        }
        private WACControlConnector getConnector(Control _control, ConnectorFactory _cfac)
        {
            WACControlConnector cCon = _cfac.GetConnectorForControl(_control);

            return(cCon);
        }
Esempio n. 6
0
 private void RegisterConnector(Control _control, WACControlConnector _connector)
 {
     connectors.TryAdd(_control.ClientID, _connector);
 }