Example #1
0
        public AppBuilder UseApp <TApp>(ChromelyApp chromelyApp = null) where TApp : ChromelyApp
        {
            _chromelyApp = chromelyApp;
            if (_chromelyApp == null)
            {
                EnsureIsDerivedType(typeof(ChromelyApp), typeof(TApp));
                _chromelyApp = (TApp)Activator.CreateInstance(typeof(TApp));
            }

            _stepCompleted = 1;
            return(this);
        }
        public AppBuilder UseApp <T>(ChromelyApp chromelyApp = null) where T : ChromelyApp
        {
            if (_stepCompleted != 1)
            {
                throw new Exception("Invalid order: step 1: Contructor must be completed before step 2.");
            }

            _chromelyApp = chromelyApp;
            if (_chromelyApp == null)
            {
                EnsureIsDerivedType(typeof(ChromelyApp), typeof(T));
                _chromelyApp = (T)Activator.CreateInstance(typeof(T));
            }

            _stepCompleted = 2;
            return(this);
        }
Example #3
0
        public AppBuilder UseApp <T>(ChromelyApp chromelyApp = null) where T : ChromelyApp
        {
            if (_stepCompleted != 1)
            {
                throw new Exception("Step 1 must be completed before step 2.");
            }

            if (typeof(T).FullName.Equals(typeof(ChromelyApp).FullName, StringComparison.OrdinalIgnoreCase))
            {
                throw new Exception($"Type {typeof(T).Name} must implement ChromelyApp.");
            }

            _chromelyApp = chromelyApp;
            if (_chromelyApp == null)
            {
                _chromelyApp = (T)Activator.CreateInstance(typeof(T));
            }

            _stepCompleted = 2;
            return(this);
        }