예제 #1
0
        public string GenerateMetaTags(SearchModelBase searchModel)
        {
            var sb = new StringBuilder();
            var searchModelType = searchModel.GetType();
            var properties = searchModelType.GetProperties();

            foreach (var propertyInfo in properties) {

                if(Ignore(propertyInfo)) continue;

                var value = GetValue(propertyInfo, searchModel);
                if (value == null)
                    value = "null";

                var name = GetName(propertyInfo);

                if(name.ToLower() == Constants.SeekitTypedModelsName.ToLower())
                    throw new DuplicateNameException("The propetyname: " +Constants.SeekitTypedModelsName +" is used internaly by seekit and may not be used as a SearchModel property name");

                var metaTag = string.Format(Constants.SeekitMetaTagFormat,
                    name,
                    value,
                    GetType(propertyInfo),
                    IsFacet(propertyInfo));

                sb.AppendLine(metaTag);
            }

            sb.AppendLine(SearchModelTypes(searchModel));

            return sb.ToString();
        }
예제 #2
0
        private string SearchModelTypes(SearchModelBase searchModel)
        {
            var currentType = searchModel.GetType();
            var typesList   = new List <string>();

            while (currentType != null && currentType.FullName != "System.Object")
            {
                typesList.Add(currentType.JsonNetFormat());
                currentType = currentType.BaseType;
            }
            return(string.Format(Constants.SeekitMetaTagFormat,
                                 Constants.SeekitTypedModelsName,
                                 HttpUtility.HtmlEncode(JsonConvert.SerializeObject(typesList)),
                                 "IEnumerable",
                                 false));
        }
예제 #3
0
        public string GenerateMetaTags(SearchModelBase searchModel)
        {
            var sb = new StringBuilder();
            var searchModelType = searchModel.GetType();
            var properties      = searchModelType.GetProperties();

            foreach (var propertyInfo in properties)
            {
                if (Ignore(propertyInfo))
                {
                    continue;
                }

                var value = GetValue(propertyInfo, searchModel);
                if (value == null)
                {
                    value = "null";
                }

                var name = GetName(propertyInfo);

                if (name.ToLower() == Constants.SeekitTypedModelsName.ToLower())
                {
                    throw new DuplicateNameException("The propetyname: " + Constants.SeekitTypedModelsName + " is used internaly by seekit and may not be used as a SearchModel property name");
                }

                var metaTag = string.Format(Constants.SeekitMetaTagFormat,
                                            name,
                                            value,
                                            GetType(propertyInfo),
                                            IsFacet(propertyInfo));

                sb.AppendLine(metaTag);
            }

            sb.AppendLine(SearchModelTypes(searchModel));

            return(sb.ToString());
        }
예제 #4
0
 private string SearchModelTypes(SearchModelBase searchModel)
 {
     var currentType = searchModel.GetType();
     var typesList = new List<string>();
     while (currentType != null && currentType.FullName != "System.Object") {
         typesList.Add(currentType.JsonNetFormat());
         currentType = currentType.BaseType;
     }
     return string.Format(Constants.SeekitMetaTagFormat,
                 Constants.SeekitTypedModelsName,
                 HttpUtility.HtmlEncode(JsonConvert.SerializeObject(typesList)),
                 "IEnumerable",
                 false);
 }