/// <summary> /// Binds the key type to a singleton <paramref name="type"/> on a GameObject /// of a given <paramref name="name"/>. /// /// If the GameObject of a given <paramref name="name"/> is not found, it's added to the scene. /// /// If <paramref name="type"/> is <see cref="UnityEngine.GameObject"/>, binds the /// key to the GameObject itself. /// /// If <paramref name="type"/> is see cref="UnityEngine.Component"/>, binds the key /// to the the instance of the component. /// /// If the <see cref="UnityEngine.Component"/> is not found on the GameObject, it will be added. /// </summary> /// <remarks> /// To prevent references to destroyed objects, only bind to game objects that won't /// be destroyed in the scene. /// </remarks> /// <param name="bindingFactory">The original binding factory.</param> /// <param name="type">The component type.</param> /// <param name="name">The GameObject name.</param> /// <returns>The binding condition object related to this binding.</returns> public static UnityBindingConditionFactory ToGameObject(this IBindingFactory bindingFactory, Type type, string name) { if (!TypeUtils.IsAssignable(bindingFactory.bindingType, type)) { throw new BindingException(BindingException.TYPE_NOT_ASSIGNABLE); } var isGameObject = TypeUtils.IsAssignable(TYPE_GAME_OBJECT, type); var isComponent = TypeUtils.IsAssignable(TYPE_COMPONENT, type); if (!isGameObject && !isComponent) { throw new BindingException(TYPE_NOT_COMPONENT); } GameObject gameObject = null; if (string.IsNullOrEmpty(name)) { gameObject = new GameObject(type.Name); } else { gameObject = GameObject.Find(name); if (gameObject == null) { gameObject = new GameObject(name); } } return(CreateSingletonBinding(bindingFactory, gameObject, type, isGameObject)); }
/// <summary> /// Binds the key type to a transient <see cref="UnityEngine.Component"/> /// of <paramref name="type"/> on the prefab. /// /// If the <see cref="UnityEngine.Component"/> is not found on the prefab /// at the moment of the instantiation, it will be added. /// </summary> /// <remarks> /// Every resolution of a transient prefab will generate a new instance. So, even /// if the component resolved from the prefab is destroyed, it won't generate any /// missing references in the container. /// </remarks> /// <param name="bindingFactory">The original binding factory.</param> /// <param name="type">The component type.</param> /// <param name="name">Prefab name. It will be loaded using <c>Resources.Load<c/>.</param> /// <returns>The binding condition object related to this binding.</returns> public static IBindingConditionFactory ToPrefab(this IBindingFactory bindingFactory, Type type, string name) { if (!TypeUtils.IsAssignable(bindingFactory.bindingType, type)) { throw new BindingException(BindingException.TYPE_NOT_ASSIGNABLE); } var isGameObject = TypeUtils.IsAssignable(typeof(GameObject), type); var isComponent = TypeUtils.IsAssignable(typeof(Component), type); if (!isGameObject && !isComponent) { throw new BindingException(TYPE_NOT_COMPONENT); } var prefab = Resources.Load(name); if (prefab == null) { throw new BindingException(PREFAB_IS_NULL); } var prefabBinding = new PrefabBinding(prefab, type); return(bindingFactory.AddBinding(prefabBinding, BindingInstance.Transient)); }
internal protected Proxy(IBindingFactory bindingFactory, System.Uri uriEndpoint) { this.bindingFactory = bindingFactory; this.uriEndpoint = uriEndpoint; this.MaxClientAttempts = DefaultMaxClientAttempts; this.WaitForNextClientAttemptInMilliseconds = DefaultWaitForNextClientAttemptInMilliseconds; }
public static UnityBindingConditionFactory ToPrefab(this IBindingFactory bindingFactory, Type type, string name) { if (!TypeUtils.IsAssignable(bindingFactory.bindingType, type)) { throw new BindingException(BindingException.TYPE_NOT_ASSIGNABLE); } var isGameObject = TypeUtils.IsAssignable(TYPE_GAME_OBJECT, type); var isComponent = TypeUtils.IsAssignable(TYPE_COMPONENT, type); if (!isGameObject && !isComponent) { throw new BindingException(TYPE_NOT_COMPONENT); } var prefab = Resources.Load(name); if (prefab == null) { throw new BindingException(string.Format(PREFAB_NAME_TYPE_IS_NULL, name, type.ToString())); } var prefabBinding = new PrefabBinding(prefab, type); return(new UnityBindingConditionFactory(bindingFactory.AddBinding(prefabBinding, BindingInstance.Transient), prefab.name)); }
public static UnityBindingConditionFactory ToPrefabSingleton(this IBindingFactory bindingFactory, Type type, string name) { if (!TypeUtils.IsAssignable(bindingFactory.bindingType, type)) { throw new BindingException(BindingException.TYPE_NOT_ASSIGNABLE); } var isGameObject = TypeUtils.IsAssignable(TYPE_GAME_OBJECT, type); var isComponent = TypeUtils.IsAssignable(TYPE_COMPONENT, type); if (!isGameObject && !isComponent) { throw new BindingException(TYPE_NOT_COMPONENT); } var prefab = Resources.Load(name); if (prefab == null) { throw new BindingException(string.Format(PREFAB_NAME_TYPE_IS_NULL, name, type.ToString())); } var gameObject = (GameObject)MonoBehaviour.Instantiate(prefab); return(CreateSingletonBinding(bindingFactory, gameObject, type, isGameObject)); }
public AltinnDownloaderService(IBindingFactory bindingFactory, IOptions <AltinnDownloadQueueConnectionSettings> connectionOptions , IOptions <MessageProcessingSettings> messageProcessingOptions) { _bindingFactory = bindingFactory; _connectionOptions = connectionOptions; _messageProcessingOptions = messageProcessingOptions; }
/// <summary> /// Creates a singleton binding. /// </summary> /// <param name="bindingFactory">The binding factory.</param> /// <param name="gameObject">The GameObject to bind to.</param> /// <param name="type">The type of the binding.</param> /// <param name="typeIsGameObject">Indicates whether the type is a GameObject.</param> /// <returns>The binding condition object related to the binding.</returns> private static IBindingConditionFactory CreateSingletonBinding(IBindingFactory bindingFactory, GameObject gameObject, Type type, bool typeIsGameObject) { if (gameObject == null) { throw new BindingException(GAMEOBJECT_IS_NULL); } if (typeIsGameObject) { return(bindingFactory.AddBinding(gameObject, BindingInstance.Singleton)); } else { var component = gameObject.GetComponent(type); if (component == null) { component = gameObject.AddComponent(type); } return(bindingFactory.AddBinding(component, BindingInstance.Singleton)); } }
/// <summary> /// Binds the key type to singletons <see cref="UnityEngine.Component"/> /// of itself on game objects of a given <paramref name="tag"/>. /// /// If <paramref name="type"/> is <see cref="UnityEngine.GameObject"/>, binds the /// key to the GameObject itself. /// /// If <paramref name="type"/> is see cref="UnityEngine.Component"/>, binds the key /// to the the instance of the component. /// /// If the <see cref="UnityEngine.Component"/> is not found on the GameObject, it will be added. /// </summary> /// <remarks> /// To prevent references to destroyed objects, only bind to game objects that won't /// be destroyed in the scene. /// </remarks> /// <param name="bindingFactory">The original binding factory.</param> /// <param name="type">The component type.</param> /// <param name="tag">The GameObject tag.</param> /// <returns>The binding condition object related to this binding.</returns> public static IBindingConditionFactory ToGameObjectsWithTag(this IBindingFactory bindingFactory, Type type, string tag) { if (!TypeUtils.IsAssignable(bindingFactory.bindingType, type)) { throw new BindingException(BindingException.TYPE_NOT_ASSIGNABLE); } var isGameObject = TypeUtils.IsAssignable(TYPE_GAME_OBJECT, type); var isComponent = TypeUtils.IsAssignable(TYPE_COMPONENT, type); if (!isGameObject && !isComponent) { throw new BindingException(TYPE_NOT_COMPONENT); } var gameObjects = GameObject.FindGameObjectsWithTag(tag); var bindingFactories = new IBindingConditionFactory[gameObjects.Length]; for (int gameObjectIndex = 0; gameObjectIndex < gameObjects.Length; gameObjectIndex++) { bindingFactories[gameObjectIndex] = CreateSingletonBinding(bindingFactory, gameObjects[gameObjectIndex], type, isGameObject); } return(new MultipleBindingConditionFactory(bindingFactories, bindingFactory.binder)); }
public ServiceModelDiscoveryService(IServiceModelDiscoveryClientWrapper discoveryClient, IChannelFactoryWrapper channelFactory, IBindingFactory bindingFactory, IOptions <ServiceModelDiscoveryOptions> options, ILogger <ServiceModelDiscoveryService> logger) { _discoveryClient = discoveryClient ?? throw new ArgumentNullException(nameof(discoveryClient)); _channelFactory = channelFactory ?? throw new ArgumentNullException(nameof(channelFactory)); _bindingFactory = bindingFactory ?? throw new ArgumentNullException(nameof(bindingFactory)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _options = options?.Value ?? throw new ArgumentNullException(nameof(options)); }
public XmlSiteMapResultFactoryContainer(ConfigurationSettings settings) { var siteMapLoaderContainer = new SiteMapLoaderContainer(settings); this.siteMapLoader = siteMapLoaderContainer.ResolveSiteMapLoader(); this.mvcContextFactory = new MvcContextFactory(); this.bindingFactory = new BindingFactory(); this.bindingProvider = new BindingProvider(this.bindingFactory, this.mvcContextFactory); this.urlPath = new UrlPath(this.mvcContextFactory, this.bindingProvider); this.cultureContextFactory = new CultureContextFactory(); }
public void GetProducerBindingTypesMismatchTest() { BoilersSetFixture _boiler = new BoilersSetFixture(); using (DataGenerator _generator = new DataGenerator(_boiler)) { IBindingFactory _bindingFactory = _generator; IProducerBinding _binding = _bindingFactory.GetProducerBinding("repositoryGroup", "processValueName", new UATypeInfo(BuiltInType.Int16)); } }
/// <summary> /// Binds the key type to a singleton <paramref name="type"/> to a given <paramref name="gameObject"/>. /// /// If <paramref name="type"/> is <see cref="UnityEngine.GameObject"/>, binds the /// key to the GameObject itself. /// /// If <paramref name="type"/> is see cref="UnityEngine.Component"/>, binds the key /// to the the instance of the component. /// /// If the <see cref="UnityEngine.Component"/> is not found on the GameObject, it will be added. /// </summary> /// <remarks> /// To prevent references to destroyed objects, only bind to game objects that won't /// be destroyed in the scene. /// </remarks> /// <param name="bindingFactory">The original binding factory.</param> /// <param name="type">The component type.</param> /// <param name="gameObject">The GameObject object.</param> /// <returns>The binding condition object related to this binding.</returns> public static UnityBindingConditionFactory ToGameObject(this IBindingFactory bindingFactory, Type type, GameObject gameObject) { var isGameObject = TypeUtils.IsAssignable(TYPE_GAME_OBJECT, type); var isComponent = TypeUtils.IsAssignable(TYPE_COMPONENT, type); if (!isGameObject && !isComponent) { throw new BindingException(TYPE_NOT_COMPONENT); } return(CreateSingletonBinding(bindingFactory, gameObject, type, isGameObject)); }
public BindingProvider( IBindingFactory bindingFactory, IMvcContextFactory mvcContextFactory ) { if (bindingFactory == null) throw new ArgumentNullException("bindingFactory"); if (mvcContextFactory == null) throw new ArgumentNullException("mvcContextFactory"); this.bindingFactory = bindingFactory; this.mvcContextFactory = mvcContextFactory; }
static private void BuildProxy <TProxyInterface>(System.Uri uriEndpoint, IBindingFactory bindingFactory, out TProxyInterface proxy, out System.ServiceModel.ICommunicationObject comms , uint maxTries, int wait) where TProxyInterface : class { System.ServiceModel.Channels.Binding binding = bindingFactory.Create(); System.ServiceModel.ChannelFactory <TProxyInterface> factory = new System.ServiceModel.ChannelFactory <TProxyInterface>( binding , new System.ServiceModel.EndpointAddress(uriEndpoint) ); proxy = factory.CreateChannel(); comms = proxy as System.ServiceModel.ICommunicationObject; AttemptClientOpen(ref comms, ref proxy, factory, maxTries, wait); }
internal ExtensionState( IPatternInfo extendingProduct, IExtensionPointInfo extensionPoint, IBindingFactory bindingFactory) { this.ExtendingProduct = extendingProduct; this.ExtensionPoint = extensionPoint; this.bindingFactory = bindingFactory; this.BindingContext = bindingFactory.CreateContext(); this.BindingContext.AddExportsFromInterfaces(extendingProduct); this.BindingContext.AddExportsFromInterfaces(extensionPoint); }
public void Initialize() { this.tracer = Mock.Of<ITracer>(); this.context = Mock.Of<IDynamicBindingContext>(); this.valueProvider = Mock.Of<IValueProvider>(vp => (string)vp.Evaluate() == "Foo"); this.binding = Mock.Of<IDynamicBinding<IValueProvider>>(binding => binding.Evaluate(It.IsAny<IDynamicBindingContext>()) == true && binding.Value == this.valueProvider && binding.CreateDynamicContext() == this.context); this.bindingFactory = Mock.Of<IBindingFactory>(factory => factory.CreateBinding<IValueProvider>(It.IsAny<IBindingSettings>()) == this.binding); }
public void Initialize() { this.tracer = Mock.Of <ITracer>(); this.context = Mock.Of <IDynamicBindingContext>(); this.valueProvider = Mock.Of <IValueProvider>(vp => (string)vp.Evaluate() == "Foo"); this.binding = Mock.Of <IDynamicBinding <IValueProvider> >(binding => binding.Evaluate(It.IsAny <IDynamicBindingContext>()) == true && binding.Value == this.valueProvider && binding.CreateDynamicContext() == this.context); this.bindingFactory = Mock.Of <IBindingFactory>(factory => factory.CreateBinding <IValueProvider>(It.IsAny <IBindingSettings>()) == this.binding); }
/// <summary> /// Initializes a new instance of the <see cref="ProducerAssociation"/> class. /// </summary> /// <param name="data">The semantic data description.</param> /// <param name="aliasName">Name of the alias - .</param> /// <param name="dataSet">The data set configuration.</param> /// <param name="bindingFactory">The binding factory.</param> /// <param name="encodingFactory">The encoding factory.</param> internal ProducerAssociation(ISemanticData data, string aliasName, DataSetConfiguration dataSet, IBindingFactory bindingFactory, IEncodingFactory encodingFactory) : base(data, dataSet.AssociationName) { m_ConfigurationVersion = dataSet.ConfigurationVersion; m_DataSetBindings = dataSet.DataSet.Select<FieldMetaData, IProducerBinding> ((_fieldMetadata) => { IProducerBinding _ret = _fieldMetadata.GetProducerBinding4DataMember(dataSet.RepositoryGroup, bindingFactory, encodingFactory); _ret.PropertyChanged += ProducerBinding_PropertyChanged; return _ret; }).ToArray<IProducerBinding>(); m_Timer = new Timer(1000) { AutoReset = true }; m_Timer.Elapsed += M_Timer_Elapsed; m_Timer.Start(); }
public static UnityBindingConditionFactory ToResource(this IBindingFactory bindingFactory, string name) { if (!TypeUtils.IsAssignable(typeof(UnityEngine.Object), bindingFactory.bindingType)) { throw new BindingException(TYPE_NOT_OBJECT); } var resource = Resources.Load(name); if (resource == null) { throw new BindingException(RESOURCE_IS_NULL); } return(new UnityBindingConditionFactory(bindingFactory.AddBinding(resource, BindingInstance.Singleton), resource.name)); }
public DependencyProperty( [NotNull] IBindingFactory bindingFactory, [CanBeNull] T value, [CanBeNull] PropertyChangedCallback <T> propertyChangedCallback, [CanBeNull] CoerceValueCallback <T> coerceValueCallback) { if (bindingFactory == null) { throw new ArgumentNullException("bindingFactory"); } _bindingFactory = bindingFactory; _value = value; _propertyChangedCallback = propertyChangedCallback; _coerceValueCallback = coerceValueCallback; }
public UaooiMessageBus( IConfigurationFactory configurationFactory, IEncodingFactory encodingFactory, IBindingFactory subscriptionFactory, IMessageHandlerFactory messageHandlerFactory, ILogger logger) { ConfigurationFactory = configurationFactory ?? throw new ComponentNotInitialisedException(nameof(configurationFactory)); EncodingFactory = encodingFactory ?? throw new ComponentNotInitialisedException(nameof(encodingFactory)); BindingFactory = subscriptionFactory ?? throw new ComponentNotInitialisedException(nameof(subscriptionFactory)); MessageHandlerFactory = messageHandlerFactory ?? throw new ComponentNotInitialisedException(nameof(messageHandlerFactory)); _logger = logger; }
public BindingProvider( IBindingFactory bindingFactory, IMvcContextFactory mvcContextFactory ) { if (bindingFactory == null) { throw new ArgumentNullException("bindingFactory"); } if (mvcContextFactory == null) { throw new ArgumentNullException("mvcContextFactory"); } this.bindingFactory = bindingFactory; this.mvcContextFactory = mvcContextFactory; }
public ApplicationController( IBindingFactory<MainController> mainControllerFactory, IOptionsManager optionsManager, IHostEnviromentConnection hostEnviroment, ISettingsManager settingsManager, IEventService eventService) { _optionsManager = optionsManager; _hostEnviroment = hostEnviroment; _settingsManager = settingsManager; _eventService = eventService; HookGlobalExceptionHandlers(); _eventService.Subscribe(this); _mainController = mainControllerFactory.CreateWithBindings(_hostEnviroment.Events); }
/// <summary> /// Binds the key type to a transient <see cref="UnityEngine.Component"/> /// of <paramref name="type"/> on the prefab. /// /// If the <see cref="UnityEngine.Component"/> is not found on the prefab /// at the moment of the instantiation, it will be added. /// </summary> /// <remarks> /// Every resolution of a transient prefab will generate a new instance. So, even /// if the component resolved from the prefab is destroyed, it won't generate any /// missing references in the container. /// </remarks> /// <param name="bindingFactory">The original binding factory.</param> /// <param name="type">The component type.</param> /// <param name="prefab">Prefab object.</param> /// <returns>The binding condition object related to this binding.</returns> public static UnityBindingConditionFactory ToPrefab(this IBindingFactory bindingFactory, Type type, GameObject prefab) { if (!TypeUtils.IsAssignable(bindingFactory.bindingType, type)) { throw new BindingException(BindingException.TYPE_NOT_ASSIGNABLE); } var isGameObject = TypeUtils.IsAssignable(TYPE_GAME_OBJECT, type); var isComponent = TypeUtils.IsAssignable(TYPE_COMPONENT, type); if (!isGameObject && !isComponent) { throw new BindingException(TYPE_NOT_COMPONENT); } return(new UnityBindingConditionFactory(bindingFactory.AddBinding(new PrefabBinding(prefab, type), BindingInstance.Transient), prefab.name)); }
public ApplicationController( IBindingFactory <MainController> mainControllerFactory, IOptionsManager optionsManager, IHostEnviromentConnection hostEnviroment, ISettingsManager settingsManager, IEventService eventService) { _optionsManager = optionsManager; _hostEnviroment = hostEnviroment; _settingsManager = settingsManager; _eventService = eventService; HookGlobalExceptionHandlers(); _eventService.Subscribe(this); _mainController = mainControllerFactory.CreateWithBindings(_hostEnviroment.Events); }
/// <summary> /// Binds the key type to a singleton <paramref name="type"/> on a GameObject /// with a given <paramref name="tag"/>. /// /// If more than one object is returned, just the first one will be binded. /// /// If <paramref name="type"/> is <see cref="UnityEngine.GameObject"/>, binds the /// key to the GameObject itself. /// /// If <paramref name="type"/> is see cref="UnityEngine.Component"/>, binds the key /// to the the instance of the component. /// /// If the <see cref="UnityEngine.Component"/> is not found on the GameObject, it will be added. /// </summary> /// <remarks> /// To prevent references to destroyed objects, only bind to game objects that won't /// be destroyed in the scene. /// </remarks> /// <param name="bindingFactory">The original binding factory.</param> /// <param name="type">The component type.</param> /// <param name="tag">The GameObject tag.</param> /// <returns>The binding condition object related to this binding.</returns> public static IBindingConditionFactory ToGameObjectWithTag(this IBindingFactory bindingFactory, Type type, string tag) { if (!TypeUtils.IsAssignable(bindingFactory.bindingType, type)) { throw new BindingException(BindingException.TYPE_NOT_ASSIGNABLE); } var isGameObject = TypeUtils.IsAssignable(typeof(GameObject), type); var isComponent = TypeUtils.IsAssignable(typeof(Component), type); if (!isGameObject && !isComponent) { throw new BindingException(TYPE_NOT_COMPONENT); } var gameObject = GameObject.FindWithTag(tag); return(CreateSingletonBinding(bindingFactory, gameObject, type, isGameObject)); }
/// <summary> /// Binds the key type to a singleton <see cref="UnityEngine.Component"/> /// of <paramref name="type"/> on a newly instantiated prefab. /// /// If the <see cref="UnityEngine.Component"/> is not found on the prefab /// at the moment of the instantiation, it will be added. /// </summary> /// <remarks> /// To prevent references to destroyed objects, only bind to prefabs that won't /// be destroyed in the scene. /// </remarks> /// <param name="bindingFactory">The original binding factory.</param> /// <param name="type">The component type.</param> /// <param name="prefab">Prefab object.</param> /// <returns>The binding condition object related to this binding.</returns> public static UnityBindingConditionFactory ToPrefabSingleton(this IBindingFactory bindingFactory, Type type, GameObject prefab) { if (!TypeUtils.IsAssignable(bindingFactory.bindingType, type)) { throw new BindingException(BindingException.TYPE_NOT_ASSIGNABLE); } var isGameObject = TypeUtils.IsAssignable(TYPE_GAME_OBJECT, type); var isComponent = TypeUtils.IsAssignable(TYPE_COMPONENT, type); if (!isGameObject && !isComponent) { throw new BindingException(TYPE_NOT_COMPONENT); } var gameObject = (GameObject)MonoBehaviour.Instantiate(prefab); return(CreateSingletonBinding(bindingFactory, gameObject, type, isGameObject)); }
public static string Evaluate(this IPropertyBindingSettings settings, IBindingFactory bindingFactory, ITracer tracer, Action <IDynamicBindingContext> contextInitializer = null) { string result; if (settings.ValueProvider != null) { var binding = bindingFactory.CreateBinding <IValueProvider>(settings.ValueProvider); // Make the entire set of element interfaces available to VP bindings. // We add the owner with its full interfaces. And we add the IProperty as well. using (var context = binding.CreateDynamicContext()) { if (contextInitializer != null) { contextInitializer(context); } if (binding.Evaluate(context)) { result = binding.Value.Evaluate() as string; } else { var failMessage = string.Format(CultureInfo.CurrentCulture, Resources.ValueProviderBinding_FailedToEvaluate, settings.Name, settings.Name, ObjectDumper.ToString(binding.EvaluationResults, 5)); tracer.Error(failMessage); throw new InvalidOperationException(failMessage); } } } else { result = settings.Value; } return(result); }
public SiteMapLoaderContainer(ConfigurationSettings settings) { // Singleton instances if (settings.EnableSiteMapFile) { this.absoluteFileName = HostingEnvironment.MapPath(settings.SiteMapFileName); } this.mvcContextFactory = new MvcContextFactory(); #if NET35 this.siteMapCache = new SiteMapCache(new AspNetCacheProvider<ISiteMap>(this.mvcContextFactory)); #else this.siteMapCache = new SiteMapCache(new RuntimeCacheProvider<ISiteMap>(System.Runtime.Caching.MemoryCache.Default)); #endif this.cacheDependency = this.ResolveCacheDependency(settings); this.requestCache = this.mvcContextFactory.GetRequestCache(); this.bindingFactory = new BindingFactory(); this.bindingProvider = new BindingProvider(this.bindingFactory, this.mvcContextFactory); this.urlPath = new UrlPath(this.mvcContextFactory, this.bindingProvider); this.siteMapCacheKeyGenerator = new SiteMapCacheKeyGenerator(this.mvcContextFactory); this.siteMapCacheKeyToBuilderSetMapper = new SiteMapCacheKeyToBuilderSetMapper(); this.reservedAttributeNameProvider = new ReservedAttributeNameProvider(settings.AttributesToIgnore); var siteMapNodeFactoryContainer = new SiteMapNodeFactoryContainer(settings, this.mvcContextFactory, this.urlPath, this.reservedAttributeNameProvider); this.siteMapNodeToParentRelationFactory = new SiteMapNodeToParentRelationFactory(); this.nodeKeyGenerator = new NodeKeyGenerator(); this.siteMapNodeFactory = siteMapNodeFactoryContainer.ResolveSiteMapNodeFactory(); this.siteMapNodeCreatorFactory = this.ResolveSiteMapNodeCreatorFactory(); this.cultureContextFactory = new CultureContextFactory(); this.dynamicSiteMapNodeBuilderFactory = new DynamicSiteMapNodeBuilderFactory(this.siteMapNodeCreatorFactory, this.cultureContextFactory); this.siteMapHierarchyBuilder = new SiteMapHierarchyBuilder(); this.siteMapNodeHelperFactory = this.ResolveSiteMapNodeHelperFactory(); this.siteMapNodeVisitor = this.ResolveSiteMapNodeVisitor(settings); this.siteMapXmlNameProvider = new SiteMapXmlNameProvider(); this.attributeAssemblyProviderFactory = new AttributeAssemblyProviderFactory(); this.mvcSiteMapNodeAttributeDefinitionProvider = new MvcSiteMapNodeAttributeDefinitionProvider(); this.siteMapNodeProvider = this.ResolveSiteMapNodeProvider(settings); this.siteMapBuiderSetStrategy = this.ResolveSiteMapBuilderSetStrategy(settings); var siteMapFactoryContainer = new SiteMapFactoryContainer(settings, this.mvcContextFactory, this.urlPath); this.siteMapFactory = siteMapFactoryContainer.ResolveSiteMapFactory(); this.siteMapCreator = new SiteMapCreator(this.siteMapCacheKeyToBuilderSetMapper, this.siteMapBuiderSetStrategy, this.siteMapFactory); }
public static string Evaluate(this IPropertyBindingSettings settings, IBindingFactory bindingFactory, ITracer tracer, Action<IDynamicBindingContext> contextInitializer = null) { string result; if (settings.ValueProvider != null) { var binding = bindingFactory.CreateBinding<IValueProvider>(settings.ValueProvider); // Make the entire set of element interfaces available to VP bindings. // We add the owner with its full interfaces. And we add the IProperty as well. using (var context = binding.CreateDynamicContext()) { if (contextInitializer != null) contextInitializer(context); if (binding.Evaluate(context)) { result = binding.Value.Evaluate() as string; } else { var failMessage = string.Format(CultureInfo.CurrentCulture, Resources.ValueProviderBinding_FailedToEvaluate, settings.Name, settings.Name, ObjectDumper.ToString(binding.EvaluationResults, 5)); tracer.Error(failMessage); throw new InvalidOperationException(failMessage); } } } else { result = settings.Value; } return result; }
public void GetProducerBindingTest() { BoilersSetFixture _boiler = new BoilersSetFixture(); using (DataGenerator _generator = new DataGenerator(_boiler)) { IBindingFactory _bindingFactory = _generator; IProducerBinding _binding = _bindingFactory.GetProducerBinding("repositoryGroup", "processValueName", new UATypeInfo(BuiltInType.Boolean)); Assert.IsNotNull(_binding); _binding.Encoding.IsEqual(new UATypeInfo(BuiltInType.Boolean)); Assert.IsFalse(_binding.NewValue); Assert.IsNull(_binding.Parameter); int _newValueInvocationCount = 0; _binding.PropertyChanged += (x, evetArgs) => _newValueInvocationCount++; _boiler.Variable.Change(); Assert.AreEqual <int>(1, _newValueInvocationCount); Assert.IsTrue(_binding.NewValue); Assert.IsTrue((bool)_binding.GetFromRepository()); Assert.IsFalse(_binding.NewValue); Assert.AreEqual <int>(1, _newValueInvocationCount); } Assert.AreEqual <int>(1, _boiler.DisposeCount); }
private void ResolveLocalOrGlobal(Expr referringExpr, Token name) { // Loop over all the scopes, from the innermost and outwards, trying to find a registered "binding factory" // that matches this name. for (int i = scopes.Count - 1; i >= 0; i--) { if (scopes[i].ContainsKey(name.Lexeme)) { IBindingFactory bindingFactory = scopes[i][name.Lexeme]; if (bindingFactory == VariableBindingFactory.None) { nameResolutionErrorHandler( new NameResolutionError("Cannot read local variable in its own initializer.", name)); return; } bindingHandler.AddLocalExpr(bindingFactory.CreateBinding(scopes.Count - 1 - i, referringExpr)); return; } } // The identifier was not found in any of the local scopes. If it cannot be found in the globals, we can // safely assume it is non-existent. if (!globals.ContainsKey(name.Lexeme)) { return; } // Note: the extra block here is actually not just "for fun". We get a conflict with the bindingFactory // in the for-loop above if we skip it. { IBindingFactory bindingFactory = globals[name.Lexeme]; bindingHandler.AddGlobalExpr(bindingFactory.CreateBinding(-1, referringExpr)); } }
/// <summary> /// Binds the key type to a singleton <paramref name="type"/> on a GameObject /// with a given <paramref name="tag"/>. /// /// If more than one object is returned, just the first one will be binded. /// /// If <paramref name="type"/> is <see cref="UnityEngine.GameObject"/>, binds the /// key to the GameObject itself. /// /// If <paramref name="type"/> is see cref="UnityEngine.Component"/>, binds the key /// to the the instance of the component. /// /// If the <see cref="UnityEngine.Component"/> is not found on the GameObject, it will be added. /// </summary> /// <remarks> /// To prevent references to destroyed objects, only bind to game objects that won't /// be destroyed in the scene. /// </remarks> /// <param name="bindingFactory">The original binding factory.</param> /// <param name="type">The component type.</param> /// <param name="tag">The GameObject tag.</param> /// <returns>The binding condition object related to this binding.</returns> public static UnityBindingConditionFactory ToGameObjectWithTag(this IBindingFactory bindingFactory, Type type, string tag) { if (!TypeUtils.IsAssignable(bindingFactory.bindingType, type)) { throw new BindingException(BindingException.TYPE_NOT_ASSIGNABLE); } var isGameObject = TypeUtils.IsAssignable(TYPE_GAME_OBJECT, type); var isComponent = TypeUtils.IsAssignable(TYPE_COMPONENT, type); if (!isGameObject && !isComponent) { throw new BindingException(TYPE_NOT_COMPONENT); } var gameObject = GameObject.FindWithTag(tag); if (gameObject == null) { throw new BindingException(string.Format(GAMEOBJECT_TAG_TYPE_IS_NULL, tag, type.ToString())); } return(CreateSingletonBinding(bindingFactory, gameObject, type, isGameObject)); }
private void InitializeDependencies() { _weakEventManagerFactory = ServiceProvider.GetRequiredService <IWeakEventManagerFactory>(); _bindingFactory = ServiceProvider.GetRequiredService <IBindingFactory>(); _weakEventManager = _weakEventManagerFactory.Create(); }
/// <summary> /// Initializes a new instance of the <see cref="ConsumerAssociation" /> class. /// </summary> /// <param name="data">The data.</param> /// <param name="dataSet">The members.</param> /// <param name="bindingFactory">The binding factory.</param> /// <param name="encodingFactory">The encoding factory.</param> internal ConsumerAssociation(ISemanticData data, DataSetConfiguration dataSet, IBindingFactory bindingFactory, IEncodingFactory encodingFactory) : base(data, dataSet.AssociationName) { m_DataSetBindings = dataSet.DataSet.Select<FieldMetaData, IConsumerBinding>(x => x.GetConsumerBinding4DataMember(dataSet.RepositoryGroup, bindingFactory, encodingFactory)).ToArray<IConsumerBinding>(); }
protected BindingSourceProcessor(IBindingFactory bindingFactory) { this.bindingFactory = bindingFactory; }
public BindingRegistry(IErrorProvider errorProvider, IBindingFactory bindingFactory) { this.errorProvider = errorProvider; this.bindingFactory = bindingFactory; }
/// <summary> /// Initializes a new instance of the <see cref="ConsumerAssociation" /> class. /// </summary> /// <param name="data">The data.</param> /// <param name="dataSet">The members.</param> /// <param name="bindingFactory">The binding factory.</param> /// <param name="encodingFactory">The encoding factory.</param> internal ConsumerAssociation(ISemanticData data, DataSetConfiguration dataSet, IBindingFactory bindingFactory, IEncodingFactory encodingFactory) : base(data, dataSet.AssociationName) { m_DataSetBindings = dataSet.DataSet.Select <FieldMetaData, IConsumerBinding>(x => x.GetConsumerBinding4DataMember(dataSet.RepositoryGroup, bindingFactory, encodingFactory)).ToArray <IConsumerBinding>(); }
public void DiscoverServiceUsingAdapter_registers_service_using_discovery(ServiceCollection services, ServiceLifetime lifetime, ITestService testService, IDiscoveryService discoveryService, IBindingFactory bindingFactory) { services.DiscoverServiceUsingAdapter <ITestService>(lifetime); services.AddSingleton <IBindingFactory>(bindingFactory); services.AddSingleton <IDiscoveryService>(discoveryService); Mock.Get(discoveryService).Setup(p => p.Discover <ITestService>(It.IsAny <NetTcpBinding>())).Returns(testService); var serviceProvider = services.BuildServiceProvider(); var service = serviceProvider.GetRequiredService <ITestService>(); Assert.That(service, Is.SameAs(testService)); }
public RuntimeBindingSourceProcessor(IBindingFactory bindingFactory, IBindingRegistry bindingRegistry, IErrorProvider errorProvider, ITestTracer testTracer) : base(bindingFactory) { this.bindingRegistry = bindingRegistry; this.errorProvider = errorProvider; this.testTracer = testTracer; }
/// <summary> /// Gets the consumer binding for data member. /// </summary> /// <param name="member">The field description captured bu object of type <see cref="FieldMetaData"/> .</param> /// <param name="repositoryGroup">The repository group.</param> /// <param name="bindingFactory">The binding factory.</param> /// <param name="encodingFactory">The encoding factory.</param> /// <returns>An instance of <see cref="IProducerBinding" /> type.</returns> internal static IProducerBinding GetProducerBinding4DataMember(this FieldMetaData member, string repositoryGroup, IBindingFactory bindingFactory, IEncodingFactory encodingFactory) { IProducerBinding _binding = bindingFactory.GetProducerBinding(repositoryGroup, member.ProcessValueName, member.TypeInformation); encodingFactory.UpdateValueConverter(_binding, repositoryGroup, member.TypeInformation); return _binding; }