protected virtual bool OnReferenced(ReferencingEventArgs args) { if (Referenced != null) { Referenced.Invoke(this, args); } return(!args.Cancel); }
public IValueReference Ref(string id) { var args = new ReferencingEventArgs(false, null); if (OnReferencing(args)) { return(args.Ref); } var scope = Scope; while (scope != null) { //TODO: Figure out more maintainable solution if (scope is FunctionScope) { return(null); } if (scope.HasVariable(id)) { args = new ReferencingEventArgs(false, scope.Ref(id)); if (args.Ref != null && OnReferenced(args)) { if (Owner != null) { Owner.NotifyReferenceCreated(args.Ref); } return(args.Ref); } return(null); } scope = scope.Parent; } return(null); }
protected virtual bool OnReferenced(ReferencingEventArgs args) { if (Referenced != null) Referenced.Invoke(this, args); return !args.Cancel; }
public IValueReference Ref(string id) { var args = new ReferencingEventArgs(false, null); if (OnReferencing(args)) return args.Ref; var scope = Scope; while (scope != null) { //TODO: Figure out more maintainable solution if (scope is FunctionScope) return null; if (scope.HasVariable(id)) { args = new ReferencingEventArgs(false, scope.Ref(id)); if (args.Ref != null && OnReferenced(args)) { if (Owner != null) { Owner.NotifyReferenceCreated(args.Ref); } return args.Ref; } return null; } scope = scope.Parent; } return null; }