Ejemplo n.º 1
0
        public DefaultContainer(ILocator componentLocator)
        {
            this.componentLocator = componentLocator;

            this.componentRegistry  = new DefaultComponentRegistry();
            this.componentCache     = new DefaultComponentCache();
            this.componentActivator = new DefaultComponentActivator(this.componentRegistry, this.componentCache);
        }
Ejemplo n.º 2
0
 public static bool HasCache([NotNull] this Component component,
                             out IComponentCache cache)
 {
     if (component == null)
     {
         throw new ArgumentNullException(nameof(component));
     }
     return(component.TryGetComponent(out cache));
 }
Ejemplo n.º 3
0
 public static bool HasCache([NotNull] this GameObject gameObject,
                             out IComponentCache cache)
 {
     if (gameObject == null)
     {
         throw new ArgumentNullException(nameof(gameObject));
     }
     return(gameObject.TryGetComponent(out cache));
 }
Ejemplo n.º 4
0
        public LocalComponentFactory(Type targetType)
        {
            _targetType = targetType ?? throw new ArgumentNullException(nameof(targetType));

            _composer                       = null;
            _componentCache                 = null;
            _componentCacheQuery            = null;
            _targetConstructor              = null;
            _constructorArgs                = null;
            _initializationPoints           = new List <InitializationPointSpecification>();
            _compositionNotificationMethods = null;
        }
Ejemplo n.º 5
0
        private void LoadComponentCache()
        {
            var attribute = ComponentContextUtils.GetComponentCacheAttribute(_targetType);

            if (attribute == null)
            {
                _componentCache = _composer.GetComponent <DefaultComponentCache>();
                return;
            }

            if (attribute.ComponentCacheType == null)
            {
                _componentCache = null;
                return;
            }

            var result = _composer.GetComponent(attribute.ComponentCacheType, attribute.ComponentCacheName);

            if (result == null)
            {
                throw new CompositionException("Can not register component type " + _targetType.FullName +
                                               " because the specified ComponentCache contract (type=" +
                                               attribute.ComponentCacheType.FullName +
                                               ", name=" + (attribute.ComponentCacheName ?? "null") +
                                               ") could not be queried from Composer.");
            }

            if (!(result is IComponentCache))
            {
                throw new CompositionException("Component cache type " + result.GetType().FullName +
                                               " that is specified as component cache handler on component " + _targetType.FullName +
                                               " does not implement IComponentCache interface.");
            }

            _componentCache = (IComponentCache)result;
        }
Ejemplo n.º 6
0
 public void SetUp()
 {
     _cache = new ComponentCache();
 }
Ejemplo n.º 7
0
 public DefaultComponentActivator(IComponentRegistry componentRegistry, IComponentCache componentCache)
 {
     this.componentRegistry = componentRegistry;
     this.componentCache    = componentCache;
 }