当前位置: 首页>>代码示例>>C#>>正文


C# IContentManager.Get方法代码示例

本文整理汇总了C#中IContentManager.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IContentManager.Get方法的具体用法?C# IContentManager.Get怎么用?C# IContentManager.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IContentManager的用法示例。


在下文中一共展示了IContentManager.Get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TermsPartHandler

        public TermsPartHandler(
            IContentDefinitionManager contentDefinitionManager,
            IRepository<TermsPartRecord> repository,
            ITaxonomyService taxonomyService,
            IContentManager contentManager) {
            _contentDefinitionManager = contentDefinitionManager;
            _contentManager = contentManager;

            Filters.Add(StorageFilter.For(repository));

            OnPublished<TermsPart>((context, part) => RecalculateCount(contentManager, taxonomyService, part));
            OnUnpublished<TermsPart>((context, part) => RecalculateCount(contentManager, taxonomyService, part));
            OnRemoved<TermsPart>((context, part) => RecalculateCount(contentManager, taxonomyService, part));
            
            // tells how to load the field terms on demand
            OnLoaded<TermsPart>((context, part) => {
                foreach(var field in part.ContentItem.Parts.SelectMany(p => p.Fields).OfType<TaxonomyField>()) {
                    var tempField = field.Name;
                    var fieldTermRecordIds = part.Record.Terms.Where(t => t.Field == tempField).Select(tci => tci.TermRecord.Id);
                    field.Terms.Loader(value => fieldTermRecordIds.Select(id => _contentManager.Get<TermPart>(id)));
                }
            });

            OnIndexing<TermsPart>(
                (context, part) => {
                    foreach (var term in part.Terms) {
                        var value = context.ContentManager.Get(term.TermRecord.Id).As<TitlePart>().Title;
                        context.DocumentIndex.Add(term.Field, value).Analyze();
                        context.DocumentIndex.Add(term.Field + "-id", term.Id).Store();
                    }
                });
        }
开发者ID:dminik,项目名称:voda_code,代码行数:32,代码来源:TermsPartHandler.cs

示例2: CommentPartHandler

        public CommentPartHandler(
            IRepository<CommentPartRecord> commentsRepository,
            IContentManager contentManager,
            ICommentService commentService
            ) {

            Filters.Add(StorageFilter.For(commentsRepository));

            OnLoading<CommentPart>((context, comment) => {
                comment.CommentedOnContentItemField.Loader(
                    item => contentManager.Get(comment.CommentedOn)
                );

                comment.CommentedOnContentItemMetadataField.Loader(
                    item => contentManager.GetItemMetadata(comment.CommentedOnContentItem)
                );
            });

            OnRemoving<CommentPart>((context, comment) => {
                foreach(var response in contentManager.Query<CommentPart, CommentPartRecord>().Where(x => x.RepliedOn == comment.Id).List()) {
                    contentManager.Remove(response.ContentItem);
                }
            });

            // keep CommentsPart.Count in sync
            OnPublished<CommentPart>((context, part) => commentService.ProcessCommentsCount(part.CommentedOn));
            OnUnpublished<CommentPart>((context, part) => commentService.ProcessCommentsCount(part.CommentedOn));
            OnVersioned<CommentPart>((context, part, newVersionPart) => commentService.ProcessCommentsCount(newVersionPart.CommentedOn));
            OnRemoved<CommentPart>((context, part) => commentService.ProcessCommentsCount(part.CommentedOn));

            OnIndexing<CommentPart>((context, commentPart) => context.DocumentIndex
                                                                .Add("commentText", commentPart.Record.CommentText));
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:33,代码来源:CommentPartHandler.cs

示例3: ContentMenuItemPartHandler

        public ContentMenuItemPartHandler(IContentManager contentManager, IRepository<ContentMenuItemPartRecord> repository) {
            _contentManager = contentManager;
            Filters.Add(new ActivatingFilter<ContentMenuItemPart>("ContentMenuItem"));
            Filters.Add(StorageFilter.For(repository));

            OnLoading<ContentMenuItemPart>((context, part) => part._content.Loader(p => contentManager.Get(part.Record.ContentMenuItemRecord.Id)));
        }
开发者ID:bigfont,项目名称:CertifiedOverheadCrane,代码行数:7,代码来源:ContentMenuItemPartHandler.cs

示例4: CustomerPartHandler

        public CustomerPartHandler(
            IContentManager contentManager,
            ICustomersService customersService,
            IRepository<CustomerPartRecord> repository
            )
        {
            Filters.Add(StorageFilter.For(repository));

            OnActivated<CustomerPart>((context, part) => {
                // User field
                part._user.Loader(user => contentManager.Get<IUser>(part.UserId));
                part._user.Setter(user => {
                    part.UserId = (user != null ? user.Id : 0);
                    return user;
                });

                // Default address field
                part._defaultAddress.Loader(address => customersService.GetAddress(part.DefaultAddressId));
                part._defaultAddress.Setter(address => {
                    part.DefaultAddressId = (address != null ? address.Id : 0);
                    return address;
                });

                // Addresses field
                part._addresses.Loader(addresses => customersService.GetAddressesForCustomer(part));
            });

            OnRemoving<CustomerPart>((context, part) => {
                foreach (var address in part.Addresses) {
                    contentManager.Remove(address.ContentItem);
                }
            });
        }
开发者ID:rtpHarry,项目名称:OShop,代码行数:33,代码来源:CustomerPartHandler.cs

示例5: CommentPartHandler

        public CommentPartHandler(
            IRepository<CommentPartRecord> commentsRepository,
            IContentManager contentManager) {

            Filters.Add(StorageFilter.For(commentsRepository));

            OnLoading<CommentPart>((context, comment) => {
                comment.CommentedOnContentItemField.Loader(
                    item => contentManager.Get(comment.CommentedOn)
                );

                comment.CommentedOnContentItemMetadataField.Loader(
                    item => contentManager.GetItemMetadata(comment.CommentedOnContentItem)
                );
            });


            OnRemoving<CommentPart>((context, comment) => {
                foreach(var response in contentManager.Query<CommentPart, CommentPartRecord>().Where(x => x.RepliedOn == comment.Id).List()) {
                    contentManager.Remove(response.ContentItem);
                }
            });

            OnIndexing<CommentPart>((context, commentPart) => context.DocumentIndex
                                                                .Add("commentText", commentPart.Record.CommentText));
        }
开发者ID:kanujhun,项目名称:orchard,代码行数:26,代码来源:CommentPartHandler.cs

示例6: NotificationBatchPartHandler

        public NotificationBatchPartHandler(
            IContentManager contentManager,
            Lazy<IRoleService> roleServiceLazy,
            Lazy<IRepository<UserRolesPartRecord>> userRolesRepositoryLazy)
        {
            OnActivated<NotificationBatchPart>((context, part) =>
            {
                part.RecipientsTypeField.Loader(() =>
                    {
                        var recipientsType = part.Retrieve<string>("RecipientsType");
                        if (string.IsNullOrEmpty(recipientsType)) return NotificationBatchRecipientsType.Role;
                        return (NotificationBatchRecipientsType)Enum.Parse(typeof(NotificationBatchRecipientsType), recipientsType);
                    });

                part.RecipientsTypeField.Setter(recipientsType =>
                    {
                        part.Store("RecipientsType", recipientsType.ToString());
                        return recipientsType;
                    });

                part.AvailableRolesField.Loader(() => roleServiceLazy.Value.GetRoles());

                part.RecipientListField.Loader(() => contentManager.Get(part.RecipientListId));

                part.AvailableRecipientListsField.Loader(() => contentManager.Query(Constants.RecipientListContentType).List());

                part.RecipientListField.Setter(recipientsList =>
                    {
                        part.RecipientListId = recipientsList != null ? recipientsList.ContentItem.Id : 0;
                        return recipientsList;
                    });

                part.ActualRecipientIdsField.Loader(() =>
                    {
                        IEnumerable<int> recipientIds;

                        switch (part.RecipientsType)
                        {
                            case NotificationBatchRecipientsType.Role:
                                recipientIds = userRolesRepositoryLazy.Value.Table
                                    .Where(record => record.Role.Id == part.RecipientsRoleId)
                                    .Select(record => record.UserId);
                                break;
                            case NotificationBatchRecipientsType.RecipientList:
                                recipientIds = part.RecipientList.As<NotificationRecipientsPart>().RecipientIds;
                                break;
                            case NotificationBatchRecipientsType.AdhocRecipients:
                                recipientIds = part.As<NotificationRecipientsPart>().RecipientIds;
                                break;
                            default:
                                throw new InvalidOperationException("Not supported recipient type.");
                        }

                        return recipientIds;
                    });

                part.ActualRecipientsField.Loader(() => contentManager.GetMany<IUser>(part.ActualRecipientIds, VersionOptions.Published, new QueryHints().ExpandParts<UserPart>()));
            });
        }
开发者ID:Lombiq,项目名称:Orchard-User-Notifications,代码行数:59,代码来源:NotificationBatchPartHandler.cs

示例7: ContentMenuItemPartHandler

        public ContentMenuItemPartHandler(IContentManager contentManager, IRepository<ContentMenuItemPartRecord> repository) {
            _contentManager = contentManager;
            Filters.Add(new ActivatingFilter<ContentMenuItemPart>("ContentMenuItem"));
            Filters.Add(StorageFilter.For(repository));

            OnLoading<ContentMenuItemPart>((context, part) => part._content.Loader(p => {
                if (part.ContentItemId != null) {
                    return contentManager.Get(part.ContentItemId.Value);
                }

                return null;
            }));
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:13,代码来源:ContentMenuItemPartHandler.cs

示例8: OfflinePaymentSettingsPartHandler

        public OfflinePaymentSettingsPartHandler(IContentManager contentManager)
        {
            _contentManager = contentManager;
            Filters.Add(new ActivatingFilter<OfflinePaymentSettingsPart>("Site"));

            OnLoading<OfflinePaymentSettingsPart>((context, part) => part._content.Loader(p => {
                if (part.ContentItemId != null) {
                    return contentManager.Get(part.ContentItemId.Value);
                }

                return null;
            }));
        }
开发者ID:rtpHarry,项目名称:OShop,代码行数:13,代码来源:OfflinePaymentSettingsPartHandler.cs

示例9: RoutePartHandler

        public RoutePartHandler(
            IOrchardServices services,
            IRepository<RoutePartRecord> repository,
            IRoutablePathConstraint routablePathConstraint,
            IRoutableService routableService,
            IContentManager contentManager,
            IWorkContextAccessor workContextAccessor,
            IEnumerable<IHomePageProvider> homePageProviders) {
            _services = services;
            _routablePathConstraint = routablePathConstraint;
            _routableService = routableService;
            _contentManager = contentManager;
            _workContextAccessor = workContextAccessor;
            _routableHomePageProvider = homePageProviders.SingleOrDefault(p => p.GetProviderName() == RoutableHomePageProvider.Name);
            T = NullLocalizer.Instance;

            Filters.Add(StorageFilter.For(repository));

            Action<RoutePart> processSlug = (
                routable => {
                    if (!_routableService.ProcessSlug(routable))
                        _services.Notifier.Warning(T("Permalinks in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",
                                                     routable.Slug, routable.GetEffectiveSlug(), routable.ContentItem.ContentType));
                });

            OnGetDisplayShape<RoutePart>(SetModelProperties);
            OnGetEditorShape<RoutePart>(SetModelProperties);
            OnUpdateEditorShape<RoutePart>(SetModelProperties);

            Action<PublishContentContext, RoutePart> handler = (context, route) => {
                FinalizePath(route, context, processSlug);

                if (_routableHomePageProvider == null)
                    return;

                var homePageSetting = _workContextAccessor.GetContext().CurrentSite.HomePage;
                var currentHomePageId = !string.IsNullOrWhiteSpace(homePageSetting)
                                            ? _routableHomePageProvider.GetHomePageId(homePageSetting)
                                            : 0;

                if (route.Id != 0 && (route.Id == currentHomePageId || route.PromoteToHomePage)) {

                    if (currentHomePageId != route.Id) {
                        // reset the path on the current home page
                        var currentHomePage = _contentManager.Get(currentHomePageId);
                        if (currentHomePage != null)
                            FinalizePath(currentHomePage.As<RoutePart>(), context, processSlug);
                        // set the new home page
                        _services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(route.ContentItem.Id);
                    }

                    // readjust the constraints of the current current home page
                    _routablePathConstraint.RemovePath(route.Path);
                    route.Path = "";
                    _routableService.FixContainedPaths(route);
                    _routablePathConstraint.AddPath(route.Path);
                }
            };

            OnPublished<RoutePart>(handler);
            OnUnpublished<RoutePart>(handler);

            OnRemoved<RoutePart>((context, route) => {
                if (!string.IsNullOrWhiteSpace(route.Path))
                    _routablePathConstraint.RemovePath(route.Path);
            });

            OnIndexing<RoutePart>((context, part) => context.DocumentIndex.Add("title", part.Record.Title).RemoveTags().Analyze());
        }
开发者ID:juaqaai,项目名称:CompanyGroup,代码行数:69,代码来源:RoutePartHandler.cs

示例10: CaptchaService

 public CaptchaService(IContentManager contentManager, ISiteService siteService)
 {
     CaptchaPart = contentManager.Get<CaptchaSettingsPart>(1);
     CurrentCulture = siteService.GetSiteSettings().SiteCulture;
     T = NullLocalizer.Instance;
 }
开发者ID:denkhaus,项目名称:Orchard.Captcha,代码行数:6,代码来源:CaptchaService.cs


注:本文中的IContentManager.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。