Example #1
0
        protected virtual bool OnReferenced(ReferencingEventArgs args)
        {
            if (Referenced != null)
            {
                Referenced.Invoke(this, args);
            }

            return(!args.Cancel);
        }
Example #2
0
        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);
        }
Example #3
0
    protected virtual bool OnReferenced(ReferencingEventArgs args)
    {
      if (Referenced != null)
        Referenced.Invoke(this, args);

      return !args.Cancel;
    }
Example #4
0
    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;
    }