當前位置: 首頁>>代碼示例>>C#>>正文


C# PublishedContent.PublishedPropertyType類代碼示例

本文整理匯總了C#中Umbraco.Core.Models.PublishedContent.PublishedPropertyType的典型用法代碼示例。如果您正苦於以下問題:C# PublishedPropertyType類的具體用法?C# PublishedPropertyType怎麽用?C# PublishedPropertyType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PublishedPropertyType類屬於Umbraco.Core.Models.PublishedContent命名空間,在下文中一共展示了PublishedPropertyType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ConvertSourceToObject

        public override object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview)
        {
            if (source == null)
                return null;

            return Umbraco.TypedMedia(source);
        }
開發者ID:bgadiel,項目名稱:tt,代碼行數:7,代碼來源:MediaPickerConverter.cs

示例2: ConvertDataToSource

    public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
    {
        if (source == null) return null;
        var sourceString = source.ToString();

        var links = JsonConvert.DeserializeObject<IEnumerable<LinksPickerItem>>(sourceString);

        foreach (var link in links)
        {
            try
            {
                link.Content = (
                    link.IsMedia
                    ? umbHelper.TypedMedia(link.Id)
                    : umbHelper.TypedContent(link.Id)
                );

                link.Url = link.Content.Url;
            }
            catch (Exception)
            {
            }

        }

        return links;
    }
開發者ID:7ASecond,項目名稱:7ASecond-Web-Site,代碼行數:27,代碼來源:LinksPickerValueConverter.cs

示例3: ConvertDataToSource

        public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
        {
            try
            {
                if (source != null && !source.ToString().IsNullOrWhiteSpace())
                {
                    var oh = JsonConvert.DeserializeObject<Dictionary<DayOfWeek, WeekdayOpeningHours>>(source.ToString());
                    return oh;
                }
            }
            catch (Exception e)
            {
                LogHelper.Error<OpeningHoursValueConverter>("Error converting value", e);
            }

            // Create default model
            var dict = new Dictionary<DayOfWeek, WeekdayOpeningHours>();

            for (var i = 0; i < 7; i++)
            {
                dict.Add((DayOfWeek)i, new WeekdayOpeningHours());
            }

            return dict;
        }
開發者ID:mattbrailsford,項目名稱:umbOpeningHours,代碼行數:25,代碼來源:WeekdayOpeningHoursValueConverter.cs

示例4: ConvertDataToSource

        public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
        {
            if (source == null) return null;
            var sourceString = source.ToString();

            return UmbracoContext.Current != null ? new MultiUrls(sourceString) : null;
        }
開發者ID:GertyEngrie,項目名稱:umbraco-multi-url-picker,代碼行數:7,代碼來源:MultiUrlPickerValueConverter.cs

示例5: IsConverter

 public bool IsConverter(PublishedPropertyType propertyType) {
     return (
         propertyType.PropertyEditorAlias == "Skybrud.SelfService.Categories"
         ||
         propertyType.PropertyEditorAlias == "Skybrud.SelfService.List"
     );
 }
開發者ID:skybrud,項目名稱:Skybrud.Umbraco.SelfService,代碼行數:7,代碼來源:SelfServicePropertyValueConverter.cs

示例6: ConvertDataToSource

        public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
        {
            // data is (both in database and xml):
            // <keyFeatureList>
            //    <values>
            //        <value>Strong</value>
            //        <value>Flexible</value>
            //        <value>Efficient</value>
            //    </values>
            // </keyFeatureList>

            var sourceString = source.ToString();
            if (string.IsNullOrWhiteSpace(sourceString)) return Enumerable.Empty<string>();

            var values = new List<string>();
            var pos = sourceString.IndexOf("<value>", StringComparison.Ordinal);
            while (pos >= 0)
            {
                pos += "<value>".Length;
                var npos = sourceString.IndexOf("<", pos, StringComparison.Ordinal);
                var value = sourceString.Substring(pos, npos - pos);
                values.Add(value);
                pos = sourceString.IndexOf("<value>", pos, StringComparison.Ordinal);
            }
            return values.ToArray();
        }
開發者ID:saciervo,項目名稱:Umbraco-CMS,代碼行數:26,代碼來源:MultipleTextStringValueConverter.cs

示例7: XmlPublishedProperty

 public XmlPublishedProperty(PublishedPropertyType propertyType, bool isPreviewing, string propertyData)
     : this(propertyType, isPreviewing)
 {
     if (propertyData == null)
         throw new ArgumentNullException("propertyData");
     _xmlValue = propertyData;
 }
開發者ID:phaniarveti,項目名稱:Experiments,代碼行數:7,代碼來源:XmlPublishedProperty.cs

示例8: ConvertDataToSource

        /// <summary>
        /// The convert data to source.
        /// </summary>
        /// <param name="propertyType">
        /// The property type.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="preview">
        /// The preview.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
        {
            var merchello = new MerchelloHelper();

            if (source == null)
                return null;

            var collectionKey = source.ToString();

            if (collectionKey.IsNullOrWhiteSpace())
            {
                var query = merchello.ProductContentQuery().Page(1).ItemsPerPage(10).OrderBy(ProductSortField.Name);

               //var defaultCollection = merchello.Query.Product.TypedProductContentSearch(1, 10);

                return new ProductContentListView(Guid.Empty, query.Execute().Items);
            }

            try
            {
                var key = new Guid(collectionKey);

                var query = merchello.ProductContentQuery().Page(1).ItemsPerPage(long.MaxValue).ConstrainByCollectionKey(key);

                return new ProductContentListView(key, query.Execute().Items);
            }
            catch (Exception ex)
            {
                MultiLogHelper.Error<ProductListViewValueConverter>("Failed to Convert Merchello.ProductListView property", ex);
                return null;
            }
        }
開發者ID:rustyswayne,項目名稱:Merchello,代碼行數:47,代碼來源:ProductListViewValueConverter.cs

示例9: ConvertDataToSource

        /// <summary>
        /// Method to convert a property value to an instance
        /// of the ColorPalette class.
        /// </summary>
        /// <param name="propertyType">The current published property
        /// type to convert.</param>
        /// <param name="source">The original property data.</param>
        /// <param name="preview">True if in preview mode.</param>
        /// <returns>An instance of the ColorPalette class.</returns>
        public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
        {
            if (source == null)
                    return null;

                if (UmbracoContext.Current == null)
                    return null;

                var retval = new ColorPalette();

                var palette = JsonConvert.DeserializeObject<ColorPalette>(source.ToString());
                if (palette == null || palette.Colors.Count < 0)
                    return retval;

                var colors = new List<Color>();

                foreach (var color in palette.Colors) {
                    colors.Add(color);
                }

                retval.Name = palette.Name;
                retval.Alias = palette.Alias;
                retval.Colors = colors;

                return retval;
        }
開發者ID:bjarnef,項目名稱:color-palettes,代碼行數:35,代碼來源:ColorPaletteEditorValueConverter.cs

示例10: ConvertDataToSource

 public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
 {
     // in xml a string is: string
     // in the database a string is: string
     // default value is: null
     return source;
 }
開發者ID:saciervo,項目名稱:Umbraco-CMS,代碼行數:7,代碼來源:TextStringValueConverter.cs

示例11: ConvertDataToSource

        /// <summary>
        /// The convert data to source.
        /// </summary>
        /// <param name="propertyType">
        /// The property type.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="preview">
        /// The preview.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
        {
            var merchello = new MerchelloHelper();

            if (source == null)
                return null;

            var collectionKey = source.ToString();

            if (collectionKey.IsNullOrWhiteSpace())
            {

                var defaultCollection = merchello.Query.Product.Search(1, 10)
                    .Items.Select(x => merchello.TypedProductContent(((ProductDisplay)x).Key));

                return new ProductContentListView(Guid.Empty, defaultCollection);
            }

            try
            {
                var key = new Guid(collectionKey);
                return new ProductContentListView(key, merchello.TypedProductContentFromCollection(key));
            }
            catch (Exception ex)
            {
                MultiLogHelper.Error<ProductDisplayValueConverter>("Failed to Convert ProductDisplay property", ex);
                return null;
            }
        }
開發者ID:ryanology,項目名稱:Merchello,代碼行數:44,代碼來源:ProductListViewValueConverter.cs

示例12: GetPropertyValueType

 public Type GetPropertyValueType(PublishedPropertyType propertyType)
 {
     if (IsMultipleDataType(propertyType.DataTypeId))
     {
         return !IsConverterDefault(propertyType) ? typeof(IEnumerable<Image>) : typeof(IEnumerable<IPublishedContent>);
     }
     return !IsConverterDefault(propertyType) ? typeof(Image) : typeof(IPublishedContent);
 }
開發者ID:ksolberg,項目名稱:Hybrid-Framework-for-Umbraco-v7-Best-Practises,代碼行數:8,代碼來源:MultipleMediaPickerConverter.cs

示例13: ConvertDataToSource

 public object ConvertDataToSource(PublishedPropertyType propertyType, object data, bool preview) {
     switch (propertyType.PropertyEditorAlias) {
         case "Skybrud.SelfService.Categories":
             return SelfServiceContext.Current.Categories.GetCategoryByIds(data as string);
         default:
             return null;
     }
 }
開發者ID:abjerner,項目名稱:Skybrud.Umbraco.SelfService,代碼行數:8,代碼來源:SelfServicePropertyValueConverter.cs

示例14: IsConverter

        /// <summary>
        /// Determines whether the specified property type is converter for Archetype.
        /// </summary>
        /// <param name="propertyType">Type of the property.</param>
        /// <returns></returns>
        public override bool IsConverter(PublishedPropertyType propertyType)
        {
            var isArcheTypePropertyEditor = !String.IsNullOrEmpty(propertyType.PropertyEditorAlias) 
                && propertyType.PropertyEditorAlias.Equals(Constants.PropertyEditorAlias);
            if (!isArcheTypePropertyEditor)
                return false;

            return !ArchetypeHelper.Instance.IsPropertyValueConverterOverridden(propertyType.DataTypeId);
        }
開發者ID:madebysonder,項目名稱:Archetype,代碼行數:14,代碼來源:ArchetypeValueConverter.cs

示例15: ConvertSourceToObject

        public override object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview)
        {
            if (source == null || UmbracoContext.Current == null)
            {
                return null;
            }

            return JsonConvert.DeserializeObject<PersonalisationGroupDefinition>(source.ToString());
        }
開發者ID:wderoo,項目名稱:UmbracoPersonalisationGroups,代碼行數:9,代碼來源:PersonalisationGroupDefinitionPropertyValueConverter.cs


注:本文中的Umbraco.Core.Models.PublishedContent.PublishedPropertyType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。