示例#1
0
        private void InitControl(IEnumerable <ContentType> contentTypes)
        {
            // if empty, set types defined on CTD
            string contentTypeNames;

            if (contentTypes == null || contentTypes.Count() == 0)
            {
                contentTypeNames = string.Join(" ", CTDContentTypeNames.OrderBy(t => t));
            }
            else
            {
                contentTypeNames = string.Join(" ", contentTypes.Select(t => t.Name).OrderBy(t => t));
            }

            var editControl = this.InnerControl;

            if (editControl != null)
            {
                editControl.Text = contentTypeNames;
            }

            var browseControl = GetInnerControl() as Label;

            if (browseControl != null)
            {
                browseControl.Text = contentTypeNames;
            }
        }
        private void InitControl(IEnumerable <ContentType> contentTypes)
        {
            var editControl   = this.InnerControl;
            var browseControl = GetInnerControl() as Label;


            // if empty, set types defined on CTD
            string contentTypeNames;

            if (!IsNewSkin)
            {
                if (contentTypes == null || contentTypes.Count() == 0)
                {
                    contentTypeNames = string.Join(" ", CTDContentTypeNames.OrderBy(t => t));
                }
                else
                {
                    contentTypeNames = string.Join(" ", contentTypes.Select(t => t.Name).OrderBy(t => t));
                }

                if (editControl != null)
                {
                    editControl.Text = contentTypeNames;
                }


                if (browseControl != null)
                {
                    browseControl.Text = contentTypeNames;
                }
            }
            else
            {
                var    js = new JavaScriptSerializer();
                string contentTypeList;

                if (contentTypes == null || contentTypes.Count() == 0)
                {
                    var list = CTDContentTypes
                               .Select(c => SenseNet.ContentRepository.Content.Create(c))
                               .Select(i => new { i.DisplayName, i.Icon, i.Path, i.Name })
                               .Distinct()
                               .OrderByDescending(i => i.Name);

                    contentTypeList = js.Serialize(list);
                }
                else
                {
                    var list = contentTypes
                               .Select(c => SenseNet.ContentRepository.Content.Create(c))
                               .Select(i => new { i.DisplayName, i.Icon, i.Path, i.Name })
                               .Distinct()
                               .OrderByDescending(i => i.Name);
                    contentTypeList = js.Serialize(list);
                }


                if (editControl != null)
                {
                    editControl.Text = contentTypeList.ToString();
                }


                if (browseControl != null)
                {
                    browseControl.Text = contentTypeList;
                }
            }
        }