本文整理汇总了C#中IProperty.GetSetMethod方法的典型用法代码示例。如果您正苦于以下问题:C# IProperty.GetSetMethod方法的具体用法?C# IProperty.GetSetMethod怎么用?C# IProperty.GetSetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProperty
的用法示例。
在下文中一共展示了IProperty.GetSetMethod方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePropertyStub
Property CreatePropertyStub(ClassDefinition node, IProperty baseProperty)
{
//try to complete partial implementation if any
Property property = node.Members[baseProperty.Name] as Property;
if (null == property) {
property = new Property(LexicalInfo.Empty);
property.Name = baseProperty.Name;
property.Modifiers = TypeSystemServices.GetAccess(baseProperty) | TypeMemberModifiers.Virtual;
property.IsSynthetic = true;
DeclareParameters(property, baseProperty.GetParameters(), baseProperty.IsStatic ? 0 : 1);
property.Type = CreateTypeReference(baseProperty.Type);
}
if (property.Getter == null && null != baseProperty.GetGetMethod())
property.Getter = CreateMethodStub(baseProperty.GetGetMethod());
if (property.Setter == null && null != baseProperty.GetSetMethod())
property.Setter = CreateMethodStub(baseProperty.GetSetMethod());
EnsureEntityFor(property);
return property;
}
示例2: CreatePropertySet
public MethodInvocationExpression CreatePropertySet(Expression target, IProperty property, Expression value)
{
return CreateMethodInvocation(target, property.GetSetMethod(), value);
}
示例3: SetProperty
void SetProperty(IProperty property, Expression reference, Expression value, bool leaveValueOnStack)
{
OpCode callOpCode = OpCodes.Call;
MethodInfo setMethod = GetMethodInfo(property.GetSetMethod());
IType targetType = null;
if (null != reference)
{
if (!setMethod.IsStatic)
{
Expression target = ((MemberReferenceExpression)reference).Target;
targetType = target.ExpressionType;
if (setMethod.DeclaringType.IsValueType || targetType is IGenericParameter)
LoadAddress(target);
else
{
callOpCode = GetCallOpCode(target, property.GetSetMethod());
target.Accept(this);
PopType();
}
}
}
value.Accept(this);
EmitCastIfNeeded(property.Type, PopType());
LocalBuilder local = null;
if (leaveValueOnStack)
{
_il.Emit(OpCodes.Dup);
local = _il.DeclareLocal(GetSystemType(property.Type));
_il.Emit(OpCodes.Stloc, local);
}
if (targetType is IGenericParameter)
{
_il.Emit(OpCodes.Constrained, GetSystemType(targetType));
callOpCode = OpCodes.Callvirt;
}
_il.EmitCall(callOpCode, setMethod, null);
if (leaveValueOnStack)
{
_il.Emit(OpCodes.Ldloc, local);
PushType(property.Type);
}
}
示例4: ResolveClassAbstractProperty
void ResolveClassAbstractProperty(ClassDefinition node,
TypeReference baseTypeRef,
IProperty entity)
{
bool resolved = false;
foreach (TypeMember member in node.Members)
{
if (entity.Name != member.Name
|| NodeType.Property != member.NodeType
|| !IsCorrectExplicitMemberImplOrNoExplicitMemberAtAll(member, entity)
|| !TypeSystemServices.CheckOverrideSignature(entity.GetParameters(), GetPropertyEntity(member).GetParameters()))
continue;
Property p = (Property) member;
ProcessPropertyAccessor(p, p.Getter, entity.GetGetMethod());
ProcessPropertyAccessor(p, p.Setter, entity.GetSetMethod());
if (null == p.Type)
{
p.Type = CodeBuilder.CreateTypeReference(entity.Type);
}
else
{
if (entity.Type != p.Type.Entity)
Error(CompilerErrorFactory.ConflictWithInheritedMember(p, p.FullName, entity.FullName));
}
resolved = true;
}
if (resolved)
return;
foreach(SimpleTypeReference parent in node.BaseTypes)
{
if(_classDefinitionList.Contains(parent.Name))
{
depth++;
ResolveClassAbstractProperty(_classDefinitionList[parent.Name] as ClassDefinition, baseTypeRef, entity);
depth--;
}
}
if(CheckInheritsInterfaceImplementation(node, entity))
return;
if(depth == 0)
{
node.Members.Add(CreateAbstractProperty(baseTypeRef, entity));
AbstractMemberNotImplemented(node, baseTypeRef, entity);
}
}
示例5: CreateAbstractProperty
Property CreateAbstractProperty(TypeReference reference, IProperty property)
{
Debug.Assert(0 == property.GetParameters().Length);
Property p = CodeBuilder.CreateProperty(property.Name, property.Type);
p.Modifiers |= TypeMemberModifiers.Abstract;
IMethod getter = property.GetGetMethod();
if (getter != null)
{
p.Getter = CodeBuilder.CreateAbstractMethod(reference.LexicalInfo, getter);
}
IMethod setter = property.GetSetMethod();
if (setter != null)
{
p.Setter = CodeBuilder.CreateAbstractMethod(reference.LexicalInfo, setter);
}
return p;
}
示例6: HasSetter
private static bool HasSetter(IProperty property)
{
return property.GetSetMethod() != null;
}