本文整理汇总了C#中Orchard.ContentManagement.MetaData.Models.ContentPartFieldDefinition类的典型用法代码示例。如果您正苦于以下问题:C# ContentPartFieldDefinition类的具体用法?C# ContentPartFieldDefinition怎么用?C# ContentPartFieldDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentPartFieldDefinition类属于Orchard.ContentManagement.MetaData.Models命名空间,在下文中一共展示了ContentPartFieldDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PartFieldEditor
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition) {
if (definition.FieldDefinition.Name == "TaxonomyField") {
var model = definition.Settings.GetModel<TaxonomyFieldSettings>();
model.Taxonomies = _taxonomyService.GetTaxonomies();
yield return DefinitionTemplate(model);
}
}
示例2: Render
public dynamic Render(PropertyContext context, ContentItem contentItem, IFieldTypeEditor fieldTypeEditor, string storageName, Type storageType, ContentPartDefinition part, ContentPartFieldDefinition field) {
var p = contentItem.Parts.FirstOrDefault( x => x.PartDefinition.Name == part.Name);
if(p == null) {
return String.Empty;
}
var f = p.Fields.FirstOrDefault(x => x.Name == field.Name);
if(f == null) {
return String.Empty;
}
object value = null;
_contentFieldValueProviders.Invoke(provider => {
var result = provider.GetValue(contentItem, f);
if (result != null) {
value = result;
}
}, Logger);
if (value == null) {
value = f.Storage.Get<object>(storageName);
}
if (value == null) {
return null;
}
// call specific formatter rendering
return _propertyFormater.Format(storageType, value, context.State);
}
示例3: PartFieldEditor
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition)
{
if (definition.FieldDefinition.Name == "BlogPostPickerField") {
var model = definition.Settings.GetModel<BlogPostPickerFieldSettings>();
yield return DefinitionTemplate(model);
}
}
示例4: ApplyFilter
public override void ApplyFilter(FilterContext context, string storageName, Type storageType, ContentPartDefinition part, ContentPartFieldDefinition field) {
var op = (OptionSetOperator) Enum.Parse(typeof (OptionSetOperator), (string) context.State.Operator);
string value = context.State.Value;
var valueArr = value != null
? value.Split('&').Select(int.Parse).ToArray()
: new[] {0};
switch (op) {
case OptionSetOperator.MatchesAny:
Action<IAliasFactory> selectorAny = alias => alias.ContentPartRecord<OptionItemContainerPartRecord>().Property("OptionItems", "opits").Property("OptionItemRecord", "opcpr");
Action<IHqlExpressionFactory> filterAny = x => x.InG("Id", valueArr);
context.Query.Where(selectorAny, filterAny);
break;
case OptionSetOperator.MatchesAll:
foreach (var id in valueArr) {
var optionId = id;
Action<IAliasFactory> selectorAll =
alias => alias.ContentPartRecord<OptionItemContainerPartRecord>().Property("OptionItems", "opit" + optionId);
Action<IHqlExpressionFactory> filterAll = x => x.Eq("OptionItemRecord.Id", optionId);
context.Query.Where(selectorAll, filterAll);
}
break;
case OptionSetOperator.NotMatchesAny:
Action<IAliasFactory> selectorNotAny = alias => alias.ContentPartRecord<OptionItemContainerPartRecord>().Property("OptionItems", "opits").Property("OptionItemRecord", "opcpr");
Action<IHqlExpressionFactory> filterNotAny = x => x.Not(y => y.InG("Id", valueArr));
context.Query.Where(selectorNotAny, filterNotAny);
break;
}
}
示例5: PartFieldEditor
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition) {
if (definition.FieldDefinition.Name == "PhoneField"
|| definition.FieldDefinition.Name == "PhoneFieldCreate") {
var model = definition.Settings.GetModel<PhoneFieldSettings>();
yield return DefinitionTemplate(model);
}
}
示例6: PartFieldEditor
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition)
{
if (definition.FieldDefinition.Name.Equals(typeof(MoneyField).Name))
{
yield return DefinitionTemplate(definition.Settings.GetModel<MoneyFieldSettings>());
}
}
示例7: BindStorage
public IFieldStorage BindStorage(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition) {
var partName = XmlConvert.EncodeLocalName(contentPart.PartDefinition.Name);
var fieldName = XmlConvert.EncodeLocalName(partFieldDefinition.Name);
var infosetPart = contentPart.As<InfosetPart>();
return new SimpleFieldStorage(
(name, valueType) => Get(infosetPart.Infoset.Element, partName, fieldName, name),
(name, valueType, value) => {
Set(infosetPart.Infoset.Element, partName, fieldName, name, value);
var context = new FieldStorageEventContext {
FieldName = partFieldDefinition.Name,
PartName = contentPart.PartDefinition.Name,
Value = value,
ValueName = name,
ValueType = valueType,
Content = infosetPart
};
foreach(var fieldEvent in _events) {
fieldEvent.SetCalled(context);
}
}
);
}
示例8: EditPartFieldViewModel
public EditPartFieldViewModel(int index, ContentPartFieldDefinition field) {
Index = index;
Name = field.Name;
FieldDefinition = new EditFieldViewModel(field.FieldDefinition);
Settings = field.Settings;
_Definition = field;
}
示例9: DisplaySortCriterion
public LocalizedString DisplaySortCriterion(SortCriterionContext context, ContentPartDefinition part, ContentPartFieldDefinition fieldDefinition) {
bool ascending = (bool)context.State.Sort;
return ascending
? T("Ordered by field {0}, ascending", fieldDefinition.Name)
: T("Ordered by field {0}, descending", fieldDefinition.Name);
}
示例10: PartFieldEditor
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition)
{
if (definition.FieldDefinition.Name == typeof(HintField).Name)
{
var model = definition.Settings.GetModel<HintFieldSettings>();
yield return DefinitionTemplate(model);
}
}
示例11: PartFieldEditor
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition)
{
if (definition.FieldDefinition.Name.Equals(typeof(MediaLibraryUploadField).Name))
{
var model = definition.Settings.GetModel<MediaLibraryUploadFieldSettings>();
yield return DefinitionTemplate(model);
}
}
示例12: PartFieldEditor
PartFieldEditor(ContentPartFieldDefinition definition)
{
if (definition.FieldDefinition.Name == "DateTimeField")
{
var model = definition.Settings.GetModel<DateTimeFieldSettings>();
yield return DefinitionTemplate(model);
}
}
示例13: BuildPartFieldEditorAsync
public Task BuildPartFieldEditorAsync(ContentPartFieldDefinition model, BuildEditorContext context)
{
return _partFieldDisplayDrivers.InvokeAsync(async contentDisplay =>
{
var result = await contentDisplay.BuildEditorAsync(model, context);
if (result != null)
result.Apply(context);
}, Logger);
}
示例14: PartFieldEditor
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition) {
if (definition.FieldDefinition.Name == "TextField") {
var model = new TextFieldSettingsEventsViewModel {
Settings = definition.Settings.GetModel<TextFieldSettings>(),
};
yield return DefinitionTemplate(model);
}
}
示例15: BindStorage
public IFieldStorage BindStorage(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition) {
var partName = XmlConvert.EncodeLocalName(contentPart.PartDefinition.Name);
var fieldName = XmlConvert.EncodeLocalName(partFieldDefinition.Name);
var infosetPart = contentPart.As<InfosetPart>();
return new SimpleFieldStorage(
(name, valueType) => Get(infosetPart.ContentItem.VersionRecord == null ? infosetPart.Infoset.Element : infosetPart.VersionInfoset.Element, partName, fieldName, name),
(name, valueType, value) => Set(infosetPart.ContentItem.VersionRecord == null ? infosetPart.Infoset.Element : infosetPart.VersionInfoset.Element, partName, fieldName, name, value));
}