コード例 #1
0
        private static List <LinkMetadata <DefaultLinkStyle> > ProcessInterfaces(Type dto, Type[] interfaces)
        {
            var result = new List <LinkMetadata <DefaultLinkStyle> >();
            var dict   = GetMappingInterfaces();

            foreach (var iface in interfaces)
            {
                if (!CompilerUtils.IsGeneric(iface))
                {
                    continue;
                }

                var genericType = iface.GetGenericTypeDefinition();

                if (!dict.ContainsKey(genericType))
                {
                    continue;
                }

                var style = dict[genericType];

                var argTypes = CompilerUtils.GenericTypeArguments(iface);

                if (argTypes.Length > 1 && genericType == typeof(IProduce <,>))
                {
                    foreach (var argType in argTypes)
                    {
                        result.Add(new LinkMetadata <DefaultLinkStyle>()
                        {
                            FromMessage = dto,
                            ToMessage   = argType,
                            Link        = style
                        });
                    }
                }
                else
                {
                    result.Add(new LinkMetadata <DefaultLinkStyle>()
                    {
                        FromMessage = dto,
                        ToMessage   = argTypes.Single(),
                        Link        = style
                    });
                }
            }

            return(result);
        }