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

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

      return !args.Cancel;
    }
Exemplo n.º 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;
    }