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


C# IContent.As方法代码示例

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


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

示例1: SetupViewModel

        public void SetupViewModel(FrontendContext frontendContext, IContent node, NodeViewModel viewModel)
        {
            if (node.ContentItem.ContentType != "WikipediaPage") return;

            viewModel.name = node.As<ITitleAspect>().Title;
            viewModel.data["url"] = node.As<WikipediaPagePart>().Url;
        }
开发者ID:Lombiq,项目名称:Associativy-Wikipedia-Instance,代码行数:7,代码来源:JitConfigurationHandler.cs

示例2: SetupViewModel

 public void SetupViewModel(FrontendContext frontendContext, IContent node, Frontends.Engines.Jit.ViewModels.NodeViewModel viewModel)
 {
     if (node.ContentItem.ContentType == "AssociativyTagNode")
     {
         viewModel.name = node.As<IAssociativyNodeLabelAspect>().Label;
     }
     else viewModel.name = node.As<ITitleAspect>().Title;
 }
开发者ID:Lombiq,项目名称:Associativy-Tags-Adapter,代码行数:8,代码来源:FrontendConfigurationHandler.cs

示例3: GetForum

        public static ForumPart GetForum(IContent content) {
            var postPart = content.As<PostPart>();
            var threadPart = content.As<ThreadPart>();

            if (postPart == null) {
                return threadPart == null ? null : threadPart.ForumPart;
            }
            return postPart.ThreadPart.ForumPart;
        }
开发者ID:six006,项目名称:NGM.Forum,代码行数:9,代码来源:HierarchyHelpers.cs

示例4: ConvertBatchToNotification

 public INotification ConvertBatchToNotification(IContent notificationBatch, IUser recipient)
 {
     return new Notification
     {
         Id = notificationBatch.ContentItem.Id,
         ContentItem = notificationBatch.ContentItem,
         TitleLazy = new Lazy<string>(() => _tokenizer.Replace(notificationBatch.As<TitlePart>().Title, new { User = recipient })),
         BodyLazy = new Lazy<string>(() => _tokenizer.Replace(notificationBatch.As<BodyPart>().Text, new { User = recipient }))
     };
 }
开发者ID:Lombiq,项目名称:Orchard-User-Notifications,代码行数:10,代码来源:NotificationConverter.cs

示例5: SetupViewModel

        public void SetupViewModel(FrontendContext frontendContext, IContent node, NodeViewModel viewModel)
        {
            // .Has<> doesn't work here
            if (node.As<ITitleAspect>() != null) viewModel.name = node.As<ITitleAspect>().Title;

            if (node.As<IAliasAspect>() != null)
            {
                viewModel.data["url"] = new UrlHelper(_orchardServices.WorkContext.HttpContext.Request.RequestContext)
                                            .RouteUrl(_orchardServices.ContentManager.GetItemMetadata(node).DisplayRouteValues);
            }
        }
开发者ID:Lombiq,项目名称:Associativy-Frontend-Engines,代码行数:11,代码来源:DefaultJitConfigurationHandler.cs

示例6:

        void ILocalizationService.SetContentCulture(IContent content, string culture) {
            var localized = content.As<LocalizationPart>();
            if (localized == null || localized.MasterContentItem == null)
                return;

            localized.Culture = _cultureManager.GetCultureByName(culture);
        }
开发者ID:sjbisch,项目名称:Orchard,代码行数:7,代码来源:LocalizationService.cs

示例7:

        IEnumerable<LocalizationPart> ILocalizationService.GetLocalizations(IContent content, VersionOptions versionOptions) {
            if (content.ContentItem.Id == 0)
                return Enumerable.Empty<LocalizationPart>();

            var localized = content.As<LocalizationPart>();

            var query = versionOptions == null
                ? _contentManager.Query<LocalizationPart>(localized.ContentItem.ContentType)
                : _contentManager.Query<LocalizationPart>(versionOptions, localized.ContentItem.ContentType);

            int contentItemId = localized.ContentItem.Id;

            if (localized.HasTranslationGroup) {
                int masterContentItemId = localized.MasterContentItem.ContentItem.Id;

                query = query.Where<LocalizationPartRecord>(l =>
                    l.Id != contentItemId // Exclude the content
                    && (l.Id == masterContentItemId || l.MasterContentItemId == masterContentItemId));
            }
            else {
                query = query.Where<LocalizationPartRecord>(l =>
                    l.MasterContentItemId == contentItemId);
            }

            // Warning: May contain more than one localization of the same culture.
            return query.List().ToList();
        }
开发者ID:RasterImage,项目名称:Orchard,代码行数:27,代码来源:LocalizationService.cs

示例8: GetTextDirection

        public static string GetTextDirection(this WorkContext workContext, IContent content) {
            var culture = workContext.CurrentSite.SiteCulture;
            if (content != null && content.Has<ILocalizableAspect>()) {
                culture = content.As<ILocalizableAspect>().Culture ?? culture;
            }

            return CultureInfo.GetCultureInfo(culture).TextInfo.IsRightToLeft ? "rtl" : "ltr"; ;
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:8,代码来源:LocalizationExtensions.cs

示例9: GetTemplates

        private IList<LayoutPart> GetTemplates(IContent content = null) {
            var query = _layoutManager.GetTemplates();
            var layoutPart = content != null ? content.As<LayoutPart>() : null;

            if (layoutPart != null) {
                query = query.Where(x => x.Id != layoutPart.Id);
            }

            return query.ToList();
        }
开发者ID:Higea,项目名称:Orchard,代码行数:10,代码来源:LayoutEditorFactory.cs

示例10: HasOwnership

        private static bool HasOwnership(IUser user, IContent content) {
            if (user == null || content == null)
                return false;

            var common = content.As<ICommonPart>();
            if (common == null || common.Owner == null)
                return false;

            return user.Id == common.Owner.Id;
        }
开发者ID:Vinna,项目名称:DeepInSummer,代码行数:10,代码来源:AuthorizationEventHandler.cs

示例11: HasOwnership

        private static bool HasOwnership(IUser user, IContent content)
        {
            if (user == null || content == null)
                return false;

            if (content.Is<CustomerPart>()) {
                var customer = content.As<CustomerPart>();
                return customer != null && user.Id == customer.UserId;
            }
            else if (content.Is<CustomerAddressPart>()) {
                var address = content.As<CustomerAddressPart>();
                return address != null && address.Customer != null && user.Id == address.Customer.UserId;
            }
            else if (content.Is<CustomerOrderPart>()) {
                var order = content.As<CustomerOrderPart>();
                return order != null && order.Customer != null && user.Id == order.Customer.UserId;
            }

            return false;
        }
开发者ID:rtpHarry,项目名称:OShop,代码行数:20,代码来源:CustomersAuthorizationEventHandler.cs

示例12: Invalidate

        private void Invalidate(IContent content) {
            // remove any page tagged with this content item id
            _cacheService.RemoveByTag(content.ContentItem.Id.ToString(CultureInfo.InvariantCulture));

            // search the cache for containers too
            var commonPart = content.As<CommonPart>();
            if (commonPart != null) {
                if (commonPart.Container != null) {
                    _cacheService.RemoveByTag(commonPart.Container.Id.ToString(CultureInfo.InvariantCulture));
                }
            }
        }
开发者ID:kanujhun,项目名称:orchard,代码行数:12,代码来源:CacheSettingsPartHandler.cs

示例13: BuildOrder

 public void BuildOrder(IShoppingCartService ShoppingCartService, IContent Order)
 {
     // Attach VAT infos to OrderDetails
     var orderPart = Order.As<OrderPart>();
     if (orderPart != null) {
         var vatParts = _contentManager.GetMany<VatPart>(orderPart.Details.Select(d => d.ContentId), VersionOptions.Published, QueryHints.Empty);
         foreach(var vatDetailPair in orderPart.Details.Join(vatParts, od => od.ContentId, vat => vat.Id, (od, vat) => new { Detail = od, Vat = vat})) {
             if (vatDetailPair.Vat.VatRate != null) {
                 vatDetailPair.Detail.SetProperty("VAT", new Tax(vatDetailPair.Vat.VatRate));
             }
         }
     }
 }
开发者ID:rtpHarry,项目名称:OShop,代码行数:13,代码来源:OrderVatResolver.cs

示例14: BuildOrder

        public void BuildOrder(IShoppingCartService ShoppingCartService, IContent Order)
        {
            var orderPart = Order.As<OrderPart>();
            if (orderPart != null) {
                var cartRecords = ShoppingCartService.ListItems();
                var products = ListProducts(cartRecords);
                foreach (var cartRecord in cartRecords.Where(cr => cr.ItemType == ProductPart.PartItemType)) {
                    var product = products.Where(p => p.Id == cartRecord.ItemId).FirstOrDefault();

                    if (product != null) {
                        orderPart.Details.Add(new OrderDetail(product, cartRecord.Quantity));
                    }
                }
            }
        }
开发者ID:rtpHarry,项目名称:OShop,代码行数:15,代码来源:ProductResolver.cs

示例15: OrderDetailUpdated

 public void OrderDetailUpdated(IContent order, OrderDetailRecord originalDetail, OrderDetailRecord updatedDetail)
 {
     if(originalDetail.ContentId == updatedDetail.ContentId) {
         var orderPart = order.As<OrderPart>();
         var stockPart = _contentManager.Get(updatedDetail.ContentId).As<StockPart>();
         if (stockPart != null && stockPart.EnableStockMgmt && orderPart != null) {
             if(orderPart.OriginalStatus != orderPart.OrderStatus) {
                 // OrderStatus changed
                 if (orderPart.OriginalStatus == OrderStatus.Canceled) {
                     if(orderPart.OrderStatus < OrderStatus.Completed) {
                         stockPart.InOrderQty += updatedDetail.Quantity;
                     }
                     else {
                         stockPart.InStockQty -= updatedDetail.Quantity;
                     }
                 }
                 else if (orderPart.OriginalStatus < OrderStatus.Completed) {
                     if (orderPart.OrderStatus == OrderStatus.Canceled) {
                         stockPart.InOrderQty -= originalDetail.Quantity;
                     }
                     else if (orderPart.OrderStatus == OrderStatus.Completed) {
                         stockPart.InOrderQty -= originalDetail.Quantity;
                         stockPart.InStockQty -= updatedDetail.Quantity;
                     }
                     else {
                         stockPart.InOrderQty += updatedDetail.Quantity - originalDetail.Quantity;
                     }
                 }
                 else {
                     stockPart.InStockQty += originalDetail.Quantity;
                     if (orderPart.OrderStatus != OrderStatus.Canceled) {
                         stockPart.InOrderQty += updatedDetail.Quantity;
                     }
                 }
             }
             else {
                 // OrderStatus unchanged
                 if (originalDetail.Quantity != updatedDetail.Quantity) {
                     stockPart.InOrderQty += updatedDetail.Quantity - originalDetail.Quantity;
                 }
             }
         }
     }
     else {
         OrderDetailDeleted(order, originalDetail);
         OrderDetailCreated(order, updatedDetail);
     }
 }
开发者ID:rtpHarry,项目名称:OShop,代码行数:48,代码来源:StocksOrderEventHandler.cs


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