Beispiel #1
0
        private ExplorerItem GetFileReaderItem(IFileMetaData fileMetaData, bool isCoreFile)
        {
            var explorerIcon = isCoreFile ? ExplorerIcon.View : ExplorerIcon.Table;
            var explorerItem = new ExplorerItem(CodeDomUtils.ExtractClassName(fileMetaData.FileName, capitalize),
                                                ExplorerItemKind.QueryableObject, explorerIcon)
            {
                Children     = new List <ExplorerItem>(),
                IsEnumerable = true
            };

            usedNames.Clear();
            foreach (var field in fileMetaData.Fields)
            {
                var fieldName = CodeDomUtils.ModifyKeywords(field.Term, capitalize);
                int i         = 1;
                while (usedNames.Contains(fieldName))
                {
                    fieldName += i.ToString();
                    i++;
                }
                usedNames.Add(fieldName);
                var icon      = GetFieldIcon(fileMetaData, field);
                var fieldItem = new ExplorerItem(fieldName, ExplorerItemKind.Property, icon);
                explorerItem.Children.Add(fieldItem);
            }
            return(explorerItem);
        }
Beispiel #2
0
        private CodeMemberProperty CreateProperty(FieldType field)
        {
            var fieldName = CodeDomUtils.ModifyKeywords(field.Term, capitalize);
            int i         = 1;

            while (usedNames.Contains(fieldName))
            {
                fieldName += i.ToString();
                i++;
            }
            var fieldProperty = new CodeMemberProperty()
            {
                Type       = new CodeTypeReference(typeof(string)),
                Attributes = MemberAttributes.Public | MemberAttributes.Final,
                Name       = fieldName,
                HasGet     = true
            };

            usedNames.Add(fieldProperty.Name);
            fieldProperty.GetStatements.Add(new CodeSnippetExpression($"return row[\"{field.Term}\"]"));
            return(fieldProperty);
        }