protected virtual void LoadDynamicExecutors
        (
            string dynamicLoadExecutorsPathsJsonFile = "dynamicLoadExecutorsPaths.json"
        )
        {
            var processors =
                GetDynamicExecutorsPathsProcess
                (
                    dynamicLoadExecutorsPathsJsonFile
                )
                .Where
                (
                    (x) =>
            {
                return
                (
                    !x
                    .IsNullOrEmptyOrWhiteSpace()
                    &&
                    Directory
                    .Exists(x)
                );
            }
                )
                .SelectMany
                (
                    (x) =>
            {
                var r =
                    CompositionHelper
                    .ImportManyExportsComposeParts
                    <IActionProcessable>
                        (x);
                return(r);
            }
                )
                .ToDictionary
                (
                    (x) =>
            {
                return
                (x.Key);
            }
                    ,
                    (x) =>
            {
                return(x);
            }
                    , StringComparer
                    .OrdinalIgnoreCase
                );

            _locker
            .LockIf
            (
                () =>
            {
                var r = (_processors == null);
                return(r);
            }
                , () =>
            {
                _processors = processors;
            }
            );
        }
        protected virtual void LoadDynamicExecutors
        (
            string dynamicLoadExecutorsPathsJsonFile = "dynamicLoadExecutorsPaths.json"
        )
        {
            var executingDirectory = Path
                                     .GetDirectoryName
                                     (
                Assembly
                .GetExecutingAssembly()
                .Location
                                     );
            var executors =
                GetDynamicLoadExecutorsPathsProcess
                (
                    //dynamicLoadExecutorsPathsJsonFile
                )
                .Select
                (
                    (x) =>
            {
                var path = x;
                if (!path.IsNullOrEmptyOrWhiteSpace())
                {
                    if
                    (
                        x.StartsWith(".")
                    )
                    {
                        path = path.TrimStart('.', '\\', '/');
                    }
                    path = Path.Combine
                           (
                        executingDirectory
                        , path
                           );
                }
                return(path);
            }
                )
                .Where
                (
                    (x) =>
            {
                return
                (
                    !x
                    .IsNullOrEmptyOrWhiteSpace()
                    &&
                    Directory
                    .Exists(x)
                );
            }
                )
                .SelectMany
                (
                    (x) =>
            {
                var r =
                    CompositionHelper
                    .ImportManyExportsComposeParts
                    <IStoreProcedureExecutable>
                        (x);
                return(r);
            }
                );
            var indexedExecutors =
                executors
                .Distinct
                (
                    new StoreProcedureComparer()
                )
                .ToDictionary
                (
                    (x) =>
            {
                return
                (x.DataBaseType);
            }
                    ,
                    (x) =>
            {
                IParametersDefinitionCacheAutoRefreshable
                rr = x as IParametersDefinitionCacheAutoRefreshable;
                if (rr != null)
                {
                    rr
                    .CachedParametersDefinitionExpiredInSeconds
                        = CachedParametersDefinitionExpiredInSeconds;
                    rr
                    .NeedAutoRefreshExecutedTimeForSlideExpire
                        = NeedAutoRefreshExecutedTimeForSlideExpire;
                }
                return(x);
            }
                    , StringComparer
                    .OrdinalIgnoreCase
                );

            _locker
            .LockIf
            (
                () =>
            {
                var r = (_indexedExecutors == null);
                return(r);
            }
                , () =>
            {
                _indexedExecutors = indexedExecutors;
            }
            );
        }
Exemplo n.º 3
0
        protected virtual void LoadDynamicValidators
        (
            //string dynamicValidatorsPathsJsonFile = "dynamicValidatorsPaths.json"
        )
        {
            var executingDirectory = Path
                                     .GetDirectoryName
                                     (
                Assembly
                .GetExecutingAssembly()
                .Location
                                     );
            var validators = GetDynamicValidatorsPathsProcess
                             (
                //dynamicValidatorsPathsJsonFile
                             )
                             .Select
                             (
                (x) =>
            {
                var path = x;
                if (!path.IsNullOrEmptyOrWhiteSpace())
                {
                    if
                    (
                        x.StartsWith(".")
                    )
                    {
                        path = path.TrimStart('.', '\\', '/');
                    }
                    path = Path.Combine
                           (
                        executingDirectory
                        , path
                           );
                }
                return(path);
            }
                             )
                             .Where
                             (
                (x) =>
            {
                return
                (
                    !x
                    .IsNullOrEmptyOrWhiteSpace()
                    &&
                    Directory
                    .Exists(x)
                );
            }
                             )
                             .SelectMany
                             (
                (x) =>
            {
                return
                (CompositionHelper
                 .ImportManyExportsComposeParts
                 <IHttpRequestValidateable <JToken> >
                 (
                     x
                     , "*Validator*Plugin*.dll"
                 ));
            }
                             );

            _indexedValidators = validators
                                 .Distinct
                                 (
                new FullTypeNameEqualityComparer
                <IHttpRequestValidateable <JToken> >
                    ()
                                 )
                                 .ToDictionary
                                 (
                (x) =>
            {
                return
                (x.Name);
            }
                , StringComparer
                .OrdinalIgnoreCase
                                 );
        }