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


C# AttributeService.ToList方法代码示例

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


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

示例1: GetEntityFields


//.........这里部分代码省略.........
                    // Enum Properties
                    if ( property.PropertyType.IsEnum )
                    {
                        entityProperty = new EntityField( property.Name, FieldKind.Property, property.PropertyType, 1 );
                        entityProperty.FilterFieldType = SystemGuid.FieldType.MULTI_SELECT;
                    }

                    // Boolean properties
                    if ( property.PropertyType == typeof( bool ) || property.PropertyType == typeof( bool? ) )
                    {
                        entityProperty = new EntityField( property.Name, FieldKind.Property, property.PropertyType, 1 );
                        entityProperty.FilterFieldType = SystemGuid.FieldType.SINGLE_SELECT;
                    }

                    // Date properties
                    if ( property.PropertyType == typeof( DateTime ) || property.PropertyType == typeof( DateTime? ) )
                    {
                        entityProperty = new EntityField( property.Name, FieldKind.Property, property.PropertyType, 2 );
                        entityProperty.FilterFieldType = SystemGuid.FieldType.DATE;
                    }

                    // Text Properties
                    else if ( property.PropertyType == typeof( string ) )
                    {
                        entityProperty = new EntityField( property.Name, FieldKind.Property, property.PropertyType, 2 );
                        entityProperty.FilterFieldType = SystemGuid.FieldType.TEXT;
                    }

                    // Integer Properties
                    else if ( property.PropertyType == typeof( int ) || property.PropertyType == typeof( int? ) )
                    {
                        var definedValueAttribute = property.GetCustomAttributes( typeof( Rock.Data.DefinedValueAttribute ), true ).FirstOrDefault();

                        if ( definedValueAttribute != null )
                        {
                            // Defined Value Properties
                            entityProperty = new EntityField( property.Name, FieldKind.Property, property.PropertyType, 1 );
                            var definedType = DefinedTypeCache.Read( ( (Rock.Data.DefinedValueAttribute)definedValueAttribute ).DefinedTypeGuid );
                            entityProperty.Title = definedType != null ? definedType.Name : property.Name.Replace( "ValueId", string.Empty ).SplitCase();
                            entityProperty.FilterFieldType = SystemGuid.FieldType.MULTI_SELECT;
                            entityProperty.DefinedTypeGuid = definedType.Guid;
                        }
                        else
                        {
                            entityProperty = new EntityField( property.Name, FieldKind.Property, property.PropertyType, 2 );
                            entityProperty.FilterFieldType = SystemGuid.FieldType.INTEGER;
                        }
                    }

                    if ( entityProperty != null )
                    {
                        entityProperty.IsPreviewable = property.GetCustomAttributes( typeof( PreviewableAttribute ), true ).Any();
                        if ( includeOnlyReportingFields )
                        {
                            bool isReportable = !property.GetCustomAttributes( typeof( HideFromReportingAttribute ), true ).Any();
                            if ( isReportable )
                            {
                                entityFields.Add( entityProperty );
                            }
                        }
                        else
                        {
                            entityFields.Add( entityProperty );
                        }
                    }
                }
            }

            // Get Attributes
            int entityTypeId = EntityTypeCache.Read( entityType ).Id;
            var rockContext = new RockContext();
            var qryAttributes = new AttributeService( rockContext ).Queryable().Where( a => a.EntityTypeId == entityTypeId );
            if ( entityType == typeof( Group ) )
            {
                // in the case of Group, show attributes that are entity global, but also ones that are qualified by GroupTypeId
                qryAttributes = qryAttributes.Where( a => a.EntityTypeQualifierColumn == string.Empty || a.EntityTypeQualifierColumn == "GroupTypeId" );
            }
            else
            {
                qryAttributes = qryAttributes.Where( a => a.EntityTypeQualifierColumn == string.Empty && a.EntityTypeQualifierValue == string.Empty );
            }

            var attributeList = qryAttributes.ToList();

            foreach ( var attribute in attributeList )
            {
                AddEntityFieldForAttribute( entityFields, AttributeCache.Read( attribute.Id ) );
            }

            int index = 1;
            _entityFields[entityType] = new List<EntityField>();
            foreach ( var entityProperty in entityFields.OrderBy( p => p.Title ).ThenBy( p => p.Name ) )
            {
                entityProperty.Index = index;
                index += entityProperty.ControlCount;
                _entityFields[entityType].Add( entityProperty );
            }

            return _entityFields[entityType];
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:101,代码来源:EntityHelper.cs

示例2: rGridAttribute_Bind

        /// <summary>
        /// Binds the grid for type attributes.
        /// </summary>
        /// <param name="typeId">The type id.</param>
        protected void rGridAttribute_Bind( string typeId )
        {
            var queryable = new AttributeService().Queryable().
                Where( a => a.EntityTypeId == _entityTypeId &&
                ( a.EntityTypeQualifierColumn ?? string.Empty ) == _entityQualifier &&
                ( a.EntityTypeQualifierValue ?? string.Empty ) == typeId );

            SortProperty sortProperty = rGridAttribute.SortProperty;
            if ( sortProperty != null )
                queryable = queryable.
                    Sort( sortProperty );
            else
                queryable = queryable.
                OrderBy( a => a.Category ).
                ThenBy( a => a.Key );

            rGridAttribute.DataSource = queryable.ToList();
            rGridAttribute.DataBind();
        }
开发者ID:jh2mhs8,项目名称:Rock-ChMS,代码行数:23,代码来源:DefinedTypes.ascx.cs


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