private void Populate(object item) { var type = ProxyUtils.GetTargetType(item); var metadata = _metadataFactory.Create(type); var properties = type.GetProperties(); foreach (var property in properties) { var propertyMetadata = metadata[property.Name]; if (propertyMetadata.IsPrimitive) { continue; } if (propertyMetadata.IsIgnored) { continue; } var value = property.GetValue(item); if (value == null) { continue; } var proxy = Factory(propertyMetadata)(metadata, property, value, item); property.SetValue(item, proxy); } }
private object NewProxy(Type type, object source) { var interceptors = new IInterceptor[] { new EntityStateInterceptor(_state), new RelationshipInterceptor(_metadataFactory, _state) }; var proxy = _generator.CreateClassProxy(type, _options, interceptors); foreach (var property in ProxyUtils.GetTargetEntityType(source).GetProperties()) { if (property.SetMethod == null) { continue; } var value = property.GetMethod.Invoke(source, null); if (value == null) { continue; } if (ProxyUtils.IsProxy(value)) { continue; } property.SetMethod.Invoke(proxy, new[] { value }); } return(proxy); }
public void properties_which_are_marked_as_ignored_are_not_proxied() { var metadataFactory = new AttributeMetadataFactory(new NullLogger()); var queryExecutorFactory = new Mock <IQueryExecutorFactory>(); var repositoryFactory = new Mock <IRepositoryFactory>(); var stateTracker = new EntityStateCache(); var proxyFactory = new DynamicProxyFactory(metadataFactory, new NullLogger()); using (var session = new GraphSession(new UnitOfWork(stateTracker), new List <IListener>(), queryExecutorFactory.Object, repositoryFactory.Object, stateTracker, proxyFactory)) { var factory = new DynamicProxyFactory(metadataFactory, new NullLogger()); var item = new EntityWithIgnoredProperty { Id = "1", Ignored = new AnotherEntity { Id = "2" }, Proxied = new AnotherEntity { Id = "3" } }; var proxy = factory.Create(item, session); Assert.True(ProxyUtils.IsProxy(proxy)); Assert.True(ProxyUtils.IsProxy(proxy.Proxied)); Assert.False(ProxyUtils.IsProxy(proxy.Ignored)); } }
public IPagedGraphCollection <TAggregate> ExecuteWithPaging(IGraphSession session, IQuery <TAggregate> query, bool enlist) { var dataset = Execute(query); if (!dataset.Any()) { return(new PagedGraphGraphCollection <TAggregate>()); } var total = dataset.First().Total; var page = total == 0 ? 1 : query.Skip / total + 1; var results = Map(item => { var aggregate = item.Create(); if (session.Uow.Contains(aggregate)) { aggregate = session.Uow.Get <TAggregate>(ProxyUtils.GetEntityId(aggregate)); } else if (enlist) { aggregate = session.ProxyFactory.Create(aggregate, session); } return(aggregate); }, dataset); return(new PagedGraphGraphCollection <TAggregate>(session, this, query, results, (int)total, (int)page, enlist)); }
public void all_objects_in_the_object_graph_are_proxied() { var metadataFactory = new AttributeMetadataFactory(new NullLogger()); var queryExecutorFactory = new Mock <IQueryExecutorFactory>(); var repositoryFactory = new Mock <IRepositoryFactory>(); var stateTracker = new EntityStateCache(); var proxyFactory = new DynamicProxyFactory(metadataFactory, new NullLogger()); using (var session = new GraphSession(new UnitOfWork(stateTracker), new List <IListener>(), queryExecutorFactory.Object, repositoryFactory.Object, stateTracker, proxyFactory)) { var factory = new DynamicProxyFactory(metadataFactory, new NullLogger()); var item = new Person { Id = "1", Contacts = new List <Contact> { new Contact { Id = "1" } } }; var proxy = factory.Create(item, session); Assert.True(ProxyUtils.IsProxy(proxy)); Assert.True(proxy.Contacts is ITrackableCollection <Contact>); Assert.True(ProxyUtils.IsProxy(proxy.Contacts[0])); } }
private InformacionEstacionBO consultarUsuariosPorID(string tipoIdEstacion, string numIdEstacion) { BizAgiWSParam param = new BizAgiWSParam(); BizAgiWSParamEntityData entity = new BizAgiWSParamEntityData(); entity.EntityName = "WFUSER"; entity.Filters = "SNumeroidentificacion = '" + numIdEstacion + "' and idTipodeDocumento = "; param.EntityData = entity; XmlDocument schemaDoc = new XmlDocument(); string schemaPath = Path.Combine(AsDirectory.AssemblyDirectory, Properties.Resources.SchemaConsultarCasoDesembolso); schemaDoc.Load(schemaPath); BizagiSOALayerOperations ejecutar = new BizagiSOALayerOperations(); string xml = SerializerManager.SerializarToXml <BizAgiWSParam>(param); ejecutar.Url = ProxyUtils.GetServiceEndpoint("URLEntityManager"); string respuesta = ejecutar.getEntitiesUsingSchemaAsString(xml, schemaDoc.OuterXml); // pendiente ajustar esta parte, se debe generar objetos de tipo wfuser para poder hacer la extracción de la información. InformacionEstacionBO datosEstacion = new InformacionEstacionBO(); return(datosEstacion); }
/* * Andres Alberto Yepes * 28-10-2016 * *************************************************************************************************************** * función encargada crear un caso de gestión desembolso. * * */ private GestionDesembolsoResponse crearCasoDesembolso(GestionDesembolsoRequest notificacion) { BizAgiWSParam <M_CAT_GestionDesembolso> param = new BizAgiWSParam <M_CAT_GestionDesembolso>(Properties.Resources.DominioDomain, Properties.Resources.UsuarioCrearCaso); BizAgiWSParamCase <M_CAT_GestionDesembolso> caso = new BizAgiWSParamCase <M_CAT_GestionDesembolso>(Properties.Resources.ProcesoDesembolso); caso.Entities.InfoCaso = new M_CAT_GestionDesembolso(); caso.Entities.InfoCaso.OidInformacionDesembolso.SNumeroTramite = notificacion.InformacionDesembolso.NumeroTramite; caso.Entities.InfoCaso.OidInformacionDesembolso.OidTrackingDesembolso.SCodigoEstacion = notificacion.InformacionEstacion.CodigoEstacion; caso.Entities.InfoCaso.OidInformacionDesembolso.OidTrackingDesembolso.SIdentificacionEstacion = notificacion.InformacionEstacion.IdentificacionEstacion; caso.Entities.InfoCaso.OidInformacionDesembolso.OidTrackingDesembolso.OidTipoDocumentoEstac.SCodigo = notificacion.InformacionEstacion.TipoIdentificacionEstacion.Codigo; caso.Entities.InfoCaso.OidInformacionDesembolso.OidTrackingDesembolso.IRuta = notificacion.RutaActual; caso.Entities.InfoCaso.OidInformacionDesembolso.OidTrackingDesembolso.IEtapa = notificacion.EtapaActual; caso.Entities.InfoCaso.OidInformacionDesembolso.OidTrackingDesembolso.DFechaNotificacion = notificacion.FechaNotificacion; if (notificacion.InformacionDesembolso.CausalReintegro != null) { caso.Entities.InfoCaso.OidInformacionDesembolso.OidTrackingDesembolso.OidCausalReintegro.SCodigo = notificacion.InformacionDesembolso.CausalReintegro.Codigo; } param.Cases[0] = caso; BizagiSOALayerOperations <BizAgiWSParam <M_CAT_GestionDesembolso> > ejecutar = new BizagiSOALayerOperations <BizAgiWSParam <M_CAT_GestionDesembolso> >(); ejecutar.Url = ProxyUtils.GetServiceEndpoint("URLWorkFlowEngine"); processes crearCasoResp = ejecutar.createCase2(param); return(getRespuestaBO(crearCasoResp, EnumSOALayerAction.CreateCase)); }
private void StartCapture() { StartStopCapture.Enabled = false; SettingsBtn.Enabled = false; FilterText.Enabled = false; LinksGrid.Rows.Clear(); // If the option to parse rules on clicking "Start" capture is enabled, do it. This option allows users to modify and reload the rules after stopping the // capture, without having to restart the program. if (Settings.IsParseRulesCapture()) { Settings.ParseRules(); } ProxyUtils.AddToHostsFile("myownwebhelper.com"); WebProxy = new TitaniumProxy(Settings, this); WebProxy.Start(FilterText.Text); ProxyUtils.EnableProxy("myownwebhelper.com", Settings.GetProxyExceptions()); StartStopCapture.Text = "Stop"; StartStopCapture.Enabled = true; }
EnrutarTramiteCredito(Cobis.EnrutarTramiteCredito.Cobis_EnrutarTramite.enrutarTramiteCredito_Input input) { ProxyUtils.ByPassCertificate(); Cobis_EnrutarTramiteCreditoImpl2 ser = new Cobis_EnrutarTramiteCreditoImpl2(); return(ser.EnrutarTramiteCredito(input)); }
private object Create(Type type, object item) { var id = EnsureIdIsNotNull(item); var reference = new EntityReference(id, type); if (IsBusyCreatingProxy(reference)) { return(_session.Uow.Get(id, type)); } _dependencyStack.Push(reference); var proxy = ProxyUtils.IsProxy(item) ? item : NewProxy(type, item); var state = GetState(proxy); state.Lock(); _session.Register(proxy, state); Populate(proxy); state.Set(_status); state.Unlock(); _dependencyStack.Pop(); if (proxy is IRequireSession) { ((IRequireSession)proxy).Set(_session); } return(proxy); }
public void CoerceDelegate_WhenSourceDelegateIsAssignableToTargetDelegateType_ReturnsSameDelegate() { VoidDelegate1 sourceDelegate = () => { }; var targetDelegate = (VoidDelegate1)ProxyUtils.CoerceDelegate(typeof(VoidDelegate1), sourceDelegate); Assert.AreSame(sourceDelegate, targetDelegate); }
private string EnsureIdIsNotNull(object item) { var id = ProxyUtils.GetEntityId(item); if (string.IsNullOrEmpty(id)) { throw new PropertyNotSetException($"The entity identified \"{Conventions.IdPropertyName}\" cannot be null or empty", item); } return(id); }
public void CoerceDelegate_Void_To_Void() { bool called = false; VoidDelegate1 d1 = () => { called = true; }; var d2 = (VoidDelegate2)ProxyUtils.CoerceDelegate(typeof(VoidDelegate2), d1); d2(); Assert.IsTrue(called); }
private void StopCapture() { StartStopCapture.Enabled = false; WebProxy.Stop(); ProxyUtils.DisableProxy(); StartStopCapture.Text = "Start"; StartStopCapture.Enabled = true; SettingsBtn.Enabled = true; FilterText.Enabled = true; }
public static ServicioResponse validarExistencia(ConsumerHeader head, ServiceRequest body) { ProxyUtils.ByPassCertificate(); Cobis_ValidarExistenciaImpl ser = new Cobis_ValidarExistenciaImpl(); ser.consumerHeader = head; ser.Url = "https://172.16.123.110:7094/esb/services/soap"; ser.Credentials = ProxyUtils.getServiceCredentials(); ser.PreAuthenticate = true; return(ser.ValidarExistencia(body)); }
public static ServicioResponse crearSolicitud(ConsumerHeader head, ServiceRequest body) { ProxyUtils.ByPassCertificate(); CuadroVentas_CrearSolicitudImpl ser = new CuadroVentas_CrearSolicitudImpl(); ser.consumerHeader = head; ser.Url = ProxyUtils.GetServiceEndpoint("ESBSOAPEndpoint"); ser.Credentials = ProxyUtils.getServiceCredentials(); ser.PreAuthenticate = true; return(ser.CrearSolicitud(body)); }
public void CoerceDelegate_IntInt_To_IntInt() { bool called = false; IntIntDelegate1 d1 = x => { called = true; return(x * x); }; var d2 = (IntIntDelegate2)ProxyUtils.CoerceDelegate(typeof(IntIntDelegate2), d1); int result = d2(4); Assert.IsTrue(called); Assert.AreEqual(16, result); }
public static ServiceResponse recuperarInfoBasicaPersonaJuridica(ConsumerHeader head, ServiceRequest1 body) { ProxyUtils.ByPassCertificate(); Cobis_RecuperarInfoBasicaPersonaJuriImpl ser = new Cobis_RecuperarInfoBasicaPersonaJuriImpl(); ser.consumerHeader = head; ser.Url = "https://172.16.123.110:7094/esb/services/soap"; ser.Credentials = ProxyUtils.getServiceCredentials(); ser.PreAuthenticate = true; return(ser.RecuperarInformacionBasicaPersonaJuridica(body)); }
private List <object> ProxyListItems(IList <object> source) { var destination = new List <object>(); for (int i = 0; i < source.Count; i++) { var type = ProxyUtils.GetTargetType(source[i]); var existing = _session.Uow.Get(ProxyUtils.GetEntityId(source[i]), type); var child = existing ?? Create(type, source[i]); destination.Add(child); } return(destination); }
public void CoerceDelegate_IntRefInt_To_ObjectRefObject() { bool called = false; IntRefIntDelegate1 d1 = (ref int x) => { called = true; return(x * x++); }; var d2 = (ObjectRefObjectDelegate1)ProxyUtils.CoerceDelegate(typeof(ObjectRefObjectDelegate1), d1); object arg = 4; object result = d2(ref arg); Assert.IsTrue(called); Assert.AreEqual(16, result); Assert.AreEqual(5, arg); }
public void CoerceDelegate_ObjectRefObject_To_ObjectRefObject() { bool called = false; ObjectRefObjectDelegate1 d1 = (ref object x) => { called = true; int y = (int)x; x = y + 1; return(y * y); }; var d2 = (ObjectRefObjectDelegate2)ProxyUtils.CoerceDelegate(typeof(ObjectRefObjectDelegate2), d1); object arg = 4; object result = d2(ref arg); Assert.IsTrue(called); Assert.AreEqual(16, result); Assert.AreEqual(5, arg); }
public Type CreateProxyType(Type serviceType) { if (null == serviceType) { throw new ArgumentNullException(nameof(serviceType)); } if (serviceType.IsInterface) { return(ProxyUtils.CreateInterfaceProxy(serviceType)); } return(ProxyUtils.CreateClassProxy(serviceType, serviceType)); }
public void Initialize() { devKey = TestContext.Parameters.Get("devKey"); //, "e161f73815492f9ba9f7ada9a6a1b23d" testcaseexternalid = TestContext.Parameters.Get("testcaseexternalid"); //, "BSI-3" testplanid = TestContext.Parameters.Get("testplanid"); //, "14" Log.WriteToJenkins("devKey params", devKey); Log.WriteToJenkins("testcaseexternalid params", testcaseexternalid); Log.WriteToJenkins("testplanid params", testplanid); _proxy = new ProxyUtils("inetproxy:83"); _driverIe = new DriverInternetExplorerUtils(_proxy); _driverIe.GetDriverInternet().Manage().Window.Maximize(); }
private object Entity(NodeMetadata metadata, PropertyInfo property, object item, object parent) { var propertyMetadata = _metadataFactory.Create(item); if (propertyMetadata.IsIgnored) { return(item); } var type = ProxyUtils.GetTargetType(item); var entity = _session.Uow.Get(ProxyUtils.GetEntityId(item), type) ?? item; return(Create(type, entity)); }
public void Test2( ) { PresentationTraceSources.Refresh(); var x1 = new NLogTraceListener { ForceLogLevel = LogLevel.Debug }; PresentationTraceSources.MarkupSource.Listeners.Add(x1); PresentationTraceSources.MarkupSource.Switch.Level = SourceLevels.All; var x = new ProxyUtils(WriteOut, ProxyUtilsBase.CreateInterceptor(WriteOut)); var @out = x.TransformXaml2(@"files/test.xaml"); Logger.Debug("{out}", @out); }
public IEnumerable <TAggregate> Execute(IGraphSession session, IQuery <TAggregate> query) { var dataset = Execute(query); var results = Map(item => { var aggregate = item.Create(); if (session.Uow.Contains(aggregate)) { aggregate = session.Uow.Get <TAggregate>(ProxyUtils.GetEntityId(aggregate)); } return(aggregate); }, dataset); return(results); }
public void CoerceDelegate_WhenDelegateTypesIncompatible_Throws() { Assert.Multiple(() => { Assert.Throws <InvalidOperationException>(() => ProxyUtils.CoerceDelegate( typeof(VoidDelegate1), new IntDelegate1(() => 42))); Assert.Throws <InvalidOperationException>(() => ProxyUtils.CoerceDelegate( typeof(IntDelegate1), new IntIntDelegate1(x => 42))); Assert.Throws <InvalidOperationException>(() => ProxyUtils.CoerceDelegate( typeof(IntIntDelegate1), new IntOutIntDelegate1((out int x) => { x = 42; return(42); }))); Assert.Throws <InvalidOperationException>(() => ProxyUtils.CoerceDelegate( typeof(IntIntDelegate1), new IntRefIntDelegate1((ref int x) => { x = 42; return(42); }))); Assert.Throws <InvalidOperationException>(() => ProxyUtils.CoerceDelegate( typeof(IntOutIntDelegate1), new IntRefIntDelegate1((ref int x) => { x = 42; return(42); }))); }); }
//Empty /// <exception cref="System.IO.IOException"/> /// <exception cref="Javax.Servlet.ServletException"/> public virtual void DoFilter(ServletRequest req, ServletResponse resp, FilterChain chain) { ProxyUtils.RejectNonHttpRequests(req); HttpServletRequest httpReq = (HttpServletRequest)req; HttpServletResponse httpResp = (HttpServletResponse)resp; if (Log.IsDebugEnabled()) { Log.Debug("Remote address for request is: {}", httpReq.GetRemoteAddr()); } if (!GetProxyAddresses().Contains(httpReq.GetRemoteAddr())) { string redirectUrl = FindRedirectUrl(); string target = redirectUrl + httpReq.GetRequestURI(); ProxyUtils.SendRedirect(httpReq, httpResp, target); return; } string user = null; if (httpReq.GetCookies() != null) { foreach (Cookie c in httpReq.GetCookies()) { if (WebAppProxyServlet.ProxyUserCookieName.Equals(c.GetName())) { user = c.GetValue(); break; } } } if (user == null) { if (Log.IsDebugEnabled()) { Log.Debug("Could not find " + WebAppProxyServlet.ProxyUserCookieName + " cookie, so user will not be set" ); } chain.DoFilter(req, resp); } else { AmIpPrincipal principal = new AmIpPrincipal(user); ServletRequest requestWrapper = new AmIpServletRequestWrapper(httpReq, principal); chain.DoFilter(requestWrapper, resp); } }
public void interceptors_are_not_created_for_re_entrant_proxies() { var metadataFactory = new AttributeMetadataFactory(new NullLogger()); var proxyFactory = new DynamicProxyFactory(metadataFactory, new NullLogger()); var queryExecutorFactory = new Mock <IQueryExecutorFactory>(); var repositoryFactory = new RepositoryFactory(proxyFactory); var parentMapper = new Mock <IMapper <Parent> >(); repositoryFactory.Register <Parent>(x => parentMapper.Object); var childMapper = new Mock <IMapper <Child> >(); repositoryFactory.Register <Child>(x => childMapper.Object); var stateTracker = new EntityStateCache(); using (var session = new GraphSession(new UnitOfWork(stateTracker), new List <IListener>(), queryExecutorFactory.Object, repositoryFactory, stateTracker, proxyFactory)) { var proxy = session.Create(new Parent { Id = "1" }); proxy.Child = session.Create(new Child { Id = "1" }); var metadata = metadataFactory.Create(proxy); var deleted = ProxyUtils.Flush(proxy, metadata["Child"].Relationship); Assert.Equal(0, deleted.SelectMany(x => x.Flush().Cast <object>()).Count()); var reentrant = session.Create(proxy); Assert.Equal(proxy, reentrant); metadata = metadataFactory.Create(reentrant); deleted = ProxyUtils.Flush(reentrant, metadata["Child"].Relationship); Assert.Equal(0, deleted.SelectMany(x => x.Flush().Cast <object>()).Count()); proxy.Child = session.Create(new Child { Id = "2" }); metadata = metadataFactory.Create(reentrant); deleted = ProxyUtils.Flush(reentrant, metadata["Child"].Relationship); Assert.Equal(1, deleted.SelectMany(x => x.Flush().Cast <object>()).Count()); } }
public void CoerceDelegate_EventHandler_To_EventHandler() { bool called = false; object actualSender = null; EventArgs actualEventArgs = null; EventHandlerDelegate1 d1 = (sender, e) => { called = true; actualSender = sender; actualEventArgs = e; }; var d2 = (EventHandlerDelegate2)ProxyUtils.CoerceDelegate(typeof(EventHandlerDelegate2), d1); object expectedSender = this; EventArgs expectedEventArgs = EventArgs.Empty; d2(expectedSender, expectedEventArgs); Assert.IsTrue(called); Assert.AreSame(expectedSender, actualSender); Assert.AreSame(expectedEventArgs, actualEventArgs); }