Esempio n. 1
0
 internal StackMarker(IApplicable thunk, object mark1, object mark2)
     : base()
 {
     this.thunk = thunk;
     this.mark1 = mark1;
     this.mark2 = mark2;
 }
Esempio n. 2
0
 internal CallFromPrimitive2(IApplicable op, object arg0, object arg1)
     : base()
 {
     this.op   = op;
     this.arg0 = arg0;
     this.arg1 = arg1;
 }
Esempio n. 3
0
 public static void ThrowIfApplied(this IApplicable applicable)
 {
     if (applicable.IsApplied)
     {
         throw new InvalidOperationException($"Applicable ({applicable.GetType()}) is applied and readonly for now");
     }
 }
Esempio n. 4
0
 public static void ApplySafety(this IApplicable applicable)
 {
     if (!applicable.IsApplied)
     {
         applicable.Apply();
     }
 }
Esempio n. 5
0
        internal static bool Call(out object answer, ref Control expression, ref Environment environment, object evop, object evarg0, object evarg1, object evarg2, object evarg3)
        {
            IApplicable op = evop as IApplicable;

            if (op == null)
            {
                throw new NotImplementedException("Application of non-procedure object.");
            }
            return(op.Call(out answer, ref expression, ref environment, evarg0, evarg1, evarg2, evarg3));
        }
Esempio n. 6
0
        public static bool WithInterruptMask(out object answer, object arg0, object arg1)
        {
            IApplicable receiver = arg1 as IApplicable;

            if (receiver == null)
            {
                throw new NotImplementedException("Receiver is not applicable.");
            }
            answer = new TailCallInterpreter(new InterruptMask(arg0, receiver), null);
            return(true);
        }
Esempio n. 7
0
        public static bool WithStackMarker(out object answer, object thunk, object mark1, object mark2)
        {
            IApplicable athunk = thunk as IApplicable;

            if (athunk == null)
            {
                throw new NotImplementedException("Thunk is not applicable.");
            }
            answer = new TailCallInterpreter(new StackMarker(athunk, mark1, mark2), null);
            return(true);
        }
Esempio n. 8
0
        /// <summary>
        ///
        /// After the enumeration of the REST API is complete, this method will enumerate through the raw payloads that
        /// were retrieved; it will then use metadata in order to parse and then load the data into specific table columns.
        ///
        /// <param name="poProcess">The structure that represents the Process being currently run</param>
        /// <returns>None</returns>
        /// </summary>
        private void ApplyDataSnapshot(AceProcess poProcess)
        {
            int nTotalRecords  = 0;
            int nFailedRecords = 0;

            string sSubject = "PmdAceConsumptionServiceImpl::ApplyDataSnapshot()";

            Hashtable CurrRecord = new Hashtable();

            try
            {
                Dictionary <string, IApplicable> BucketApplyManagers = CreateApplyManagers(poProcess);

                using (AceChangeRecordReader oRecordReader = new AceChangeRecordReader(moStgConnectionMetadata, poProcess))
                {
                    foreach (Hashtable TempRecord in oRecordReader)
                    {
                        CurrRecord = TempRecord;

                        // We should probably have a better way of detecting successful records vs. error records
                        if (TempRecord.Count > 1)
                        {
                            foreach (string sTmpBucketName in BucketApplyManagers.Keys)
                            {
                                if (AreBucketValuesPresent(poProcess, sTmpBucketName, TempRecord))
                                {
                                    IApplicable ApplyManager = BucketApplyManagers[sTmpBucketName];

                                    ApplyManager.UpsertRecord(TempRecord);
                                }
                            }
                        }
                        else
                        {
                            nFailedRecords++;
                        }

                        nTotalRecords++;

                        if ((nTotalRecords % 1000) == 0)
                        {
                            LogInfo(sSubject, "Applied (" + nTotalRecords + ") records to the staging table(s)");
                            Console.Out.Flush();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(sSubject,
                         "ERROR!  An error has taken place with record -> Contents: (" + CurrRecord.ToString() + ")",
                         ex);
            }
        } // method()
Esempio n. 9
0
        public static bool WithHistoryDisabled(out object answer, object arg0)
        {
            IApplicable thunk = arg0 as IApplicable;

            if (thunk == null)
            {
                throw new NotImplementedException("Thunk is not applicable.");
            }
            answer = new TailCallInterpreter(new HistoryDisabled(thunk), null);
            return(true);
        }
Esempio n. 10
0
        public AppliedEventResult <TEntity> Result <TEntity>(
            Func <TEvent, TEntity, TEntity> whenFunc,
            IApplicable <TEntity> entity
            )
        {
            var applied = entity.Appled();

            return(new AppliedEventResult <TEntity>(
                       whenFunc((TEvent)_event, applied.Result()),
                       applied
                       .Events()
                       .Concat(new [] { _event })
                       ));
        }
Esempio n. 11
0
        public static bool UserApply(out object answer, object arg0, object arg1)
        {
            ////Primitive.Noisy = true;
            IApplicable op    = arg0 as IApplicable;
            Cons        rands = arg1 as Cons;

            if (op == null)
            {
                throw new NotImplementedException("Apply non applicable.");
            }
            if (arg1 != null && rands == null)
            {
                throw new NotImplementedException("Bad list to apply.");
            }
            answer = new TailCallInterpreter(new ApplyFromPrimitive(op, rands), null);
            return(true); // special return
        }
Esempio n. 12
0
        public static bool CallWithCurrentContinuation(out object answer, object arg)
        {
            //if (cwccTroubleCount++ > 7) Debugger.Break ();
            // extreme hair ahead

            IApplicable receiver = arg as IApplicable;

            if (receiver == null)
            {
                throw new NotImplementedException("Receiver cannot be applied.");
            }
            // Create an initial unwinder state.  After reload, we resume at
            // CWCCFrame0.
            UnwinderState env = new UnwinderState(new CWCCFrame0(receiver));

            // Return from the primitive with instructions to unwind the stack.
            answer = new TailCallInterpreter(Interpreter.UnwindStackExpression, env);
            return(true);
        }
Esempio n. 13
0
        public static bool WithinControlPoint(out object answer, object arg0, object arg1)
        {
            // extreme hair ahead

            IApplicable thunk = arg1 as IApplicable;

            if (thunk == null)
            {
                throw new NotImplementedException("Thunk is not applicable.");
            }

            // Create an initial unwinder state.  After reload, we resume at
            // WithinControlPointFrame.
            UnwinderState env = new UnwinderState((ControlPoint)arg0, new WithinControlPointFrame(thunk));

            // Return from the primitive with instructions to unwind the stack.
            answer = new TailCallInterpreter(Interpreter.UnwindStackExpression, env);
            return(true);
        }
Esempio n. 14
0
 internal HistoryDisabled(IApplicable arg0)
     : base()
 {
     this.thunk = arg0;
 }
Esempio n. 15
0
        static ZilResult PerformMap([NotNull] Context ctx, ZilObject finalf, IApplicable loopf, [NotNull] IStructure[] structs, bool first)
        {
            if (structs == null)
            {
                throw new ArgumentNullException(nameof(structs));
            }

            var finalf_app = finalf.AsApplicable(ctx);

            int numStructs = structs.Length;
            var loopArgs   = new ZilObject[numStructs];

            var  results = new List <ZilObject>();
            bool running = true;

            while (running)
            {
                // prepare loop args
                int i;
                for (i = 0; i < numStructs; i++)
                {
                    var st = structs[i];
                    if (st == null || st.IsEmpty)
                    {
                        break;
                    }

                    if (first)
                    {
                        loopArgs[i] = st.GetFirst();
                    }
                    else
                    {
                        loopArgs[i] = (ZilObject)st;
                    }

                    structs[i] = st.GetRest(1);
                }

                if (i < numStructs)
                {
                    break;
                }

                // apply loop function
                var result = loopf.ApplyNoEval(ctx, loopArgs);

                if (result.IsMapControl(out var outcome, out var value))
                {
                    switch (outcome)
                    {
                    case ZilResult.Outcome.MapStop:
                        // add values to results and exit loop
                        results.AddRange((IEnumerable <ZilObject>)value);
                        running = false;
                        continue;

                    case ZilResult.Outcome.MapRet:
                        // add values to results and continue
                        results.AddRange((IEnumerable <ZilObject>)value);
                        continue;

                    case ZilResult.Outcome.MapLeave:
                        // discard results, skip finalf, and return this value from the map
                        return(value);

                    default:
                        throw new UnhandledCaseException(outcome.ToString());
                    }
                }

                if (result.ShouldPass())
                {
                    return(result);
                }

                results.Add((ZilObject)result);
            }

            // apply final function
            if (finalf_app != null)
            {
                return(finalf_app.ApplyNoEval(ctx, results.ToArray()));
            }

            return(results.Count > 0 ? results[results.Count - 1] : ctx.FALSE);
        }
Esempio n. 16
0
 internal CallFromPrimitive1(IApplicable op, object arg0)
     : base()
 {
     this.op   = op;
     this.arg0 = arg0;
 }
Esempio n. 17
0
 internal CallFromPrimitive0(IApplicable op)
     : base()
 {
     this.op = op;
 }
Esempio n. 18
0
 public static CallFromPrimitive Make(IApplicable op, object arg0, object arg1)
 {
     return new CallFromPrimitive2(op, arg0, arg1);
 }
Esempio n. 19
0
 internal ApplyFromPrimitive(IApplicable op, Cons rands)
     : base()
 {
     this.op = op;
     this.rands = rands;
 }
Esempio n. 20
0
 internal InterruptMask(object arg0, IApplicable receiver)
     : base()
 {
     this.arg0 = arg0;
     this.receiver = receiver;
 }
Esempio n. 21
0
 public CWCCFrame0(IApplicable receiver)
 {
     this.receiver = receiver;
 }
Esempio n. 22
0
 internal CallFromPrimitive1(IApplicable op, object arg0)
     : base()
 {
     this.op = op;
     this.arg0 = arg0;
 }
Esempio n. 23
0
 public Tab(IApplicable <TabType> entity)
     : this(entity, new EmptyEventStream())
 {
 }
Esempio n. 24
0
 public Tab(IApplicable <TabType> entity, IEventStream eventStream) : base(entity, eventStream)
 {
 }
Esempio n. 25
0
 public AppliedTabCreatedEvent(TabCreatedEvent evnt, IApplicable <TabType> entity) : base(evnt, entity)
 {
 }
Esempio n. 26
0
 internal InterruptMask(object arg0, IApplicable receiver)
     : base()
 {
     this.arg0     = arg0;
     this.receiver = receiver;
 }
Esempio n. 27
0
 public static ZilResult MAPR([NotNull] Context ctx,
                              [Decl("<OR FALSE APPLICABLE>")] ZilObject finalf,
                              IApplicable loopf, [NotNull][ItemNotNull] IStructure[] structs)
 {
     return(PerformMap(ctx, finalf, loopf, structs, false));
 }
Esempio n. 28
0
 public WithinControlPointFrame(IApplicable thunk)
 {
     this.thunk = thunk;
 }
Esempio n. 29
0
 public static CallFromPrimitive Make(IApplicable op)
 {
     return new CallFromPrimitive0 (op);
 }
Esempio n. 30
0
 public FakeAggregateRoot(Func <TEntity, TEventType, IApplicable <TEntity> > f, IApplicable <TEntity> entity, IEnumerable <IDomainEvent> ucommetedEvents)
 {
     _f               = f;
     _entity          = entity;
     _ucommetedEvents = ucommetedEvents;
 }
Esempio n. 31
0
 internal CallFromPrimitive0(IApplicable op)
     : base()
 {
     this.op = op;
 }
Esempio n. 32
0
 protected Combination2Q(Quotation rator, SCode rand0, SCode rand1)
     : base(rator, rand0, rand1)
 {
     this.ratorValue = (IApplicable) rator.Quoted;
 }
Esempio n. 33
0
 internal CallFromPrimitive2(IApplicable op, object arg0, object arg1)
     : base()
 {
     this.op = op;
     this.arg0 = arg0;
     this.arg1 = arg1;
 }
Esempio n. 34
0
 public CWCCFrame0(IApplicable receiver)
 {
     this.receiver = receiver;
 }
Esempio n. 35
0
 internal HistoryDisabled(IApplicable arg0)
     : base()
 {
     this.thunk = arg0;
 }
Esempio n. 36
0
 public WithinControlPointFrame(IApplicable thunk)
 {
     this.thunk = thunk;
 }
Esempio n. 37
0
 internal StackMarker(IApplicable thunk, object mark1, object mark2)
     : base()
 {
     this.thunk = thunk;
     this.mark1 = mark1;
     this.mark2 = mark2;
 }
Esempio n. 38
0
 internal ApplyFromPrimitive(IApplicable op, Cons rands)
     : base()
 {
     this.op    = op;
     this.rands = rands;
 }
Esempio n. 39
0
 public FakeAggregateRoot(Func <TEntity, TEventType, IApplicable <TEntity> > f, IApplicable <TEntity> entity)
     : this(f, entity, new List <IDomainEvent>())
 {
 }
Esempio n. 40
0
 public static CallFromPrimitive Make(IApplicable op)
 {
     return(new CallFromPrimitive0(op));
 }
Esempio n. 41
0
        //protected AggregateRoot(EntityState<TEntity> entityState)
        //{
        //    _entityState = entityState;

        //}
        protected AggregateRoot(IApplicable <TEntity> entity, IEventStream eventStream)
        {
            _entity      = entity;
            _eventStream = eventStream;
        }
Esempio n. 42
0
 public static CallFromPrimitive Make(IApplicable op, object arg0, object arg1)
 {
     return(new CallFromPrimitive2(op, arg0, arg1));
 }