/// <summary>
 /// Initializes a new instance of the <see cref="MongoWhereClauseExpressionTreeVisitor"/> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 private ProjectionBuilder(IMappingStore mappingStore, ParameterExpression documentParameter)
 {
     this.mappingStore = mappingStore;
     this.resultObjectMappingParameter = documentParameter;
     this.fields = new Document();
     this.memberNames = new Stack<string>();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DocumentClassMapPropertyDescriptor"/> class.
        /// </summary>
        /// <param name="mappingStore">The mapping store.</param>
        /// <param name="classMap">The class map.</param>
        /// <param name="document">The document.</param>
        public DocumentClassMapPropertyDescriptor(IMappingStore mappingStore, IClassMap classMap, Document document)
            : base(mappingStore, classMap)
        {
            if (document == null)
                throw new ArgumentNullException("document");

            _document = document;
        }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "MongoConfiguration" /> class.
 /// </summary>
 public MongoConfiguration()
 {
     IsModifiable = true;
     _connectionString = string.Empty;
     _mappingStore = new AutoMappingStore();
     _serializationFactory = new SerializationFactory(this);
     _readLocalTime = true;
 }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "MongoConfiguration" /> class.
 /// </summary>
 public MongoConfiguration()
 {
     IsModifiable          = true;
     _connectionString     = string.Empty;
     _mappingStore         = new AutoMappingStore();
     _serializationFactory = new SerializationFactory(this);
     _readLocalTime        = true;
 }
        /// <summary>
        ///   Initializes a new instance of the <see cref = "AutoMappingStore" /> class.
        /// </summary>
        /// <param name = "autoMapper">The auto mapper.</param>
        /// <param name = "mappingStore">The mapping store.</param>
        public AutoMappingStore(IAutoMapper autoMapper, IMappingStore mappingStore)
        {
            if(autoMapper == null)
                throw new ArgumentNullException("autoMapper");

            _autoMapper = autoMapper;
            _autoMaps = new Dictionary<Type, IClassMap>();
            _wrappedMappingStore = mappingStore;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ExampleClassMapPropertyDescriptor"/> class.
        /// </summary>
        /// <param name="mappingStore">The mapping store.</param>
        /// <param name="classMap">The class map.</param>
        /// <param name="example">The example.</param>
        public ExampleClassMapPropertyDescriptor(IMappingStore mappingStore, IClassMap classMap, object example)
            : base(mappingStore, classMap)
        {
            if (example == null)
                throw new ArgumentNullException("example");

            _example = example;
            _exampleType = _example.GetType();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Cursor&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="serializationFactory">The serialization factory.</param>
 /// <param name="mappingStore">The mapping store.</param>
 /// <param name="connection">The conn.</param>
 /// <param name="databaseName">Name of the database.</param>
 /// <param name="collectionName">Name of the collection.</param>
 internal Cursor(ISerializationFactory serializationFactory, IMappingStore mappingStore, Connection connection, string databaseName, string collectionName)
 {
     //Todo: add public constrcutor for users to call
     IsModifiable          = true;
     _connection           = connection;
     _databaseName         = databaseName;
     FullCollectionName    = databaseName + "." + collectionName;
     _serializationFactory = serializationFactory;
     _mappingStore         = mappingStore;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ClassMapPropertyDescriptor"/> class.
        /// </summary>
        /// <param name="mappingStore">The mapping store.</param>
        /// <param name="classMap">The class map.</param>
        /// <param name="instance">The instance.</param>
        public ClassMapPropertyDescriptor(IMappingStore mappingStore, IClassMap classMap, object instance)
            : base(mappingStore, classMap)
        {
            if (instance == null)
                throw new ArgumentNullException("instance");

            _instance = instance;
            if (ClassMap.HasExtendedProperties)
                _extendedProperties = (IDictionary<string, object>)ClassMap.ExtendedPropertiesMap.GetValue(instance);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DocumentClassMapPropertyDescriptor"/> class.
        /// </summary>
        /// <param name="mappingStore">The mapping store.</param>
        /// <param name="classMap">The class map.</param>
        /// <param name="document">The document.</param>
        public DocumentClassMapPropertyDescriptor(IMappingStore mappingStore, IClassMap classMap, Document document)
            : base(mappingStore, classMap)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            _document = document;
        }
Beispiel #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExampleClassMapPropertyDescriptor"/> class.
        /// </summary>
        /// <param name="mappingStore">The mapping store.</param>
        /// <param name="classMap">The class map.</param>
        /// <param name="example">The example.</param>
        public ExampleClassMapPropertyDescriptor(IMappingStore mappingStore, IClassMap classMap, object example)
            : base(mappingStore, classMap)
        {
            if (example == null)
            {
                throw new ArgumentNullException("example");
            }

            _example     = example;
            _exampleType = _example.GetType();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ClassMapPropertyDescriptorBase"/> class.
        /// </summary>
        /// <param name="mappingStore">The mapping store.</param>
        /// <param name="classMap">The class map.</param>
        protected ClassMapPropertyDescriptorBase(IMappingStore mappingStore, IClassMap classMap)
        {
            if (mappingStore == null)
                throw new ArgumentNullException("mappingStore");
            if (classMap == null)
                throw new ArgumentNullException("classMap");

            _mappingStore = mappingStore;
            ClassMap = classMap;
            _codeReplacer = new JavascriptMemberNameReplacer(_mappingStore);
        }
        /// <summary>
        ///   Initializes a new instance of the <see cref = "AutoMappingStore" /> class.
        /// </summary>
        /// <param name = "autoMapper">The auto mapper.</param>
        /// <param name = "mappingStore">The mapping store.</param>
        public AutoMappingStore(IAutoMapper autoMapper, IMappingStore mappingStore)
        {
            if (autoMapper == null)
            {
                throw new ArgumentNullException("autoMapper");
            }

            _autoMapper          = autoMapper;
            _autoMaps            = new Dictionary <Type, IClassMap>();
            _wrappedMappingStore = mappingStore;
        }
        public BsonClassMapDescriptor(IMappingStore mappingStore, Type rootType)
        {
            if (mappingStore == null)
                throw new ArgumentNullException("mappingStore");
            if (rootType == null)
                throw new ArgumentNullException("rootType");

            _isDictionaryProperty = false;
            _mappingStore = mappingStore;
            _types = new Stack<Type>();
            _types.Push(rootType);
        }
Beispiel #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MemberMapPath"/> class.
        /// </summary>
        /// <param name="mappingStore">The mapping store.</param>
        /// <param name="type">ValueType of the entity.</param>
        /// <param name="memberNames">The member names.</param>
        public MemberMapPath(IMappingStore mappingStore, Type type, IEnumerable<string> memberNames)
        {
            if (mappingStore == null)
                throw new ArgumentNullException("mappingStore");
            if (type == null)
                throw new ArgumentNullException("type");
            if (memberNames == null)
                throw new ArgumentNullException("memberNames");
            this.type = type;
            this.mappingStore = mappingStore;

            this.Initialize(memberNames);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Cursor&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="serializationFactory">The serialization factory.</param>
 /// <param name="mappingStore">The mapping store.</param>
 /// <param name="connection">The conn.</param>
 /// <param name="databaseName">Name of the database.</param>
 /// <param name="collectionName">Name of the collection.</param>
 /// <param name="spec">The spec.</param>
 /// <param name="limit">The limit.</param>
 /// <param name="skip">The skip.</param>
 /// <param name="fields">The fields.</param>
 internal Cursor(ISerializationFactory serializationFactory, IMappingStore mappingStore, Connection connection, string databaseName, string collectionName, object spec, int limit, int skip, object fields)
     : this(serializationFactory, mappingStore, connection, databaseName, collectionName)
 {
     //Todo: add public constrcutor for users to call
     if (spec == null)
     {
         spec = new Document();
     }
     _spec   = spec;
     _limit  = limit;
     _skip   = skip;
     _fields = fields;
 }
        public static MongoQueryProjection Build(IMappingStore mappingStore, Expression expression)
        {
            var resultObjectMappingParameter = Expression.Parameter(typeof(ResultObjectMapping), "resultObjectMapping");
            ProjectionBuilder builder = new ProjectionBuilder(mappingStore, resultObjectMappingParameter);

            var body = builder.VisitExpression(expression);

            var projector = Expression.Lambda<Func<ResultObjectMapping, object>>(body, resultObjectMappingParameter);

            var projection = new MongoQueryProjection();
            projection.Fields = builder.fields;
            projection.Projector = projector.Compile();
            return projection;
        }
Beispiel #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClassMapPropertyDescriptor"/> class.
        /// </summary>
        /// <param name="mappingStore">The mapping store.</param>
        /// <param name="classMap">The class map.</param>
        /// <param name="instance">The instance.</param>
        public ClassMapPropertyDescriptor(IMappingStore mappingStore, IClassMap classMap, object instance)
            : base(mappingStore, classMap)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            _instance = instance;
            if (ClassMap.HasExtendedProperties)
            {
                _extendedProperties = (IDictionary <string, object>)ClassMap.ExtendedPropertiesMap.GetValue(instance);
            }
        }
Beispiel #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClassMapPropertyDescriptorBase"/> class.
        /// </summary>
        /// <param name="mappingStore">The mapping store.</param>
        /// <param name="classMap">The class map.</param>
        protected ClassMapPropertyDescriptorBase(IMappingStore mappingStore, IClassMap classMap)
        {
            if (mappingStore == null)
            {
                throw new ArgumentNullException("mappingStore");
            }
            if (classMap == null)
            {
                throw new ArgumentNullException("classMap");
            }

            _mappingStore = mappingStore;
            ClassMap      = classMap;
            _codeReplacer = new JavascriptMemberNameReplacer(_mappingStore);
        }
        public BsonClassMapDescriptor(IMappingStore mappingStore, Type rootType)
        {
            if (mappingStore == null)
            {
                throw new ArgumentNullException("mappingStore");
            }
            if (rootType == null)
            {
                throw new ArgumentNullException("rootType");
            }

            _isDictionaryProperty = false;
            _mappingStore         = mappingStore;
            _types = new Stack <Type>();
            _types.Push(rootType);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MongoSessionFactory"/> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="mongo">The mongo.</param>
        public MongoSessionFactory(string databaseName, IMappingStore mappingStore, IMongoFactory mongoFactory, IProxyGenerator proxyGenerator)
        {
            if (string.IsNullOrEmpty(databaseName))
                throw new ArgumentException("Cannot be null or empty.", "databaseName");
            if (mappingStore == null)
                throw new ArgumentNullException("mappingStore");
            if (mongoFactory == null)
                throw new ArgumentNullException("mongoFactory");
            if (proxyGenerator == null)
                throw new ArgumentNullException("proxyGenerator");

            this.databaseName = databaseName;
            this.initialized = false;
            this.initializationObject = new object();
            this.mappingStore = mappingStore;
            this.mongoFactory = mongoFactory;
            this.proxyGenerator = proxyGenerator;
        }
Beispiel #21
0
 public JavascriptMemberNameReplacer(IMappingStore mappingStore)
 {
     _mappingStore = mappingStore;
 }
 public BsonClassMapBuilder(IMappingStore mappingStore, Type classType)
 {
     _mappingStore = mappingStore;
     _types = new Stack<Type>();
     _types.Push(classType);
 }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "AutoMappingStore" /> class.
 /// </summary>
 /// <param name = "profile">The profile.</param>
 /// <param name = "mappingStore">The mapping store.</param>
 public AutoMappingStore(IAutoMappingProfile profile, IMappingStore mappingStore)
     : this(new AutoMapper(profile), mappingStore)
 {
 }
 public BsonClassMapBuilder(IMappingStore mappingStore, Type classType)
 {
     _mappingStore = mappingStore;
     _types        = new Stack <Type>();
     _types.Push(classType);
 }
Beispiel #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemberMapPath"/> class.
 /// </summary>
 /// <param name="mappingStore">The mapping store.</param>
 /// <param name="type">ValueType of the entity.</param>
 /// <param name="memberNames">The member names.</param>
 public MemberMapPath(IMappingStore mappingStore, Type type, params string[] memberNames)
     : this(mappingStore, type, (IEnumerable<string>)memberNames)
 {
 }
Beispiel #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemberMapPath"/> class.
 /// </summary>
 /// <param name="mappingStore">The mapping store.</param>
 /// <param name="type">ValueType of the entity.</param>
 /// <param name="memberInfos">The member infos.</param>
 public MemberMapPath(IMappingStore mappingStore, Type type, params MemberInfo[] memberInfos)
     : this(mappingStore, type, (IEnumerable<MemberInfo>)memberInfos)
 {
 }
Beispiel #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemberMapPath"/> class.
 /// </summary>
 /// <param name="mappingStore">The mapping store.</param>
 /// <param name="type">ValueType of the entity.</param>
 /// <param name="memberInfos">The member infos.</param>
 public MemberMapPath(IMappingStore mappingStore, Type type, IEnumerable<MemberInfo> memberInfos)
     : this(mappingStore, type, memberInfos.Select(mi => mi.Name))
 {
 }
 public JavascriptMemberNameReplacer(IMappingStore mappingStore)
 {
     _mappingStore = mappingStore;
 }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "AutoMappingStore" /> class.
 /// </summary>
 /// <param name = "profile">The profile.</param>
 /// <param name = "mappingStore">The mapping store.</param>
 public AutoMappingStore(IAutoMappingProfile profile, IMappingStore mappingStore)
     : this(new AutoMapper(profile), mappingStore)
 {
 }