Base Index Model
Inheritance: System.Dynamic.DynamicObject, Lava.ILiquidizable
Esempio n. 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;
                }
            }
        }
Esempio n. 2
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, 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;
                }
            }
        }