本文整理汇总了C#中Orchard.Environment.Extensions.Models.Feature类的典型用法代码示例。如果您正苦于以下问题:C# Feature类的具体用法?C# Feature怎么用?C# Feature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Feature类属于Orchard.Environment.Extensions.Models命名空间,在下文中一共展示了Feature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessPlacementFile
private void ProcessPlacementFile(ShapeTableBuilder builder, FeatureDescriptor featureDescriptor, PlacementFile placementFile) {
var feature = new Feature { Descriptor = featureDescriptor };
// invert the tree into a list of leaves and the stack
var entries = DrillDownShapeLocations(placementFile.Nodes, Enumerable.Empty<PlacementMatch>());
foreach (var entry in entries) {
var shapeLocation = entry.Item1;
var matches = entry.Item2;
string shapeType;
string differentiator;
GetShapeType(shapeLocation, out shapeType, out differentiator);
Func<ShapePlacementContext, bool> predicate = ctx => true;
if (differentiator != "") {
predicate = ctx => (ctx.Differentiator ?? "") == differentiator;
}
if (matches.Any()) {
predicate = matches.SelectMany(match => match.Terms).Aggregate(predicate, BuildPredicate);
}
var placement = new PlacementInfo();
var segments = shapeLocation.Location.Split(';').Select(s => s.Trim());
foreach (var segment in segments) {
if (!segment.Contains('=')) {
placement.Location = segment;
}
else {
var index = segment.IndexOf('=');
var property = segment.Substring(0, index).ToLower();
var value = segment.Substring(index + 1);
switch (property) {
case "shape":
placement.ShapeType = value;
break;
case "alternate":
placement.Alternates = new[] { value };
break;
case "wrapper":
placement.Wrappers = new[] { value };
break;
}
}
}
builder.Describe(shapeType)
.From(feature)
.Placement(ctx => {
var hit = predicate(ctx);
// generate 'debugging' information to trace which file originated the actual location
if (hit) {
var virtualPath = featureDescriptor.Extension.Location + "/" + featureDescriptor.Extension.Id + "/Placement.info";
ctx.Source = virtualPath;
}
return hit;
}, placement);
}
}
示例2: Enabled
public void Enabled(Feature feature)
{
const string taxonomyName = "Package Types";
var taxonomy = _taxonomyService.GetTaxonomyByName(taxonomyName);
if (taxonomy != null) {
var moduleTerm = _taxonomyService.GetTermByName(taxonomy.Id, "Module");
if (moduleTerm == null) {
moduleTerm = _taxonomyService.NewTerm(taxonomy);
moduleTerm.Name = "Module";
moduleTerm.Slug = "Modules";
moduleTerm.Container = taxonomy.ContentItem;
_services.ContentManager.Create(moduleTerm, VersionOptions.Published);
}
var themeTerm = _taxonomyService.GetTermByName(taxonomy.Id, "Theme");
if (themeTerm == null) {
themeTerm = _taxonomyService.NewTerm(taxonomy);
themeTerm.Name = "Theme";
themeTerm.Slug = "Themes";
themeTerm.Container = taxonomy.ContentItem;
_services.ContentManager.Create(themeTerm, VersionOptions.Published);
}
}
}
示例3: Uninstalled
public void Uninstalled(Feature feature)
{
var featureName = feature.Descriptor.Id;
if (_dataMigrationManager.IsFeatureAlreadyInstalled(featureName))
{
_dataMigrationManager.Uninstall(featureName);
}
}
示例4: Enabled
public void Enabled(Feature feature)
{
if (feature.Descriptor.Id != "Szmyd.Orchard.Modules.Menu") return;
var currentMainMenu = _menuService.GetMenu("main");
if (currentMainMenu == null)
{
_services.ContentManager.Create<AdvancedMenuPart>("Menu", p => p.Name = "main");
}
var currentItems = _menuService.GetMenuItems("main");
/* Creating new menu with Home in it */
if (!currentItems.Any())
{
_services.ContentManager.Create<AdvancedMenuItemPart>("SimpleMenuItem",
nItem =>
{
nItem.DisplayHref = true;
nItem.DisplayText = true;
nItem.MenuName = "main";
nItem.Url = "/";
nItem.Position = "0";
nItem.Text = "Home";
});
}
// Adding the default menu widget to Navigation zone in Default layer
var layerPart = _widgets.GetLayers().FirstOrDefault(l => l.Name == "Default");
if (layerPart == null)
{
return;
}
var countDefault = _services.ContentManager
.Query<WidgetPart, WidgetPartRecord>()
.Where(p => p.Zone == "Navigation")
.ForType("MenuWidget").List();
if (countDefault.Count() == 0)
{
_services.ContentManager.Create<WidgetPart>("StyledMenuWidget",
widget =>
{
widget.Record.Title = "Main menu";
widget.Record.Position = "0";
widget.Record.Zone = "Navigation";
widget.LayerPart = layerPart;
widget.As<MenuWidgetPart>().Levels = 0;
widget.As<MenuWidgetPart>().CutOrFlattenLower = false;
widget.As<MenuWidgetPart>().MenuName = "main";
widget.As<MenuWidgetPart>().WrapChildrenInDiv = false;
widget.As<MenuWidgetPart>().Mode = MenuWidgetMode.AllItems;
widget.As<MenuStylingPart>().BackColor = "#FFFFFF";
widget.As<MenuStylingPart>().ForeColor = "#333333";
widget.As<MenuStylingPart>().HoverBackColor = "#F7F7F7";
widget.As<MenuStylingPart>().HoverForeColor = "#444444";
widget.As<MenuStylingPart>().SelectedForeColor = "#333333";
widget.As<MenuStylingPart>().SelectedBackColor = "#F1F1F1";
widget.As<MenuStylingPart>().Style = MenuStyles.SuperfishHorizontal;
});
}
}
示例5: Disabled
public void Disabled(Feature feature) {
var currentTheme = _siteThemeService.GetCurrentThemeName();
if (feature.Descriptor.Name == currentTheme) {
_siteThemeService.SetSiteTheme(null);
// Notifications don't work in feature events. See: https://github.com/OrchardCMS/Orchard/issues/6106
_notifier.Warning(T("The current theme was disabled, because one of its dependencies was disabled."));
}
}
示例6: Enabled
public void Enabled(Feature feature)
{
CreateTaxonomy("FeatureCategory", new List<string> {
"Operations",
"Accounting",
"Accessibility",
"Sales"
});
}
示例7: AddDefaultTagsForFeature
public void AddDefaultTagsForFeature(Feature feature)
{
var featureName = feature.Descriptor.Id;
if (!featureName.Equals(Constants.LocalArea, StringComparison.OrdinalIgnoreCase))
return;
var taxonomy = _taxonomyService.GetTaxonomyByName(Constants.Taxonomies.Tags);
_taxonomyImportService.CreateTermFor(taxonomy, "Question", null);
}
示例8: ShapeAlterationBuilder
public ShapeAlterationBuilder(Feature feature, string shapeType) {
_feature = feature;
_bindingName = shapeType;
var delimiterIndex = shapeType.IndexOf("__");
if (delimiterIndex < 0) {
_shapeType = shapeType;
}
else {
_shapeType = shapeType.Substring(0, delimiterIndex);
}
}
示例9: AddDefaultCategoriesForFeature
public void AddDefaultCategoriesForFeature(Feature feature)
{
var featureName = feature.Descriptor.Id;
if (!featureName.Equals(Constants.LocalArea, StringComparison.OrdinalIgnoreCase))
return;
var taxonomy = _taxonomyService.GetTaxonomyByName(Constants.Taxonomies.Categories);
_taxonomyImportService.CreateTermFor(taxonomy, "Administration", null);
_taxonomyImportService.CreateTermFor(taxonomy, "Announcements", null);
_taxonomyImportService.CreateTermFor(taxonomy, "General", null);
}
示例10: Enabled
public void Enabled(Feature feature)
{
//var taxonomyList = new List<string> {
// "Remodel",
// "Construction",
// "Repair"
//};
}
示例11: Enabled
public void Enabled(Feature feature) {
if (feature.Descriptor.Id != "NGM.CasClient")
return;
var settings = _orchardServices.WorkContext.CurrentSite.As<CASSettingsPart>();
settings.ProcessIncomingSingleSignOutRequests = true;
settings.ProxyCallbackParameterName = "proxyResponse";
settings.GatewayParameterName = "gatewayResponse";
settings.ArtifactParameterName = "ticket";
settings.GatewayStatusCookieName = "cas_gateway_status";
settings.TicketValidatorName = "Saml11";
settings.ServiceTicketManager = "CacheServiceTicketManager";
settings.ProxyTicketManager = "CacheProxyTicketManager";
settings.TicketTimeTolerance = 5000;
}
示例12: AddDefaultRolesForFeature
public void AddDefaultRolesForFeature(Feature feature) {
var featureName = feature.Descriptor.Id;
// when another module is being enabled, locate matching permission providers
var providersForEnabledModule = _permissionProviders.Where(x => x.Feature.Descriptor.Id == featureName);
if (providersForEnabledModule.Any()) {
Logger.Debug("Configuring default roles for module {0}", featureName);
}
else {
Logger.Debug("No default roles for module {0}", featureName);
}
foreach (var permissionProvider in providersForEnabledModule) {
// get and iterate stereotypical groups of permissions
var stereotypes = permissionProvider.GetDefaultStereotypes();
foreach (var stereotype in stereotypes) {
// turn those stereotypes into roles
var role = _roleService.GetRoleByName(stereotype.Name);
if (role == null) {
Logger.Information("Defining new role {0} for permission stereotype", stereotype.Name);
_roleService.CreateRole(stereotype.Name);
role = _roleService.GetRoleByName(stereotype.Name);
}
// and merge the stereotypical permissions into that role
var stereotypePermissionNames = (stereotype.Permissions ?? Enumerable.Empty<Permission>()).Select(x => x.Name);
var currentPermissionNames = role.RolesPermissions.Select(x => x.Permission.Name);
var distinctPermissionNames = currentPermissionNames
.Union(stereotypePermissionNames)
.Distinct();
// update role if set of permissions has increased
var additionalPermissionNames = distinctPermissionNames.Except(currentPermissionNames);
if (additionalPermissionNames.Any()) {
foreach (var permissionName in additionalPermissionNames) {
Logger.Information("Default role {0} granted permission {1}", stereotype.Name, permissionName);
_roleService.CreatePermissionForRole(role.Name, permissionName);
}
}
}
}
}
示例13: Enabled
public void Enabled(Feature feature)
{
CreateTaxonomy("PropertyType", new List<string> {
"Single-Family Home",
"Apartment",
"Duplex",
"Triplex",
"Quadraplex",
"Townhouse",
"Detached House",
"Cottage",
"Cabin",
"Multi-Family Home",
"Villa",
"Zero-Lot-Line Home",
"Patio Home",
"Courtyard Home",
"Terraced House",
"Condominium",
"Timeshare/Interval Ownership",
"Housing Cooperative",
"Land Lease",
"Carriage Home/Coach Home",
"Mobile Home",
"Houseboat",
"Boxcar",
"Tent"
});
CreateTaxonomy("Ammenities", new List<string> {
"Air Conditioning",
"Washer and Dryer",
"Laundromat on Property",
"Dishwasher",
"On Site Security",
"Pets Allowed",
"Smoking Allowed",
"Fireplace",
"Walk In Closet",
"Hot Tub / Spa",
"Cable Tv",
"High Speed Internet",
"Community Grill",
"Covered Parking",
"Gated /Controlled Entrance",
"Bus/Public Transportation"
});
CreateTaxonomy("RentOrSale", new List<string> {"Rent","Sale"});
}
示例14: Enabled
public void Enabled(Feature feature) {
//if genre taxonomy not defined - the ncreate
if(_taxonomyService.GetTaxonomyByName("Genre")==null) {
var genre= _contentManager.New<TaxonomyPart>("Taxonomy");
genre.Name = "Genre";
_contentManager.Create(genre, VersionOptions.Published);
CreateTerm(genre, "Action");
CreateTerm(genre, "Adventure");
CreateTerm(genre, "Animation");
CreateTerm(genre, "Comedy");
CreateTerm(genre, "Drama");
CreateTerm(genre, "Crime");
CreateTerm(genre, "Documentary");
}
}
示例15: Enabled
public void Enabled(Feature feature) {
// if Genre taxonomy does not exist
// create Genre taxonomy
// create several genre terms in the taxonomy
if (_taxonomyService.GetTaxonomyByName("Genre") == null) {
var genre = _contentManager.New<TaxonomyPart>("Taxonomy");
genre.Name = "Genre";
_contentManager.Create(genre, VersionOptions.Published);
CreateTerm(genre, "Action");
CreateTerm(genre, "Adventure");
CreateTerm(genre, "Animation");
CreateTerm(genre, "Comedy");
CreateTerm(genre, "Crime");
CreateTerm(genre, "Documentary");
CreateTerm(genre, "Drama");
}
}