本文整理汇总了C#中System.Reflection.PropertyInfo.CanWriteExtended方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.CanWriteExtended方法的具体用法?C# PropertyInfo.CanWriteExtended怎么用?C# PropertyInfo.CanWriteExtended使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.CanWriteExtended方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddScalarMember
private static void AddScalarMember(
Type type, PropertyInfo clrProperty, StructuralType ospaceType, EdmProperty cspaceProperty, EdmType propertyType)
{
DebugCheck.NotNull(type);
DebugCheck.NotNull(clrProperty);
Debug.Assert(clrProperty.CanRead && clrProperty.CanWriteExtended(), "The clr property has to have a setter and a getter.");
DebugCheck.NotNull(ospaceType);
DebugCheck.NotNull(cspaceProperty);
DebugCheck.NotNull(propertyType);
Debug.Assert(Helper.IsScalarType(propertyType), "Property has to be primitive or enum.");
var cspaceType = cspaceProperty.DeclaringType;
var isKeyMember = Helper.IsEntityType(cspaceType) && ((EntityType)cspaceType).KeyMemberNames.Contains(clrProperty.Name);
// the property is nullable only if it is not a key and can actually be set to null (i.e. is not a value type or is a nullable value type)
var nullableFacetValue = !isKeyMember
&&
(!clrProperty.PropertyType.IsValueType() || Nullable.GetUnderlyingType(clrProperty.PropertyType) != null);
var ospaceProperty =
new EdmProperty(
cspaceProperty.Name,
TypeUsage.Create(
propertyType, new FacetValues
{
Nullable = nullableFacetValue
}),
clrProperty,
type);
if (isKeyMember)
{
((EntityType)ospaceType).AddKeyMember(ospaceProperty);
}
else
{
ospaceType.AddMember(ospaceProperty);
}
}
示例2: CreateAndAddEnumProperty
// <summary>
// Creates an Enum property based on <paramref name="clrProperty" /> and adds it to the parent structural type.
// </summary>
// <param name="type">
// CLR type owning <paramref name="clrProperty" /> .
// </param>
// <param name="ospaceType"> OSpace type the created property will be added to. </param>
// <param name="cspaceProperty"> Corresponding property from CSpace. </param>
// <param name="clrProperty"> CLR property used to build an Enum property. </param>
private void CreateAndAddEnumProperty(Type type, StructuralType ospaceType, EdmProperty cspaceProperty, PropertyInfo clrProperty)
{
EdmType propertyType;
if (CspaceToOspace.TryGetValue(cspaceProperty.TypeUsage.EdmType, out propertyType))
{
if (clrProperty.CanRead
&& clrProperty.CanWriteExtended())
{
AddScalarMember(type, clrProperty, ospaceType, cspaceProperty, propertyType);
}
else
{
LogError(
Strings.Validator_OSpace_Convention_ScalarPropertyMissginGetterOrSetter(
clrProperty.Name, type.FullName, type.Assembly().FullName),
cspaceProperty.TypeUsage.EdmType);
}
}
else
{
LogError(
Strings.Validator_OSpace_Convention_MissingOSpaceType(cspaceProperty.TypeUsage.EdmType.FullName),
cspaceProperty.TypeUsage.EdmType);
}
}