Ejemplo n.º 1
0
        void Register()
        {
            BaseIOCContext[] contexts = FindObjectsOfType <BaseIOCContext> ();

            foreach (BaseIOCContext c in contexts)
            {
                if (!c.Ready)
                {
                    continue;
                }

                FactoryBase TFactory = c.GetFactoryForType <T> ();
                if (TFactory != null)
                {
                    m_TFactory = TFactory;
                    m_Ready    = true;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        FactoryBase CreateFactoryForType <T>()
        {
            string typeName  = typeof(T).AssemblyQualifiedName;
            string boundName = "";

            m_BoundFactories.TryGetValue(typeName, out boundName);

            if (boundName == null)
            {
                Debug.Log("Factory Binding for type " + typeof(T).Name + " not found. Aborting.");
                return(null);
            }

            FactoryBase factory = System.Activator.CreateInstance(System.Type.GetType(boundName)) as FactoryBase;

            if (factory != null)
            {
                m_FactoryInstances.Add(typeName, factory);
            }

            return(factory);
        }