Exemple #1
0
        public virtual IResolvedTypeInfo Get(ITypeReference typeInfo, string collectionFormat)
        {
            if (typeInfo == null)
            {
                return(null);
            }

            ICollectionFormatter collectionFormatter = null;
            ResolvedTypeInfo     type = null;

            foreach (var classLookup in _typeSources)
            {
                var foundClass = classLookup.GetType(typeInfo);
                if (foundClass != null)
                {
                    collectionFormatter = classLookup.CollectionFormatter;
                    type = new ResolvedTypeInfo(foundClass);
                    break;
                }
            }

            type = type ?? ResolveType(typeInfo);
            if (typeInfo.GenericTypeParameters.Any())
            {
                type.Name = FormatGenerics(type, typeInfo.GenericTypeParameters.Select(x => Get(x, collectionFormat)));
            }

            if (typeInfo.IsCollection)
            {
                collectionFormatter = (collectionFormat != null) ? new CollectionFormatter(collectionFormat) : (collectionFormatter ?? _defaultCollectionFormatter);
                type.IsPrimitive    = false;
                type.Name           = collectionFormatter.AsCollection(type);
            }

            return(type);
        }
 public static ITypeSource Create(ISoftwareFactoryExecutionContext context, string templateId, ICollectionFormatter collectionFormatter)
 {
     return(ClassTypeSource.Create(context, templateId).WithCollectionFormatter(collectionFormatter));
 }
 public CSharpTypeResolverContext(ICSharpProject project, ICollectionFormatter formatter) : base(formatter)
 {
     _project = project;
 }
 public CSharpTypeResolver(ICSharpProject project, ICollectionFormatter defaultFormatter) : base(new CSharpTypeResolverContext(project, defaultFormatter))
 {
     _project          = project;
     _defaultFormatter = defaultFormatter;
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PseudoCollectionFormatter"/> class.
 /// </summary>
 /// <param name="transformer">The <see cref="ITransformer"/> to use.</param>
 /// <param name="inner">The inner <see cref="ICollectionFormatter"/> to use before applying transforms.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="transformer"/> or <paramref name="inner"/> is <see langword="null"/>.
 /// </exception>
 public PseudoCollectionFormatter(ITransformer transformer, ICollectionFormatter inner)
 {
     Transformer = transformer ?? throw new ArgumentNullException(nameof(transformer));
     Inner       = inner ?? throw new ArgumentNullException(nameof(inner));
 }
Exemple #6
0
 public void SetCollectionFormatter(ICollectionFormatter formatter)
 {
     _defaultCollectionFormatter = formatter;
 }
Exemple #7
0
 protected TypeResolverContextBase(ICollectionFormatter defaultCollectionFormatter)
 {
     _defaultCollectionFormatter = defaultCollectionFormatter;
 }
 public ClassTypeSource WithCollectionFormatter(ICollectionFormatter formatter)
 {
     _options.CollectionFormatter = formatter;
     return(this);
 }
Exemple #9
0
 public TypeScriptTypeResolverContext(ICollectionFormatter defaultCollectionFormatter) : base(defaultCollectionFormatter)
 {
 }