Exemplo n.º 1
0
        /// <summary>
        /// Shows the control.
        /// </summary>
        private void ShowControl()
        {
            if (MainPlaceHolder.Controls.Count > 0)
            {
                MainPlaceHolder.Controls.Clear();
            }

            string        metaTypeName = FormatList.SelectedValue;
            MetaFieldType fieldType    = MetaDataWrapper.GetMetaFieldTypeByName(metaTypeName);

            if (fieldType != null)
            {
                if (fieldType.McDataType == McDataType.Enum)
                {
                    if (fieldType.Attributes.GetValue <bool>(McDataTypeAttribute.EnumMultivalue, false))
                    {
                        metaTypeName = "EnumMultiValue";
                    }
                    else
                    {
                        metaTypeName = "Enum";
                    }
                }
                if (fieldType.McDataType == McDataType.MultiReference)
                {
                    metaTypeName = "MultiReference";
                }
            }

            ResolvedPath resPath = ControlPathResolver.Current.ResolveStrong(metaTypeName, "Manage", "", "", "ListInfoImport");

            // Try to use empty place
            if (resPath == null)
            {
                resPath = ControlPathResolver.Current.Resolve(metaTypeName, "Manage", "", "", "ListInfoImport");
            }

            if (resPath == null)
            {
                return;
            }

            string controlPath = resPath.Path;             //MetaFieldControlPathResolver.Resolve(metaTypeName, "Manage", "");

            if (controlPath.IndexOf("Manage") <= 0)
            {
                return;
            }

            if (File.Exists(Server.MapPath(controlPath)))
            {
                Control control = (Control)LoadControl(controlPath);
                control.ID = "ManageControl";
                MainPlaceHolder.Controls.Add(control);

                ViewState[currentControlKey] = controlPath;

                IAutogenerateSystemNames iAutogenerateSystemNames = control as IAutogenerateSystemNames;
                if (iAutogenerateSystemNames != null)
                {
                    iAutogenerateSystemNames.AutogenerateSystemNames = AutogenerateSystemNames;
                }

                IManageControl iManageControl = control as IManageControl;
                if (iManageControl != null)
                {
                    iManageControl.BindData(null, FormatList.SelectedValue);
                }
            }
        }