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


C# MappingManager.Add方法代码示例

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


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

示例1: Add_duplicate_property_overwrites

 public void Add_duplicate_property_overwrites() {
     var mgr = new MappingManager();
     mgr.Add(typeof (Entity).GetProperty("Id"), "id");
     mgr.Add(typeof (Entity).GetProperty("Id"), "id2");
     var fields = mgr.GetFields(typeof (Entity));
     Assert.AreEqual(1, fields.Count);
     Assert.AreEqual("id2", fields.First().Value.FieldName);
 }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:8,代码来源:MappingManagerTests.cs

示例2: MappedPropertyForWhichSolrFieldExistsInSchemaShouldNotReturnError

        public void MappedPropertyForWhichSolrFieldExistsInSchemaShouldNotReturnError() {
            var mgr = new MappingManager();
            mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("ID"), "id");
            mgr.SetUniqueKey(typeof (SchemaMappingTestDocument).GetProperty("ID"));
            mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("Name"), "name");

            var schemaManager = new MappingValidator(mgr, new[] {new MappedPropertiesIsInSolrSchemaRule()});

            var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml");
            var solrSchemaParser = new SolrSchemaParser();
            var schema = solrSchemaParser.Parse(schemaXmlDocument);

            var validationResults = schemaManager.EnumerateValidationResults(typeof (SchemaMappingTestDocument), schema).ToList();
            Assert.AreEqual(0, validationResults.Count);
        }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:15,代码来源:MappedPropertiesIsInSolrSchemaRuleTests.cs

示例3: MakeMapper

 private static MappingManager MakeMapper(Type t)
 {
     // See https://github.com/mausch/SolrNet/blob/master/Documentation/Overriding-mapper.md
     var mapper = new MappingManager();
     foreach (var prop in t.GetProperties())
     {
         foreach (Attribute attribute in prop.GetCustomAttributes(true))
         {
             if (attribute is FieldAttribute)
             {
                 var fa = attribute as FieldAttribute;
                 string fieldName = string.IsNullOrWhiteSpace(fa.FieldName) ? prop.Name : fa.FieldName;
                 mapper.Add(prop, fieldName, fa.Boost);
             }
             else if (attribute is SolrFieldAttribute)
             {
                 var fa = attribute as SolrFieldAttribute;
                 string fieldName = string.IsNullOrWhiteSpace(fa.FieldName) ? prop.Name : fa.FieldName;
                 mapper.Add(prop, fieldName, fa.Boost);
             }
             if (attribute is UniqueKeyAttribute)
             {
                 var uka = attribute as UniqueKeyAttribute;
                 mapper.SetUniqueKey(prop);
             }
             if (attribute is SolrUniqueKeyAttribute)
             {
                 var uka = attribute as SolrUniqueKeyAttribute;
                 mapper.SetUniqueKey(prop);
             }
         }
     }
     return mapper;
 }
开发者ID:Crownpeak,项目名称:Search-Results-Examples,代码行数:34,代码来源:Utils.cs

示例4: MappingTypesAreCompatibleWithSolrTypesRule_with_nonexistant_rule

 public void MappingTypesAreCompatibleWithSolrTypesRule_with_nonexistant_rule()
 {
     var rule = new MappingTypesAreCompatibleWithSolrTypesRule(new[] {new StringSolrFieldTypeChecker()});
     var mappingManager = new MappingManager();
     mappingManager.Add(typeof (SchemaMappingTestDocument).GetProperty("Name"));
     var validations = rule.Validate(typeof (SchemaMappingTestDocument), new SolrSchema(), mappingManager).ToList();
 }
开发者ID:holytshirt,项目名称:SolrNet,代码行数:7,代码来源:MappingTypesAreCompatibleWithSolrTypesRuleTests.cs

示例5: AddAndGet

 public void AddAndGet()
 {
     var mgr = new MappingManager();
     mgr.Add(typeof (Entity).GetProperty("Id"), "id");
     var fields = mgr.GetFields(typeof (Entity));
     Assert.AreEqual(1, fields.Count);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:7,代码来源:MappingManagerTests.cs

示例6: SetupSolr

        private void SetupSolr() {
            Startup.InitContainer();

            Startup.Container.Remove<IReadOnlyMappingManager>();
            var mapper = new MappingManager();
            mapper.Add(typeof (Entity).GetProperty("Description"), "name");
            mapper.Add(typeof (Entity).GetProperty("Id"), "id");
            mapper.Add(typeof (Entity).GetProperty("Tags"), "cat");
            Startup.Container.Register<IReadOnlyMappingManager>(c => mapper);

            Startup.Container.Remove<ISolrDocumentPropertyVisitor>();
            var propertyVisitor = new DefaultDocumentVisitor(mapper, Startup.Container.GetInstance<ISolrFieldParser>());
            Startup.Container.Register<ISolrDocumentPropertyVisitor>(c => propertyVisitor);

            Startup.Init<Entity>("http://localhost:8983/solr");
            var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Entity>>();
            solr.Delete(SolrQuery.All).Commit();
        }
开发者ID:tzsage,项目名称:LuceneExamples,代码行数:18,代码来源:Runner.cs

示例7: MappedPropertiesIsInSolrSchemaRule_ignores_score

 public void MappedPropertiesIsInSolrSchemaRule_ignores_score()
 {
     var rule = new MappedPropertiesIsInSolrSchemaRule();
     var mapper = new MappingManager();
     mapper.Add(typeof (SchemaMappingTestDocument).GetProperty("Score"), "score");
     var results = rule.Validate(typeof (SchemaMappingTestDocument), new SolrSchema(), mapper).ToList();
     Assert.IsNotNull(results);
     Assert.AreEqual(0, results.Count);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:9,代码来源:MappedPropertiesIsInSolrSchemaRuleTests.cs

示例8: UniqueKey_Set_and_get

        public void UniqueKey_Set_and_get() {
            var mgr = new MappingManager();
            var property = typeof (Entity).GetProperty("Id");
            mgr.Add(property, "id");
            mgr.SetUniqueKey(property);
            var key = mgr.GetUniqueKey(typeof (Entity));

            Assert.AreEqual(property, key.Property);
            Assert.AreEqual("id", key.FieldName);
        }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:10,代码来源:MappingManagerTests.cs

示例9: DictionaryFields_are_ignored

 public void DictionaryFields_are_ignored()
 {
     var rule = new MappedPropertiesIsInSolrSchemaRule();
     var mapper = new MappingManager();
     mapper.Add(typeof(SchemaMappingTestDocument).GetProperty("DynamicMapped"), "ma_*");
     var schema = new SolrSchema();
     var fieldType = new SolrFieldType("string", "solr.StrField");
     schema.SolrFields.Add(new SolrField("ma_uaua", fieldType));
     var results = rule.Validate(typeof(SchemaMappingTestDocument), new SolrSchema(), mapper).ToList();
     Assert.AreEqual(0, results.Count);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:11,代码来源:MappedPropertiesIsInSolrSchemaRuleTests.cs

示例10: SchemaNull_MappingNotNull_generates_error

 public void SchemaNull_MappingNotNull_generates_error() {
     var rule = new UniqueKeyMatchesMappingRule();
     var mapper = new MappingManager();
     var idProperty = typeof (SchemaMappingTestDocument).GetProperty("ID");
     mapper.Add(idProperty);
     mapper.SetUniqueKey(idProperty);
     var validations = rule.Validate(typeof (SchemaMappingTestDocument), new SolrSchema(), mapper).ToList();
     Assert.IsNotNull(validations);
     Assert.AreEqual(1, validations.Count);
     foreach (var v in validations)
         Console.WriteLine("{0}: {1}", v.GetType(), v.Message);
     Assert.IsInstanceOfType<ValidationError>(validations[0]);
 }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:13,代码来源:UniqueKeyMatchesMappingRuleTests.cs

示例11: MultivaluedSolrFieldMappedToCollectionShouldNotReturnError

        public void MultivaluedSolrFieldMappedToCollectionShouldNotReturnError() {
            var mgr = new MappingManager();
            mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("NameCollection"), "name");

            var schemaManager = new MappingValidator(mgr, new[] {new MultivaluedMappedToCollectionRule()});

            var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaMultiValuedName.xml");
            var solrSchemaParser = new SolrSchemaParser();
            var schema = solrSchemaParser.Parse(schemaXmlDocument);

            var validationResults = schemaManager.EnumerateValidationResults(typeof (SchemaMappingTestDocument), schema).ToList();
            Assert.AreEqual(0, validationResults.Count);
        }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:13,代码来源:MultivaluedMappedToCollectionRuleTests.cs

示例12: NonMatchingUniqueKeyMappingShouldReturnError

        public void NonMatchingUniqueKeyMappingShouldReturnError() {
            var mgr = new MappingManager();
            mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("Name"), "name");
            mgr.SetUniqueKey(typeof (SchemaMappingTestDocument).GetProperty("Name"));

            var schemaManager = new MappingValidator(mgr, new[] {new UniqueKeyMatchesMappingRule()});

            var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml");
            var solrSchemaParser = new SolrSchemaParser();
            var schema = solrSchemaParser.Parse(schemaXmlDocument);

            var validationResults = schemaManager.EnumerateValidationResults(typeof (SchemaMappingTestDocument), schema).ToList();
            Assert.AreEqual(1, validationResults.Count);
        }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:14,代码来源:UniqueKeyMatchesMappingRuleTests.cs

示例13: StringMappedToIntShouldReturnError

        public void StringMappedToIntShouldReturnError() {
            var mappingTypesCompatibleRule = new MappingTypesAreCompatibleWithSolrTypesRule(new[] {new StringSolrFieldTypeChecker()});

            var mgr = new MappingManager();
            mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("FieldNotSolrSchema"), "popularity");

            var schemaManager = new MappingValidator(mgr, new[] {mappingTypesCompatibleRule});

            var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaMappingTypes.xml");
            var solrSchemaParser = new SolrSchemaParser();
            var schema = solrSchemaParser.Parse(schemaXmlDocument);

            var validationResults = schemaManager.EnumerateValidationResults(typeof (SchemaMappingTestDocument), schema).ToList();
            Assert.AreEqual(1, validationResults.Count);
        }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:15,代码来源:MappingTypesAreCompatibleWithSolrTypesRuleTests.cs

示例14: Add_property_only

 public void Add_property_only()
 {
     var mgr = new MappingManager();
     var property = typeof (Entity).GetProperty("Id");
     mgr.Add(property);
     var fields = mgr.GetFields(typeof (Entity));
     Assert.AreEqual(1, fields.Count);
     Assert.AreEqual("Id", fields.First().Value.FieldName);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:9,代码来源:MappingManagerTests.cs

示例15: GetRegistered

 public void GetRegistered()
 {
     var mgr = new MappingManager();
     mgr.Add(typeof(Entity).GetProperty("Id"), "id");
     var types = mgr.GetRegisteredTypes();
     Assert.AreEqual(1, types.Count);
     Assert.Contains(typeof(Entity), types.ToArray());
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:8,代码来源:MappingManagerTests.cs


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