示例#1
0
 public void Get(IPersistenceObjectCollection persistenceObjectCollection, HybridDictionary parameterCollection)
 {
     if (_proxyTypeSelect == null)
     {
         throw new ApplicationException(string.Format("Proxy Get Method is not defined for object {0}.", persistenceObjectCollection.GetType().Name));
     }
     using (var proxy = (IDisposable)Activator.CreateInstance(_proxyTypeSelect))
     {
         try
         {
             var fieldMapperCollection    = MapperFactory.GetInstance().GetFieldMappers(persistenceObjectCollection.GetType().FullName);
             var methodInfo               = _proxyTypeSelect.GetMethod(_mapperInfo.MethodNameSelect);
             var parameterValueCollection = WsRecordMapper.PopulateMethodParameters(methodInfo, fieldMapperCollection, parameterCollection);
             WsRecordMapper.ProcessProxyCallBack(proxy, _callbackTypeSelect, _mapperInfo.ProxyCallbackPropertyNameSelect);
             var result = methodInfo.Invoke(proxy, parameterValueCollection);
             Populate(persistenceObjectCollection, result);
             WsRecordMapper.Populate(persistenceObjectCollection, methodInfo, parameterValueCollection, result);
         }
         catch (TargetInvocationException ex)
         {
             if (ex.InnerException != null)
             {
                 throw ex.InnerException;
             }
             throw;
         }
     }
 }
示例#2
0
        public void Get(IPersistenceObjectCollection persistenceObjectCollection, IObjectKey parentObjectKey, HybridDictionary parameterCollection)
        {
            if (_proxyTypeSelect == null)
            {
                throw new ApplicationException(string.Format("Proxy Get Method is not defined for object {0}.", persistenceObjectCollection.GetType().Name));
            }
            using (var proxy = (IDisposable)Activator.CreateInstance(_proxyTypeSelect))
            {
                try
                {
                    var fieldMapperCollection = MapperFactory.GetInstance().GetFieldMappers(persistenceObjectCollection.GetType().FullName);
                    var methodInfo            = _proxyTypeSelect.GetMethod(_mapperInfo.MethodNameSelect);

                    // copy objectKey collection and parameterCollection into a combined collection
                    var objectKeyFieldCollection    = parentObjectKey.ToDictionary();
                    var combinedParameterCollection = new HybridDictionary(objectKeyFieldCollection.Count + parameterCollection.Count);
                    foreach (DictionaryEntry item in objectKeyFieldCollection)
                    {
                        combinedParameterCollection.Add(item.Key, item.Value);
                    }
                    foreach (DictionaryEntry item in parameterCollection)
                    {
                        combinedParameterCollection.Add(item.Key, item.Value);
                    }

                    var parameterValueCollection = WsRecordMapper.PopulateMethodParameters(methodInfo, fieldMapperCollection, combinedParameterCollection);
                    WsRecordMapper.ProcessProxyCallBack(proxy, _callbackTypeSelect, _mapperInfo.ProxyCallbackPropertyNameSelect);
                    var result = methodInfo.Invoke(proxy, parameterValueCollection);
                    Populate(persistenceObjectCollection, result);
                    WsRecordMapper.Populate(persistenceObjectCollection, methodInfo, parameterValueCollection, result);
                }
                catch (TargetInvocationException ex)
                {
                    if (ex.InnerException != null)
                    {
                        throw ex.InnerException;
                    }
                    throw;
                }
            }
        }