本文整理汇总了C#中PropertyDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# PropertyDeclaration类的具体用法?C# PropertyDeclaration怎么用?C# PropertyDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyDeclaration类属于命名空间,在下文中一共展示了PropertyDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitPropertyDeclaration
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
Push();
object result = base.VisitPropertyDeclaration(propertyDeclaration, data);
Pop();
return result;
}
示例2: VisitPropertyDeclaration
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
if (propertyDeclaration.Getter.Body.IsNull && propertyDeclaration.Setter.Body.IsNull)
UnlockWith(propertyDeclaration);
return base.VisitPropertyDeclaration(propertyDeclaration, data);
}
示例3: EmitPropertyMethod
protected virtual void EmitPropertyMethod(PropertyDeclaration propertyDeclaration, Accessor accessor, bool setter)
{
var memberResult = this.Emitter.Resolver.ResolveNode(propertyDeclaration, this.Emitter) as MemberResolveResult;
if (memberResult != null &&
(memberResult.Member.Attributes.Any(a => a.AttributeType.FullName == "Bridge.FieldPropertyAttribute") ||
(propertyDeclaration.Getter.IsNull && propertyDeclaration.Setter.IsNull)))
{
return;
}
if (!accessor.IsNull && this.Emitter.GetInline(accessor) == null)
{
this.EnsureComma();
this.ResetLocals();
var prevMap = this.BuildLocalsMap();
var prevNamesMap = this.BuildLocalsNamesMap();
if (setter)
{
this.AddLocals(new ParameterDeclaration[] { new ParameterDeclaration { Name = "value" } }, accessor.Body);
}
XmlToJsDoc.EmitComment(this, this.PropertyDeclaration);
var overloads = OverloadsCollection.Create(this.Emitter, propertyDeclaration, setter);
string name = overloads.GetOverloadName();
this.Write((setter ? "set" : "get") + name);
this.WriteColon();
this.WriteFunction();
this.WriteOpenParentheses();
this.Write(setter ? "value" : "");
this.WriteCloseParentheses();
this.WriteSpace();
var script = this.Emitter.GetScript(accessor);
if (script == null)
{
accessor.Body.AcceptVisitor(this.Emitter);
}
else
{
this.BeginBlock();
foreach (var line in script)
{
this.Write(line);
this.WriteNewLine();
}
this.EndBlock();
}
this.ClearLocalsMap(prevMap);
this.ClearLocalsNamesMap(prevNamesMap);
this.Emitter.Comma = true;
}
}
示例4: HandleVisitorPropertyDeclarationVisited
void HandleVisitorPropertyDeclarationVisited (PropertyDeclaration node, InspectionData data)
{
foreach (var rule in policy.Rules) {
if (rule.CheckProperty (node, data))
return;
}
}
示例5: AddRange
/// <summary>
/// Adds the elements of an array to the end of this PropertyDeclarationCollection.
/// </summary>
/// <param name="items">
/// The array whose elements are to be added to the end of this PropertyDeclarationCollection.
/// </param>
public virtual void AddRange(PropertyDeclaration[] items)
{
foreach (PropertyDeclaration item in items)
{
this.List.Add(item);
}
}
示例6: VisitPropertyDeclaration
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
if (propertyDeclaration.Setter.Modifiers.HasFlag(Modifiers.Private))
{
UnlockWith(propertyDeclaration.Setter);
}
return base.VisitPropertyDeclaration(propertyDeclaration, data);
}
示例7: PropertyReferenceExpression
public PropertyReferenceExpression(Expression target,PropertyDeclaration property)
{
if (target==null)
throw new ArgumentNullException("target");
if (property==null)
throw new ArgumentNullException("property");
this.target = target;
this.property = property;
}
示例8: ContainsGetter
bool ContainsGetter (PropertyDeclaration property, VariableInitializer initializer)
{
if (property.Getter.IsNull || property.Getter.Body.Statements.Count () != 1)
return false;
var ret = property.Getter.Body.Statements.Single () as ReturnStatement;
if (ret == null)
return false;
return ret.Expression.IsMatch (new IdentifierExpression (initializer.Name)) ||
ret.Expression.IsMatch (new MemberReferenceExpression (new ThisReferenceExpression (), initializer.Name));
}
示例9: Create
public static OverloadsCollection Create(IEmitter emitter, PropertyDeclaration propDeclaration, bool isSetter = false)
{
string key = propDeclaration.GetHashCode().ToString() + isSetter.GetHashCode().ToString();
if (emitter.OverloadsCache.ContainsKey(key))
{
return emitter.OverloadsCache[key];
}
return new OverloadsCollection(emitter, propDeclaration, isSetter);
}
示例10: VisitPropertyDeclaration
public override void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration)
{
if (propertyDeclaration.HasModifier(Modifiers.Static))
{
this.CheckDependency(propertyDeclaration.ReturnType);
if (!propertyDeclaration.Getter.IsNull)
{
propertyDeclaration.Getter.AcceptVisitor(this);
}
}
}
示例11: CreateChangedEventDeclaration
EventDeclaration CreateChangedEventDeclaration (RefactoringContext context, PropertyDeclaration propertyDeclaration)
{
return new EventDeclaration {
Modifiers = propertyDeclaration.HasModifier (Modifiers.Static) ? Modifiers.Public | Modifiers.Static : Modifiers.Public,
ReturnType = context.CreateShortType("System", "EventHandler"),
Variables = {
new VariableInitializer {
Name = propertyDeclaration.Name + "Changed"
}
}
};
}
示例12: AddPropertyGuard
public static void AddPropertyGuard(PropertyDeclaration property, MethodBodyTransformationContext context, InstructionBlock block, InstructionWriter writer)
{
var propertyType = property.PropertyType;
var methodBody = block.MethodBody;
var sequence = block.AddInstructionSequence(null, NodePosition.After, null);
if (sequence == null) return;
var oldValueVariable =
block.DefineLocalVariable(propertyType, string.Format("old{0}Value", property.Name));
var assets = GetTransformationAssets(property.Module);
writer.AttachInstructionSequence(sequence);
var isLocationBinding = CheckIfIsLocationBinding(methodBody,assets);
if (isLocationBinding) {
writer.AssignValue_LocalVariable(oldValueVariable
, () => writer.Call_MethodOnTarget(property.GetGetter()
,
() => {
//Load the instance parameter of the SetValue method
//and convert it to the type
writer.EmitInstruction(OpCodeNumber.Ldarg_1);
//writer.EmitInstructionLoadIndirect(Assets.ObjectTypeSignature);
writer.EmitInstructionType(OpCodeNumber.Ldobj, assets.ObjectTypeSignature);
writer.EmitConvertFromObject(property.Parent);
}
)
);
//On the location binding the value parameter is at psotion 3
writer.EmitInstruction(OpCodeNumber.Ldarg_3);
} else {
writer.AssignValue_LocalVariable(oldValueVariable,
() => writer.Get_PropertyValue(property));
//For a normal property the value parameter is at position 1
writer.EmitInstruction(OpCodeNumber.Ldarg_1);
}
if (propertyType.IsStruct()) {
writer.EmitInstructionType(OpCodeNumber.Box, propertyType);
}
writer.Box_LocalVariableIfNeeded(oldValueVariable);
var isPrimitive = propertyType.IsPrimitive();
if (isPrimitive) {
writer.Compare_Primitives();
} else {
//TODO: Try and use the equality operator when present
writer.Compare_Objects(assets.ObjectEqualsMethod);
}
//writer.Leave_IfTrue(_context.LeaveBranchTarget);
writer.Leave_IfTrue(context.LeaveBranchTarget);
writer.DetachInstructionSequence();
}
开发者ID:DamianReeves,项目名称:PostEdge,代码行数:51,代码来源:EnhancePropertySetterMethodBodyWrappingImplementation.cs
示例13: BuildAccessorStatement
static Statement BuildAccessorStatement (RefactoringContext context, PropertyDeclaration pdecl)
{
if (pdecl.Setter.IsNull && !pdecl.Getter.IsNull) {
var field = RemoveBackingStore.ScanGetter (context, pdecl);
if (field != null)
return new ExpressionStatement (new AssignmentExpression (new IdentifierExpression (field.Name), AssignmentOperatorType.Assign, new IdentifierExpression ("value")));
}
if (!pdecl.Setter.IsNull && pdecl.Getter.IsNull) {
var field = RemoveBackingStore.ScanSetter (context, pdecl);
if (field != null)
return new ReturnStatement (new IdentifierExpression (field.Name));
}
return new ThrowStatement (new ObjectCreateExpression (context.CreateShortType ("System", "NotImplementedException")));
}
示例14: GetBackingField
internal static IField GetBackingField (BaseRefactoringContext context, PropertyDeclaration propertyDeclaration)
{
// automatic properties always need getter & setter
if (propertyDeclaration == null || propertyDeclaration.Getter.IsNull || propertyDeclaration.Setter.IsNull || propertyDeclaration.Getter.Body.IsNull || propertyDeclaration.Setter.Body.IsNull)
return null;
if (!context.Supports(csharp3) || propertyDeclaration.HasModifier (ICSharpCode.NRefactory.CSharp.Modifiers.Abstract) || ((TypeDeclaration)propertyDeclaration.Parent).ClassType == ClassType.Interface)
return null;
var getterField = ScanGetter (context, propertyDeclaration);
if (getterField == null)
return null;
var setterField = ScanSetter (context, propertyDeclaration);
if (setterField == null)
return null;
if (!getterField.Equals(setterField))
return null;
return getterField;
}
示例15: EmitPropertyMethod
protected virtual void EmitPropertyMethod(PropertyDeclaration propertyDeclaration, Accessor accessor, bool setter)
{
var memberResult = this.Emitter.Resolver.ResolveNode(propertyDeclaration, this.Emitter) as MemberResolveResult;
if (memberResult != null &&
(memberResult.Member.Attributes.Any(a => a.AttributeType.FullName == "Bridge.FieldPropertyAttribute") ||
(propertyDeclaration.Getter.IsNull && propertyDeclaration.Setter.IsNull)))
{
return;
}
if (!accessor.IsNull && this.Emitter.GetInline(accessor) == null)
{
var p = (PropertyDeclaration)accessor.Parent;
var overloads = OverloadsCollection.Create(this.Emitter, propertyDeclaration, setter);
string name = overloads.GetOverloadName();
this.Write((setter ? "set" : "get") + name);
this.WriteOpenParentheses();
if (setter)
{
this.Write("value");
this.WriteColon();
name = BridgeTypes.ToJsName(p.ReturnType, this.Emitter);
name = EmitBlock.HandleType(name);
this.Write(name);
}
this.WriteCloseParentheses();
this.WriteColon();
if (setter)
{
this.Write("void");
}
else
{
name = BridgeTypes.ToJsName(p.ReturnType, this.Emitter);
name = EmitBlock.HandleType(name);
this.Write(name);
}
this.WriteSemiColon();
this.WriteNewLine();
}
}