Ejemplo n.º 1
0
        private DataTypeItem BuildDataTypeItem(DataTypeDefinition dataTypeDefinition)
        {
            var dataTypeItem = new DataTypeItem();
            dataTypeItem.Id = dataTypeDefinition.DataType.DataTypeDefinitionId;
            dataTypeItem.ControlTypeName = dataTypeDefinition.DataType.GetType().FullName;

            var node = new CMSNode(dataTypeItem.Id);
            dataTypeItem.DataTypeName = node.Text;

            dataTypeItem.PreValueItems = this.BuildPreValues(dataTypeDefinition);
            dataTypeItem.Type = this.DetermineType(dataTypeItem);
            dataTypeItem.ModelType = DetermineModelType(dataTypeItem);
            return dataTypeItem;
        }
Ejemplo n.º 2
0
        private DataTypeItem BuildDataTypeItem(DataTypeDefinition dataTypeDefinition)
        {
            try
            {
                var dataTypeItem = new DataTypeItem();
                dataTypeItem.Id = dataTypeDefinition.DataType.DataTypeDefinitionId;
                dataTypeItem.ControlTypeName = dataTypeDefinition.DataType.GetType().FullName;

                var node = new CMSNode(dataTypeItem.Id);
                dataTypeItem.DataTypeName = node.Text;

                dataTypeItem.PreValueItems = this.BuildPreValues(dataTypeDefinition);
                dataTypeItem.Type = this.DetermineType(dataTypeItem);
                dataTypeItem.ModelType = DetermineModelType(dataTypeItem);
                return dataTypeItem;

            }
            catch (Exception ex)
            {
                throw new DataTypeException(string.Format("Data type {0} '{1}' could not be loaded.", dataTypeDefinition.Id.ToString(), dataTypeDefinition.Text));
            }
        }
Ejemplo n.º 3
0
 private string XPathDropDownListDataType(DataTypeItem dataType)
 {
     if (dataType.PreValueItems != null && dataType.PreValueItems.Count > 0)
     {
         var preValue = dataType.PreValueItems[0];
         var json = new JavaScriptSerializer();
         var dictionary = json.Deserialize<Dictionary<string, object>>(preValue.Value);
         if (dictionary.ContainsKey("UseId") && dictionary["UseId"].ToString().ToUpper().Equals("TRUE")) return "int";
     }
     return "string";
 }
Ejemplo n.º 4
0
        private string DetermineType(DataTypeItem dataType)
        {
            switch (dataType.ControlTypeName)
            {
                case "umbraco.editorControls.colorpicker.ColorPickerDataType": return "string";
                case "umbraco.editorControls.folderbrowser.DataTypeFolderBrowser": return "string";
                case "umbraco.editorControls.imagecropper.DataType": return "string";
                case "umbraco.editorControls.label.DataTypeNoEdit": return "string";
                case "umbraco.editorControls.macrocontainer.DataType": return "string";
                case "umbraco.editorControls.memberpicker.MemberPickerDataType": return "string";
                case "umbraco.editorControls.relatedlinks.RelatedLinksDataType": return "string";
                case "umbraco.editorControls.tinyMCE3.tinyMCE3dataType": return "string";
                case "umbraco.editorControls.simpleEditor.simpleEditorDataType": return "string";
                case "umbraco.editorControls.tags.DataType": return "string";
                case "umbraco.editorControls.textfieldmultiple.textfieldMultipleDataType": return "string";
                case "umbraco.editorControls.textfield.TextFieldDataType": return "string";
                case "umbraco.editorControls.ultimatepicker.ultimatePickerDataType": return "string";
                case "umbraco.editorControls.uploadfield.DataTypeUploadField": return "string";
                case "umbraco.editorControls.XPathDropDownList.XPathDropDownListDataType": return XPathDropDownListDataType(dataType);

                case "umbraco.editorControls.yesno.YesNoDataType": return "bool";

                case "umbraco.editorControls.dropdownlist.DropdownListDataType": return "enum";
                case "umbraco.editorControls.dropdownlist.DropdownListKeysDataType": return "enum";
                case "umbraco.editorControls.checkboxlist.checkboxListDataType": return "List<enum>";
                case "umbraco.editorControls.radiobuttonlist.RadioButtonListDataType": return "enum";
                case "umbraco.editorControls.listbox.ListBoxDataType": return "List<enum>";

                case "umbraco.editorControls.numberfield.IDataTypenteger": return "int";
                case "umbraco.editorControls.pagepicker.PagePickerDataType": return "int";

                case "umbraco.editorControls.datefieldmultiple.DataTypeDatefieldMultiple": return "DateTime";
                case "umbraco.editorControls.datepicker.DateDataType": return "DateTime";

                case "umbraco.editorControls.mediapicker.MemberPickerDataType": return "MediaInfo";
                case "umbraco.editorControls.MultiNodeTreePicker.MNTP_DataType": return "MultiNodePicker";

                case "uComponents.DataTypes.MultiPickerRelations.MultiPickerRelationsDataType": return "string";
                case "uComponents.DataTypes.MultiUrlPicker.MultiUrlPickerDataType": return "MultiUrlPicker";
                case "uComponents.DataTypes.UrlPicker.UrlPickerDataType": return "UrlPicker";
                case "uComponents.DataTypes.Notes.NotesDataType": return "string";
                case "uComponents.DataTypes.DataTypeGrid.DataType": return "DataGrid";
                case "uComponents.DataTypes.MultipleDates.MD_DataType": return "string";
                case "uComponents.DataTypes.SqlCheckBoxList.SqlCheckBoxListDataType": return "SqlCheckBoxList";

                case "Our.Umbraco.GoogleMaps.DataTypes.SingleLocation.SingleLocationDataType": return "string";
            }
            return "string";
        }
Ejemplo n.º 5
0
 private string DetermineModelType(DataTypeItem dataType)
 {
     switch (dataType.Type)
     {
         case "enum": return Naming.PascalCase(Naming.IdentifierName(dataType.DataTypeName));
         case "List<enum>": return Naming.PascalCase(Naming.IdentifierName(dataType.DataTypeName));
         case "DataGrid": return Naming.PascalCase(Naming.IdentifierName(dataType.DataTypeName));
         case "MultiNodePicker": return "List<int>";
         case "MultiUrlPicker": return "List<Hyperlink>";
         case "UrlPicker": return "Hyperlink";
     }
     switch (dataType.ControlTypeName)
     {
         case "uComponents.DataTypes.MultipleDates.MD_DataType": return "List<DateTime>";
         case "umbraco.editorControls.XPathDropDownList.XPathDropDownListDataType": return this.XPathDropDownListDataType(dataType);
         case "uComponents.DataTypes.SqlCheckBoxList.SqlCheckBoxListDataType": return "List<string>";
     }
     return dataType.Type;
 }