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


C# IContent.GetType方法代码示例

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


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

示例1: IndexContentPage

        public static int IndexContentPage(IContent content)
        {
            // Does this type have any CategoryAssignment properties?
            if (!HasCategoryAssignments(content))
            {
                return 0;
            }

            var baseType = content.GetType().BaseType;

            var contentRef = content.ContentLink.ToReferenceWithoutVersion();

            var categoryRepo = ServiceLocator.Current.GetInstance<ICategoryRepository>();
            categoryRepo.DeleteAssignmentsByContent(contentRef);

            var assignmentsAdded = 0;
            foreach (var propertyName in CategoryAssignmentProperties[baseType])
            {
                var propertyData = content.Property[propertyName].Value;
                if(propertyData == null)
                {
                    continue;
                }
                foreach (var value in (IEnumerable<ContentReference>)propertyData)
                {
                    assignmentsAdded++;
                    categoryRepo.AddAssignment(contentRef, value, propertyName);
                }
            }

            return assignmentsAdded;
        }
开发者ID:deanebarker,项目名称:Episerver-Extended-Categories,代码行数:32,代码来源:CategoriesManager.cs

示例2: Create

        public PageContentProjection Create(IPageContent pageContent, IContent content, IList<IOption> options)
        {
            IContentAccessor contentAccessor = null;
            Type contentType;

            if (content is IProxy)
            {
                contentType = content.GetType().BaseType;
            }
            else
            {
                contentType = content.GetType();
            }

            string key = "CONTENTRENDERER-" + contentType.Name.ToUpperInvariant();

            if (containerProvider.CurrentScope.IsRegisteredWithKey<IContentAccessor>(key))
            {
                contentAccessor = containerProvider.CurrentScope
                    .ResolveKeyed<IContentAccessor>(key, new Parameter[]
                                                             {
                                                                 new PositionalParameter(0, content),
                                                                 new PositionalParameter(1, options)
                                                             });
            }

            if (contentAccessor == null)
            {
                Log.Error(string.Format("A content accessor was not found for the content type {0} with id={1}.", content.GetType().FullName, content.Id));

                contentAccessor = new EmptyContentAccessor(string.Format("<i style=\"color:red;\">{0}</i>", RootGlobalization.Message_FailedToRenderContent));
            }

            PageContentProjection pageContentProjection = new PageContentProjection(pageContent, content, contentAccessor);

            return pageContentProjection;
        }
开发者ID:tkirda,项目名称:BetterCMS,代码行数:37,代码来源:PageContentProjectionFactory.cs

示例3: ContentInfo

        public ContentInfo(IContent content)
        {
            this.Id = content.Id;
            this.ContentTypeName = content.ContentType.TypeName;
            this.PropertyTypeNames = new List<string>();
            this.Name = content.Name;
            this.Version = content.Version;
            this.Status = content.Status;
            this.Culture = content.Culture;
            this.ContentType = content.GetType();

            string propertyTypeName = string.Empty;

            foreach (var property in content.ContentType.Properties)
            {
                propertyTypeName = property.GetType().FullName;

                if (!string.IsNullOrWhiteSpace(propertyTypeName))
                {
                    this.PropertyTypeNames.Add(propertyTypeName);
                }

            }
        }
开发者ID:mchound,项目名称:LewCMS,代码行数:24,代码来源:IContentInfo.cs

示例4: ResolvePath

        /// <summary>
        /// Resolves the path.
        /// </summary>
        /// <param name="routeData">The route data.</param>
        /// <param name="virtualUrl">The virtual URL.</param>
        /// <returns></returns>
        public IPathData ResolvePath(RouteData routeData, string virtualUrl)
        {
            // Set the default action to index
            _pathData.Action = UIRoute.DefaultAction;
            // Get an up to date document session from structuremap
            _session = _container.GetInstance<IDocumentSession>();

            // The requested url is for the start page with no action
            if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl, "/")) {

                _pageModel = _session.Query<IPageModel>()
                    .Customize(x => x.Include<IPageModel>(y => y.ContentReference))
                    .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                    .SingleOrDefault(x => x.Parent == null);

            } else {

                // Remove the trailing slash
                virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl).TrimStart(new[] { '/' });
                // The normal beahaviour should be to load the page based on the url
                _pageModel = _session.Query<IPageModel, PageByUrl>()
                    .Customize(x => x.Include<IPageModel>(y => y.ContentReference))
                    .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                    .FirstOrDefault(x => x.Metadata.Url == virtualUrl);
                // Try to load the page without the last segment of the url and set the last segment as action))
                if (_pageModel == null && virtualUrl.LastIndexOf("/") > 0) {
                    var index = virtualUrl.LastIndexOf("/");
                    var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] { '/' });
                    virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' });
                    _pageModel = _session.Query<IPageModel, PageByUrl>()
                        .Customize(x => x.Include<IPageModel>(y => y.ContentReference))
                        .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                        .FirstOrDefault(x => x.Metadata.Url == virtualUrl);
                    _pathData.Action = action;
                }
                // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl)
                if (_pageModel == null) {
                    _pageModel = _session.Query<IPageModel>()
                        .Customize(x => x.Include<IPageModel>(y => y.ContentReference))
                        .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                        .SingleOrDefault(x => x.Parent == null);
                    if(_pageModel == null) {
                        return null;
                    }
                    _content = _session.Load<IContent>(_pageModel.ContentReference);
                    var contentTypeAttribute = _content.GetType().GetAttribute<ContentTypeAttribute>();
                    object area;
                    _controllerName = _controllerMapper.GetControllerName(routeData.Values.TryGetValue("area", out area) ? typeof(PagesController) : contentTypeAttribute.ControllerType);
                    var action = virtualUrl.TrimStart(new[] { '/' });
                    if (!_controllerMapper.ControllerHasAction(_controllerName, action)) {
                        return null;
                    }
                    _pathData.Action = action;
                }
            }

            if (_pageModel == null) {
                return null;
            }
            _content = _session.Load<IContent>(_pageModel.ContentReference);
            var controllerType = _content.GetType().GetAttribute<ContentTypeAttribute>().ControllerType;
            _pathData.CurrentContent = _content;
            _pathData.Controller = controllerType != null ? _controllerMapper.GetControllerName(controllerType) : null;
            _pathData.CurrentPage = _pageModel;
            _pathData.NavigationContext = _session.GetPublishedPages(_pageModel.Id);
            return _pathData;
        }
开发者ID:bbqchickenrobot,项目名称:brickpile,代码行数:73,代码来源:PathResolver.cs

示例5: ShowContentInfo

        private void ShowContentInfo(IContent content)
        {
            Assembly assembly = content.GetType().Assembly;
            string s = string.Empty;
            s += string.Format("位置: {0}\r\n", assembly.Location);
            s += string.Format("名称: {0}\r\n", content.Name);
            s += string.Format("描述: {0}\r\n", content.Description);
            s += string.Format("版本: {0}\r\n", assembly.GetName ().Version);

            this.txtContent.Text = s;
        }
开发者ID:hkiaipc,项目名称:qa,代码行数:11,代码来源:frmContentManager.cs

示例6: Add

 /// <summary>
 /// 
 /// </summary>
 /// <param name="content"></param>
 private void Add(IContent content)
 {
     this.lstContent.Items.Add(content.GetType().FullName);
     this._contentList.Add(content);
 }
开发者ID:hkiaipc,项目名称:qa,代码行数:9,代码来源:frmContentManager.cs

示例7: HasCategoryAssignments

 public static bool HasCategoryAssignments(IContent content)
 {
     return CategoryAssignmentProperties.ContainsKey(content.GetType().BaseType);
 }
开发者ID:deanebarker,项目名称:Episerver-Extended-Categories,代码行数:4,代码来源:CategoriesManager.cs

示例8: OnSerialization

 public void OnSerialization(IContent content, JObject jObject)
 {
     jObject.Add(Constants.InheritanceFieldName, JToken.FromObject(content.GetType().GetInheritancHierarchy()));
 }
开发者ID:kneeclass,项目名称:ElasticEPi,代码行数:4,代码来源:TypesModifiers.cs


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