当前位置: 首页>>代码示例>>C#>>正文


C# IPropertySymbol类代码示例

本文整理汇总了C#中IPropertySymbol的典型用法代码示例。如果您正苦于以下问题:C# IPropertySymbol类的具体用法?C# IPropertySymbol怎么用?C# IPropertySymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IPropertySymbol类属于命名空间,在下文中一共展示了IPropertySymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetParsedProperty

        private SDProperty GetParsedProperty(IPropertySymbol property)
        {
            var syntaxReference = property.DeclaringSyntaxReferences.Any() ? property.DeclaringSyntaxReferences.Single() : null;
            var sdProperty = new SDProperty(property.GetIdentifier())
            {
                Name = property.Name,
                DeclaringType = _typeRefParser.GetParsedTypeReference(property.ContainingType),
                Accessibility = property.DeclaredAccessibility.ToString().ToLower(),
                ReturnType = _typeRefParser.GetParsedTypeReference(property.Type),
                CanGet = property.GetMethod != null,
                CanSet = property.SetMethod != null,
                IsAbstract = property.IsAbstract,
                IsVirtual = property.IsVirtual,
                IsOverride = property.IsOverride,
                Documentations = DocumentationParser.ParseDocumentation(property),
                Region = syntaxReference != null ? new SDRegion
                {
                    Start = syntaxReference.Span.Start,
                    End = syntaxReference.Span.End,
                    StartLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).StartLinePosition.Line + 1,
                    EndLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).EndLinePosition.Line + 1,
                    FilePath = syntaxReference.SyntaxTree.FilePath,
                    Filename = Path.GetFileName(syntaxReference.SyntaxTree.FilePath)
                } : null
            };

            ParserOptions.SDRepository.AddMember(sdProperty);
            return sdProperty;
        }
开发者ID:Geaz,项目名称:sharpDox,代码行数:29,代码来源:PropertyParser.cs

示例2: CreatePropertySymbol

 internal static IPropertySymbol CreatePropertySymbol(
     INamedTypeSymbol containingType,
     IList<AttributeData> attributes,
     Accessibility accessibility,
     DeclarationModifiers modifiers,
     ITypeSymbol type,
     IPropertySymbol explicitInterfaceSymbol,
     string name,
     IList<IParameterSymbol> parameters,
     IMethodSymbol getMethod,
     IMethodSymbol setMethod,
     bool isIndexer = false,
     SyntaxNode initializer = null)
 {
     var result = new CodeGenerationPropertySymbol(
         containingType,
         attributes,
         accessibility,
         modifiers,
         type,
         explicitInterfaceSymbol,
         name,
         isIndexer,
         parameters,
         getMethod,
         setMethod);
     CodeGenerationPropertyInfo.Attach(result, modifiers.IsNew, modifiers.IsUnsafe, initializer);
     return result;
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:29,代码来源:CodeGenerationSymbolFactory.cs

示例3: FindSimilarityRank

        public virtual SimilarityRank<IPropertySymbol> FindSimilarityRank(IPropertySymbol sourceProperty, IEnumerable<IPropertySymbol> targetProperties, List<IClassPropertyComparer> allComparers)
        {
            var allMatches = FindAllMatches(sourceProperty, targetProperties, allComparers);
            var topMatch = allMatches.OrderByDescending(r => r.Confidence).FirstOrDefault(r => r.Confidence > 0);

            return (topMatch ?? new SimilarityRank<IPropertySymbol>());
        }
开发者ID:tategriffin,项目名称:Cartographer,代码行数:7,代码来源:ClassPropertyFinder.cs

示例4: HandleValueField

 internal void HandleValueField(ValueField valueField, IPropertySymbol property, ImmutableArray<AttributeData> propertyAttributes)
 {
     AddKeyAttribute(property, propertyAttributes, valueField);
     AddIndexAttribute(property, propertyAttributes, valueField);
     AddMaxLengthAttribute(property, propertyAttributes, valueField);
     AddDatabaseGeneratedAttribute(property, propertyAttributes, valueField);
 }
开发者ID:RicardoNiepel,项目名称:Z3.ObjectTheorem,代码行数:7,代码来源:AssumptionHandler.cs

示例5: GenerateSetAccessor

            private IMethodSymbol GenerateSetAccessor(
                Compilation compilation,
                IPropertySymbol property,
                Accessibility accessibility,
                bool generateAbstractly,
                bool useExplicitInterfaceSymbol,
                INamedTypeSymbol[] attributesToRemove,
                CancellationToken cancellationToken)
            {
                if (property.SetMethod == null)
                {
                    return null;
                }

                var setMethod = property.SetMethod.RemoveInaccessibleAttributesAndAttributesOfTypes(
                     this.State.ClassOrStructType,
                     attributesToRemove);

                return CodeGenerationSymbolFactory.CreateAccessorSymbol(
                    setMethod,
                    attributes: null,
                    accessibility: accessibility,
                    explicitInterfaceSymbol: useExplicitInterfaceSymbol ? property.SetMethod : null,
                    statements: GetSetAccessorStatements(compilation, property, generateAbstractly, cancellationToken));
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:25,代码来源:AbstractImplementInterfaceService.CodeAction_Property.cs

示例6: Create

 public static void Create(IPropertySymbol symbol, SymbolKeyWriter visitor)
 {
     visitor.WriteString(symbol.MetadataName);
     visitor.WriteSymbolKey(symbol.ContainingSymbol);
     visitor.WriteBoolean(symbol.IsIndexer);
     visitor.WriteRefKindArray(symbol.Parameters);
     visitor.WriteParameterTypesArray(symbol.OriginalDefinition.Parameters);
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:8,代码来源:SymbolKey.PropertySymbolKey.cs

示例7: Compare

        public SimilarityRank<IPropertySymbol> Compare(IPropertySymbol sourceProperty, IPropertySymbol targetProperty)
        {
            //TODO: check for subclasses
            bool sameType = sourceProperty.Type.Equals(targetProperty.Type);
            int confidence = (sameType ? 100 : 0);

            return new SimilarityRank<IPropertySymbol>() { Confidence = confidence, Symbol = targetProperty };
        }
开发者ID:tategriffin,项目名称:Cartographer,代码行数:8,代码来源:TypeComparer.cs

示例8: Attach

 public static void Attach(
     IPropertySymbol property,
     bool isNew,
     bool isUnsafe)
 {
     var info = new CodeGenerationPropertyInfo(isNew, isUnsafe);
     propertyToInfoMap.Add(property, info);
 }
开发者ID:riversky,项目名称:roslyn,代码行数:8,代码来源:CodeGenerationPropertyInfo.cs

示例9: HaveSameSignature

		public static bool HaveSameSignature (IPropertySymbol property1, IPropertySymbol property2, bool caseSensitive)
		{
			try {
				return (bool)haveSameSignature2Method.Invoke(instance, new object[] { property1, property2, caseSensitive });
			} catch (TargetInvocationException ex) {
				ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
				return false;
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:9,代码来源:SignatureComparer.cs

示例10: Attach

 public static void Attach(
     IPropertySymbol property,
     bool isNew,
     bool isUnsafe,
     SyntaxNode initializer)
 {
     var info = new CodeGenerationPropertyInfo(isNew, isUnsafe, initializer);
     s_propertyToInfoMap.Add(property, info);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:CodeGenerationPropertyInfo.cs

示例11: ReadSymbol

        protected override void ReadSymbol(IPropertySymbol propertySymbol)
        {
            // we don't need to know about static members
            // because they won't be delegated from child to mixin
            if (propertySymbol.IsStatic)
                return;

            // we ignore private and protected memebers
            var hasGetter = propertySymbol.GetMethod != null &&
                      !(propertySymbol.GetMethod.DeclaredAccessibility == Accessibility.Private ||
                        propertySymbol.GetMethod.DeclaredAccessibility == Accessibility.Protected);
            var hasSetter = propertySymbol.SetMethod != null &&
                      !(propertySymbol.SetMethod.DeclaredAccessibility == Accessibility.Private ||
                        propertySymbol.SetMethod.DeclaredAccessibility == Accessibility.Protected);

            // property has no accessors or accessors are not accessible => skip property
            if (!hasSetter && !hasGetter)
                return;

            Property property = null;

            if (propertySymbol.IsIndexer) // symbol is an indexer property
            {
                var indexerProperty = new IndexerProperty(
                    propertySymbol.Type,
                    hasGetter,
                    hasSetter);
                var parameterReader = new ParameterSymbolReader(indexerProperty);
                parameterReader.VisitSymbol(propertySymbol);
                property = indexerProperty;
            }
            else // symbol is a normal property
            {
                property = new Property(
                    propertySymbol.Name,
                    propertySymbol.Type,
                    hasGetter,
                    hasSetter);
            }
            property.IsAbstract = propertySymbol.IsAbstract;
            property.IsOverride = propertySymbol.IsOverride;

            // store information if accessors are internal,
            // we will need this for the generation later
            property.IsGetterInternal = hasGetter &&
                                        propertySymbol.GetMethod
                                        .DeclaredAccessibility.HasFlag(Accessibility.Internal);
            property.IsSetterInternal = hasSetter &&
                                        propertySymbol.SetMethod
                                        .DeclaredAccessibility.HasFlag(Accessibility.Internal);
                    
            property.Documentation = new DocumentationComment(propertySymbol.GetDocumentationCommentXml());

            _properties.AddProperty(property);
        }
开发者ID:pgenfer,项目名称:mixinSharp,代码行数:55,代码来源:PropertySymbolReader.cs

示例12: FindAllMatches

        private List<SimilarityRank<IPropertySymbol>> FindAllMatches(IPropertySymbol sourceProperty, IEnumerable<IPropertySymbol> targetProperties, List<IClassPropertyComparer> allComparers)
        {
            var allMatches = new List<SimilarityRank<IPropertySymbol>>();

            foreach (var comparer in allComparers)
            {
                allMatches.AddRange(FindMatches(sourceProperty, targetProperties, comparer));
            }

            return allMatches;
        }
开发者ID:tategriffin,项目名称:Cartographer,代码行数:11,代码来源:ClassPropertyFinder.cs

示例13: AddPropertyTo

        internal static CompilationUnitSyntax AddPropertyTo(
            CompilationUnitSyntax destination,
            IPropertySymbol property,
            CodeGenerationOptions options,
            IList<bool> availableIndices)
        {
            var declaration = GeneratePropertyOrIndexer(property, CodeGenerationDestination.CompilationUnit, options);

            var members = Insert(destination.Members, declaration, options,
                availableIndices, after: LastPropertyOrField, before: FirstMember);
            return destination.WithMembers(members);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:12,代码来源:PropertyGenerator.cs

示例14: CompoundCompare

        private SimilarityRank<IPropertySymbol> CompoundCompare(IPropertySymbol sourceProperty, IPropertySymbol targetProperty, IEnumerable<IClassPropertyComparer> comparers)
        {
            List<SimilarityRank<IPropertySymbol>> allResultRanks = new List<SimilarityRank<IPropertySymbol>>();
            foreach (var propertyComparer in comparers)
            {
                SimilarityRank<IPropertySymbol> rank = propertyComparer.Compare(sourceProperty, targetProperty);

                allResultRanks.Add(rank);
            }

            return BuildCombinedRank(targetProperty, allResultRanks);
        }
开发者ID:tategriffin,项目名称:Cartographer,代码行数:12,代码来源:CompoundClassPropertyComparer.cs

示例15: GenerateProperty

            private ISymbol GenerateProperty(
                Compilation compilation,
                IPropertySymbol property,
                Accessibility accessibility,
                DeclarationModifiers modifiers,
                bool generateAbstractly,
                bool useExplicitInterfaceSymbol,
                string memberName,
                CancellationToken cancellationToken)
            {
                var factory = this.Document.GetLanguageService<SyntaxGenerator>();
                var comAliasNameAttribute = compilation.ComAliasNameAttributeType();

                var getAccessor = property.GetMethod == null
                    ? null
                    : CodeGenerationSymbolFactory.CreateAccessorSymbol(
                        property.GetMethod.RemoveInaccessibleAttributesAndAttributesOfType(
                            accessibleWithin: this.State.ClassOrStructType,
                            removeAttributeType: comAliasNameAttribute),
                        attributes: null,
                        accessibility: accessibility,
                        explicitInterfaceSymbol: useExplicitInterfaceSymbol ? property.GetMethod : null,
                        statements: GetGetAccessorStatements(compilation, property, generateAbstractly, cancellationToken));

                var setAccessor = property.SetMethod == null
                    ? null
                    : CodeGenerationSymbolFactory.CreateAccessorSymbol(
                        property.SetMethod.RemoveInaccessibleAttributesAndAttributesOfType(
                            accessibleWithin: this.State.ClassOrStructType,
                            removeAttributeType: comAliasNameAttribute),
                        attributes: null,
                        accessibility: accessibility,
                        explicitInterfaceSymbol: useExplicitInterfaceSymbol ? property.SetMethod : null,
                        statements: GetSetAccessorStatements(compilation, property, generateAbstractly, cancellationToken));

                var syntaxFacts = Document.GetLanguageService<ISyntaxFactsService>();
                var parameterNames = NameGenerator.EnsureUniqueness(
                    property.Parameters.Select(p => p.Name).ToList(), isCaseSensitive: syntaxFacts.IsCaseSensitive);

                var updatedProperty = property.RenameParameters(parameterNames);

                updatedProperty = updatedProperty.RemoveAttributeFromParameters(comAliasNameAttribute);

                // TODO(cyrusn): Delegate through throughMember if it's non-null.
                return CodeGenerationSymbolFactory.CreatePropertySymbol(
                    updatedProperty,
                    accessibility: accessibility,
                    modifiers: modifiers,
                    explicitInterfaceSymbol: useExplicitInterfaceSymbol ? property : null,
                    name: memberName,
                    getMethod: getAccessor,
                    setMethod: setAccessor);
            }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:53,代码来源:AbstractImplementInterfaceService.CodeAction_Property.cs


注:本文中的IPropertySymbol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。