本文整理汇总了C#中IPropertySymbol.IsAutoImplemented方法的典型用法代码示例。如果您正苦于以下问题:C# IPropertySymbol.IsAutoImplemented方法的具体用法?C# IPropertySymbol.IsAutoImplemented怎么用?C# IPropertySymbol.IsAutoImplemented使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPropertySymbol
的用法示例。
在下文中一共展示了IPropertySymbol.IsAutoImplemented方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsBindable
Either<CompleterError, bool> IsBindable(IPropertySymbol property, BindableInfo bindableInfo)
{
if(bindableInfo?.IsBindable ?? false) {
if(property.IsSealed)
return CompleterError.CreatePropertyError(property, Messages.POCO_PropertyIsSealed);
if(!property.IsVirtual)
return CompleterError.CreatePropertyError(property, Messages.POCO_PropertyIsNotVirual);
if(property.IsReadOnly)
return CompleterError.CreatePropertyError(property, Messages.POCO_PropertyHasNoSetter);
if(property.GetMethod.DeclaredAccessibility != Accessibility.Public)
return CompleterError.CreatePropertyError(property, Messages.POCO_PropertyHasNoPublicGetter);
}
return property.IsVirtual
&& (bindableInfo?.IsBindable ?? true)
&& property.DeclaredAccessibility == Accessibility.Public
&& property.GetMethod.DeclaredAccessibility == Accessibility.Public
&& property.IsAutoImplemented() || bindableInfo.Return(bi => bi.IsBindable, () => false);
}
示例2: GenerateProperty
Either<CompleterError, string> GenerateProperty(IPropertySymbol property, BindableInfo bindableInfo)
{
Func<Chang, string, Either<CompleterError, MethodCallInfo>> getCallInfo = (chang, attributeMethodName) => {
var methodName = attributeMethodName ?? $"On{property.Name}Chang{chang}".If(x => property.IsAutoImplemented());
if(methodName != null && GetMethods(methodName).Length > 1)
return CompleterError.CreatePropertyError(property, Messages.POCO_MoreThanOnePropertyChangedMethod(chang));
var method = methodName.With(x => GetMethods(x).SingleOrDefault());
if(method == null && attributeMethodName != null)
return CompleterError.CreateForPropertyName(property, Messages.POCO_PropertyChangedMethodNotFound(chang).Format(attributeMethodName));
if(method != null) {
if(method.Parameters.Length > 1)
return CompleterError.CreateMethodError(method, Messages.POCO_PropertyChangedCantHaveMoreThanOneParameter(chang));
if(!method.ReturnsVoid)
return CompleterError.CreateMethodError(method, Messages.POCO_PropertyChangedCantHaveReturnType(chang));
if(method.Parameters.Length == 1 && method.Parameters.Single().Type != property.Type)
return CompleterError.CreateParameterError(method.Parameters.Single(), Messages.POCO_PropertyChangedMethodArgumentTypeShouldMatchPropertyType(chang));
}
var needParameter = method.Return(x => x.Parameters.Length == 1, () => false);
var valueName = needParameter ? (chang == Chang.ed ? "oldValue" : "value") : null;
var methodCall = method.With(x => $"{x.Name}({valueName});".AddTabs(2));
return new MethodCallInfo(methodCall, needParameter);
};
return from changed in getCallInfo(Chang.ed, bindableInfo?.OnPropertyChangedMethodName)
from changing in getCallInfo(Chang.ing, bindableInfo?.OnPropertyChangingMethodName)
select GenerateProperty(property, changed, changing);
}