public XmlElement CreateMessageEventElement(XmlElement modelElement,string eventName,string messageSort, EventKind eventKind)
 {
     string umlModelType=GetEventElementUmlType(messageSort, eventKind);
     XmlElement createdMessageEventElement=CreateUmlAttributeAsElement(modelElement,EVENT_ELEMENT_TYPE_NAME,umlModelType);
     AddEventNameAttribute(createdMessageEventElement,eventName);
     return createdMessageEventElement;
 }
示例#2
0
 public EventDescription(EventKind kind, UserViewModel source, UserViewModel target, TweetViewModel tweet = null)
 {
     this.CreatedAt = DateTime.Now;
     this.Kind = kind;
     this.SourceUser = source;
     this.TargetUser = target;
     this.TargetTweet = tweet;
 }
示例#3
0
 protected void AddAutoCommand(EventKind eventKind, string pattern, string command)
 {
     var autoCommand = new AutoCommand(
         AutoCommandGroup.Default,
         eventKind,
         command,
         pattern);
     VimData.AutoCommands = VimData.AutoCommands.Concat(new[] { autoCommand }).ToFSharpList();
 }
            public EventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers)
            {
                Contract.Requires<ArgumentNullException>(modifiers != null, "modifiers");

                _internalEventKind = internalEventKind;
                _requestId = requestId;
                _suspendPolicy = suspendPolicy;
                _modifiers = new ImmutableList<EventRequestModifier>(modifiers);
            }
            public static EventFilter CreateFilter(EventKind internalEventKind, JvmtiEnvironment environment, JniEnvironment nativeEnvironment, RequestId requestId, SuspendPolicy suspendPolicy, ImmutableList<EventRequestModifier> modifiers)
            {
                if (modifiers.Count == 0)
                    return new PassThroughEventFilter(internalEventKind, requestId, suspendPolicy, modifiers);

                EventFilter[] elements = modifiers.Select(modifier => CreateFilter(internalEventKind, environment, nativeEnvironment, requestId, suspendPolicy, modifiers, modifier)).ToArray();
                if (elements.Length == 1)
                    return elements[0];

                return new AggregateEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, elements);
            }
示例#6
0
 public NotificationViewModel(MainWindowViewModel parent, UserViewModel source, UserViewModel target, string text, EventKind eventKind = EventKind.Undefined)
 {
     this.Parent = parent;
     this.SourceUser = source;
     this.TargetUser = target;
     this.Text = text;
     this.NotifyEventKind = eventKind;
     this.RaisePropertyChanged(() => SourceUser);
     this.RaisePropertyChanged(() => TargetUser);
     this.RaisePropertyChanged(() => Text);
     this.RaisePropertyChanged(() => NotifyEventKind);
 }
示例#7
0
文件: Event.cs 项目: riga8008/domain
 public Event(string Title, string Description, DateTime InitialDateTime, DateTime FinalDateTime, string EnviromentLocation, EventKind Kind)
 {
     this.Title = Title;
     this.Description = this.Description;
     this.InitialDateTime = InitialDateTime;
     this.FinalDateTime = FinalDateTime;
     this.EnvironmentLocation = EnvironmentLocation;
     this.Kind = Kind;
     // - Default properties.
     this.CreationDateTime = DateTime.Now;
     this.ModificationDateTime = DateTime.Now;
     this.Status = EventStatus.Created;
 }
        private string GetOperationEventType(EventKind eventKind)
        {
            string operationEventType=null;

            if(eventKind.Equals(EventKind.ReceiveEvent))
            {
                operationEventType=UmlModel.RECEIVE_OPERATION_EVENT;
            }
            else if(eventKind.Equals(EventKind.SendEvent))
            {
                operationEventType=UmlModel.SEND_OPERATION_EVENT;
            }
            return operationEventType;
        }
        private string GetEventElementUmlType(string messageSort, EventKind eventKind)
        {
            string eventElementUmlType=null;

            if((messageSort.Equals(UmlModel.ASYNCH_CALL))||(messageSort.Equals(UmlModel.SYNCH_CALL)))
            {
                eventElementUmlType=GetOperationEventType(eventKind);
            }
            else if(messageSort.Equals(UmlModel.ASYNCH_SIGNAL))
            {
                eventElementUmlType=GetSignalEventType(eventKind);
            }

            return eventElementUmlType;
        }
示例#10
0
		internal HtmlEventArgs (HtmlObject source,
					ScriptObject eventObj)
		{
			this.source_element = source;
			this.eventObject = eventObj;

			eventType = (string) eventObject.GetProperty("type");

			if (eventType.StartsWith ("click") ||
			    eventType.StartsWith ("dblclick") ||
			    eventType.StartsWith ("mouse"))
				eventKind = EventKind.Mouse;
			else if (eventType.StartsWith ("key")) {
				eventKind = EventKind.Key;
			}
		}
 internal static void Write(EventKind eventKind, string message, params object[] args)
 {
     switch (eventKind)
     {
         case EventKind.Error:
         case EventKind.Critical:
             Trace.TraceError(message, args);
             break;
         case EventKind.Warning:
             Trace.TraceWarning(message, args);
             break;
         case EventKind.Information:
         case EventKind.Verbose:
             Trace.TraceInformation(message, args);
             break;
     }
 }
            private static EventFilter CreateFilter(EventKind internalEventKind, JvmtiEnvironment environment, JniEnvironment nativeEnvironment, RequestId requestId, SuspendPolicy suspendPolicy, ImmutableList<EventRequestModifier> modifiers, EventRequestModifier modifier)
            {
                switch (modifier.Kind)
                {
                case ModifierKind.Count:
                    return new CountEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, modifier.Count);

                case ModifierKind.ThreadFilter:
                    return new ThreadEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, modifier.Thread);

                case ModifierKind.ClassTypeFilter:
                    throw new NotImplementedException();

                case ModifierKind.ClassMatchFilter:
                    throw new NotImplementedException();

                case ModifierKind.ClassExcludeFilter:
                    throw new NotImplementedException();

                case ModifierKind.LocationFilter:
                    return new LocationEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, modifier.Location);

                case ModifierKind.ExceptionFilter:
                    return new ExceptionEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, modifier.ExceptionOrNull, modifier.Caught, modifier.Uncaught);

                case ModifierKind.FieldFilter:
                    throw new NotImplementedException();

                case ModifierKind.Step:
                    return new StepEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, modifier.Thread, environment, nativeEnvironment, modifier.StepSize, modifier.StepDepth);

                case ModifierKind.InstanceFilter:
                    throw new NotImplementedException();

                case ModifierKind.SourceNameMatchFilter:
                    throw new NotImplementedException();

                case ModifierKind.Conditional:
                    throw new NotImplementedException();

                case ModifierKind.Invalid:
                default:
                    throw new ArgumentException();
                }
            }
示例#13
0
 public Event(EventKind ek, object pm)
 {
     kind       = ek;
     eventParam = pm;
 }
        public Error ClearEvent(EventKind eventKind, RequestId requestId)
        {
            List<RequestId> linkedRequests;
            if (_linkedRequests.TryRemove(requestId, out linkedRequests))
            {
                Suspend();

                foreach (RequestId request in linkedRequests)
                {
                    RequestId ignored;
                    _requestRemap.TryRemove(request, out ignored);

                    ClearEvent(eventKind, request);
                }

                return Resume();
            }

            byte[] packet = new byte[HeaderSize + sizeof(byte) + sizeof(int)];
            int id = GetMessageId();
            SerializeHeader(packet, id, EventRequestCommand.Clear);
            packet[HeaderSize] = (byte)eventKind;
            WriteInt32(packet, HeaderSize + sizeof(byte), requestId.Id);

            byte[] response = SendPacket(id, packet);
            return ReadErrorCode(response);
        }
示例#15
0
 public Event(EventKind kind, int floor)
 {
     Kind  = kind;
     Floor = floor;
 }
示例#16
0
 private void EnqueueEvent(EventKind kind, object element)
 {
     _pendingNotifications.Enqueue(new EventPair(kind, element));
     //Console.WriteLine ("Enqueued: " + _pendingNotifications.Peek());
 }
示例#17
0
 public Event(EventKind kind, Address address, byte[] data = null)
 {
     this.Kind    = kind;
     this.Address = address;
     this.Data    = data;
 }
            public Error SetEventInternal(JvmtiEnvironment environment, JniEnvironment nativeEnvironment, EventKind eventKind, EventFilter filter)
            {
                EventRequestModifier locationModifier = default(EventRequestModifier);
                EventRequestModifier stepModifier = default(EventRequestModifier);

                switch (eventKind)
                {
                case EventKind.Breakpoint:
                    // we're going to need the location modifier to set the breakpoint
                    if (filter.Modifiers.Count == 0 || filter.Modifiers[0].Kind != ModifierKind.LocationFilter)
                        return Error.IllegalArgument;

                    locationModifier = filter.Modifiers[0];
                    break;

                case EventKind.SingleStep:
                    // the first modifier contains the step properties
                    if (filter.Modifiers.Count == 0 || filter.Modifiers[0].Kind != ModifierKind.Step)
                        return Error.IllegalArgument;

                    stepModifier = filter.Modifiers[0];
                    break;

                case EventKind.FramePop:
                    if (filter.InternalEventKind == EventKind.SingleStep)
                        goto case EventKind.SingleStep;

                    break;

                default:
                    break;
                }

                lock (_eventRequests)
                {
                    Dictionary<RequestId, EventFilter> requests;
                    if (!_eventRequests.TryGetValue(eventKind, out requests))
                    {
                        requests = new Dictionary<RequestId, EventFilter>();
                        _eventRequests.Add(eventKind, requests);
                    }

                    requests.Add(filter.RequestId, filter);
                    if (requests.Count == 1)
                    {
                        JvmEventType? eventToEnable = GetJvmEventType(eventKind);

                        if (eventToEnable != null)
                        {
                            jvmtiError error = Environment.SetEventNotificationMode(JvmEventMode.Enable, eventToEnable.Value);
                            if (error != jvmtiError.None)
                                return GetStandardError(error);
                        }
                    }
                }

                switch (eventKind)
                {
                case EventKind.Breakpoint:
                    {
                        Contract.Assert(locationModifier.Kind == ModifierKind.LocationFilter);
                        jmethodID methodId = locationModifier.Location.Method;
                        jlocation location = new jlocation((long)locationModifier.Location.Index);
                        jvmtiError error = Environment.SetBreakpoint(methodId, location);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        break;
                    }

                case EventKind.FramePop:
                    if (filter.InternalEventKind == EventKind.SingleStep)
                    {
                        using (var thread = VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, stepModifier.Thread))
                        {
                            if (!thread.IsAlive)
                                return Error.InvalidThread;

                            jvmtiError error = environment.RawInterface.NotifyFramePop(environment, thread.Value, 0);
                            if (error != jvmtiError.None)
                                return GetStandardError(error);
                        }
                    }

                    break;

                default:
                    break;
                }

                return Error.None;
            }
示例#19
0
    protected override async Task <bool> SendCallStack(SessionId sessionId, ExecutionContext context, string reason, int thread_id, Breakpoint bp, JObject data, JObject args, EventKind event_kind, CancellationToken token)
    {
        Frame frame = null;
        var   commandParamsWriter = new MonoBinaryWriter();

        commandParamsWriter.Write(thread_id);
        commandParamsWriter.Write(0);
        commandParamsWriter.Write(1);
        var retDebuggerCmdReader = await context.SdbAgent.SendDebuggerAgentCommand(CmdThread.GetFrameInfo, commandParamsWriter, token);

        var frame_count = retDebuggerCmdReader.ReadInt32();

        if (frame_count > 0)
        {
            var frame_id = retDebuggerCmdReader.ReadInt32();
            var methodId = retDebuggerCmdReader.ReadInt32();
            var il_pos   = retDebuggerCmdReader.ReadInt32();
            retDebuggerCmdReader.ReadByte();
            var method = await context.SdbAgent.GetMethodInfo(methodId, token);

            if (method is null)
            {
                return(false);
            }

            if (await ShouldSkipMethod(sessionId, context, event_kind, 0, method, token))
            {
                await SendResume(sessionId, token);

                return(true);
            }

            SourceLocation location = method?.Info.GetLocationByIl(il_pos);
            if (location == null)
            {
                return(false);
            }

            Log("debug", $"frame il offset: {il_pos} method token: {method.Info.Token} assembly name: {method.Info.Assembly.Name}");
            Log("debug", $"\tmethod {method.Name} location: {location}");
            frame             = new Frame(method, location, frame_id);
            context.CallStack = new List <Frame>();
            context.CallStack.Add(frame);
        }
        if (!await EvaluateCondition(sessionId, context, frame, bp, token))
        {
            context.ClearState();
            await SendResume(sessionId, token);

            return(true);
        }

        args["why"]["type"] = context.PauseKind;

        await SendEvent(sessionId, "", args, token);

        return(true);
    }
示例#20
0
        /// <summary>
        /// 通知を発行する
        /// </summary>
        private static void IssueNotification(UserViewModel source, UserViewModel target, string text, EventKind eventKind, string soundPath = null)
        {
            if (Setting.Instance.StateProperty.IsInSilentMode)
            {
                return;
            }

            if (Setting.Instance.NotificationProperty.WindowNotificationStrategy != Configuration.Settings.NotificationStrategy.Disabled)
            {
                DispatcherHelper.BeginInvoke(() =>
                {
                    try
                    {
                        if (Setting.Instance.NotificationProperty.WindowNotificationStrategy == Configuration.Settings.NotificationStrategy.OnlyInactive &&
                            Application.Current.MainWindow.IsActive)
                        {
                            return;
                        }
                    }
                    catch (NullReferenceException nrex)
                    {
                        throw new NullReferenceException("Rewrap(BEFORE-1)", nrex);
                    }
                    try
                    {
                        var nvm = new NotificationViewModel(
                            Core.KernelService.MainWindowViewModel,
                            source,
                            target,
                            text,
                            eventKind);
                        Core.KernelService.MainWindowViewModel.Messenger.Raise(
                            new TransitionMessage(nvm, TransitionMode.Normal, "Notification"));
                    }
                    catch (NullReferenceException nrex)
                    {
                        throw new NullReferenceException("Rewrap(BEFORE-2)", nrex);
                    }
                });
            }
            if (Setting.Instance.NotificationProperty.SoundNotificationStrategy != Configuration.Settings.NotificationStrategy.Disabled)
            {
                DispatcherHelper.BeginInvoke(() =>
                {
                    try
                    {
                        if (Setting.Instance.NotificationProperty.SoundNotificationStrategy == Configuration.Settings.NotificationStrategy.OnlyInactive &&
                            Application.Current.MainWindow.IsActive)
                        {
                            return;
                        }
                        PlaySound(eventKind, soundPath);
                    }
                    catch (NullReferenceException nrex)
                    {
                        throw new NullReferenceException("Rewrap (AFTER)", nrex);
                    }
                }, System.Windows.Threading.DispatcherPriority.Background);
            }
        }
 public void setEventKind(EventKind ek)
 {
     this.eventKind = ek;
 }
示例#22
0
 public EventInfo(string regionName, double inRegionX, double inRegionY, double regionWidth, double regionHeight, EventKind kind, string commandName = null)
 {
     Kind         = kind;
     InRegionX    = inRegionX;
     InRegionY    = inRegionY;
     RegionName   = regionName;
     RegionWidth  = regionWidth;
     RegionHeight = regionHeight;
     CommandName  = commandName;
 }
 private XmlElement CreateMessageOccurrenceSpecElement(XmlElement parentElement,XmlElement messageElement,XmlElement lifelineElement,EventKind eventKind)
 {
     string messageElementID=messageElement.GetAttribute(UmlModel.XMI_ID_ATTR_COMPLETE_NAME);
     string messageSort=messageElement.GetAttribute(UmlModel.MESSAGE_SORT_ATTR_NAME);
     MessageOccurrenceSpecElementCreator elementCreator=
                 new MessageOccurrenceSpecElementCreator(this.XmiDocument,this.XmiDocumentBuilder,messageSort,eventKind);
     XmlElement newMessageOccurenceSpecElement=elementCreator.CreateMessageOccurrenceSpecificationElement(parentElement,lifelineElement,messageElementID);
     return newMessageOccurenceSpecElement;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectChangedEvent"/> class.
 /// </summary>
 /// <param name="thing">
 /// The payload <see cref="Thing"/>.
 /// </param>
 /// <param name="eventKind">
 /// The event kind.
 /// </param>
 public ObjectChangedEvent(Thing thing, EventKind eventKind)
 {
     this.ChangedThing = thing;
     this.EventKind    = eventKind;
 }
示例#25
0
        public void Notify(EventKind kind, Address address, byte[] bytes)
        {
            var contract = CurrentContext.Name;

            switch (kind)
            {
            case EventKind.GasEscrow:
            {
                Expect(contract == Nexus.GasContractName, $"event kind only in {Nexus.GasContractName} contract");

                var gasInfo = Serialization.Unserialize <GasEventData>(bytes);
                Expect(gasInfo.price >= this.MinimumFee, "gas fee is too low");
                this.MaxGas    = gasInfo.amount;
                this.GasPrice  = gasInfo.price;
                this.GasTarget = address;
                break;
            }

            case EventKind.GasPayment:
            {
                Expect(contract == Nexus.GasContractName, $"event kind only in {Nexus.GasContractName} contract");

                if (address.IsNull)
                {
                    Expect(gasPaymentInProgress, $"gas payment not in progress");
                    this.gasPaymentInProgress = false;
                    return;         // this event should be ignored, it is mostly an hack
                }
                else
                {
                    Expect(!gasPaymentInProgress, $"gas payment already in progress");
                    this.gasPaymentInProgress = true;

                    var gasInfo = Serialization.Unserialize <GasEventData>(bytes);
                    this.PaidGas += gasInfo.amount;

                    if (address != this.Chain.Address)
                    {
                        this.FeeTargetAddress = address;
                    }
                }
                break;
            }

            case EventKind.ValidatorSwitch:
                Expect(contract == Nexus.BlockContractName, $"event kind only in {Nexus.BlockContractName} contract");
                break;

            case EventKind.PollCreated:
            case EventKind.PollClosed:
            case EventKind.PollVote:
                Expect(contract == Nexus.ConsensusContractName, $"event kind only in {Nexus.ConsensusContractName} contract");
                break;

            case EventKind.ChainCreate:
            case EventKind.TokenCreate:
            case EventKind.FeedCreate:
                Expect(this.IsRootChain(), $"event kind only in root chain");
                break;

            case EventKind.FileCreate:
            case EventKind.FileDelete:
                Expect(contract == Nexus.StorageContractName, $"event kind only in {Nexus.StorageContractName } contract");
                break;

            case EventKind.ValidatorPropose:
            case EventKind.ValidatorElect:
            case EventKind.ValidatorRemove:
                Expect(contract == Nexus.ValidatorContractName, $"event kind only in {Nexus.ValidatorContractName} contract");
                break;

            case EventKind.ValueCreate:
            case EventKind.ValueUpdate:
                Expect(contract == Nexus.GovernanceContractName, $"event kind only in {Nexus.GovernanceContractName} contract");
                break;
            }

            var evt = new Event(kind, address, contract, bytes);

            _events.Add(evt);
        }
示例#26
0
        /// <summary>触发事件</summary>
        /// <param name="session"></param>
        /// <param name="kind"></param>
        /// <param name="he"></param>
        /// <returns>返回是否取消操作</returns>
        Boolean RaiseEvent(Session session, EventKind kind, HttpProxyEventArgs he)
        {
            GetHandler(kind)?.Invoke(session, he);

            return(he.Cancel);
        }
示例#27
0
        public static void Write(EventKind eventKind, string message, params object[] args)
        {
            try
            {
                //Check Whether the Loggiing is Enabled in the Configurations
                int loggingLevel = 4;
                try
                {
                    string loggingLevelValue = RoleEnvironment.GetConfigurationSettingValue("LoggingLevel");
                    if (!string.IsNullOrEmpty(loggingLevelValue))
                    {
                        int.TryParse(loggingLevelValue, out loggingLevel);
                    }
                }
                catch
                {
                }

                switch (eventKind)
                {
                case EventKind.Error:
                    if (loggingLevel >= 0)
                    {
                        Trace.TraceError(message, args);
                        LogInEventLog(EventLogEntryType.Error, message, args);
                    }
                    break;

                case EventKind.Critical:
                    if (loggingLevel >= 1)
                    {
                        Trace.TraceError(message, args);
                        LogInEventLog(EventLogEntryType.Error, message, args);
                    }
                    break;

                case EventKind.Warning:
                    if (loggingLevel >= 2)
                    {
                        Trace.TraceWarning(message, args);
                        LogInEventLog(EventLogEntryType.Warning, message, args);
                    }
                    break;

                case EventKind.Information:
                    if (loggingLevel >= 3)
                    {
                        Trace.TraceInformation(message, args);
                        LogInEventLog(EventLogEntryType.Information, message, args);
                    }
                    break;

                case EventKind.Verbose:
                    if (loggingLevel == 4)
                    {
                        Trace.TraceInformation(message, args);
                        LogInEventLog(EventLogEntryType.Information, message, args);
                    }
                    break;
                }
            }
            catch
            {
                LogInEventLog(EventLogEntryType.Error, "Failed to log message");
                LogInEventLog(EventLogEntryType.Error, message, args);
            }
        }
示例#28
0
 /// <summary>
 /// 通知を発行する
 /// </summary>
 private static void IssueNotification(UserViewModel source, UserViewModel target, string text, EventKind eventKind, string soundPath = null)
 {
     if (Setting.Instance.StateProperty.IsInSilentMode) return;
     if (Setting.Instance.NotificationProperty.WindowNotificationStrategy != Configuration.Settings.NotificationStrategy.Disabled)
     {
         DispatcherHelper.BeginInvoke(() =>
         {
             if (Setting.Instance.NotificationProperty.WindowNotificationStrategy == Configuration.Settings.NotificationStrategy.OnlyInactive &&
                 Application.Current.MainWindow.IsActive)
                 return;
             var nvm = new NotificationViewModel(
                 Core.KernelService.MainWindowViewModel,
                 source,
                 target,
                 text,
                 eventKind);
             Core.KernelService.MainWindowViewModel.Messenger.Raise(
                 new TransitionMessage(nvm, TransitionMode.Normal, "Notification"));
         });
     }
     if (Setting.Instance.NotificationProperty.SoundNotificationStrategy != Configuration.Settings.NotificationStrategy.Disabled)
     {
         DispatcherHelper.BeginInvoke(() =>
         {
             if (Setting.Instance.NotificationProperty.SoundNotificationStrategy == Configuration.Settings.NotificationStrategy.OnlyInactive &&
                 Application.Current.MainWindow.IsActive)
                 return;
             PlaySound(eventKind, soundPath);
         }, System.Windows.Threading.DispatcherPriority.Background);
     }
 }
示例#29
0
        private string GetSignalEventType(EventKind eventKind)
        {
            string signalEventType=null;

            if(eventKind.Equals(EventKind.ReceiveEvent))
            {
                signalEventType=UmlModel.RECEIVE_SIGNAL_EVENT;
            }
            else if(eventKind.Equals(EventKind.SendEvent))
            {
                signalEventType=UmlModel.SEND_SIGNAL_EVENT;
            }
            return signalEventType;
        }
示例#30
0
 private static void PlaySound(EventKind eventKind, string overrideSoundPath)
 {
     string path = Path.GetDirectoryName(Define.ExeFilePath);
     path = Path.Combine(path, Define.MediaDirectory);
     switch (eventKind)
     {
         case EventKind.Mention:
             path = Path.Combine(path, Define.MentionWavFile);
             break;
         case EventKind.DirectMessage:
             path = Path.Combine(path, Define.DirectMessageWavFile);
             break;
         case EventKind.Undefined:
             path = Path.Combine(path, Define.NewReceiveWavFile);
             break;
         case EventKind.Follow:
         case EventKind.Favorite:
         case EventKind.Retweet:
         case EventKind.Unfavorite:
             path = Path.Combine(path, Define.EventWavFile);
             break;
         default:
             return;
     }
     if (!String.IsNullOrEmpty(overrideSoundPath) &&
         File.Exists(overrideSoundPath))
     {
         path = overrideSoundPath;
     }
     if (File.Exists(path))
     {
         Task.Factory.StartNew(() =>
         {
             if (isPlaying) return;
             isPlaying = true;
             try
             {
                 using (var soundplayer = new SoundPlayer(path))
                 {
                     soundplayer.PlaySync();
                 }
             }
             catch (Exception ex)
             {
                 ExceptionStorage.Register(ex, ExceptionCategory.InternalError,
                     "通知音の再生ができませんでした。");
             }
             isPlaying = false;
         });
     }
 }
            public Error ClearEventInternal(EventKind eventKind, RequestId requestId)
            {
                lock (_eventRequests)
                {
                    Dictionary<RequestId, EventFilter> requests;
                    if (!_eventRequests.TryGetValue(eventKind, out requests))
                        return Error.None;

                    EventFilter eventFilter;
                    if (!requests.TryGetValue(requestId, out eventFilter))
                        return Error.None;

                    requests.Remove(requestId);
                    if (requests.Count == 0)
                    {
                        JvmEventType? eventToDisable = GetJvmEventType(eventKind);
                        if (eventToDisable != null)
                        {
                            jvmtiError error = Environment.SetEventNotificationMode(JvmEventMode.Disable, eventToDisable.Value);
                            if (error != jvmtiError.None)
                                return GetStandardError(error);
                        }
                    }

                    if (eventKind == EventKind.Breakpoint)
                    {
                        LocationEventFilter locationFilter = eventFilter as LocationEventFilter;
                        if (locationFilter == null)
                        {
                            AggregateEventFilter aggregateFilter = eventFilter as AggregateEventFilter;
                            Contract.Assert(aggregateFilter != null);
                            locationFilter = aggregateFilter.Filters.OfType<LocationEventFilter>().FirstOrDefault();
                        }

                        Contract.Assert(locationFilter != null);
                        jmethodID methodId = locationFilter.Location.Method;
                        jlocation location = new jlocation((long)locationFilter.Location.Index);
                        jvmtiError error = Environment.ClearBreakpoint(methodId, location);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);
                    }

                    return Error.None;
                }
            }
 public PassThroughEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable <EventRequestModifier> modifiers)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
 }
 public MessageOccurrenceSpecElementCreator(XmlDocument xmiDocument,XmlDocumentBuilder xmiDocumentBuilder,string messageSort,EventKind eventKind)
     : base(xmiDocument,xmiDocumentBuilder)
 {
     this.messageSort=messageSort;
     this.eventKind=eventKind;
 }
 public AggregateEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable <EventRequestModifier> modifiers, IEnumerable <EventFilter> filters)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
     Contract.Requires <ArgumentNullException>(filters != null, "filters");
     _filters = filters.ToArray();
 }
示例#35
0
        private DropOperationBaseEvent AssertDequeueEtwEvent(DropEtwListener etwListener, bool succeeded, EventKind kind)
        {
            var dropEvent = etwListener.DequeueDropEvent();

            Assert.Equal(succeeded, dropEvent.Succeeded);
            Assert.Equal(kind, dropEvent.Kind);
            return(dropEvent);
        }
 public CountEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable <EventRequestModifier> modifiers, int count)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
     _count = count;
 }
        public Error SetEvent(out RequestId requestId, EventKind eventKind, SuspendPolicy suspendPolicy, EventRequestModifier[] modifiers)
        {
            if (eventKind == EventKind.SingleStep && modifiers.Length == 1 && modifiers[0].Thread == default(ThreadId))
            {
                ThreadId[] threads;
                Error threadsErrorCode = GetAllThreads(out threads);
                if (threadsErrorCode != Error.None)
                {
                    requestId = default(RequestId);
                    return threadsErrorCode;
                }

                requestId = default(RequestId);

                threadsErrorCode = Suspend();
                if (threadsErrorCode != Error.None)
                    return threadsErrorCode;

                List<RequestId> requests = new List<RequestId>();
                foreach (var thread in threads)
                {
                    EventRequestModifier modifier = modifiers[0];
                    modifier.Thread = thread;
                    threadsErrorCode = SetEvent(out requestId, eventKind, suspendPolicy, new[] { modifier });
                    if (threadsErrorCode != Error.None)
                        return threadsErrorCode;

                    requests.Add(requestId);
                }

                _linkedRequests[requestId] = requests;
                foreach (var request in requests)
                    _requestRemap[request] = requestId;

                threadsErrorCode = Resume();
                if (threadsErrorCode != Error.None)
                    return threadsErrorCode;

                return Error.None;
            }

            byte[] packet = new byte[HeaderSize + 6];
            packet[HeaderSize] = (byte)eventKind;
            packet[HeaderSize + 1] = (byte)suspendPolicy;
            WriteInt32(packet, HeaderSize + 2, modifiers.Length);

            List<byte> packetData = new List<byte>(packet);
            foreach (EventRequestModifier modifier in modifiers)
            {
                packetData.Add((byte)modifier.Kind);

                switch (modifier.Kind)
                {
                case ModifierKind.Count:
                    {
                        byte[] additionalData = new byte[sizeof(int)];
                        WriteInt32(additionalData, 0, modifier.Count);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.Conditional:
                    {
                        byte[] additionalData = new byte[sizeof(int)];
                        WriteInt32(additionalData, 0, modifier.ExpressionId);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.ThreadFilter:
                    {
                        byte[] additionalData = new byte[ThreadIdSize];
                        WriteObjectId(additionalData, 0, modifier.Thread);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.ClassTypeFilter:
                    {
                        byte[] additionalData = new byte[ReferenceTypeIdSize];
                        WriteReferenceTypeId(additionalData, 0, modifier.Class);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.ClassMatchFilter:
                case ModifierKind.ClassExcludeFilter:
                    {
                        byte[] stringData = Encoding.UTF8.GetBytes(modifier.ClassPattern);
                        byte[] sizeData = new byte[sizeof(int)];
                        WriteInt32(sizeData, 0, stringData.Length);
                        packetData.AddRange(sizeData);
                        packetData.AddRange(stringData);
                    }
                    continue;

                case ModifierKind.LocationFilter:
                    {
                        byte[] additionalData = new byte[LocationSize];
                        WriteLocation(additionalData, 0, modifier.Location);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.ExceptionFilter:
                    {
                        byte[] additionalData = new byte[_referenceTypeIdSize.Value + 2];
                        WriteReferenceTypeId(additionalData, 0, modifier.ExceptionOrNull);
                        additionalData[_referenceTypeIdSize.Value] = (byte)(modifier.Caught ? 1 : 0);
                        additionalData[_referenceTypeIdSize.Value + 1] = (byte)(modifier.Uncaught ? 1 : 0);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.FieldFilter:
                    {
                        byte[] additionalData = new byte[ReferenceTypeIdSize + FieldIdSize];
                        WriteReferenceTypeId(additionalData, 0, modifier.Class);
                        WriteFieldId(additionalData, ReferenceTypeIdSize, modifier.Field);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.Step:
                    {
                        if (modifier.StepSize == StepSize.Statement)
                            throw new NotSupportedException();

                        byte[] additionalData = new byte[ThreadIdSize + (2 * sizeof(int))];
                        WriteObjectId(additionalData, 0, modifier.Thread);
                        WriteInt32(additionalData, ThreadIdSize, (int)modifier.StepSize);
                        WriteInt32(additionalData, ThreadIdSize + sizeof(int), (int)modifier.StepDepth);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.InstanceFilter:
                    {
                        byte[] additionalData = new byte[ObjectIdSize];
                        WriteObjectId(additionalData, 0, modifier.Instance);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.SourceNameMatchFilter:
                    {
                        byte[] stringData = Encoding.UTF8.GetBytes(modifier.SourceNamePattern);
                        byte[] sizeData = new byte[sizeof(int)];
                        WriteInt32(sizeData, 0, stringData.Length);
                        packetData.AddRange(sizeData);
                        packetData.AddRange(stringData);
                    }
                    continue;

                case ModifierKind.Invalid:
                default:
                    throw new InvalidOperationException();
                }
            }

            packet = packetData.ToArray();
            int id = GetMessageId();
            SerializeHeader(packet, id, EventRequestCommand.Set);

            byte[] response = SendPacket(id, packet);
            Error errorCode = ReadErrorCode(response);
            if (errorCode != Error.None)
            {
                requestId = default(RequestId);
                return errorCode;
            }

            int offset = HeaderSize;
            requestId = new RequestId(ReadInt32(response, ref offset));
            return Error.None;
        }
 public ThreadEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable <EventRequestModifier> modifiers, ThreadId thread)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
     _thread = thread;
 }
        private IEnumerable <LinuxEvent> NextEvent(Regex regex, FastStream source)
        {
            string line = string.Empty;

            while (true)
            {
                source.SkipWhiteSpace();

                if (source.EndOfStream)
                {
                    break;
                }

                EventKind eventKind = EventKind.Cpu;

                StringBuilder sb = new StringBuilder();

                // Command - Stops at first number AFTER first word(non-whitespace) and whitespace
                for (;;)
                {
                    if (sb.Length != 0)
                    {
                        if (this.IsNumberChar((char)source.Current))
                        {
                            break;
                        }
                        sb.Append(' ');
                    }
                    source.ReadAsciiStringUpToTrue(sb, delegate(byte c)
                    {
                        return(!char.IsWhiteSpace((char)c));
                    });
                    source.SkipWhiteSpace();
                }

                string comm = sb.ToString();
                sb.Clear();

                // Process ID
                int pid = source.ReadInt();
                source.MoveNext(); // Move past the "/"

                // Thread ID
                int tid = source.ReadInt();

                // CPU
                source.SkipWhiteSpace();
                source.MoveNext(); // Move past the "["
                int cpu = source.ReadInt();
                source.MoveNext(); // Move past the "]"

                // Time
                source.SkipWhiteSpace();
                source.ReadAsciiStringUpTo(':', sb);

                double time = double.Parse(sb.ToString()) * 1000; // To convert to MSec
                sb.Clear();
                source.MoveNext();                                // Move past ":"

                // Time Property
                source.SkipWhiteSpace();
                int timeProp = -1;
                if (this.IsNumberChar((char)source.Current))
                {
                    timeProp = source.ReadInt();
                }

                // Event Name
                source.SkipWhiteSpace();
                source.ReadAsciiStringUpTo(':', sb);
                string eventName = sb.ToString();
                sb.Clear();
                source.MoveNext();

                // Event Properties
                // I mark a position here because I need to check what type of event this is without screwing up the stream
                var markedPosition = source.MarkPosition();
                source.ReadAsciiStringUpTo('\n', sb);
                string eventDetails = sb.ToString().Trim();
                sb.Clear();

                if (eventDetails.Length >= SchedulerEvent.Name.Length && eventDetails.Substring(0, SchedulerEvent.Name.Length) == SchedulerEvent.Name)
                {
                    eventKind = EventKind.Scheduler;
                }

                // Now that we know the header of the trace, we can decide whether or not to skip it given our pattern
                if (regex != null && !regex.IsMatch(eventName))
                {
                    while (true)
                    {
                        source.MoveNext();
                        if (this.IsEndOfSample(source, source.Current, source.Peek(1)))
                        {
                            break;
                        }
                    }

                    yield return(null);
                }
                else
                {
                    LinuxEvent linuxEvent;

                    Frame threadTimeFrame = null;

                    // For the sake of immutability, I have to do a similar if-statement twice. I'm trying to figure out a better way
                    //   but for now this will do.
                    ScheduleSwitch schedSwitch = null;
                    if (eventKind == EventKind.Scheduler)
                    {
                        source.RestoreToMark(markedPosition);
                        schedSwitch = this.ReadScheduleSwitch(source);
                        source.SkipUpTo('\n');
                    }

                    IEnumerable <Frame> frames = this.ReadFramesForSample(comm, pid, tid, threadTimeFrame, source);

                    if (eventKind == EventKind.Scheduler)
                    {
                        linuxEvent = new SchedulerEvent(comm, tid, pid, time, timeProp, cpu, eventName, eventDetails, frames, schedSwitch);
                    }
                    else
                    {
                        linuxEvent = new CpuEvent(comm, tid, pid, time, timeProp, cpu, eventName, eventDetails, frames);
                    }

                    yield return(linuxEvent);
                }
            }
        }
 public LocationEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable <EventRequestModifier> modifiers, Location location)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
     _location = location;
 }
示例#41
0
        private IEnumerable <LinuxEvent> NextEvent(Regex regex, FastStream source)
        {
            string line = string.Empty;

            while (true)
            {
                source.SkipWhiteSpace();

                if (source.EndOfStream)
                {
                    break;
                }

                EventKind eventKind = EventKind.Cpu;

                StringBuilder sb = new StringBuilder();

                // Fetch Command (processName) - Stops when it sees the pattern \s+\d+/\d
                int idx = FindEndOfProcessCommand(source);
                if (idx < 0)
                {
                    break;
                }

                source.ReadFixedString(idx, sb);
                source.SkipWhiteSpace();
                string processCommand = sb.ToString();
                sb.Clear();

                // Process ID
                int pid = source.ReadInt();
                source.MoveNext(); // Move past the "/"

                // Thread ID
                int tid = source.ReadInt();

                // CPU
                source.SkipWhiteSpace();
                int cpu = -1;
                if (source.Peek(0) == '[')
                {
                    source.MoveNext(); // Move past the "["
                    cpu = source.ReadInt();
                    source.MoveNext(); // Move past the "]"
                }

                // Time
                source.SkipWhiteSpace();
                source.ReadAsciiStringUpTo(':', sb);

                double time = double.Parse(sb.ToString(), CultureInfo.InvariantCulture) * 1000; // To convert to MSec
                sb.Clear();
                source.MoveNext();                                                              // Move past ":"

                // Time Property
                source.SkipWhiteSpace();
                int timeProp = -1;
                if (IsNumberChar((char)source.Current))
                {
                    timeProp = source.ReadInt();
                }

                // Event Name
                source.SkipWhiteSpace();
                source.ReadAsciiStringUpTo(':', sb);
                string eventName = sb.ToString();
                sb.Clear();
                source.MoveNext();

                // Event Properties
                // I mark a position here because I need to check what type of event this is without screwing up the stream
                var markedPosition = source.MarkPosition();
                source.ReadAsciiStringUpTo('\n', sb);
                string eventDetails = sb.ToString().Trim();
                sb.Clear();

                if (eventDetails.Length >= SchedulerEvent.Name.Length && eventDetails.Substring(0, SchedulerEvent.Name.Length) == SchedulerEvent.Name)
                {
                    eventKind = EventKind.Scheduler;
                }

                // Now that we know the header of the trace, we can decide whether or not to skip it given our pattern
                if (regex != null && !regex.IsMatch(eventName))
                {
                    while (true)
                    {
                        source.MoveNext();
                        if (IsEndOfSample(source, source.Current, source.Peek(1)))
                        {
                            break;
                        }
                    }

                    yield return(null);
                }
                else
                {
                    LinuxEvent linuxEvent;

                    Frame threadTimeFrame = null;

                    // For the sake of immutability, I have to do a similar if-statement twice. I'm trying to figure out a better way
                    //   but for now this will do.
                    ScheduleSwitch schedSwitch = null;
                    if (eventKind == EventKind.Scheduler)
                    {
                        source.RestoreToMark(markedPosition);
                        schedSwitch = ReadScheduleSwitch(source);
                        source.SkipUpTo('\n');
                    }

                    IEnumerable <Frame> frames = ReadFramesForSample(processCommand, pid, tid, threadTimeFrame, source);

                    if (eventKind == EventKind.Scheduler)
                    {
                        linuxEvent = new SchedulerEvent(processCommand, tid, pid, time, timeProp, cpu, eventName, eventDetails, frames, schedSwitch);
                    }
                    else
                    {
                        linuxEvent = new CpuEvent(processCommand, tid, pid, time, timeProp, cpu, eventName, eventDetails, frames);
                    }

                    yield return(linuxEvent);
                }
            }
        }
            public StepEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable <EventRequestModifier> modifiers, ThreadId thread, JvmtiEnvironment environment, JniEnvironment nativeEnvironment, StepSize size, StepDepth depth)
                : base(internalEventKind, requestId, suspendPolicy, modifiers, thread)
            {
                if (size == StepSize.Statement && JavaVM.DisableStatementStepping)
                {
                    size = StepSize.Line;
                }

                _size  = size;
                _depth = depth;

                // gather reference information for the thread
                using (var threadHandle = environment.VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, thread))
                {
                    if (threadHandle.IsAlive)
                    {
                        jvmtiError error = environment.GetFrameLocation(threadHandle.Value, 0, out _lastMethod, out _lastLocation);
                        if (error == jvmtiError.None)
                        {
                            error = environment.GetFrameCount(threadHandle.Value, out _stackDepth);
                        }

                        if (error == jvmtiError.None)
                        {
                            _hasMethodInfo = true;
                        }

                        UpdateLastLine(environment);

                        if (error == jvmtiError.None && size == StepSize.Statement && (depth == StepDepth.Over || depth == StepDepth.Into))
                        {
                            byte[] bytecode;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetBytecodes(_lastMethod, out bytecode));
                            _disassembledMethod = BytecodeDisassembler.Disassemble(bytecode);

                            TaggedReferenceTypeId declaringClass;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodDeclaringClass(nativeEnvironment, _lastMethod, out declaringClass));
                            using (var classHandle = environment.VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, declaringClass.TypeId))
                            {
                                int    constantPoolCount;
                                byte[] data;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetConstantPool(classHandle.Value, out constantPoolCount, out data));

                                List <ConstantPoolEntry> entryList = new List <ConstantPoolEntry>();
                                int currentPosition = 0;
                                for (int i = 0; i < constantPoolCount - 1; i++)
                                {
                                    entryList.Add(ConstantPoolEntry.FromBytes(data, ref currentPosition));
                                    switch (entryList.Last().Type)
                                    {
                                    case ConstantType.Double:
                                    case ConstantType.Long:
                                        // these entries take 2 slots
                                        entryList.Add(ConstantPoolEntry.Reserved);
                                        i++;
                                        break;

                                    default:
                                        break;
                                    }
                                }

                                _constantPool = entryList.AsReadOnly();

                                string classSignature;
                                string classGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassSignature(classHandle.Value, out classSignature, out classGenericSignature));
                                string methodName;
                                string methodSignature;
                                string methodGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodName(_lastMethod, out methodName, out methodSignature, out methodGenericSignature));

                                jobject classLoader;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassLoader(classHandle.Value, out classLoader));
                                long classLoaderTag;
                                JvmtiErrorHandler.ThrowOnFailure(environment.TagClassLoader(classLoader, out classLoaderTag));

                                ReadOnlyCollection <ExceptionTableEntry> exceptionTable;
                                JvmtiErrorHandler.ThrowOnFailure(environment.VirtualMachine.GetExceptionTable(classLoaderTag, classSignature, methodName, methodSignature, out exceptionTable));

                                _evaluationStackDepths = BytecodeDisassembler.GetEvaluationStackDepths(_disassembledMethod, _constantPool, exceptionTable);
                            }
                        }
                    }
                }
            }
 public void addEvent(EventKind pEK)
 {
     events.Add(pEK);
 }
示例#44
0
        public void Notify(EventKind kind, Address address, byte[] bytes)
        {
            var evt = new Event(kind, address, bytes);

            _events.Add(evt);
        }
        public async Task LargeInstanceEventsTest(EventKind kind, string kindName)
        {
            BuildXL.Utilities.Analysis.IgnoreArgument(kindName, "Kind name is only specified so enum value name shows up in test name");
            if (kind == EventKind.Blob)
            {
                // Blob events don't have a large equivalent since they just have a storage id
                return;
            }

            var context = new OperationContext(new Context(Logger));
            var harness = new LargeEventTestHarness();
            var sender  = harness.Sender;

            var configuration  = new MemoryContentLocationEventStoreConfiguration();
            var memoryEventHub = new MemoryEventHubClient(configuration);
            var eventStore     = new EventHubContentLocationEventStore(configuration,
                                                                       harness,
                                                                       "TestMachine",
                                                                       harness,
                                                                       TestRootDirectoryPath / "eventwork",
                                                                       SystemClock.Instance);

            await eventStore.StartupAsync(context).ThrowIfFailure();

            eventStore.StartProcessing(context, new EventSequencePoint(DateTime.UtcNow)).ThrowIfFailure();

            var serializer = CreateContentLocationEventDataSerializer();

            await sendAndVerifyLargeEvent(kind);

            using var stream = new MemoryStream();
            using var writer = BuildXL.Utilities.BuildXLWriter.Create(stream);

            serializer.SerializeEvents(writer, harness.Events);

            stream.Position.Should().BeGreaterThan(ContentLocationEventDataSerializer.MaxEventDataPayloadSize,
                                                   "Event should be larger than max event payload size to properly test serialization logic");

            bool canSplit = kind == EventKind.AddLocation ||
                            kind == EventKind.AddLocationWithoutTouching ||
                            kind == EventKind.RemoveLocation ||
                            kind == EventKind.RemoveLocation ||
                            kind == EventKind.Touch;

            foreach (var eventData in harness.Events)
            {
                eventData.SerializationKind.Should().Be(kind);
            }

            configuration.Hub.EventStream.Count.Should().BeGreaterThan(0);
            foreach (var rawEvent in configuration.Hub.EventStream)
            {
                rawEvent.Body.Count.Should().BeLessOrEqualTo(ContentLocationEventDataSerializer.MaxEventDataPayloadSize);
            }

            if (canSplit)
            {
                // Events should be split
                harness.Events.Count.Should().BeGreaterThan(1);
                configuration.Hub.EventStream.Count.Should().BeGreaterThan(1);

                // No uploads/downloads should happen for splittable events
                harness.State.DownloadedCount.Should().Be(0);
                harness.State.UploadedCount.Should().Be(0);
                harness.State.UploadedSize.Should().Be(0);
                harness.State.DownloadedSize.Should().Be(0);
            }
            else
            {
                harness.Events.Count.Should().Be(1);
                configuration.Hub.EventStream.Count.Should().Be(1);

                harness.State.DownloadedCount.Should().Be(1);
                harness.State.UploadedCount.Should().Be(1);
                harness.State.UploadedSize.Should().BeGreaterOrEqualTo(stream.Position);
                harness.State.UploadedSize.Should().Be(harness.State.DownloadedSize);
            }

            async Task sendAndVerifyLargeEvent(EventKind kind)
            {
                const int largeEventContentCount = 50000;

                switch (kind)
                {
                case EventKind.AddLocation:
                case EventKind.AddLocationWithoutTouching:
                {
                    var sent = Enumerable.Range(0, largeEventContentCount).Select(_ => new ContentHashWithSize(ContentHash.Random(), ThreadSafeRandom.Generator.Next(0, 100000))).ToList();

                    eventStore.AddLocations(
                        context,
                        sender,
                        sent,
                        touch: kind == EventKind.AddLocation).ThrowIfFailure();

                    var received = harness.Events.Cast <AddContentLocationEventData>().SelectMany(e => e.ContentHashes.SelectList((hash, index) => (hash, size: e.ContentSizes[index]))).ToList();

                    received.Count.Should().Be(sent.Count);

                    for (int i = 0; i < received.Count; i++)
                    {
                        received[i].hash.Should().Be(new ShortHash(sent[i].Hash));
                        received[i].size.Should().Be(sent[i].Size);
                    }

                    return;
                }

                case EventKind.RemoveLocation:
                {
                    var sent = Enumerable.Range(0, largeEventContentCount).Select(_ => ContentHash.Random()).ToList();

                    eventStore.RemoveLocations(
                        context,
                        sender,
                        sent).ThrowIfFailure();

                    var received = harness.Events.Cast <RemoveContentLocationEventData>().SelectMany(e => e.ContentHashes).ToList();

                    received.Count.Should().Be(sent.Count);

                    for (int i = 0; i < received.Count; i++)
                    {
                        received[i].Should().Be(new ShortHash(sent[i]));
                    }

                    return;
                }

                case EventKind.Touch:
                {
                    var sent = Enumerable.Range(0, largeEventContentCount).Select(_ => ContentHash.Random()).ToList();

                    eventStore.Touch(
                        context,
                        sender,
                        sent,
                        DateTime.UtcNow).ThrowIfFailure();

                    var received = harness.Events.Cast <TouchContentLocationEventData>().SelectMany(e => e.ContentHashes).ToList();

                    received.Count.Should().Be(sent.Count);

                    for (int i = 0; i < received.Count; i++)
                    {
                        received[i].Should().Be(new ShortHash(sent[i]));
                    }

                    return;
                }

                case EventKind.UpdateMetadataEntry:
                {
                    var contentHashes = Enumerable.Range(0, largeEventContentCount).Select(_ => ContentHash.Random()).ToArray();
                    var sent          = new UpdateMetadataEntryEventData(
                        sender,
                        StrongFingerprint.Random(),
                        new MetadataEntry(
                            new ContentHashListWithDeterminism(
                                new ContentHashList(contentHashes),
                                CacheDeterminism.None),
                            DateTime.UtcNow));

                    await eventStore.UpdateMetadataEntryAsync(context, sent).ShouldBeSuccess();

                    var received = harness.Events.Cast <UpdateMetadataEntryEventData>().SelectMany(e => e.Entry.ContentHashListWithDeterminism.ContentHashList.Hashes).ToList();

                    received.Count.Should().Be(contentHashes.Length);

                    for (int i = 0; i < received.Count; i++)
                    {
                        received[i].Should().Be(contentHashes[i]);
                    }

                    return;
                }

                default:
                    throw Contract.AssertFailure($"No large event for kind {kind}. Add large event to ensure this case is tested");
                }
            }
        }
 public Event(EventKind eventKind)
 {
     hidden         = true;
     this.eventKind = eventKind;
     initializeUI();
 }
            public Error SetEvent(JvmtiEnvironment environment, JniEnvironment nativeEnvironment, EventKind eventKind, SuspendPolicy suspendPolicy, ImmutableList<EventRequestModifier> modifiers, bool internalRequest, out RequestId requestId)
            {
                Contract.Requires<ArgumentNullException>(modifiers != null, "modifiers");

                requestId = default(RequestId);

                EventKind internalEventKind = eventKind;

                EventRequestModifier locationModifier = default(EventRequestModifier);
                EventRequestModifier stepModifier = default(EventRequestModifier);

                switch (eventKind)
                {
                case EventKind.Breakpoint:
                    // we're going to need the location modifier to set the breakpoint
                    if (modifiers.Count == 0 || modifiers[0].Kind != ModifierKind.LocationFilter)
                        return Error.IllegalArgument;

                    locationModifier = modifiers[0];
                    break;

                case EventKind.SingleStep:
                    // the first modifier contains the step properties
                    if (modifiers.Count == 0 || modifiers[0].Kind != ModifierKind.Step)
                        return Error.IllegalArgument;

                    stepModifier = modifiers[0];
                    if (stepModifier.StepDepth == StepDepth.Out)
                    {
                        // we want to attach the filter as a frame pop request instead of a step request
                        eventKind = EventKind.FramePop;
                        internalEventKind = EventKind.SingleStep;
                    }

                    break;

                default:
                    break;
                }

                requestId = new RequestId(Interlocked.Increment(ref _nextRequestId));
                if (internalRequest)
                    requestId = new RequestId(-requestId.Id);

                EventFilter filter = EventFilter.CreateFilter(internalEventKind, environment, nativeEnvironment, requestId, suspendPolicy, modifiers);
                return SetEventInternal(environment, nativeEnvironment, eventKind, filter);
            }
            private EventFilter[] GetEventFilters(EventKind eventKind)
            {
                lock (_eventRequests)
                {
                    Dictionary<RequestId, EventFilter> requests;
                    if (!_eventRequests.TryGetValue(eventKind, out requests))
                        return new EventFilter[0];

                    return requests.Values.ToArray();
                }
            }
            public Error ClearEvent(EventKind eventKind, RequestId requestId)
            {
                if (eventKind == EventKind.SingleStep)
                {
                    // this event might also be registered as a frame pop event with the same request ID
                    Error error = ClearEventInternal(EventKind.FramePop, requestId);
                    if (error != Error.None)
                        return error;
                }

                return ClearEventInternal(eventKind, requestId);
            }
示例#50
0
        private static void AttachEvent(DependencyObject owner, EventKind kind)
        {
            var sender = owner as UIElement;
            if (sender == null)
            {
                return;
            }

            switch (kind)
            {
                case EventKind.Tapped:
                    sender.AddHandler(UIElement.TappedEvent, (TappedEventHandler) ExecuteCommand, true);
                    break;

                case EventKind.TextChanged:
                    var text = sender as TextBox;
                    if (text != null)
                    {
                        text.TextChanged += TextChanged;
                    }
                    break;

                case EventKind.SelectionChanged:

                    var control = sender as Selector;
                    if (control != null)
                    {
                        control.SelectionChanged += ControlSelectionChanged;
                    }

                    break;

                default:
                    throw new NotSupportedException("Unsupported event");
            }
        }
            private static JvmEventType? GetJvmEventType(EventKind eventKind)
            {
                switch (eventKind)
                {
                case EventKind.Breakpoint:
                    return JvmEventType.Breakpoint;

                case EventKind.SingleStep:
                    return JvmEventType.SingleStep;

                case EventKind.ThreadStart:
                    return JvmEventType.ThreadStart;

                case EventKind.ThreadEnd:
                    return JvmEventType.ThreadEnd;

                case EventKind.ClassLoad:
                    return JvmEventType.ClassLoad;

                case EventKind.ClassPrepare:
                    return JvmEventType.ClassPrepare;

                case EventKind.ClassUnload:
                    throw new NotSupportedException();

                case EventKind.Exception:
                    return JvmEventType.Exception;

                case EventKind.ExceptionCatch:
                    return JvmEventType.ExceptionCatch;

                case EventKind.FieldAccess:
                    return JvmEventType.FieldAccess;

                case EventKind.FieldModification:
                    return JvmEventType.FieldModification;

                case EventKind.FramePop:
                    return JvmEventType.FramePop;

                case EventKind.MethodEntry:
                    return JvmEventType.MethodEntry;

                case EventKind.MethodExit:
                    return JvmEventType.MethodExit;

                default:
                    return null;
                }
            }
示例#52
0
 public EventPair(EventKind kind, object subject)
 {
     Kind = kind;
     Subject = subject;
 }
示例#53
0
 /// <summary>
 ///     Sets the value of the Event attached property
 ///     for a given dependency object.
 /// </summary>
 /// <param name="obj">
 ///     The object to which the property value
 ///     is written.
 /// </param>
 /// <param name="value">Sets the Event value of the specified object.</param>
 public static void SetEvent(DependencyObject obj, EventKind value)
 {
     obj.SetValue(EventProperty, value);
 }
示例#54
0
 /// <summary>
 /// Sets a type of event.
 /// </summary>
 /// <param name="kind">Type of event.</param>
 protected void SetKind(EventKind kind)
 {
     _kind = kind;
 }
示例#55
0
        public static void Write(EventKind eventKind, string message, params object[] args)
        {
            try
            {
                //Check Whether the Loggiing is Enabled in the Configurations
                int loggingLevel = 4;
                try
                {
                    string loggingLevelValue = RoleEnvironment.GetConfigurationSettingValue("LoggingLevel");
                    if (!string.IsNullOrEmpty(loggingLevelValue))
                        int.TryParse(loggingLevelValue, out loggingLevel);
                }
                catch
                {

                }

                switch (eventKind)
                {
                    case EventKind.Error:
                        if (loggingLevel >= 0)
                        {
                            Trace.TraceError(message, args);
                            LogInEventLog(EventLogEntryType.Error, message, args);
                        }
                        break;
                    case EventKind.Critical:
                        if (loggingLevel >= 1)
                        {
                            Trace.TraceError(message, args);
                            LogInEventLog(EventLogEntryType.Error, message, args);
                        }
                        break;
                    case EventKind.Warning:
                        if (loggingLevel >= 2)
                        {
                            Trace.TraceWarning(message, args);
                            LogInEventLog(EventLogEntryType.Warning, message, args);
                        }
                        break;
                    case EventKind.Information:
                        if (loggingLevel >= 3)
                        {
                            Trace.TraceInformation(message, args);
                            LogInEventLog(EventLogEntryType.Information, message, args);
                        }
                        break;
                    case EventKind.Verbose:
                        if (loggingLevel == 4)
                        {
                            Trace.TraceInformation(message, args);
                            LogInEventLog(EventLogEntryType.Information, message, args);
                        }
                        break;
                }
            }
            catch
            {
                LogInEventLog(EventLogEntryType.Error, "Failed to log message");
                LogInEventLog(EventLogEntryType.Error, message, args);
            }
        }
示例#56
0
 public Event(EventKind kind, Id <LsifDocument> data, IdFactory idFactory)
     : this(kind, "document", data.As <LsifDocument, Element>(), idFactory)
 {
 }
        public static void Notify <T>(this IRuntime runtime, EventKind kind, Address address, T content)
        {
            var bytes = content == null ? new byte[0] : Serialization.Serialize(content);

            runtime.Notify(kind, address, bytes);
        }
示例#58
0
 public void eventCard(Player p, EventKind ek)
 {
     displayRecord(p.getRoleKind().ToString() + " played Event Card: " + ek.ToString());
 }
示例#59
0
 public Event(EventKind kind, Id <LsifProject> data, IdFactory idFactory)
     : this(kind, "project", data.As <LsifProject, Element>(), idFactory)
 {
 }
 public void removeEvent(EventKind pEK)
 {
     events.Remove(pEK);
 }