Ejemplo n.º 1
0
        private void CheckEntityType()
        {
            if (FormType == null)
            {
                TypeChecked = true;
                return;
            }
            if (_Form == null || _Form.IsDisposed)
            {
                if (FormType.GetInterface("IEntityControl") != null)
                {
                    _Form = new frmDocument(FormType);
                }
                else if (FormType.IsSubclassOf(typeof(Form)))
                {
                    _Form = BaseFactory.CreateInstance(FormType) as Form;
                }
                else
                {
                    throw new ApplicationException("FormType harus Form, IEntityControl");
                }

                _Ief = _Form as IEntityForm;
                if (_Ief == null)
                {
                    foreach (Control Ctrl in _Form.Controls)
                    {
                        if (object.ReferenceEquals(Ctrl.GetType(), UINType))
                        {
                            _UIN            = (UINavigator)Ctrl;
                            _UIN.EntityForm = this;
                            break;
                        }
                    }
                }
                else
                {
                    _Ief.SetOwner(this);
                }

                _Form.MdiParent = BaseWinFramework._MdiParent;
            }
            if (!TypeChecked)
            {
                EntityType = _UIN != null?_UIN.GetEntity().GetType() :
                                 _Ief != null?_Ief.GetEntityType() : null;

                TypeChecked = true;
            }
        }