private DataType BuildGraph(
            DataType parent,
            Type type, 
            bool inputGraph,
            IEnumerable<Type> ancestors, 
            MemberDescription memberDescription = null,
            ActionCall action = null)
        {
            var description = _typeConvention.GetDescription(type);

            var dataType = new DataType
            {
                Name = !type.IsSimpleType() && memberDescription != null ? 
                    memberDescription.Name : description.Name,
                LongNamespace = parent.MapOrEmpty(x => x.LongNamespace.Concat(x.Name).ToList(), new List<string>()),
                ShortNamespace = new List<string>(),
                Comments = description.Comments
            };

            if (type.IsDictionary())
                BuildDictionary(dataType, type, description, inputGraph, ancestors, memberDescription);
            else if (type.IsArray || type.IsList())
                BuildArray(dataType, type, description, inputGraph, ancestors, memberDescription);
            else if (type.IsSimpleType()) BuildSimpleType(dataType, type);
            else BuildComplexType(dataType, type, inputGraph, ancestors, action);

            return _configuration.TypeOverrides.Apply(type, dataType);
        }
示例#2
0
        private void BuildArray(
            DataType dataType,
            Type type,
            TypeDescription typeDescription,
            bool inputGraph,
            IEnumerable <Type> ancestors,
            MemberDescription memberDescription)
        {
            dataType.IsArray  = true;
            dataType.Comments = memberDescription.WhenNotNull(x => x.Comments).OtherwiseDefault() ?? dataType.Comments;
            var itemType = BuildGraph(dataType, type.GetListElementType(), inputGraph, ancestors);

            dataType.ArrayItem = new ArrayItem
            {
                Name = memberDescription.WhenNotNull(x => x.ArrayItem.Name).OtherwiseDefault() ??
                       typeDescription.WhenNotNull(x => x.ArrayItem.Name).OtherwiseDefault() ?? itemType.Name,
                Comments = memberDescription.WhenNotNull(x => x.ArrayItem.Comments).OtherwiseDefault() ??
                           typeDescription.ArrayItem.WhenNotNull(x => x.Comments).OtherwiseDefault(),
                Type = itemType
            };
        }
示例#3
0
        private DataType BuildGraph(
            DataType parent,
            Type type,
            bool inputGraph,
            IEnumerable <Type> ancestors,
            MemberDescription memberDescription = null,
            ActionCall action = null)
        {
            var description = _typeConvention.GetDescription(type);

            var dataType = new DataType
            {
                Name = !type.IsSimpleType() && memberDescription != null ?
                       memberDescription.Name : description.Name,
                LongNamespace  = parent.MapOrEmpty(x => x.LongNamespace.Concat(x.Name).ToList(), new List <string>()),
                ShortNamespace = new List <string>(),
                Comments       = description.Comments
            };

            if (type.IsDictionary())
            {
                BuildDictionary(dataType, type, description, inputGraph, ancestors, memberDescription);
            }
            else if (type.IsArray || type.IsList())
            {
                BuildArray(dataType, type, description, inputGraph, ancestors, memberDescription);
            }
            else if (type.IsSimpleType())
            {
                BuildSimpleType(dataType, type);
            }
            else
            {
                BuildComplexType(dataType, type, inputGraph, ancestors, action);
            }

            return(_configuration.TypeOverrides.Apply(type, dataType));
        }
 private void BuildDictionary(
     DataType dataType,
     Type type,
     TypeDescription typeDescription,
     bool inputGraph,
     IEnumerable<Type> ancestors, 
     MemberDescription memberDescription)
 {
     var types = type.GetGenericDictionaryTypes();
     dataType.IsDictionary = true;
     dataType.Comments = memberDescription.WhenNotNull(x => x.Comments).OtherwiseDefault() ?? dataType.Comments;
     dataType.DictionaryEntry = new DictionaryEntry
     {
         KeyName = memberDescription.WhenNotNull(x => x.DictionaryEntry.KeyName).OtherwiseDefault() ??
                   typeDescription.WhenNotNull(x => x.DictionaryEntry.KeyName).OtherwiseDefault(),
         KeyComments = memberDescription.WhenNotNull(x => x.DictionaryEntry.KeyComments).OtherwiseDefault() ??
                       typeDescription.WhenNotNull(x => x.DictionaryEntry.KeyComments).OtherwiseDefault(),
         KeyType = BuildGraph(dataType, types.Key, inputGraph, ancestors),
         ValueComments = memberDescription.WhenNotNull(x => x.DictionaryEntry.ValueComments).OtherwiseDefault() ??
                         typeDescription.WhenNotNull(x => x.DictionaryEntry.ValueComments).OtherwiseDefault(),
         ValueType = BuildGraph(dataType, types.Value, inputGraph, ancestors)
     };
 }
示例#5
0
        private void BuildDictionary(
            DataType dataType,
            Type type,
            TypeDescription typeDescription,
            bool inputGraph,
            IEnumerable <Type> ancestors,
            MemberDescription memberDescription)
        {
            var types = type.GetGenericDictionaryTypes();

            dataType.IsDictionary    = true;
            dataType.Comments        = memberDescription.WhenNotNull(x => x.Comments).OtherwiseDefault() ?? dataType.Comments;
            dataType.DictionaryEntry = new DictionaryEntry
            {
                KeyName = memberDescription.WhenNotNull(x => x.DictionaryEntry.KeyName).OtherwiseDefault() ??
                          typeDescription.WhenNotNull(x => x.DictionaryEntry.KeyName).OtherwiseDefault(),
                KeyComments = memberDescription.WhenNotNull(x => x.DictionaryEntry.KeyComments).OtherwiseDefault() ??
                              typeDescription.WhenNotNull(x => x.DictionaryEntry.KeyComments).OtherwiseDefault(),
                KeyType       = BuildGraph(dataType, types.Key, inputGraph, ancestors),
                ValueComments = memberDescription.WhenNotNull(x => x.DictionaryEntry.ValueComments).OtherwiseDefault() ??
                                typeDescription.WhenNotNull(x => x.DictionaryEntry.ValueComments).OtherwiseDefault(),
                ValueType = BuildGraph(dataType, types.Value, inputGraph, ancestors)
            };
        }
 private void BuildArray(
     DataType dataType,
     Type type,
     TypeDescription typeDescription,
     bool inputGraph,
     IEnumerable<Type> ancestors,
     MemberDescription memberDescription)
 {
     dataType.IsArray = true;
     dataType.Comments = memberDescription.WhenNotNull(x => x.Comments).OtherwiseDefault() ?? dataType.Comments;
     var itemType = BuildGraph(dataType, type.GetListElementType(), inputGraph, ancestors);
     dataType.ArrayItem = new ArrayItem
     {
         Name = memberDescription.WhenNotNull(x => x.ArrayItem.Name).OtherwiseDefault() ??
                typeDescription.WhenNotNull(x => x.ArrayItem.Name).OtherwiseDefault() ?? itemType.Name,
         Comments = memberDescription.WhenNotNull(x => x.ArrayItem.Comments).OtherwiseDefault() ??
                    typeDescription.ArrayItem.WhenNotNull(x => x.Comments).OtherwiseDefault(),
         Type = itemType
     };
 }
示例#7
0
 public Member(MemberDescription memberDescription, MemberValue memberValue)
 {
     MemberDescription = memberDescription;
     MemberValue       = memberValue;
 }