Example #1
0
        public T GetInstance(string key)
        {
            //return null;
            //var finalAppId = appId ?? AppEntity.CurrentRuningU3DApp.LocAppId;

            //if (!AppInstances.ContainsKey(finalAppId))
            //{
            //    AppInstances.Add(finalAppId, new Dictionary<string, T>());
            //}

            T instance;

            //var instances = AppInstances[finalAppId];
            if (AppInstances.ContainsKey(key))
            {
                instance = AppInstances[key];
            }
            else
            {
                var type = GetType(key);
                if (type == null)
                {
                    instance = default(T);
                }
                else
                {
                    instance = (T)Activator.CreateInstance(type);
                }
            }

            return(instance);
        }
        public T GetInstance(string key)
        {
            T instance;

            if (AppInstances.ContainsKey(key))
            {
                instance = AppInstances[key];
            }
            else
            {
                var func = GetFunc(key);
                instance = func();
            }

            return(null);
        }
 public void RemoveAppInstance(string instanceName)
 {
     try
     {
         if (AppInstances.ContainsKey(instanceName))
         {
             AppInstances.Remove(instanceName);
         }
         else
         {
             throw new Exception("App Instance '" + instanceName + "' not found!");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void AddAppInstance(string instanceName, object appObject)
        {
            if (AppInstances.ContainsKey(instanceName) && engineSettings.OverrideExistingAppInstances)
            {
                ReportProgress("Overriding Existing Instance: " + instanceName);
                AppInstances.Remove(instanceName);
            }
            else if (AppInstances.ContainsKey(instanceName) && !engineSettings.OverrideExistingAppInstances)
            {
                throw new Exception("App Instance already exists and override has been disabled in engine settings! Enable override existing app instances or use unique instance names!");
            }

            try
            {
                this.AppInstances.Add(instanceName, appObject);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }