本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例5: IsConverter
public bool IsConverter(PublishedPropertyType propertyType) {
return (
propertyType.PropertyEditorAlias == "Skybrud.SelfService.Categories"
||
propertyType.PropertyEditorAlias == "Skybrud.SelfService.List"
);
}
示例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();
}
示例7: XmlPublishedProperty
public XmlPublishedProperty(PublishedPropertyType propertyType, bool isPreviewing, string propertyData)
: this(propertyType, isPreviewing)
{
if (propertyData == null)
throw new ArgumentNullException("propertyData");
_xmlValue = propertyData;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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