Exemplo n.º 1
0
        /// <summary>
        /// Adds an <see cref="EditableCheckBoxAttribute"/> to the item definition.
        /// </summary>
        /// <param name="itemDefinition">Specifies the <see cref="ItemDefinition"/> the 
        /// <see cref="EditableCheckBoxAttribute"/> will be added to.</param>
        /// <param name="title">Specifies the value to use for 
        /// <see cref="EditableCheckBoxAttribute.CheckBoxText"/>.</param>
        /// <param name="sortOrder">Specifies the value to use for 
        /// <see cref="EditableCheckBoxAttribute.SortOrder"/>.</param>
        /// <param name="containerName">Specifies the value to use for 
        /// <see cref="EditableCheckBoxAttribute.ContainerName"/>.</param>
        /// <param name="propertyKey">Specifies the value to use for 
        /// <see cref="EditableCheckBoxAttribute.Name"/>.</param>
        /// <param name="helpTitle">Specifies the value to use for 
        /// <see cref="EditableCheckBoxAttribute.HelpTitle"/>.</param>
        /// <param name="helpText">Specifies the value to use for 
        /// <see cref="EditableCheckBoxAttribute.HelpText"/>.</param>
        /// <returns>The <see cref="EditableCheckBoxAttribute"/> added to the item definition.</returns>
        public static EditableCheckBoxAttribute AddEditableCheckBox(this ItemDefinition itemDefinition, string title, int sortOrder, string containerName, string propertyKey, bool? defaultValue = null, string helpTitle = null, string helpText = null)
        {
            if (itemDefinition == null)
                throw new ArgumentNullException("itemDefinition", "itemDefinition is null.");
            if (String.IsNullOrEmpty(title))
                throw new ArgumentException("title is null or empty.", "title");
            if (String.IsNullOrEmpty(containerName))
                throw new ArgumentException("containerName is null or empty.", "containerName");
            if (String.IsNullOrEmpty(propertyKey))
                throw new ArgumentException("propertyKey is null or empty.", "propertyKey");

            EditableCheckBoxAttribute result = new EditableCheckBoxAttribute(title, sortOrder)
            {
                ContainerName = containerName,
                Name = propertyKey,
                HelpTitle = helpTitle,
                HelpText = helpText,
                DefaultValue = defaultValue
            };

            itemDefinition.Add(result);

            Debug.WriteLine(string.Format("{0} property added to {1}", propertyKey, itemDefinition.Title));

            return result;
        }
        public void Start()
        {
            foreach (ItemDefinition definition in definitions.GetDefinitions())
            {
                if (typeof (ISyndicatable).IsAssignableFrom(definition.ItemType))
                {
                    EditableCheckBoxAttribute ecb = new EditableCheckBoxAttribute(CheckBoxText, 10);
                    ecb.Name = SyndicatableDetailName;
                    ecb.ContainerName = ContainerName;
                    ecb.SortOrder = SortOrder;

                    definition.Add(ecb);
                }
            }
        }
 public void Start()
 {
     foreach (ItemDefinition definition in _definitionManager.GetDefinitions())
     {
         if (typeof(ModelBase).IsAssignableFrom(definition.ItemType) && !definition.IsPage)
         {
             var ecb = new EditableCheckBoxAttribute
             {
                 Title = "",
                 CheckBoxText = "Wrap with container",
                 Name = "UseContainer",
                 DefaultValue = true,
                 ContainerName = Defaults.Containers.Metadata
             };
             definition.Add(ecb);
         }
     }
 }
		private ContentRegistration RegisterPart(PartDefinitionPage pd)
		{
			var def = DefinitionMap.Instance.GetOrCreateDefinition(typeof(ContentPart), pd.Title); // no extensions

			// registration - compare Dinamico views  @{ Content.Define(re => ... ) }
			var re = new ContentRegistration(def)
			    {
			        Definition = {TemplateKey = pd.Name, Description = pd.Description},
			        Context = {GlobalSortOffset = pd.PartSortOrder},
			        ContentType = def.ItemType,
			        Title = pd.Title,
			        IconUrl = pd.IconUrl
			    };

		    //if (!string.IsNullOrEmpty(pd.Definition))
			//{
			//    var jsd = new JavaScriptRegistration();
			//    jsd.Eval(re, pd.Definition);
			//}

			foreach (var attrDef in pd.Attributes)
			{
				AbstractEditableAttribute attr = null;
				var name = RemoveSpecialCharacters(attrDef.Title);
				switch (attrDef.PartType)
				{
					case PartDefinitionPage.AttributePart.AttributePartTypeEnum.RichText:
						attr = new EditableTextAttribute { TextMode = TextBoxMode.MultiLine, Name = name, Title = attrDef.Title };
						break;

					case PartDefinitionPage.AttributePart.AttributePartTypeEnum.Number:
						attr = new EditableNumberAttribute { Name = name, Title = attrDef.Title };
						break;

					case PartDefinitionPage.AttributePart.AttributePartTypeEnum.CheckBox:
						attr = new EditableCheckBoxAttribute { Name = name, Title = attrDef.Title };
						break;

					case PartDefinitionPage.AttributePart.AttributePartTypeEnum.Url:
						attr = new EditableUrlAttribute { Name = name, Title = attrDef.Title };
						break;

					case PartDefinitionPage.AttributePart.AttributePartTypeEnum.Image:
						attr = new EditableImageAttribute { Name = name, Title = attrDef.Title };
						break;

#if TODO // use a better mechanism to find available types/attrs
                    case PartDefinitionPage.AttributePart.AttributePartTypeEnum.Category:
                        attr = new EditableCategorySelectionAttribute("ID:" + name) { Name = name, Title = attrDef.Title };
                        break;

                    case PartDefinitionPage.AttributePart.AttributePartTypeEnum.Product:
                        attr = new EditableProductMultiSelectionAttribute("Id:" + name) { Name = name, Title = attrDef.Title };
                        break;
#endif
                    case PartDefinitionPage.AttributePart.AttributePartTypeEnum.Text:
                    default:
                        attr = new EditableTextAttribute { TextMode = TextBoxMode.SingleLine, Name = name, Title = attrDef.Title };
                        break;
                    //throw new ArgumentOutOfRangeException();
				}
				if (!string.IsNullOrEmpty(attrDef.DefaultValue))
					attr.DefaultValue = attrDef.DefaultValue;

				attr.HelpText = attrDef.HelpText;

				re.Add(attr);
			}

			re.IsDefined = true;
			re.Finalize();
			return re; 
		}