Beispiel #1
0
        // Most general case - called by the overloads below
        /// <summary>
        /// Converts a parameter from an Excel-friendly type (e.g. object, or string) to an add-in friendly type, e.g. double? or InternalType.
        /// Will only be considered for those parameters that have a 'to' type that matches targetTypeOrNull,
        ///  or for all types if null is passes for the first parameter.
        /// </summary>
        /// <param name="parameterConversion"></param>
        /// <param name="targetTypeOrNull"></param>
        public ParameterConversionConfiguration AddParameterConversion(Func <Type, ExcelParameterRegistration, LambdaExpression> parameterConversion, Type targetTypeOrNull = null)
        {
            var pc = new ParameterConversion(parameterConversion, targetTypeOrNull);

            ParameterConversions.Add(pc);
            return(this);
        }
Beispiel #2
0
 public StateConfiguration OnEntryFrom <TArg0, TArg1>(TriggerWithParameters <TArg0, TArg1> trigger, Action <TArg0, TArg1, Transition> entryAction)
 {
     mRepresentation.AddEntryAction(trigger.Trigger, (t, args) => entryAction(
                                        ParameterConversion.Unpack <TArg0>(args, 0),
                                        ParameterConversion.Unpack <TArg1>(args, 1), t));
     return(this);
 }
Beispiel #3
0
 public void ValidateParameters(object[] args)
 {
     if (args != null)
     {
         ParameterConversion.Validate(args, mArgumentTypes);
     }
 }
 public void AddEvent(Event @event)
 {
     ParameterConversion.ConvertEvent(@event, internalEvent =>
     {
         CEventTrace.EventTracerAddEvent(eventTracer, internalEvent);
     });
 }
        // Returns the SpanId of the newly-created Span in the EventTracer
        public SpanId AddSpan(SpanId[] causes)
        {
            unsafe
            {
                if (causes == null)
                {
                    return(AddSpan());
                }

                var causeIds = new CEventTrace.SpanId[causes.Length];
                for (var i = 0; i < causes.Length; i++)
                {
                    causeIds[i] = ParameterConversion.ConvertSpanId(causes[i]);
                }

                CEventTrace.SpanId createdSpanId;
                fixed(CEventTrace.SpanId *fixedCauseIds = causeIds)
                {
                    createdSpanId = CEventTrace.EventTracerAddSpan(eventTracer, fixedCauseIds, (uint)causeIds.Length);
                }

                var newSpanId = new SpanId();
                ApiInterop.Memcpy(newSpanId.Data, createdSpanId.Data, SpanId.SpanIdSize);

                return(newSpanId);
            }
        }
Beispiel #6
0
 public StateConfiguration PermitDynamicIf <TArg0>(TriggerWithParameters <TArg0> trigger, Func <TArg0, TState> destinationStateSelector, Func <bool> guard)
 {
     return(InternalPermitDynamicIf(
                trigger.Trigger,
                args => destinationStateSelector(
                    ParameterConversion.Unpack <TArg0>(args, 0)),
                guard));
 }
        public bool ShouldSampleEvent(Event @event)
        {
            bool shouldSampleEvent = false;

            ParameterConversion.ConvertEvent(@event, internalEvent =>
            {
                shouldSampleEvent = CEventTrace.EventTracerShouldSampleEvent(eventTracer, internalEvent) > 0;
            });

            return(shouldSampleEvent);
        }
 public EventTracer(EventTracerParameters[] parameters)
 {
     unsafe
     {
         ParameterConversion.ConvertEventTracerParameters(parameters, (internalParameters, handles) =>
         {
             eventTracer = CEventTrace.EventTracerCreate(internalParameters);
             handleList  = handles;
         });
     }
 }
        public SpanId AddSpan(SpanId spanId)
        {
            var newSpanId = new SpanId();

            unsafe
            {
                var internalSpanId = ParameterConversion.ConvertSpanId(spanId);
                var createdSpanId  = CEventTrace.EventTracerAddSpan(eventTracer, &internalSpanId, 1);
                ApiInterop.Memcpy(newSpanId.Data, createdSpanId.Data, SpanId.SpanIdSize);
            }

            return(newSpanId);
        }
        public static Item DeserializeNextItemFromStream(IOStream stream)
        {
            unsafe
            {
                var itemContainer = GetThreadLocalItem();
                var itemSize      = CEventTrace.GetNextSerializedItemSize(stream.Stream);

                var deserializeStatus = CEventTrace.DeserializeItemFromStream(stream.Stream, itemContainer, itemSize);
                if (deserializeStatus != 1)
                {
                    var errorMessage = CEventTrace.GetLastError();
                    throw new IOException(ApiInterop.FromUtf8Cstr(errorMessage));
                }

                return(ParameterConversion.ConvertItem(itemContainer));
            }
        }
        public static Item Create(IOStorage storage, Item?itemToConvert = null)
        {
            unsafe
            {
                var newItem = new Item();
                if (itemToConvert != null)
                {
                    ParameterConversion.ConvertItem(itemToConvert.Value, nativeItem =>
                    {
                        newItem = ParameterConversion.ConvertItem(CEventTrace.ItemCreate(storage.Storage, nativeItem));
                    });
                }
                else
                {
                    newItem = ParameterConversion.ConvertItem(CEventTrace.ItemCreate(storage.Storage, null));
                }

                return(newItem);
            }
        }
        public void SerializeToStream(IOStream stream)
        {
            unsafe
            {
                var serializedItemResult = 0;
                ParameterConversion.ConvertItem(this, nativeItem =>
                {
                    var itemSize         = CEventTrace.GetSerializedItemSize(nativeItem);
                    serializedItemResult = CEventTrace.SerializeItemToStream(stream.Stream, nativeItem, itemSize);
                });

                if (serializedItemResult == 1)
                {
                    return;
                }

                var errorMessage = CEventTrace.GetLastError();
                throw new IOException(ApiInterop.FromUtf8Cstr(errorMessage));
            }
        }
Beispiel #13
0
 public StateConfiguration OnEntry <TArg0, TArg1, TArg2>(Action <TArg0, TArg1, TArg2, Transition> entryAction)
 {
     mRepresentation.AddEntryAction((t, args) => entryAction(ParameterConversion.Unpack <TArg0>(args, 0),
                                                             ParameterConversion.Unpack <TArg1>(args, 1), ParameterConversion.Unpack <TArg2>(args, 2), t));
     return(this);
 }
 public override int GetHashCode()
 {
     return(CEventTrace.SpanIdHash(ParameterConversion.ConvertSpanId(this)));
 }
 public void SetActiveSpanId(SpanId spanId)
 {
     CEventTrace.EventTracerSetActiveSpanId(eventTracer, ParameterConversion.ConvertSpanId(spanId));
 }
 public bool Equals(SpanId other)
 {
     return(CEventTrace.SpanIdEqual(
                ParameterConversion.ConvertSpanId(this),
                ParameterConversion.ConvertSpanId(other)) > 0);
 }