protected override IEnumerable <ConsumerExecutorDescriptor> FindConsumersFromInterfaceTypes(IServiceProvider provider) { var executorDescriptorList = new List <ConsumerExecutorDescriptor>(); using (var scoped = provider.CreateScope()) { var scopedProvider = scoped.ServiceProvider; var consumerServices = scopedProvider.GetServices <ICapSubscribe>(); foreach (var service in consumerServices) { var serviceType = service.GetType(); // Castle dynamic proxy... TypeInfo typeInfo = ProxyServices.IsDynamicProxy(serviceType) ? ProxyUtil.GetUnproxiedType(service).GetTypeInfo() : serviceType.GetTypeInfo(); if (!typeof(ICapSubscribe).GetTypeInfo().IsAssignableFrom(typeInfo)) { continue; } executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo)); } return(executorDescriptorList); } }
/// <summary> /// 获取类型代理前的类型 /// </summary> /// <param name="type"></param> /// <returns></returns> public static Type GetRawType(Type type) { while (ProxyServices.IsDynamicProxy(type)) { type = type.BaseType; } return(type); }
public HomeController() { if (Login.TryLogin()) { //ViewBag.Contacts = EDProxyService.GetOdataCollection(); contactsApi = ProxyServices.GetOdataCollection(); } }
public override ManagerStateEnum Start() { if (this.ManagerState != ManagerStateEnum.Started) { if (LOGGER.IsInfoEnabled) { LOGGER.Info(string.Format("{0}, initializing locator...", LOG_PREFIX)); } OnStart(ManagerEventStateEnum.Before); try { Forge.Net.TerraGraf.NetworkManager.Instance.Start(); Forge.Net.Remoting.Channels.ChannelServices.Initialize(); Forge.Net.Remoting.Proxy.ProxyServices.Initialize(); // check channel this.ChannelId = ConfigurationAccessHelper.GetValueByPath(NetworkServiceConfiguration.Settings.CategoryPropertyItems, string.Format("Locators/{0}", Id)); if (string.IsNullOrEmpty(this.ChannelId)) { this.ChannelId = Id; } Channel channel = LookUpChannel(); if (!ProxyServices.IsContractRegistered(typeof(TIProxyType))) { ProxyServices.RegisterContract(typeof(TIProxyType), channel.ChannelId, typeof(TProxyImplementationType)); } // init TerraGraf and find the service Forge.Net.TerraGraf.NetworkManager.Instance.NetworkPeerContextChanged += new EventHandler <NetworkPeerContextEventArgs>(NetworkPeerContextChangedEventHandler); Forge.Net.TerraGraf.NetworkManager.Instance.NetworkPeerDiscovered += new EventHandler <NetworkPeerChangedEventArgs>(NetworkPeerDiscoveredEventHandler); Forge.Net.TerraGraf.NetworkManager.Instance.NetworkPeerUnaccessible += new EventHandler <NetworkPeerChangedEventArgs>(NetworkPeerUnaccessibleEventHandler); Forge.Net.TerraGraf.NetworkManager.Instance.NetworkPeerContextChanged += new EventHandler <NetworkPeerContextEventArgs>(NetworkPeerContextChangedEventHandler); FindService(); this.ManagerState = ManagerStateEnum.Started; if (LOGGER.IsInfoEnabled) { LOGGER.Info(string.Format("{0}, locator successfully initialized.", LOG_PREFIX)); } } catch (Exception) { this.ManagerState = ManagerStateEnum.Fault; throw; } finally { OnStart(ManagerEventStateEnum.After); } } return(this.ManagerState); }
public ActionResult Delete(Guid contactId) { if (ModelState.IsValid) { ProxyServices.DeleteContact(contactId); TempData["message"] = "Удаление контакта было произведено"; return(RedirectToAction("Index")); } else { return(View()); } }
public ActionResult Create(Contact newContact) { if (ModelState.IsValid) { ProxyServices.CreateContact(newContact); TempData["message"] = string.Format("Контакт {0} был создан", newContact.Name); return(RedirectToAction("Index")); } else { return(View(newContact)); } }
private bool CheckUserValidity(List <TextBox> TextList, List <Label> LabelListError) { if (isValidInput(TextList, LabelListError)) { try { if (ProxyServices.IsValidUser(CardNumber, PinNumber)) { if (!ProxyServices.IsCardExperiedByDate(CardNumber)) { if (ProxyServices.getUsingTime(CardNumber) < 18000) { if (!ProxyServices.IsActive(CardNumber)) { return(true); } else { MessageBox.Show("The Card is now active"); return(false); } } else { MessageBox.Show("Your Total Using Time is excceding Cards Time Limit"); return(false); } } else { MessageBox.Show("Your Card is Expered by 180 days"); return(false); } } else { MessageBox.Show("Card Number or Pin Number is incorrect"); return(false); } } catch (Exception) { MessageBox.Show("Try Again Server is not Running at that moment"); return(false); } } else { return(false); } }
public ActionResult Save(Contact contact) { if (ModelState.IsValid) { ProxyServices.UpdateContact(contact); TempData["message"] = string.Format("Изменения контакта {0} были сохранены", contact.Name); //return RedirectToAction("Index"); } else { TempData["message"] = string.Format("Изменения контакта {0} не были сохранены", contact.Name); } return(RedirectToAction("Index")); }
public void OnBehalfAware_ProxyGenarationHook_works_on_dependencies() { OnBehalfAwareProxyGenerationHook.target = null; Container.Register(Component.For <OnBehalfAwareProxyGenerationHook>().LifeStyle.Transient, Component.For <StandardInterceptor>().LifeStyle.Transient, Component.For <UsesSimpleComponent1>().LifeStyle.Transient, Component.For <SimpleComponent1>().LifeStyle.Transient .Interceptors <StandardInterceptor>() .Proxy.Hook(h => h.Service <OnBehalfAwareProxyGenerationHook>())); var service = Container.Resolve <UsesSimpleComponent1>(); Assert.IsTrue(ProxyServices.IsDynamicProxy(service.Dependency.GetType())); Assert.IsNotNull(OnBehalfAwareProxyGenerationHook.target); Assert.AreEqual(typeof(SimpleComponent1), OnBehalfAwareProxyGenerationHook.target.Services.Single()); }
public void InterceptorSelector_can_be_OnBehalfAware() { OnBehalfAwareInterceptorSelector.target = null; Container.Register(Component.For <OnBehalfAwareInterceptorSelector>().LifeStyle.Transient, Component.For <StandardInterceptor>().LifeStyle.Transient, Component.For <ISimpleService>() .ImplementedBy <SimpleService>() .LifeStyle.Transient .Interceptors <StandardInterceptor>() .SelectInterceptorsWith(s => s.Service <OnBehalfAwareInterceptorSelector>())); var service = Container.Resolve <ISimpleService>(); Assert.IsTrue(ProxyServices.IsDynamicProxy(service.GetType())); Assert.IsNotNull(OnBehalfAwareInterceptorSelector.target); Assert.AreEqual(typeof(ISimpleService), OnBehalfAwareInterceptorSelector.target.Services.Single()); }
/// <summary> /// Initializes this instance. /// </summary> public virtual void Initialize() { if (!IsInitialized) { try { Net.TerraGraf.NetworkManager.Instance.Start(); ProxyServices.Initialize(); mLocator = RemoteServiceLocatorManager.GetServiceLocator <IRemoteDesktop, RemoteDesktopServiceLocator>(); mLocator.EventAvailableServiceProvidersChanged += new EventHandler <ServiceProvidersChangedEventArgs>(AvailableServiceProvidersChangedEventHandler); mLocator.Start(); AvailableServiceProvidersChangedEventHandler(mLocator, new ServiceProvidersChangedEventArgs(mLocator.AvailableServiceProviders)); IsInitialized = true; } catch (Exception ex) { MessageBox.Show(this, string.Format(Resources.Error_FailedToStartNetwork, ex.Message), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }