예제 #1
0
        public Result.IfSuccess <QualifiedProperty> TryGetProperty(QualifiedType qualifiedType, string propertyName)
        {
            var propertySymbol = this.codeAnalyzer.TryGetMember(
                qualifiedType,
                propertyName,
                x => x.OfType <IPropertySymbol>().FirstOrDefault());

            if (propertySymbol != null)
            {
                return(Result.Success(QualifiedSymbolFactory.CreateProperty(this.codeAnalyzer, propertySymbol, propertyName)));
            }

            return(Result.Error());
        }
예제 #2
0
        public QualifiedType GetType(string namespaceQualifiedName)
        {
            if (this.namespaceQualifiedTypeCache.TryGetValue(namespaceQualifiedName, out var qualifiedType))
            {
                return(qualifiedType);
            }

            var typeSymbol = this.codeAnalyzer.Compilation.GetTypeByMetadataName(namespaceQualifiedName);

            if (typeSymbol == null)
            {
                throw new TypeNotFoundException($"The namespace qualified type: {namespaceQualifiedName} could not be found");
            }

            qualifiedType = QualifiedSymbolFactory.CreateType(this.codeAnalyzer, typeSymbol);
            this.namespaceQualifiedTypeCache.Add(namespaceQualifiedName, qualifiedType);
            return(qualifiedType);
        }