Exemplo n.º 1
0
 public void RaiseProgramError(PainState currentState)
 {
     if (this.OnProgramError != null)
     {
         PainProgramErrorEventArgs args = new PainProgramErrorEventArgs()
         {
             Context = this,
             Program = currentState.Program,
             State   = currentState
         };
         this.OnProgramError(this, args);
         args.Clean();
     }
 }
Exemplo n.º 2
0
        //////////////////////////////////////////////

        public void RaiseProgramStart(PainState state, IList <PainMethodParam> finalParameters)
        {
            PainState currentState = this.Stack.Peek();

            if (this.OnProgramStart != null)
            {
                PainProgramChangedEventArgs args = new PainProgramChangedEventArgs()
                {
                    Context    = this,
                    Program    = state.Program,
                    State      = state,
                    Parameters = finalParameters
                };
                this.OnProgramStart(this, args);
                args.Clean();
            }
        }
Exemplo n.º 3
0
 public Boolean RaiseError(PainState currentState, Exception Error)
 {
     if (this.OnError != null)
     {
         PainErrorEventArgs args = new PainErrorEventArgs()
         {
             Context = this,
             Program = currentState.Program,
             State   = currentState,
             Error   = Error,
             Handled = false
         };
         this.OnError(this, args);
         args.Clean();
         return(args.Handled);
     }
     return(false);
 }
Exemplo n.º 4
0
        public PainState PopContext()
        {
            PainState currentState = this.Stack.Peek();

            if (currentState != null &&
                currentState.ContextType != PainContextType.GLOBAL)
            {
                RaiseProgramEnd(currentState);

                currentState.Clean();

                PainState popedState = this.Stack.Pop();
                this.CurrentState = this.Stack.Peek();

                return(currentState);
            }
            return(null);
        }
Exemplo n.º 5
0
        //////////////////////////////////////////////

        //public PainState PushContext(String DisplayName, Guid ObjectID, PainContextType ContextType)
        public PainState PushContext(
            PainProgram Program,
            PainContextType ContextType,
            IList <Object> Parameters)
        {
            PainState  state = new PainState(Program, ContextType); // DisplayName, ObjectID, ContextType);
            PainObject obj   = state.Object;

            this.Stack.Push(state);
            this.CurrentState = state;

            List <PainMethodParam> finalParameters = new List <PainMethodParam>();
            Int32 index = -1;

            if (Program is PainMethod)
            {
                PainMethod method = (PainMethod)Program;
                foreach (String parameter in method.Parameters)
                {
                    index++;

                    Object parameterValue = Parameters == null ? null :
                                            index < Parameters.Count ?
                                            Parameters[index] :
                                            new Undefined();

                    if (obj != null)
                    {
                        obj[parameter] = parameterValue;
                        finalParameters.Add(new PainMethodParam()
                        {
                            Name  = parameter,
                            Value = parameterValue
                        });
                    }
                }
            }

            if (obj != null)
            {
                foreach (PainMethod painMethod in Program.Methods)
                {
                    if (state.Program is PainClass)
                    {
                        PainMethod newMethod = (PainMethod)painMethod.Clone();
                        newMethod.ParentObject = obj;
                        obj[newMethod.Name]    = newMethod;
                    }
                    else
                    {
                        obj[painMethod.Name] = painMethod;
                    }
                }

                foreach (PainClass painClass in Program.Classes)
                {
                    obj[painClass.Name] = painClass;
                }
            }

            RaiseProgramStart(
                state,
                finalParameters);

            return(state);
        }