Base Index Model
Inheritance: System.Dynamic.DynamicObject, Lava.ILiquidizable
コード例 #1
0
        /// <summary>
        /// Adds the indexable attributes.
        /// </summary>
        /// <param name="indexModel">The index model.</param>
        /// <param name="sourceModel">The source model.</param>
        protected static void AddIndexableAttributes(IndexModelBase indexModel, Attribute.IHasAttributes sourceModel)
        {
            sourceModel.LoadAttributes();

            foreach (var attributeValue in sourceModel.AttributeValues)
            {
                // check that the attribute is marked as IsIndexEnabled
                var attribute = AttributeCache.Get(attributeValue.Value.AttributeId);

                if (attribute.IsIndexEnabled)
                {
                    var key = attributeValue.Key;

                    // remove invalid characters
                    key = key.Replace(".", "_");
                    key = key.Replace(",", "_");
                    key = key.Replace("#", "_");
                    key = key.Replace("*", "_");
                    key = key.StartsWith("_") ? key.Substring(1) : key;

                    indexModel[key] = attributeValue.Value.ValueFormatted;
                }
            }
        }
コード例 #2
0
ファイル: IndexModelBase.cs プロジェクト: NewSpring/Rock
        /// <summary>
        /// Adds the indexable attributes.
        /// </summary>
        /// <param name="indexModel">The index model.</param>
        /// <param name="sourceModel">The source model.</param>
        protected static void AddIndexableAttributes( IndexModelBase indexModel, IHasAttributes sourceModel )
        {
            sourceModel.LoadAttributes();

            foreach ( var attributeValue in sourceModel.AttributeValues )
            {
                // check that the attribute is marked as IsIndexEnabled
                var attribute = AttributeCache.Read(attributeValue.Value.AttributeId);

                if ( attribute.IsIndexEnabled )
                {

                    var key = attributeValue.Key;

                    // remove invalid characters
                    key = key.Replace( ".", "_" );
                    key = key.Replace( ",", "_" );
                    key = key.Replace( "#", "_" );
                    key = key.Replace( "*", "_" );
                    key = key.StartsWith( "_" ) ? key.Substring( 1 ) : key;

                    indexModel[key] = attributeValue.Value.ValueFormatted;
                }
            }
        }