Beispiel #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;
         }
     }
 }
Beispiel #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;
                }
            }
        }
Beispiel #3
0
        private static void Populate(IPersistenceObjectCollection persistenceObjectCollection, object result)
        {
            if (result == null)
            {
                return;
            }
            if (!(result is IList))
            {
                throw new ApplicationException("Unexpected non-collection returns from Web Service");
            }
            var list = ((IList)result);

            persistenceObjectCollection.Initialize(list.Count);
            for (var index = 0; index < list.Count; index++)
            {
                IPersistenceObject persistenceObject = persistenceObjectCollection.CreateObjectForRetrieval();
                //WsRecordMapper.Populate(persistenceObject,  );
                WsRecordMapper.Populate(persistenceObject, list[index]);
                persistenceObjectCollection.AddRetrievedObject(persistenceObject);
            }
        }