示例#1
0
        public override Form CreateForm(object value)
        {
            string scriptName = (string)value;

            script       = null;
            wasGenerated = false;

            // Open the script this property is referencing.
            if (scriptName.Length > 0)
            {
                script = EditorControl.World.GetScript(scriptName);
            }

            // If it is null, create a new hidden script.
            if (script == null)
            {
                script       = EditorControl.GenerateInternalScript();
                wasGenerated = true;

                if (PropertyGrid.PropertyObject is IEventObject)
                {
                    ObjectEvent e = ((IEventObject)PropertyGrid.PropertyObject).Events.GetEvent(property.Name);
                    if (e != null)
                    {
                        script.Parameters = e.Parameters;
                    }
                }
            }

            // Open the scrpit editor form.
            ScriptEditor form = new ScriptEditor(script, EditorControl);

            return(form);
        }
示例#2
0
        public override void SetOwner(GameObject owner)
        {
            Owner = owner;
            var ownerPoint = new Point((int)owner.TopLeft.X, (int)owner.TopLeft.Y);

            _currentEvent = _boundaryRectangle.Contains(ownerPoint) ? _onEnterBoundary : _onExitBoundary;
        }
示例#3
0
 public void RegisterListener(EventListenerSO listener, ObjectEvent callback)
 {
     if (!IsRegistered(listener))
     {
         listenersCallbacks.Add(new ListenerEventPair(listener, callback));
     }
 }
示例#4
0
        public override void Awake()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif

            base.Awake();

            Activators = new List <HedgehogController>();

            OnActivate     = OnActivate ?? new ObjectEvent();
            OnActivateStay = OnActivateStay ?? new ObjectEvent();
            OnDeactivate   = OnDeactivate ?? new ObjectEvent();

            OnActivatorEnter = OnActivatorEnter ?? new ObjectEvent();
            OnActivatorStay  = OnActivatorStay ?? new ObjectEvent();
            OnActivatorExit  = OnActivatorExit ?? new ObjectEvent();

            Activated = false;

            Animator = Animator ?? GetComponentInChildren <Animator>();
            if (Animator == null)
            {
                return;
            }

            ActivatedTriggerHash = string.IsNullOrEmpty(ActivatedTrigger) ? 0 : Animator.StringToHash(ActivatedTrigger);
            ActivatedBoolHash    = string.IsNullOrEmpty(ActivatedBool) ? 0 : Animator.StringToHash(ActivatedBool);
        }
示例#5
0
        internal Delegate GetEventLoggerDelegate(ObjectEvent objectEvent)
        {
            EventInfo eventInfo = objectEvent._eventInfo;
            Type      handlerType;
            Type      delegateType = eventInfo.EventHandlerType;

            objectEvent.SetEventParams();

            lock (this)
            {
                handlerType = (Type)_loggerTypeHash[eventInfo.EventHandlerType];
                if (handlerType == null)
                {
                    handlerType = CreateEventHandlerDelegate(eventInfo, objectEvent._eventParams,
                                                             objectEvent._eventReturnType);
                    _loggerTypeHash.Add(eventInfo.EventHandlerType, handlerType);
                }
            }

            // Create the setup the logger object
            EventLogger logger = (EventLogger)Activator.CreateInstance(handlerType);

            AddLoggerInstance(objectEvent, logger);
            logger._eventLog    = this;
            logger._objectEvent = objectEvent;

            Delegate d = Delegate.CreateDelegate(delegateType, logger, "Logger");

            TraceUtil.WriteLineInfo(this, "Found delegate: " + delegateType);
            return(d);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            switch (reader.TokenType)
            {
            case JsonToken.StartObject:
                existingValue = existingValue ?? serializer.ContractResolver.ResolveContract(objectType).DefaultCreator();
                serializer.Populate(reader, existingValue);
                switch (existingValue)
                {
                case ObjectMeta om:
                    var nom = new ObjectMeta
                    {
                        Objects = om.Objects,
                        Meta    = om.Meta.Select(mt => ((JObject)mt).ToObject(GetOJtype(om.Objects.Type))).ToArray(),
                        Ticks   = om.Ticks
                    };
                    return(nom);

                case ObjectStateUpdate osu:
                    var nosu = new ObjectStateUpdate
                    {
                        Objects = osu.Objects,
                        States  = osu.States.Select(mt => ((JObject)mt).ToObject(GetOJtype(osu.Objects.Type)))
                                  .ToArray()
                    };
                    return(nosu);

                case ObjectData oda:
                {
                    var noda = new ObjectData
                    {
                        Objects = oda.Objects,
                        Data    = oda.Data.Select(mt => ((JObject)mt).ToObject(GetOJtype(oda.Objects.Type)))
                                  .ToArray(),
                        Ticks = oda.Ticks
                    };
                    return(noda);
                }

                case ObjectEvent oev:
                {
                    var noda = new ObjectEvent
                    {
                        Objects = oev.Objects,
                        Events  = oev.Events.Select(mt => ((JObject)mt).ToObject(GetOJtype(oev.Objects.Type)))
                                  .ToArray(),
                        Ticks = oev.Ticks
                    };
                    return(noda);
                }
                }
                return(null);

            case JsonToken.Null:
                return(null);

            default:
                throw new JsonSerializationException();
            }
        }
        public void Given_NoRequiredProperties_When_Serialised_Should_ThrowException()
        {
            var ev = new ObjectEvent <FakeData>();

            Action action = () => JsonConvert.SerializeObject(ev);

            action.Should().Throw <JsonSerializationException>();

            ev.EventType = null;
            ev.Source    = (new Uri("http://localhost")).ToString();
            ev.EventId   = Guid.NewGuid().ToString();
            action       = () => JsonConvert.SerializeObject(ev);
            action.Should().Throw <JsonSerializationException>();

            ev.EventType = "com.example.someevent";
            ev.Source    = null;
            ev.EventId   = Guid.NewGuid().ToString();
            action       = () => JsonConvert.SerializeObject(ev);
            action.Should().Throw <JsonSerializationException>();

            ev.EventType = "com.example.someevent";
            ev.Source    = (new Uri("http://localhost")).ToString();
            ev.EventId   = null;
            action       = () => JsonConvert.SerializeObject(ev);
            action.Should().Throw <JsonSerializationException>();
        }
示例#8
0
 public override bool Equals(Object other)
 {
     if (other is ObjectEvent)
     {
         ObjectEvent otherOe = (ObjectEvent)other;
         bool        eq      = false;
         if (_object != null && otherOe._object != null)
         {
             eq = otherOe._object.Equals(_object);
         }
         if (eq)
         {
             if (_eventInfo != null &&
                 otherOe._eventInfo != null)
             {
                 eq = ReflectionHelper.
                      IsMemberEqual(otherOe._eventInfo,
                                    _eventInfo);
             }
             // If they are both null, then this is equal
         }
         return(eq);
     }
     return(false);
 }
        /// <summary>
        /// Creates a new instance of the <see cref="CloudEvent{T}"/> class.
        /// </summary>
        /// <typeparam name="T">Type of data.</typeparam>
        /// <param name="contentType">Content type.</param>
        /// <param name="data">Event data.</param>
        /// <param name="cloudEventsVersion"><see cref="CloudEventsVersion"/> value.</param>
        /// <returns>Returns the <see cref="CloudEvent{T}"/> instance created.</returns>
        public static CloudEvent <T> Create <T>(string contentType, T data, string cloudEventsVersion = CloudEventsVersion.Version01)
        {
            if (IsJson(contentType))
            {
                var objectEventised = new ObjectEvent <T>(cloudEventsVersion)
                {
                    ContentType = contentType, Data = data
                };

                return(objectEventised);
            }

            if (ContentTypeValidator.IsText(contentType))
            {
                var stringified     = data as string;
                var stringEventised = new StringEvent(cloudEventsVersion)
                {
                    ContentType = contentType, Data = stringified
                };

                return(stringEventised as CloudEvent <T>);
            }

            var binarified      = data as byte[];
            var binaryEventised = new BinaryEvent(cloudEventsVersion)
            {
                ContentType = contentType, Data = binarified
            };

            return(binaryEventised as CloudEvent <T>);
        }
        public IActionResult SendPlaydate(ViewModelSendInvite invite)
        {
            var userId     = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var petOwnerId = _repo.PetOwner.GetPetOwnerById(userId).Id;

            ObjectCalendar objectCalendar = _repo.ObjectCalendar.GetCalenderByIdentityUser(userId);

            ObjectEvent eventCreated = new ObjectEvent();

            eventCreated.Title            = invite.Title;
            eventCreated.Date             = invite.Date;
            eventCreated.Details          = invite.Details;
            eventCreated.StartTime        = invite.StartTime;
            eventCreated.Location         = invite.Location;
            eventCreated.EndTime          = invite.EndTime;
            eventCreated.ObjectCalendarId = objectCalendar.Id;
            _repo.ObjectEvent.CreateEvent(eventCreated);
            _repo.Save();

            ObjectEvent  objectEvent = _repo.ObjectEvent.GetEventByAllProperties(invite.Title, invite.Location, invite.Details, invite.Date, invite.StartTime, invite.EndTime, objectCalendar.Id);
            ObjectInvite invitation  = new ObjectInvite();

            invitation.isInvitationAccepted = null;
            invitation.ObjectEventId        = eventCreated.Id;
            invitation.OwnerInvitedId       = invite.OwnerInvitedId;
            invitation.OwnerSendingId       = petOwnerId;
            invitation.ObjectEventId        = objectEvent.Id;
            invitation.OwnerSendingName     = invite.OwnerSendingName;
            invitation.ObjectEventName      = invite.Title;
            _repo.ObjectInvite.CreateInvite(invitation);
            _repo.Save();

            return(RedirectToAction("SearchPetProfiles"));
        }
示例#11
0
 internal EventLogger GetLoggerInstance(ObjectEvent oe)
 {
     lock (this)
     {
         return((EventLogger)_loggerInstanceHash[oe]);
     }
 }
示例#12
0
        public void Given_ValidContentType_When_DataIsSet_Should_BeOk()
        {
            var data = new FakeData()
            {
                FakeProperty = "hello world"
            };

            var ev = new ObjectEvent <FakeData>();

            ev.ContentType = "text/json";
            ev.Data        = data;
            ev.Data.Should().Be(data);

            ev.ContentType = "application/json";
            ev.Data        = data;
            ev.Data.Should().Be(data);

            ev.ContentType = "application/json-seq";
            ev.Data        = data;
            ev.Data.Should().Be(data);

            ev.ContentType = "application/cloudevents+json";
            ev.Data        = data;
            ev.Data.Should().Be(data);

            ev.ContentType = "application/geo+json-seq";
            ev.Data        = data;
            ev.Data.Should().Be(data);
        }
示例#13
0
        // Note: We can't store the node anywhere because it is subject
        // to change if it gets invalidated, so we can only use the
        // node for the life of this method
        internal void ToggleLogging(IEventLoggingNode node,
                                    bool start)
        {
            ObjectEvent oe = new ObjectEvent(node.LogEventObject,
                                             node.LogEventInfo);

            ToggleLogging(oe, node.LogObjectName, start);
        }
 /// <summary>
 /// Raises an event if goes outside the game (scaled) boundaries
 /// </summary>
 public OutOfBoundsComponent(ObjectEvent publishEvent, int leftPadding = 0, int topPadding = 0, int rightPadding = 0, int bottomPadding = 0)
 {
     _publishEvent  = publishEvent;
     _leftPadding   = leftPadding;
     _topPadding    = topPadding;
     _rightPadding  = rightPadding;
     _bottomPadding = bottomPadding;
 }
示例#15
0
 public CounterComponent(ObjectEvent decreaseEvent, ObjectEvent increseEvent, int minValue, int maxValue)
 {
     _decreaseEvent = decreaseEvent;
     _increseEvent  = increseEvent;
     _minValue      = minValue;
     _maxValue      = maxValue;
     CurrentValue   = minValue;
 }
示例#16
0
        public void Given_Version_Should_HaveVersion()
        {
            var version = "v1";

            var ev = new ObjectEvent <FakeData>(version);

            ev.CloudEventsVersion.Should().Be(version);
        }
示例#17
0
    public static void Send(string eventName, object[] param)
    {
        ObjectEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(param);
        }
    }
示例#18
0
    public static void TriggerEvent(string eventName, object obj)
    {
        ObjectEvent thisEvent = null;

        if (instance.objectEventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(obj);
        }
    }
示例#19
0
        public static void TriggerEvent(string eventName, object data = null, GameObject trigger = null) //adds a new event in the dictionary
        {
            ObjectEvent thisEvent = null;

            if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.Invoke(data, trigger);
            }
        }
示例#20
0
 public SpriteRepeaterComponent(Texture2D texture, Vector2 relativeLocation, bool isVertical, ObjectEvent subscribeEvent, CounterIncrementComponent counterIncrementComponent, bool isReverse = false, Color?color = null)
 {
     Texture                    = texture;
     _relativeLocation          = relativeLocation;
     _currentValue              = counterIncrementComponent.CurrentValue;
     _isVertical                = isVertical;
     _subscribeEvent            = subscribeEvent;
     _counterIncrementComponent = counterIncrementComponent;
     _isReverse                 = isReverse;
     _color = color ?? Color.White;
 }
 // TODO: Determine descending by if start > 0
 public CounterIncrementComponent(ObjectEvent subscribeEvent, ObjectEvent publishEvent, ObjectEvent lastEvent, ObjectEvent resetEvent, int startValue, int lastValue, bool isDescending = true)
 {
     _subscribeEvent = subscribeEvent;
     _publishEvent   = publishEvent;
     _lastEvent      = lastEvent;
     _resetEvent     = resetEvent;
     _startValue     = startValue;
     _lastValue      = lastValue;
     CurrentValue    = startValue;
     _isDescending   = isDescending;
 }
示例#22
0
        internal bool IsLogging(Object obj,
                                EventInfo eventInfo)
        {
            ObjectEvent oe = new ObjectEvent(obj, eventInfo);

            if (GetLoggerInstance(oe) != null)
            {
                return(true);
            }
            return(false);
        }
示例#23
0
    private void ObjectEvent_PointOfInterestEvent(ObjectEvent oEvent)
    {
        string key = "you hit: " + oEvent.getEventName;

        if (PlayerPrefs.GetInt(key) == 1)
        {
            return;
        }
        PlayerPrefs.SetInt(key, 1);
        Debug.Log(key);
    }
示例#24
0
        private async Task <IActionResult> PublishEvent(Guid id, ObjectEvent.EventType type)
        {
            var ev = new ObjectEvent
            {
                Id   = id,
                Name = "ObjectEvent",
                Type = type
            };
            await _dapr.PublishEventAsync <ObjectEvent>("dapr-eh", "CallBService", ev);

            return(Ok());
        }
示例#25
0
 internal void RemoveLoggerInstance(ObjectEvent oe)
 {
     lock (this)
     {
         _loggerInstanceHash.Remove(oe);
         ObjectEventCountHolder h = (ObjectEventCountHolder)_loggerObjectHash[oe._object];
         h._count--;
         if (h._count == 0)
         {
             _loggerObjectHash.Remove(oe._object);
         }
     }
 }
示例#26
0
        public void Given_RequiredProperties_When_Serialised_Should_BeOk()
        {
            var ev = new ObjectEvent <FakeData>();

            ev.EventType = "com.example.someevent";
            ev.Source    = (new Uri("http://localhost")).ToString();
            ev.EventId   = Guid.NewGuid().ToString();

            var    serialised = string.Empty;
            Action action     = () => serialised = JsonConvert.SerializeObject(ev);

            action.Should().NotThrow <Exception>();
        }
示例#27
0
    public static void StopListening(string eventName, UnityAction <object> listener)
    {
        if (eventManager == null)
        {
            return;
        }
        ObjectEvent thisEvent = null;

        if (instance.objectEventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
        public IActionResult CreateEvent()
        {
            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var petOwner      = _repo.PetBusiness.GetPetBusinessById(userId).Id;
            var ownerCalendar = _repo.ObjectCalendar.GetCalenderByIdentityUser(userId).Id;

            ObjectEvent newEvent = new ObjectEvent();

            newEvent.ObjectCalendarId = ownerCalendar;

            return(View(newEvent));
        }
示例#29
0
        public SpriteGenericComponent(Texture2D[] textures, Vector2 relativeLocation, ObjectEvent subscribeEvent, CounterIncrementComponent counterIncrementComponent, Func <int, int, IEnumerable <Vector2> > drawMethod)
        {
            Textures = textures;

            Width  = Textures.Max(t => t.Width);
            Height = Textures.Max(t => t.Height);

            _relativeLocation          = relativeLocation;
            _currentValue              = counterIncrementComponent.CurrentValue;
            _subscribeEvent            = subscribeEvent;
            _counterIncrementComponent = counterIncrementComponent;
            _drawMethod = drawMethod;
            _locations  = drawMethod.Invoke(_currentValue, 0).ToList();
        }
        public IActionResult DeleteEvent(ObjectEvent objectEvent)
        {
            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var petOwner      = _repo.PetBusiness.GetPetBusinessById(userId).Id;
            var ownerCalendar = _repo.ObjectCalendar.GetCalenderByIdentityUser(userId).Id;

            ObjectEvent deletingEvent = _repo.ObjectEvent.FindByCondition(e => e.Id == objectEvent.Id).FirstOrDefault();

            _repo.ObjectEvent.Delete(deletingEvent);
            _repo.Save();

            return(RedirectToAction("DisplayCalendar"));
        }
示例#31
0
		// Change the state of the logger with respect to event
		// logging
		internal void ToggleLogging(ObjectEvent oe,
									String name,
									bool start)
		{
			TraceUtil.WriteLineInfo(this, "Event " + oe + " ToggleLogging start: " + start);

			if (start)
			{
				if (IsLogging(oe._object, oe._eventInfo))
					return;

				// Make a separate object for each event to keep the event
				// name
				Delegate d = GetEventLoggerDelegate(oe);
				try
				{
					oe._eventInfo.AddEventHandler(oe._object, d);
				}
				catch (Exception ex)
				{
					TraceUtil.WriteLineWarning(this, "Exception while enabling logging: " + name + " " + ex);

					Console.WriteLine("Inner: " + ex.InnerException);

					Exception showException = ex;
					// Remove the useless wrapper exception
					if (showException is TargetInvocationException) {
						showException = ex.InnerException;
					}

					String moreText = "";
					if (showException is InvalidCastException)
					{
						moreText = "  If this is an Excel event, this "
							+ "exception is likely related to "
							+ "Microsoft problem Q316653 ("
							+ "http://support.microsoft.com/default.aspx?"
							+ "scid=kb;en-us;Q316653)"
							+ ".  "
							+ "To use events in Excel, please modify "
							+ "the assembly " + 
							oe._object.GetType().Assembly.GetName().Name
							+ " (in the converted assemblies directory) "
							+ "according to the instructions for that "
							+ "problem.  Once you have modified the assembly "
							+ "and restarted the Inspector, event "
							+ "tracing will work.";
					}

					// Undo the GetEventLoggerDelegate
					RemoveLoggerInstance(oe);
					throw new Exception("Error enabling logging for " + oe
										+ moreText,
										showException);
				}


				ListViewItem li = new ListViewItem(name);
				li.Tag = oe;
				_eventsBeingLogged.Items.Add(li);
				if (_eventsBeingLogged.Items.Count == 1)
				{
					_eventsBeingLoggedTabPage.Controls.Clear();
					_eventsBeingLoggedTabPage.Controls.Add(_eventsBeingLogged);
				}
				li.SubItems.Add(oe._eventInfo.Name);
			}
			else
			{
				if (!IsLogging(oe._object, oe._eventInfo))
					return;

				for (int i = 0; i < _eventsBeingLogged.Items.Count; i++)
				{
					ListViewItem li = 
						(ListViewItem)_eventsBeingLogged.Items[i];
					if (li.Tag.Equals(oe))
					{
						_eventsBeingLogged.Items.Remove(li);
						break;
					}
				}

				if (_eventsBeingLogged.Items.Count == 0)
				{
					_eventsBeingLoggedTabPage.Controls.Clear();
					_eventsBeingLoggedTabPage.Controls.Add(_eblText);
				}

				EventLogger logger = GetLoggerInstance(oe);
				Delegate d = Delegate.CreateDelegate(oe._eventInfo.EventHandlerType, logger, "Logger");
				oe._eventInfo.RemoveEventHandler(oe._object, d);
				RemoveLoggerInstance(oe);
			}
		}
示例#32
0
		internal bool IsLogging(Object obj,
								EventInfo eventInfo)
		{
			ObjectEvent oe = new ObjectEvent(obj, eventInfo);
			if (GetLoggerInstance(oe) != null)
			{
				return true;
			}
			return false;
		}
示例#33
0
		internal EventLogger GetLoggerInstance(ObjectEvent oe)
		{
			lock (this)
			{
				return (EventLogger)_loggerInstanceHash[oe];
			}
		}
 public void addLeftOnObjectEventReceiver(ObjectEvent pReceiver)
 {
     leftOnObjectEvent += pReceiver;
 }
 public void addRightOnObjectEventReceiver(ObjectEvent pReceiver)
 {
     rightOnObjectEvent += pReceiver;
 }
示例#36
0
		// Note: We can't store the node anywhere because it is subject
		// to change if it gets invalidated, so we can only use the
		// node for the life of this method
		internal void ToggleLogging(IEventLoggingNode node,
									bool start)
		{
			ObjectEvent oe = new ObjectEvent(node.LogEventObject,
											 node.LogEventInfo);
			ToggleLogging(oe, node.LogObjectName, start);
		}
示例#37
0
		internal Delegate GetEventLoggerDelegate(ObjectEvent objectEvent)
		{
			EventInfo eventInfo = objectEvent._eventInfo;
			Type handlerType;
			Type delegateType = eventInfo.EventHandlerType;

			objectEvent.SetEventParams();

			lock (this)
			{
				handlerType = (Type)_loggerTypeHash[eventInfo.EventHandlerType];
				if (handlerType == null)
				{
					handlerType = CreateEventHandlerDelegate(eventInfo, objectEvent._eventParams,
						 objectEvent._eventReturnType);
					_loggerTypeHash.Add(eventInfo.EventHandlerType, handlerType);
				}
			}

			// Create the setup the logger object
			EventLogger logger = (EventLogger)Activator.CreateInstance(handlerType);
			AddLoggerInstance(objectEvent, logger);
			logger._eventLog = this;
			logger._objectEvent = objectEvent;

			Delegate d = Delegate.CreateDelegate(delegateType, logger, "Logger");
			TraceUtil.WriteLineInfo(this, "Found delegate: " + delegateType);
			return d;
		}
示例#38
0
		internal void AddLoggerInstance(ObjectEvent oe, EventLogger logger)								
		{
			lock (this)
			{
				_loggerInstanceHash.Add(oe, logger);
				ObjectEventCountHolder h = (ObjectEventCountHolder)_loggerObjectHash[oe._object];
				if (h == null)
				{
					h = new ObjectEventCountHolder();
					_loggerObjectHash.Add(oe._object, h);
				}
				h._count++;
			}
		}
示例#39
0
		internal void RemoveLoggerInstance(ObjectEvent oe)
		{
			lock (this)
			{
				_loggerInstanceHash.Remove(oe);
				ObjectEventCountHolder h = (ObjectEventCountHolder)_loggerObjectHash[oe._object];
				h._count--;
				if (h._count == 0) {
					_loggerObjectHash.Remove(oe._object);
				}
			}
		}