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


C# IPropertySymbol.ToDisplayString方法代码示例

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


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

示例1: ValidateIdentityProperty

            private void ValidateIdentityProperty(IPropertySymbol identityProperty)
            {
                var stringType = compilation.GetTypeByMetadataName(typeof(string).FullName);
                var identifierAttributeType = compilation.GetTypeByMetadataName(Constants.IdentifierAttribute);

                if (identityProperty.Type != stringType)
                {
                    throw new InvalidOperationException(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "The property '{0}' must be of type {1} to be used as the identity property for an entity. If this property is intended to be the identity property for the entity please change its type to {1}. If it is not intended to be the identity property, either rename this property or create an identity property and decorate it with the [{2}] attribute.",
                            identityProperty.ToDisplayString(this.ErrorMessageDisplayFormat),
                            stringType.ToDisplayString(this.ErrorMessageDisplayFormat),
                            identifierAttributeType.ToDisplayString(this.ErrorMessageDisplayFormat)));
                }

                if (identityProperty.SetMethod != null)
                {
                    throw new InvalidOperationException(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "The property '{0}' must not have a setter to be used as the identity property for an entity. If this property is intended to be the identity property for the entity please remove the setter. If it is not intended to be the identity property, either rename this property or create an identity propertyn and decorate it with the [{1}] attribute.",
                            identityProperty.ToDisplayString(this.ErrorMessageDisplayFormat),
                            identifierAttributeType.ToDisplayString(this.ErrorMessageDisplayFormat)));
                }
            }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:26,代码来源:Generator.cs

示例2: ValidateProperty

            private void ValidateProperty(IPropertySymbol property, out bool isCollection, out ITypeSymbol scalarType)
            {
                if (!IsSupportedPropertyType(property.Type, out isCollection, out scalarType))
                {
                    throw new InvalidOperationException(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "Invalid property: {0} - the property type {1} is not supported by Entity Framework.",
                            property.ToDisplayString(this.ErrorMessageDisplayFormat),
                            property.Type.ToDisplayString(this.ErrorMessageDisplayFormat)));
                }

                var inversePropertyAttributeType = compilation.GetTypeByMetadataName(Constants.InversePropertyAttribute);
                var inversePropertyAttribute = property.GetAttributes().SingleOrDefault(x => x.AttributeClass == inversePropertyAttributeType);

                if (inversePropertyAttribute != null)
                {
                    var scalarTypeCopy = scalarType;
                    var targetType = this.interfaceSymbols.SingleOrDefault(x => x == scalarTypeCopy);

                    if (targetType == null)
                    {
                        throw new InvalidOperationException(
                            string.Format(
                                CultureInfo.InvariantCulture,
                                "Invalid {0} attribute on property {1}. The property type {2} must be marked as an Entity.",
                                inversePropertyAttributeType.ToDisplayString(this.ErrorMessageDisplayFormat),
                                property.ToDisplayString(this.ErrorMessageDisplayFormat),
                                scalarType.ToDisplayString(this.ErrorMessageDisplayFormat)));
                    }

                    var inversePropertyName = (string)inversePropertyAttribute.ConstructorArguments[0].Value;

                    var targetProperty = targetType
                        .GetMembers()
                        .OfType<IPropertySymbol>()
                        .Where(x => x.Name == inversePropertyName)
                        .FirstOrDefault();

                    if (targetProperty == null)
                    {
                        throw new InvalidOperationException(
                            string.Format(
                                CultureInfo.InvariantCulture,
                                "Invalid {0} attribute on property {1}. A property named '{2}' cannot be found on the target interface type {3}.",
                                inversePropertyAttributeType.ToDisplayString(this.ErrorMessageDisplayFormat),
                                property.ToDisplayString(this.ErrorMessageDisplayFormat),
                                inversePropertyName,
                                targetType.ToDisplayString(this.ErrorMessageDisplayFormat)));
                    }
                }
            }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:52,代码来源:Generator.cs

示例3: GetTooltipForProperty

 private string GetTooltipForProperty(IPropertySymbol propertySymbol)
     => propertySymbol.ToDisplayString();
开发者ID:lukas-lansky,项目名称:CSharpFormatting,代码行数:2,代码来源:ReportingCSharpSyntaxWalker.cs


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