示例#1
0
        public UpdateRequest AddObject <T>(IList <T> objs, IDataMappingHandler mappingHandler) where T : class, new()
        {
            if (objs == null)
            {
                throw new ArgumentNullException("objs");
            }
            if (mappingHandler == null)
            {
                throw new ArgumentNullException("mappingHandler");
            }
            var handler = mappingHandler.GetMappingHandler <T>();

            if (handler == null)
            {
                throw new MizoreMappingException(mappingHandler, "Can't map the type " + typeof(T).Name);
            }

            if (_documents == null)
            {
                _documents = new List <SolrInputDocument>();
            }

            foreach (var obj in objs)
            {
                if (obj == null)
                {
                    continue;
                }
                _documents.Add(handler.GetDocument(obj));
            }
            _changed = true;
            return(this);
        }
示例#2
0
文件: Program.cs 项目: hiiru/Mizore
 private static void AddObject(ISolrServerHandler server, SimpleBook book, IDataMappingHandler mapper)
 {
     var doc = mapper.GetDocument(book);
     var updateRequest = new UpdateRequest(server.GetUriBuilder()).Add(doc).Commit(true);
     //if (updateRequest.Content != null)
     //{
     //    using (var requestStream = File.OpenWrite("update.json"))
     //    {
     //        server.SerializerFactory.DefaultSerializer.Serialize(updateRequest.Content, requestStream);
     //    }
     //}
     server.Request<UpdateResponse>(updateRequest);
 }
示例#3
0
        public T GetObject <T>(IDataMappingHandler mapping) where T : class, new()
        {
            if (mapping == null)
            {
                return(null);
            }
            var handler = mapping.GetMappingHandler <T>();

            if (handler == null)
            {
                return(null);
            }
            return(handler.GetObject(Document));
        }
示例#4
0
文件: Program.cs 项目: hiiru/Mizore
        private static void AddObject(ISolrServerHandler server, SimpleBook book, IDataMappingHandler mapper)
        {
            var doc           = mapper.GetDocument(book);
            var updateRequest = new UpdateRequest(server.GetUriBuilder()).Add(doc).Commit(true);

            //if (updateRequest.Content != null)
            //{
            //    using (var requestStream = File.OpenWrite("update.json"))
            //    {
            //        server.SerializerFactory.DefaultSerializer.Serialize(updateRequest.Content, requestStream);
            //    }
            //}
            server.Request <UpdateResponse>(updateRequest);
        }
示例#5
0
        public IList <T> GetObjects <T>(IDataMappingHandler mapping) where T : class, new()
        {
            if (mapping == null)
            {
                return(null);
            }
            var handler = mapping.GetMappingHandler <T>();

            if (handler == null)
            {
                return(null);
            }
            var list = new List <T>(Documents.Count);

            foreach (var doc in Documents)
            {
                list.Add(handler.GetObject(doc));
            }
            return(list);
        }
示例#6
0
 public MizoreMappingException(IDataMappingHandler handler, string message, Exception innerException = null)
     : base(message, innerException)
 {
     DataMappingHandler = handler;
 }
示例#7
0
 public MizoreMappingException(IDataMappingHandler handler, Exception innerException)
     : this(handler, innerException.Message, innerException)
 {
 }
示例#8
0
 public MizoreMappingException(IDataMappingHandler handler, Exception innerException)
     : this(handler, innerException.Message, innerException)
 {
 }
示例#9
0
 public MizoreMappingException(IDataMappingHandler handler, string message, Exception innerException = null)
     : base(message, innerException)
 {
     DataMappingHandler = handler;
 }
示例#10
0
文件: Program.cs 项目: hiiru/Mizore
 private static SimpleBook GetObject(ISolrServerHandler server, string iban, IDataMappingHandler mapper)
 {
     var doc = Get(server, iban);
     return mapper.GetObject(doc) as SimpleBook;
 }
示例#11
0
文件: Program.cs 项目: hiiru/Mizore
        private static SimpleBook GetObject(ISolrServerHandler server, string iban, IDataMappingHandler mapper)
        {
            var doc = Get(server, iban);

            return(mapper.GetObject(doc) as SimpleBook);
        }