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


C# Models.FeatureDescriptor類代碼示例

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


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

示例1: Resolve

        protected override void Resolve(ILifetimeScope container) {
            _compositionStrategy = container.Resolve<CompositionStrategy>();
            _compositionStrategy.Logger = container.Resolve<ILogger>();

            var alphaExtension = new ExtensionDescriptor {
                Id = "Alpha",
                Name = "Alpha",
                ExtensionType = "Module"
            };

            var alphaFeatureDescriptor = new FeatureDescriptor {
                Id = "Alpha",
                Name = "Alpha",
                Extension = alphaExtension
            };

            var betaFeatureDescriptor = new FeatureDescriptor {
                Id = "Beta",
                Name = "Beta",
                Extension = alphaExtension,
                Dependencies = new List<string> {
                    "Alpha"
                }
            };

            alphaExtension.Features = new List<FeatureDescriptor> {
                alphaFeatureDescriptor,
                betaFeatureDescriptor
            };

            _availableExtensions = new[] {
                alphaExtension
            };

            _installedFeatures = new List<Feature> {
                new Feature {
                    Descriptor = alphaFeatureDescriptor,
                    ExportedTypes = new List<Type> {
                        typeof(AlphaDependency)
                    }
                },
                new Feature {
                    Descriptor = betaFeatureDescriptor,
                    ExportedTypes = new List<Type> {
                        typeof(BetaDependency)
                    }
                }
            };

            _loggerMock.Setup(x => x.IsEnabled(It.IsAny<LogLevel>())).Returns(true);

            _extensionManager.Setup(x => x.AvailableExtensions()).Returns(() => _availableExtensions);

            _extensionManager.Setup(x => x.AvailableFeatures()).Returns(() =>
                _extensionManager.Object.AvailableExtensions()
                .SelectMany(ext => ext.Features)
                .ToReadOnlyCollection());

            _extensionManager.Setup(x => x.LoadFeatures(It.IsAny<IEnumerable<FeatureDescriptor>>())).Returns(() => _installedFeatures);
        }
開發者ID:Higea,項目名稱:Orchard,代碼行數:60,代碼來源:CompositionStrategyTests.cs

示例2: 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);
            }
        }
開發者ID:maxpavlov,項目名稱:HumanizedOrchard,代碼行數:60,代碼來源:ShapePlacementParsingStrategy.cs

示例3: ProcessFeatureDescriptor

 private void ProcessFeatureDescriptor(ShapeTableBuilder builder, FeatureDescriptor featureDescriptor) {
     var virtualPath = featureDescriptor.Extension.Location + "/" + featureDescriptor.Extension.Id + "/Placement.info";
     var placementFile = _placementFileParser.Parse(virtualPath);
     if (placementFile != null) {
         ProcessPlacementFile(builder, featureDescriptor, placementFile);
     }
 }
開發者ID:maxpavlov,項目名稱:HumanizedOrchard,代碼行數:7,代碼來源:ShapePlacementParsingStrategy.cs

示例4: Register

        public override void Register(ContainerBuilder builder) {
            var mockFeatureManager = new Mock<IFeatureManager>();

            var theme1 = new FeatureDescriptor {Extension = new ExtensionDescriptor { Zones = ThemeZoneName1, ExtensionType = "Theme" }};
            var theme2 = new FeatureDescriptor { Extension = new ExtensionDescriptor { Zones = ThemeZoneName2, ExtensionType = "Theme" } };
            var theme3 = new FeatureDescriptor { Extension = new ExtensionDescriptor { Zones = DuplicateZoneNames, ExtensionType = "Theme" } };
            var module1 = new FeatureDescriptor { Extension = new ExtensionDescriptor { Zones = "DontSeeMeBecauseIAmNotATheme", ExtensionType = "Module" } };
            mockFeatureManager.Setup(x => x.GetEnabledFeatures())
                .Returns(new[] { theme1, theme2, theme3, module1 });

            builder.RegisterType<DefaultContentManager>().As<IContentManager>();
            builder.RegisterType<StubCacheManager>().As<ICacheManager>();
            builder.RegisterType<Signals>().As<ISignals>();
            builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
            builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
            builder.RegisterInstance(new Mock<ITransactionManager>().Object);
            builder.RegisterInstance(new Mock<IAuthorizer>().Object);
            builder.RegisterInstance(new Mock<INotifier>().Object);
            builder.RegisterInstance(mockFeatureManager.Object);
            builder.RegisterType<OrchardServices>().As<IOrchardServices>();
            builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
            builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
            builder.RegisterType<WidgetsService>().As<IWidgetsService>();
            builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();


            builder.RegisterType<StubWidgetPartHandler>().As<IContentHandler>();
            builder.RegisterType<StubLayerPartHandler>().As<IContentHandler>();
            builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
            builder.RegisterInstance(new Mock<IPageClassBuilder>().Object); 
            builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();

        }
開發者ID:joeya,項目名稱:test,代碼行數:33,代碼來源:WidgetsServiceTest.cs

示例5: ProcessFeatureDescriptor

        private void ProcessFeatureDescriptor(ShapeTableBuilder builder, FeatureDescriptor featureDescriptor)
        {
            var virtualPath = _fileSystem
                .GetExtensionFileProvider(featureDescriptor.Extension, _logger)
                .GetFileInfo("Placement.info");

            var placementFile = _placementFileParser.Parse(virtualPath);
            if (placementFile != null)
            {
                ProcessPlacementFile(builder, featureDescriptor, placementFile);
            }
        }
開發者ID:jimitndiaye,項目名稱:Orchard2,代碼行數:12,代碼來源:ShapePlacementParsingStrategy.cs

示例6: HasDependency

        /// <summary>
        /// Returns true if the item has an explicit or implicit dependency on the subject
        /// </summary>
        /// <param name="item"></param>
        /// <param name="subject"></param>
        /// <returns></returns>
        internal static bool HasDependency(FeatureDescriptor item, FeatureDescriptor subject) {
            if (DefaultExtensionTypes.IsTheme(item.Extension.ExtensionType)) {
                if (DefaultExtensionTypes.IsModule(subject.Extension.ExtensionType)) {
                    // Themes implicitly depend on modules to ensure build and override ordering
                    return true;
                }

                if (DefaultExtensionTypes.IsTheme(subject.Extension.ExtensionType)) {
                    // Theme depends on another if it is its base theme
                    return item.Extension.BaseTheme == subject.Id;
                }
            }

            // Return based on explicit dependencies
            return item.Dependencies != null &&
                   item.Dependencies.Any(x => StringComparer.OrdinalIgnoreCase.Equals(x, subject.Id));
        }
開發者ID:jecofang01,項目名稱:OrchardNoCMS,代碼行數:23,代碼來源:ExtensionManager.cs

示例7: ProcessFeatureDescriptor

        private void ProcessFeatureDescriptor(ShapeTableBuilder builder, FeatureDescriptor featureDescriptor)
        {
            var virtualPath = _fileSystem
                .GetExtensionFileProvider(featureDescriptor.Extension, _logger)
                .GetFileInfo("placement.json");

            if (virtualPath.Exists)
            {
                using (var stream = virtualPath.CreateReadStream())
                {
                    using (var reader = new StreamReader(stream))
                    {
                        using (var jtr = new JsonTextReader(reader))
                        {
                            JsonSerializer serializer = new JsonSerializer();
                            var placementFile = serializer.Deserialize<PlacementFile>(jtr);
                            ProcessPlacementFile(builder, featureDescriptor, placementFile);
                        }
                    }
                }
            }
        }
開發者ID:jchenga,項目名稱:Orchard2,代碼行數:22,代碼來源:ShapePlacementParsingStrategy.cs

示例8: ProcessPlacementFile

        private void ProcessPlacementFile(ShapeTableBuilder builder, FeatureDescriptor featureDescriptor, PlacementFile placementFile)
        {
            var feature = new Feature { Descriptor = featureDescriptor };

            foreach (var entry in placementFile)
            {
                var shapeType = entry.Key;
                var matches = entry.Value;


                foreach (var filter in entry.Value)
                {
                    var placement = new PlacementInfo();
                    placement.Location = filter.Location;
                    placement.Alternates = filter.Alternates;
                    placement.Wrappers = filter.Wrappers;
                    placement.ShapeType = filter.ShapeType;

                    builder.Describe(shapeType)
                        .From(feature)
                        .Placement(ctx => CheckFilter(ctx, filter), placement);
                }
            }
        }
開發者ID:jchenga,項目名稱:Orchard2,代碼行數:24,代碼來源:ShapePlacementParsingStrategy.cs

示例9: LoadFeature

        private Feature LoadFeature(FeatureDescriptor featureDescriptor)
        {
            var extensionDescriptor = featureDescriptor.Extension;
            var featureId = featureDescriptor.Id;
            var extensionId = extensionDescriptor.Id;

            ExtensionEntry extensionEntry;
            try {
                extensionEntry = BuildEntry(extensionDescriptor);
            }
            catch (Exception ex) {
                _logger.LogError(string.Format("Error loading extension '{0}'", extensionId), ex);
                throw new OrchardException(T("Error while loading extension '{0}'.", extensionId), ex);
            }

            if (extensionEntry == null) {
                // If the feature could not be compiled for some reason,
                // return a "null" feature, i.e. a feature with no exported types.
                return new Feature {
                    Descriptor = featureDescriptor,
                    ExportedTypes = Enumerable.Empty<Type>()
                };
            }

            var extensionTypes = extensionEntry.ExportedTypes.Where(t => t.GetTypeInfo().IsClass && !t.GetTypeInfo().IsAbstract);
            var featureTypes = new List<Type>();

            foreach (var type in extensionTypes) {
                string sourceFeature = GetSourceFeatureNameForType(type, extensionId);
                if (String.Equals(sourceFeature, featureId, StringComparison.OrdinalIgnoreCase)) {
                    featureTypes.Add(type);
                }
            }

            return new Feature {
                Descriptor = featureDescriptor,
                ExportedTypes = featureTypes
            };
        }
開發者ID:vebin,項目名稱:Brochard,代碼行數:39,代碼來源:ExtensionManager.cs

示例10: GetPriority

 internal static int GetPriority(FeatureDescriptor featureDescriptor)
 {
     return featureDescriptor.Priority;
 }
開發者ID:vebin,項目名稱:Brochard,代碼行數:4,代碼來源:ExtensionManager.cs

示例11: FrameworkFeature

 private static Feature FrameworkFeature(FeatureDescriptor descriptor) {
     return new Feature {
         Descriptor = descriptor
     };
 }
開發者ID:RasterImage,項目名稱:Orchard,代碼行數:5,代碼來源:ThemeServiceTests.cs

示例12: ExtensionManagerShouldReturnEmptyFeatureIfFeatureDoesNotExist

        public void ExtensionManagerShouldReturnEmptyFeatureIfFeatureDoesNotExist()
        {
            var featureDescriptor = new FeatureDescriptor { Id = "NoSuchFeature", Extension = new ExtensionDescriptor { Id = "NoSuchFeature" } };
            var manager = new ExtensionManager(new StubExtensionLocator(), new StubLoaders[] { }, new TypeFeatureProvider(), new NullLogger<ExtensionManager>());

            Feature feature = manager.LoadFeatures(new[] { featureDescriptor }).First();
            Assert.Equal(featureDescriptor, feature.Descriptor);
            Assert.Equal(0, feature.ExportedTypes.Count());
        }
開發者ID:jchenga,項目名稱:Orchard2,代碼行數:9,代碼來源:ExtensionManagerTests.cs

示例13: HasDependency

 /// <summary>
 /// Returns true if the item has an explicit or implicit dependency on the subject
 /// </summary>
 /// <param name="item"></param>
 /// <param name="subject"></param>
 /// <returns></returns>
 internal static bool HasDependency(FeatureDescriptor item, FeatureDescriptor subject)
 {
     // Return based on explicit dependencies
     return item.Dependencies != null &&
            item.Dependencies.Any(x => StringComparer.OrdinalIgnoreCase.Equals(x, subject.Id));
 }
開發者ID:qhme,項目名稱:OrchardLite,代碼行數:12,代碼來源:ExtensionManager.cs

示例14: ApplyChanges

        public void ApplyChanges()
        {
            if (Logger.IsEnabled(LogLevel.Information))
            {
                Logger.LogInformation("Applying changes for for shell '{0}'", _settings.Name);
            }

            var shellState = _stateManager.GetShellStateAsync().Result;

            // start with description of all declared features in order - order preserved with all merging
            var orderedFeatureDescriptors = _extensionManager.AvailableFeatures();

            // merge feature state into ordered list
            var orderedFeatureDescriptorsAndStates = orderedFeatureDescriptors
                .Select(featureDescriptor => new
                {
                    FeatureDescriptor = featureDescriptor,
                    FeatureState = shellState.Features.FirstOrDefault(s => s.Name == featureDescriptor.Id),
                })
                .Where(entry => entry.FeatureState != null)
                .ToArray();

            // get loaded feature information
            var loadedFeatures = _extensionManager.LoadFeatures(orderedFeatureDescriptorsAndStates.Select(entry => entry.FeatureDescriptor)).ToArray();

            // merge loaded feature information into ordered list
            var loadedEntries = orderedFeatureDescriptorsAndStates.Select(
                entry => new
                {
                    Feature = loadedFeatures.SingleOrDefault(f => f.Descriptor == entry.FeatureDescriptor)
                              ?? new Feature
                              {
                                  Descriptor = entry.FeatureDescriptor,
                                  ExportedTypes = Enumerable.Empty<Type>()
                              },
                    entry.FeatureDescriptor,
                    entry.FeatureState,
                }).ToList();

            // find feature state that is beyond what's currently available from modules
            var additionalState = shellState.Features.Except(loadedEntries.Select(entry => entry.FeatureState));

            // create additional stub entries for the sake of firing state change events on missing features
            var allEntries = loadedEntries.Concat(additionalState.Select(featureState =>
            {
                var featureDescriptor = new FeatureDescriptor
                {
                    Id = featureState.Name,
                    Extension = new ExtensionDescriptor
                    {
                        Id = featureState.Name
                    }
                };
                return new
                {
                    Feature = new Feature
                    {
                        Descriptor = featureDescriptor,
                        ExportedTypes = Enumerable.Empty<Type>(),
                    },
                    FeatureDescriptor = featureDescriptor,
                    FeatureState = featureState
                };
            })).ToArray();

            // lower enabled states in reverse order
            foreach (var entry in allEntries.Reverse().Where(entry => entry.FeatureState.EnableState == ShellFeatureState.State.Falling))
            {
                if (Logger.IsEnabled(LogLevel.Information))
                {
                    Logger.LogInformation("Disabling feature '{0}'", entry.Feature.Descriptor.Id);
                }

                _eventBus.Notify<IFeatureEventHandler>(x => x.Disabling(entry.Feature));
                _stateManager.UpdateEnabledState(entry.FeatureState, ShellFeatureState.State.Down);
                _eventBus.Notify<IFeatureEventHandler>(x => x.Disabled(entry.Feature));
            }

            // lower installed states in reverse order
            foreach (var entry in allEntries.Reverse().Where(entry => entry.FeatureState.InstallState == ShellFeatureState.State.Falling))
            {
                if (Logger.IsEnabled(LogLevel.Information))
                {
                    Logger.LogInformation("Uninstalling feature '{0}'", entry.Feature.Descriptor.Id);
                }

                _eventBus.Notify<IFeatureEventHandler>(x => x.Uninstalling(entry.Feature));
                _stateManager.UpdateInstalledState(entry.FeatureState, ShellFeatureState.State.Down);
                _eventBus.Notify<IFeatureEventHandler>(x => x.Uninstalled(entry.Feature));
            }

            // raise install and enabled states in order
            foreach (var entry in allEntries.Where(entry => IsRising(entry.FeatureState)))
            {
                if (entry.FeatureState.InstallState == ShellFeatureState.State.Rising)
                {
                    if (Logger.IsEnabled(LogLevel.Information))
                    {
                        Logger.LogInformation("Installing feature '{0}'", entry.Feature.Descriptor.Id);
                    }
//.........這裏部分代碼省略.........
開發者ID:vairam-svs,項目名稱:Orchard2,代碼行數:101,代碼來源:ShellStateUpdater.cs

示例15: LoadFeature

        private Feature LoadFeature(FeatureDescriptor featureDescriptor)
        {
            var extensionDescriptor = featureDescriptor.Extension;
            var featureId = featureDescriptor.Id;
            var extensionId = extensionDescriptor.Id;

            ExtensionEntry extensionEntry;
            try
            {
                extensionEntry = _cacheManager.Get(extensionId, ctx =>
                {
                    var entry = BuildEntry(extensionDescriptor);
                    if (entry != null)
                    {
                        ctx.Monitor(_asyncTokenProvider.GetToken(monitor =>
                        {
                            foreach (var loader in _loaders)
                            {
                                loader.Monitor(entry.Descriptor, token => monitor(token));
                            }
                        }));
                    }
                    return entry;
                });
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Error loading extension '{0}'", extensionId);
                throw new CoreException(string.Format("Error while loading extension '{0}'.", extensionId), ex);
            }

            if (extensionEntry == null)
            {
                // If the feature could not be compiled for some reason,
                // return a "null" feature, i.e. a feature with no exported types.
                return new Feature
                {
                    Descriptor = featureDescriptor,
                    ExportedTypes = Enumerable.Empty<Type>()
                };
            }

            var extensionTypes = extensionEntry.ExportedTypes.Where(t => t.IsClass && !t.IsAbstract);
            var featureTypes = new List<Type>();

            foreach (var type in extensionTypes)
            {
                string sourceFeature = GetSourceFeatureNameForType(type, extensionId);
                if (String.Equals(sourceFeature, featureId, StringComparison.OrdinalIgnoreCase))
                {
                    featureTypes.Add(type);
                }
            }

            return new Feature
            {
                Descriptor = featureDescriptor,
                ExportedTypes = featureTypes
            };
        }
開發者ID:qhme,項目名稱:OrchardLite,代碼行數:60,代碼來源:ExtensionManager.cs


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