Exemplo n.º 1
0
        /// <summary>
        /// Get the instance
        /// </summary>
        /// <param name="ioc">The ioc container</param>
        /// <param name="createNew">True for a non-shared instance</param>
        /// <returns>The resolved instance</returns>
        public object GetInstance(IPortableIoC ioc, bool createNew)
        {
            if (createNew)
            {
                return(_creation(ioc));
            }

            if (HasInstance)
            {
                return(_instance);
            }

            Monitor.Enter(_mutex);

            try
            {
                if (HasInstance)
                {
                    return(_instance);
                }

                _instance   = _creation(ioc);
                HasInstance = true;

                return(_instance);
            }
            finally
            {
                Monitor.Exit(_mutex);
            }
        }
Exemplo n.º 2
0
        //PortableIOC
        private static void Bootstrap()
        {
            // Create the container as usual.
            var container = new PortableIoc();

            // Register your types, for instance:
            //container.Register<IMainViewModel>(ioc => new MainViewModel());

            // Store the container for use by the application.
            App.container = container;

            // Support UI cross thread
            StaticFunctions.BaseContext = System.Threading.SynchronizationContext.Current;

            // Create the AbstractFunctions instance
            EtcUtility.Instance = new PhoneEtcUtility();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Grabs the typed implementation of the base instance
 /// </summary>
 /// <param name="ioc">The ioc container</param>
 /// <param name="createNew">True for a non-shared instance</param>
 /// <returns>The resolved instance</returns>
 public T GetTypedInstance(IPortableIoC ioc, bool createNew)
 {
     return((T)GetInstance(ioc, createNew));
 }
Exemplo n.º 4
0
 public void TestInitialize()
 {
     _target = new PortableIoc();
 }