• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IPropertySymbol类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: HaveSameSignature

        public bool HaveSameSignature(IPropertySymbol property1, IPropertySymbol property2, bool caseSensitive)
        {
            if (!IdentifiersMatch(property1.Name, property2.Name, caseSensitive) ||
                property1.Parameters.Length != property2.Parameters.Length ||
                property1.IsIndexer != property2.IsIndexer)
            {
                return false;
            }

            return property1.Parameters.SequenceEqual(
                property2.Parameters,
                this.ParameterEquivalenceComparer);
        }
开发者ID:riversky,项目名称:roslyn,代码行数:13,代码来源:SignatureComparer.cs


示例17: ForEachSymbols

 internal ForEachSymbols(IMethodSymbol getEnumeratorMethod,
                         IMethodSymbol moveNextMethod,
                         IPropertySymbol currentProperty,
                         IMethodSymbol disposeMethod,
                         ITypeSymbol elementType)
     : this()
 {
     this.GetEnumeratorMethod = getEnumeratorMethod;
     this.MoveNextMethod = moveNextMethod;
     this.CurrentProperty = currentProperty;
     this.DisposeMethod = disposeMethod;
     this.ElementType = elementType;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:13,代码来源:ForEachSymbols.cs


示例18: AddHasForeignKeyAttribute

        private void AddHasForeignKeyAttribute(IPropertySymbol classProperty, IEnumerable<AttributeData> propertyAttributes, SingleField singleField)
        {
            var foreignKeyAttribute = propertyAttributes.SingleOrDefault(a => a.AttributeClass.Name == "HasForeignKeyAttribute");

            var foreignKeyAttributeString = "-";
            if (foreignKeyAttribute != null)
            {
                foreignKeyAttributeString = (string)foreignKeyAttribute.ConstructorArguments[0].Value;
            }

            var assumption = _constraintBuilder.Assume(() => singleField.ForeignKeyAttribute == foreignKeyAttributeString);
            _propertyAssumptions.Add(new HasForeignKeyAttributePropertyAssumption(classProperty, assumption, singleField));
        }
开发者ID:RicardoNiepel,项目名称:Z3.ObjectTheorem,代码行数:13,代码来源:AssumptionHandler.cs


示例19: AddDatabaseGeneratedAttribute

        private void AddDatabaseGeneratedAttribute(IPropertySymbol classProperty, IEnumerable<AttributeData> propertyAttributes, ValueField valueField)
        {
            var databaseGeneratedAttributeValue = DatabaseGeneratedAttribute.None;

            var databaseGeneratedAttribute = propertyAttributes.SingleOrDefault(a => a.AttributeClass.Name == "DatabaseGeneratedAttribute");
            if (databaseGeneratedAttribute != null)
            {
                var databaseGeneratedOption = Enum.GetName(typeof(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption), databaseGeneratedAttribute.ConstructorArguments[0].Value);
                databaseGeneratedAttributeValue = (DatabaseGeneratedAttribute)Enum.Parse(typeof(DatabaseGeneratedAttribute), databaseGeneratedOption);
            }

            var assumption = _constraintBuilder.Assume(() => valueField.DatabaseGeneratedAttribute == databaseGeneratedAttributeValue);
            _propertyAssumptions.Add(new DatabaseGeneratedAttributePropertyAssumption(classProperty, assumption, valueField));
        }
开发者ID:RicardoNiepel,项目名称:Z3.ObjectTheorem,代码行数:14,代码来源:AssumptionHandler.cs


示例20: FindMatches

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

            foreach (var targetProperty in targetProperties)
            {
                var rank = comparer.Compare(sourceProperty, targetProperty);
                if (rank.Confidence > 0)
                {
                    allMatches.Add(rank);
                }
            }

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IPropertyValidator类代码示例发布时间:2022-05-24
下一篇:
C# IPropertySet类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap