Exemplo n.º 1
0
        public ScriptServices Build()
        {
            var defaultExecutorType = typeof(ScriptExecutor);

            _scriptExecutorType = Overrides.ContainsKey(typeof(IScriptExecutor))
                ? (Type)Overrides[typeof(IScriptExecutor)]
                : defaultExecutorType;

            var defaultReplType = typeof(Repl);

            _replType = Overrides.ContainsKey(typeof(IRepl)) ? (Type)Overrides[typeof(IRepl)] : defaultReplType;

            _scriptEngineType = (Type)Overrides[typeof(IScriptEngine)];

            var initDirectoryCatalog = _scriptName != null || _repl;

            if (_runtimeServices == null)
            {
                _runtimeServices = new RuntimeServices(
                    _logger,
                    Overrides,
                    ConsoleInstance,
                    _scriptEngineType,
                    _scriptExecutorType,
                    _replType,
                    initDirectoryCatalog,
                    InitializationServices,
                    _scriptName);
            }

            return(_runtimeServices.GetScriptServices());
        }
        public virtual void Process(MigrateItemPipelineArgs args)
        {
            if (args.Source == null ||
                args.Item != null)
            {
                return;
            }

            var source = args.Source;

            var id     = (Overrides.ContainsKey(source.Id)) ? Overrides[source.Id] : source.Id;
            var itemId = new ID(id);

            args.Item = Sitecore.Context.Database.GetItem(itemId);

            if (args.Item != null)
            {
                if (KeepExistingMedia && args.Item.Paths.IsMediaItem && args.Item.TemplateID != TemplateIDs.MediaFolder)
                {
                    args.AbortPipeline();
                }

                return;
            }

            var results = _createItemPipeline.Run(source, itemId);

            if (results.Aborted)
            {
                args.AbortPipeline();
                return;
            }

            args.Item = results.Item;
        }
Exemplo n.º 3
0
        public ScriptServices Build(IEnumerable <Assembly> applicationAssemblies)
        {
            var defaultExecutorType = typeof(ScriptExecutor);

            _scriptExecutorType = Overrides.ContainsKey(typeof(IScriptExecutor))
                ? (Type)Overrides[typeof(IScriptExecutor)]
                : defaultExecutorType;

            var defaultReplType = typeof(Repl);

            _replType = Overrides.ContainsKey(typeof(IRepl)) ? (Type)Overrides[typeof(IRepl)] : defaultReplType;

            //todo: this hardcodes the engine for now
            var defaultEngineType = _repl ? typeof(CSharpReplEngine) : typeof(CSharpScriptEngine);

            _scriptEngineType = Overrides.ContainsKey(typeof(IScriptEngine)) ? (Type)Overrides[typeof(IScriptEngine)] : defaultEngineType;

            bool initDirectoryCatalog;

            if (_loadScriptPacks.HasValue)
            {
                initDirectoryCatalog = _loadScriptPacks.Value;
            }
            else
            {
                initDirectoryCatalog = _scriptName != null || _repl;
            }

            if (_runtimeServices == null)
            {
                _runtimeServices = new RuntimeServices(
                    _logProvider,
                    Overrides,
                    ConsoleInstance,
                    _scriptEngineType,
                    _scriptExecutorType,
                    _replType,
                    initDirectoryCatalog,
                    InitializationServices,
                    _scriptName, applicationAssemblies);
            }

            return(_runtimeServices.GetScriptServices());
        }
Exemplo n.º 4
0
        public ScriptServices Build()
        {
            var defaultExecutorType = _debug ? typeof(DebugScriptExecutor) : typeof(ScriptExecutor);
            var defaultEngineType   = _debug ? typeof(RoslynScriptDebuggerEngine) : typeof(RoslynScriptEngine);

            _scriptExecutorType = Overrides.ContainsKey(typeof(IScriptExecutor)) ? (Type)Overrides[typeof(IScriptExecutor)] : defaultExecutorType;
            _scriptEngineType   = Overrides.ContainsKey(typeof(IScriptEngine)) ? (Type)Overrides[typeof(IScriptEngine)] : defaultEngineType;

            var initDirectoryCatalog = _scriptName != null || _repl;

            if (_runtimeServices == null)
            {
                _runtimeServices = new RuntimeServices(_logger, Overrides, LineProcessors, _console,
                                                       _scriptEngineType, _scriptExecutorType,
                                                       initDirectoryCatalog,
                                                       _initializationServices);
            }
            return(_runtimeServices.GetScriptServices());
        }
Exemplo n.º 5
0
 public bool HasExplicitValue(string key)
 {
     return(Overrides.ContainsKey(key));
 }
Exemplo n.º 6
0
 public bool HasSetting(string key)
 {
     return(Overrides.ContainsKey(key) || Defaults.ContainsKey(key));
 }
Exemplo n.º 7
0
 /// <summary>
 /// True if there is an explicit value for the given key.
 /// </summary>
 /// <param name="key">The Key.</param>
 /// <returns>True if found.</returns>
 public bool HasExplicitValue(string key)
 {
     Guard.AgainstNullAndEmpty(nameof(key), key);
     return(Overrides.ContainsKey(key));
 }
Exemplo n.º 8
0
 /// <summary>
 /// True if there is a default or explicit value for the given key.
 /// </summary>
 /// <param name="key">The Key.</param>
 /// <returns>True if found.</returns>
 public bool HasSetting(string key)
 {
     Guard.AgainstNullAndEmpty(nameof(key), key);
     return(Overrides.ContainsKey(key) || Defaults.ContainsKey(key));
 }