Example #1
0
        private void AddViewTemplate(
            AnalysisUnit unit,
            IAnalysisSet model,
            IAnalysisSet querySet,
            IEnumerable <string> contextObjName,
            string templateName
            )
        {
            TemplateVariables tags;

            if (!_templateFiles.TryGetValue(templateName, out tags))
            {
                _templateFiles[templateName] = tags = new TemplateVariables();
            }

            if (querySet != null)
            {
                foreach (var name in contextObjName)
                {
                    tags.UpdateVariable(name, unit, AnalysisSet.Empty);
                }
            }
            else if (model != null)
            {
                foreach (var modelInst in model)
                {
                    foreach (var name in contextObjName.DefaultIfEmpty(modelInst.Name.ToLower()))
                    {
                        tags.UpdateVariable(name, unit, modelInst.GetInstanceType());
                    }
                }
            }
        }
Example #2
0
        private void AddTemplateMapping(
            AnalysisUnit unit,
            string filename,
            IEnumerable<AnalysisValue> dictArgs,
            IEnumerable<AnalysisValue> context
        ) {
            TemplateVariables tags;
            if (!_templateFiles.TryGetValue(filename, out tags)) {
                _templateFiles[filename] = tags = new TemplateVariables();
            }

            IEnumerable<KeyValuePair<IAnalysisSet, IAnalysisSet>> items = null;
            if (context != null) {
                items = context.OfType<ContextMarker>()
                    .SelectMany(ctxt => ctxt.Arguments.SelectMany(v => v.GetItems()));
            } else if (dictArgs != null) {
                items = dictArgs.SelectMany(v => v.GetItems());
            }

            if (items != null) {
                foreach (var keyValue in items) {
                    foreach (var key in keyValue.Key) {
                        var keyName = key.GetConstantValueAsString();
                        if (keyName != null) {
                            tags.UpdateVariable(keyName, unit, keyValue.Value);
                        }
                    }
                }
            }
        }
Example #3
0
        private void AddTemplateMapping(
            AnalysisUnit unit,
            string filename,
            IEnumerable<AnalysisValue> dictArgs,
            IEnumerable<AnalysisValue> context
        ) {
            TemplateVariables tags;
            if (!_templateFiles.TryGetValue(filename, out tags)) {
                _templateFiles[filename] = tags = new TemplateVariables();
            }

            IEnumerable<KeyValuePair<IAnalysisSet, IAnalysisSet>> items = null;
            if (context != null) {
                items = context.OfType<ContextMarker>()
                    .SelectMany(ctxt => ctxt.Arguments.SelectMany(v => v.GetItems()));
            } else if (dictArgs != null) {
                items = dictArgs.SelectMany(v => v.GetItems());
            }

            if (items != null) {
                foreach (var keyValue in items) {
                    foreach (var key in keyValue.Key) {
                        var keyName = key.GetConstantValueAsString();
                        if (keyName != null) {
                            tags.UpdateVariable(keyName, unit, keyValue.Value);
                        }
                    }
                }
            }
        }
Example #4
0
        private void AddViewTemplate(
            AnalysisUnit unit,
            IAnalysisSet model,
            IAnalysisSet querySet,
            IEnumerable<string> contextObjName,
            string templateName
        ) {
            TemplateVariables tags;
            if (!_templateFiles.TryGetValue(templateName, out tags)) {
                _templateFiles[templateName] = tags = new TemplateVariables();
            }

            if (querySet != null) {
                foreach (var name in contextObjName) {
                    tags.UpdateVariable(name, unit, AnalysisSet.Empty);
                }
            } else if (model != null) {
                foreach (var modelInst in model) {
                    foreach (var name in contextObjName.DefaultIfEmpty(modelInst.Name.ToLower())) {
                        tags.UpdateVariable(name, unit, modelInst.GetInstanceType());
                    }
                }
            }
        }