Esempio n. 1
0
        internal GlobalRunSpec(
            IDirectory templateRoot,
            IComponentManager componentManager,
            IParameterSet parameters,
            IVariableCollection variables,
            IGlobalRunConfig globalConfig,
            IReadOnlyList <KeyValuePair <string, IGlobalRunConfig> > fileGlobConfigs,
            IReadOnlyList <string> ignoreFileNames)
        {
            EnsureOperationConfigs(componentManager);

            RootVariableCollection = variables;
            IgnoreFileNames        = ignoreFileNames;
            Operations             = ResolveOperations(globalConfig, templateRoot, variables, parameters);
            List <KeyValuePair <IPathMatcher, IRunSpec> > specials = new List <KeyValuePair <IPathMatcher, IRunSpec> >();

            if (fileGlobConfigs != null)
            {
                foreach (KeyValuePair <string, IGlobalRunConfig> specialEntry in fileGlobConfigs)
                {
                    IReadOnlyList <IOperationProvider> specialOps = null;

                    if (specialEntry.Value != null)
                    {
                        specialOps = ResolveOperations(specialEntry.Value, templateRoot, variables, parameters);
                    }

                    RunSpec spec = new RunSpec(specialOps, specialEntry.Value.VariableSetup.FallbackFormat);
                    specials.Add(new KeyValuePair <IPathMatcher, IRunSpec>(new GlobbingPatternMatcher(specialEntry.Key), spec));
                }
            }

            Special = specials;
        }
        public GlobalRunSpec(
            IDirectory templateRoot,
            IComponentManager componentManager,
            IParameterSet parameters,
            IVariableCollection variables,
            IGlobalRunConfig globalConfig,
            IReadOnlyList <KeyValuePair <string, IGlobalRunConfig> > fileGlobConfigs,
            IReadOnlyDictionary <string, IReadOnlyList <IOperationProvider> > localizationOperations,
            string placeholderFilename)
        {
            EnsureOperationConfigs(componentManager);

            RootVariableCollection = variables;
            LocalizationOperations = localizationOperations;
            PlaceholderFilename    = placeholderFilename;
            Operations             = ResolveOperations(globalConfig, templateRoot, variables, parameters);
            List <KeyValuePair <IPathMatcher, IRunSpec> > specials = new List <KeyValuePair <IPathMatcher, IRunSpec> >();

            if (fileGlobConfigs != null)
            {
                foreach (KeyValuePair <string, IGlobalRunConfig> specialEntry in fileGlobConfigs)
                {
                    IReadOnlyList <IOperationProvider> specialOps = null;
                    IVariableCollection specialVariables          = variables;

                    if (specialEntry.Value != null)
                    {
                        specialOps       = ResolveOperations(specialEntry.Value, templateRoot, variables, parameters);
                        specialVariables = VariableCollection.SetupVariables(templateRoot.MountPoint.EnvironmentSettings, parameters, specialEntry.Value.VariableSetup);
                    }

                    RunSpec spec = new RunSpec(specialOps, specialVariables ?? variables, specialEntry.Value.VariableSetup.FallbackFormat);
                    specials.Add(new KeyValuePair <IPathMatcher, IRunSpec>(new GlobbingPatternMatcher(specialEntry.Key), spec));
                }
            }

            Special = specials;
        }
        public GlobalRunSpec(FileSource source, ITemplateSourceFolder templateRoot, IParameterSet parameters, IReadOnlyDictionary <string, JObject> operations, IReadOnlyDictionary <string, Dictionary <string, JObject> > special)
        {
            int expect = source.Include?.Length ?? 0;
            List <IPathMatcher> includes = new List <IPathMatcher>(expect);

            if (source.Include != null && expect > 0)
            {
                foreach (string include in source.Include)
                {
                    includes.Add(new GlobbingPatternMatcher(include));
                }
            }
            Include = includes;

            expect = source.CopyOnly?.Length ?? 0;
            List <IPathMatcher> copyOnlys = new List <IPathMatcher>(expect);

            if (source.CopyOnly != null && expect > 0)
            {
                foreach (string copyOnly in source.CopyOnly)
                {
                    copyOnlys.Add(new GlobbingPatternMatcher(copyOnly));
                }
            }
            CopyOnly = copyOnlys;

            expect = source.Exclude?.Length ?? 0;
            List <IPathMatcher> excludes = new List <IPathMatcher>(expect);

            if (source.Exclude != null && expect > 0)
            {
                foreach (string exclude in source.Exclude)
                {
                    excludes.Add(new GlobbingPatternMatcher(exclude));
                }
            }
            Exclude = excludes;

            Rename = source.Rename != null
                ? new Dictionary <string, string>(source.Rename, StringComparer.OrdinalIgnoreCase)
                : new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            VariableCollection variables;

            Operations             = ProcessOperations(parameters, templateRoot, operations, out variables);
            RootVariableCollection = variables;
            Dictionary <IPathMatcher, IRunSpec> specials = new Dictionary <IPathMatcher, IRunSpec>();

            if (special != null)
            {
                foreach (KeyValuePair <string, Dictionary <string, JObject> > specialEntry in special)
                {
                    IReadOnlyList <IOperationProvider> specialOps = null;
                    VariableCollection specialVariables           = variables;

                    if (specialEntry.Value != null)
                    {
                        specialOps = ProcessOperations(parameters, templateRoot, specialEntry.Value, out specialVariables);
                    }

                    RunSpec spec = new RunSpec(specialOps, specialVariables ?? variables);
                    specials[new GlobbingPatternMatcher(specialEntry.Key)] = spec;
                }
            }

            Special = specials;
        }