本文整理汇总了C#中Orchard.ContentManagement.MetaData.Models.ContentTypeDefinition类的典型用法代码示例。如果您正苦于以下问题:C# ContentTypeDefinition类的具体用法?C# ContentTypeDefinition怎么用?C# ContentTypeDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentTypeDefinition类属于Orchard.ContentManagement.MetaData.Models命名空间,在下文中一共展示了ContentTypeDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLayout
private string GetLayout(ContentTypeDefinition contentTypeDefinition, ICollection<Section> data) {
//check field valid
if (contentTypeDefinition.Parts.Any()) {
var part = contentTypeDefinition.Parts.First(x => x.PartDefinition.Name == contentTypeDefinition.Name);
var partFields = part.PartDefinition.Fields.ToList();
var fields = data.SelectMany(x => x.Rows)
.SelectMany(x => x.Columns)
.Where(x => x.Field != null)
.Select(x => x.Field).ToList();
if (partFields.Any(f => f.Settings.ContainsKey(AlwaysInLayoutKey)
&& bool.Parse(f.Settings[AlwaysInLayoutKey])
&& !fields.Select(x => x.FieldName).Contains(f.Name))) {
return string.Empty;
}
foreach (var field in fields) {
if (partFields.Any(x => x.Name == field.FieldName)) {
field.IsValid = true;
}
else if (contentTypeDefinition.Parts.Any(x => x.PartDefinition.Name == field.FieldName)) {
field.IsValid = true;
}
}
}
ViewDataDictionary viewData = new ViewDataDictionary();
viewData.Add("Layout", data);
string layout = _templateViewService
.RenderView("Coevery.FormDesigner", "FormTemplate", "FormDesignerLayout", viewData);
return layout;
}
示例2: EditTypeViewModel
public EditTypeViewModel(ContentTypeDefinition contentTypeDefinition)
{
Name = contentTypeDefinition.Name;
DisplayName = contentTypeDefinition.DisplayName;
Settings = contentTypeDefinition.Settings;
TypeDefinition = contentTypeDefinition;
}
示例3: GetTypeFields
private IEnumerable<EditPartFieldViewModel> GetTypeFields(ContentTypeDefinition contentTypeDefinition) {
var implicitTypePart = contentTypeDefinition.Parts.SingleOrDefault(p => string.Equals(p.PartDefinition.Name, Name, StringComparison.OrdinalIgnoreCase));
return implicitTypePart == null
? Enumerable.Empty<EditPartFieldViewModel>()
: implicitTypePart.PartDefinition.Fields.Select((f, i) => new EditPartFieldViewModel(i, f) { Part = new EditPartViewModel(implicitTypePart.PartDefinition) });
}
示例4: Create
public int Create()
{
try {
SchemaBuilder.CreateTable("ProxyPartRecord", table => table
.ContentPartRecord()
.Column("ServiceUrl", DbType.String)
);
var proxy = new ContentTypeDefinition("Proxy", "Proxy");
ContentDefinitionManager.StoreTypeDefinition(proxy);
ContentDefinitionManager.AlterTypeDefinition("Proxy", cfg => cfg.Creatable()
.WithPart("ProxyPart")
.WithPart("CommonPart")
.WithPart("TitlePart")
.WithPart("IdentityPart")
.WithPart("ContentPermissionsPart", builder => builder
.WithSetting("ContentPermissionsPartSettings.View", "Administrator")
.WithSetting("ContentPermissionsPartSettings.Publish", "Administrator")
.WithSetting("ContentPermissionsPartSettings.Edit", "Administrator")
.WithSetting("ContentPermissionsPartSettings.Delete", "Administrator")
.WithSetting("ContentPermissionsPartSettings.DisplayedRoles", "Administrator,Authenticated")
)
);
} catch (Exception e) {
var message = string.Format("Error creating Proxy module. {0}", e.Message);
Logger.Warning(message);
Notifier.Warning(T(message));
return 0;
}
return 1;
}
示例5: TypeEditor
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) {
var settings = definition.Settings.GetModel<ContentPermissionsTypeSettings>();
var model = new SecurableContentItemsSettingsViewModel {
SecurableContentItems = settings.SecurableContentItems,
};
yield return DefinitionTemplate(model);
}
示例6: EditTypeViewModel
public EditTypeViewModel(ContentTypeDefinition contentTypeDefinition) {
Name = contentTypeDefinition.Name;
DisplayName = contentTypeDefinition.DisplayName;
Settings = contentTypeDefinition.Settings;
Fields = GetTypeFields(contentTypeDefinition).ToList();
Parts = GetTypeParts(contentTypeDefinition).ToList();
_Definition = contentTypeDefinition;
}
示例7: CreateDynamicPermission
/// <summary>
/// Generates a permission dynamically for a content type
/// </summary>
public static Permission CreateDynamicPermission(Permission template, ContentTypeDefinition typeDefinition) {
return new Permission {
Name = String.Format(template.Name, typeDefinition.Name),
Description = String.Format(template.Description, typeDefinition.DisplayName),
Category = typeDefinition.DisplayName,
ImpliedBy = (template.ImpliedBy ?? new Permission[0]).Select(t => CreateDynamicPermission(t, typeDefinition))
};
}
示例8: Edit
public override IDisplayResult Edit(ContentTypeDefinition contentTypeDefinition)
{
return Shape<ContentTypeViewModel>("ContentType_Edit", model =>
{
model.DisplayName = contentTypeDefinition.DisplayName;
return Task.CompletedTask;
}).Location("Content");
}
示例9: CreateSubmitPermission
/// <summary>
/// Generates a permission dynamically for a content type
/// </summary>
public static Permission CreateSubmitPermission(ContentTypeDefinition typeDefinition) {
return new Permission {
Name = String.Format(SubmitForm.Name, typeDefinition.Name),
Description = String.Format(SubmitForm.Description, typeDefinition.DisplayName),
Category = "Custom Forms",
ImpliedBy = new [] { SubmitForm }
};
}
示例10: BuildTypeEditorAsync
public Task BuildTypeEditorAsync(ContentTypeDefinition model, BuildEditorContext context)
{
return _typeDisplayDrivers.InvokeAsync(async contentDisplay =>
{
var result = await contentDisplay.BuildEditorAsync(model, context);
if (result != null)
result.Apply(context);
}, Logger);
}
示例11: TypeEditor
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition)
{
var settings = definition.Settings.GetModel<DynamicTypeSettings>();
var model = new DynamicTypeSettingsViewModel
{
IsDeployed = settings.IsDeployed
};
yield return DefinitionTemplate(model);
}
示例12: Export
public XElement Export(ContentTypeDefinition typeDefinition) {
var typeElement = NewElement(typeDefinition.Name, typeDefinition.Settings);
if (typeElement.Attribute("DisplayName") == null && typeDefinition.DisplayName != null) {
typeElement.Add(new XAttribute("DisplayName", typeDefinition.DisplayName));
}
foreach(var typePart in typeDefinition.Parts) {
typeElement.Add(NewElement(typePart.PartDefinition.Name, typePart.Settings));
}
return typeElement;
}
示例13: ContentTypeDefinitionBuilder
public ContentTypeDefinitionBuilder(ContentTypeDefinition existing) {
if (existing == null) {
_parts = new List<ContentTypePartDefinition>();
_settings = new SettingsDictionary();
}
else {
_name = existing.Name;
_displayName = existing.DisplayName;
_parts = existing.Parts.ToList();
_settings = new SettingsDictionary(existing.Settings.ToDictionary(kv => kv.Key, kv => kv.Value));
}
}
示例14: GivenIHaveAContainableContentType
public void GivenIHaveAContainableContentType(string name) {
var webApp = Binding<WebAppHosting>();
webApp.Host.Execute(() => {
using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) {
var cdm = environment.Resolve<IContentDefinitionManager>();
var contentTypeDefinition = new ContentTypeDefinition(name, name);
cdm.StoreTypeDefinition(contentTypeDefinition);
cdm.AlterTypeDefinition(name, cfg => cfg.WithPart("CommonPart").WithPart("BodyPart").WithPart("RoutePart").WithPart("ContainablePart").Creatable().Draftable());
}
});
}
示例15: ContentTypeDefinitionModel
public ContentTypeDefinitionModel(ContentTypeDefinition contentTypeDefinition) {
Parts = new List<ContentPartDefinitionModel>();
Settings = new Dictionary<string, string>(contentTypeDefinition.Settings);
foreach (var partDefinitionModel in contentTypeDefinition.Parts.Select(partDefinition => new ContentPartDefinitionModel(partDefinition)))
{
Parts.Add(partDefinitionModel);
}
Name = contentTypeDefinition.Name;
DisplayName = contentTypeDefinition.DisplayName;
}