Exemplo n.º 1
0
        private static void WriteGenericTypeName(
            this TranslationBuffer buffer,
            Type genericType,
            TranslationSettings settings)
        {
            var typeGenericTypeArguments = genericType.GetGenericTypeArguments();

            if (!genericType.IsNested)
            {
                buffer.WriteTypeNamespaceIfRequired(genericType, settings);
                buffer.WriteClosedGenericTypeName(genericType, ref typeGenericTypeArguments, settings);
                return;
            }

            var types = new List <Type> {
                genericType
            };

            // ReSharper disable once PossibleNullReferenceException
            while (genericType.IsNested)
            {
                genericType = genericType.DeclaringType;
                types.Add(genericType);
            }

            buffer.WriteTypeNamespaceIfRequired(genericType, settings);

            for (var i = types.Count; ;)
            {
                buffer.WriteClosedGenericTypeName(types[--i], ref typeGenericTypeArguments, settings);

                if (i == 0)
                {
                    return;
                }

                buffer.WriteToTranslation('.');
            }
        }