Example #1
0
 public ComDataContext(object globalContext, Assembly mappingsAssembly)
 {
     this.globalContext  = new GlobalContext(globalContext);
     mappingSource       = MappingSource.Map(this.globalContext, mappingsAssembly);
     comObjectMapper     = new ComObjectMapper(mappingSource, this.globalContext);
     queryProvider       = RelinqHelpers.CreateQueryProvider(mappingSource.TypeRegistry, Execute);
     parametersConverter = new ParametersConverter(comObjectMapper, this.globalContext);
     metadataAccessor    = new MetadataAccessor(mappingSource, this.globalContext);
 }
Example #2
0
        public static Func <object, object> GetMapper(Projection projection, ComObjectMapper mapper)
        {
            var cacheKey = projection.GetCacheKey();
            Func <Projection, ComObjectMapper, Func <object, object> > result;

            if (!mappers.TryGetValue(cacheKey, out result))
            {
                var argumentsExtractor = CreateArgumentsExtractor(projection);
                var instanceFactory    = CreateInstanceFactory(projection);
                mappers.TryAdd(cacheKey, result = delegate(Projection currentProjection, ComObjectMapper currentMapper)
                {
                    var arguments = argumentsExtractor(currentProjection, currentMapper);
                    return(queryResultRow => instanceFactory(arguments(queryResultRow)));
                });
            }
            return(result(projection, mapper));
        }
Example #3
0
 public ParametersConverter(ComObjectMapper comObjectMapper,
                            GlobalContext globalContext)
 {
     this.comObjectMapper = comObjectMapper;
     this.globalContext   = globalContext;
 }
Example #4
0
 internal ComValueSource(object comObject, ComObjectMapper comObjectMapper, bool writable)
 {
     this.comObjectMapper = comObjectMapper;
     this.comObject       = comObject;
     Writable             = writable;
 }