Exemplo n.º 1
0
        public EventHandlerSource(RuntimeEvent @event, object owner)
        {
            this.@event = @event;
            this.owner  = owner;

            eventHandler = @event.CreateDelegate(this, HandleOwnerEventMethodInfo);
        }
Exemplo n.º 2
0
        public EventCommandTrigger(RuntimeEvent @event, object owner)
        {
            _event = @event;
            Owner  = owner;

            _eventHandler = @event.CreateDelegate(this, HandleOwnerEventMethodInfo);
        }
Exemplo n.º 3
0
 void OnGreedyEvent(RuntimeEvent greedy_events)
 {
     Debug.Log(String.Format("OnGreedyEvent - {0}", greedy_events));
     if (greedy_events == RuntimeEvent.CAMPAIGN_LOADED ||
         greedy_events == RuntimeEvent.CAMPAIGN_NOT_LOADED)
     {
         //Application.LoadLevel (1);
     }
 }
Exemplo n.º 4
0
 protected override void OnRaiseRuntimeEvent(RuntimeEvent runtimeEvent)
 {
     lock (_eventsLock)
     {
         foreach (var eventHandler in _eventHandlers)
         {
             runtimeEvent.HandleEvent(eventHandler);
         }
     }
 }
Exemplo n.º 5
0
        private bool HasOffRuntimePolicy(RuntimeEvent policyName)
        {
            var policy = DetermineAndStoreAccumulatedRuntimePolicy(policyName);

            if (policy.HasFlag(RuntimePolicy.Off))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
        private bool HasOffRuntimePolicy(RuntimeEvent policyName)
        {
            var policy = GetRuntimePolicy(policyName);

            if (policy.HasFlag(RuntimePolicy.Off))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 7
0
        private void ExecuteTabs(RuntimeEvent runtimeEvent)
        {
            var runtimeContext = Configuration.FrameworkProvider.RuntimeContext;
            var frameworkProviderRuntimeContextType = runtimeContext.GetType();
            var messageBroker = Configuration.MessageBroker;

            // Only use tabs that either don't specify a specific context type, or have a context type that matches the current framework provider's.
            var runtimeTabs =
                Configuration.Tabs.Where(
                    tab =>
                    tab.RequestContextType == null ||
                    frameworkProviderRuntimeContextType.IsSubclassOf(tab.RequestContextType) ||
                    tab.RequestContextType == frameworkProviderRuntimeContextType);

            var supportedRuntimeTabs = runtimeTabs.Where(p => p.ExecuteOn.HasFlag(runtimeEvent));
            var tabResultsStore      = TabResultsStore;
            var logger = Configuration.Logger;

            foreach (var tab in supportedRuntimeTabs)
            {
                TabResult result;
                var       key = CreateKey(tab);
                try
                {
                    var tabContext = new TabContext(runtimeContext, GetTabStore(key), logger, messageBroker);
                    var tabData    = tab.GetData(tabContext);

                    var tabSection = tabData as TabSection;
                    if (tabSection != null)
                    {
                        tabData = tabSection.Build();
                    }

                    result = new TabResult(tab.Name, tabData);
                }
                catch (Exception exception)
                {
                    result = new TabResult(tab.Name, exception.ToString());
                    logger.Error(Resources.ExecuteTabError, exception, key);
                }

                if (tabResultsStore.ContainsKey(key))
                {
                    tabResultsStore[key] = result;
                }
                else
                {
                    tabResultsStore.Add(key, result);
                }
            }
        }
Exemplo n.º 8
0
        public static void TriggerEvent(int id, RuntimeData runnignData)
        {
            if (id == 0)
            {
                return;
            }
            var          skill = GetEvent(id);
            RuntimeEvent re    = new RuntimeEvent();

            re.Init(skill, runnignData);
            re.FinishAction = OnFinish;
            runtimeEvents.Add(re);
            DLog.Log("trigger event " + id);
        }
Exemplo n.º 9
0
        private RuntimePolicy GetRuntimePolicy(RuntimeEvent runtimeEvent)
        {
            var frameworkProvider = Configuration.FrameworkProvider;
            var requestStore      = frameworkProvider.HttpRequestStore;

            // Begin with the lowest policy for this request, or the lowest policy per config
            var finalResult = requestStore.Contains(Constants.RuntimePolicyKey)
                             ? requestStore.Get <RuntimePolicy>(Constants.RuntimePolicyKey)
                             : Configuration.DefaultRuntimePolicy;

            if (!finalResult.HasFlag(RuntimePolicy.Off))
            {
                var logger = Configuration.Logger;

                // only run policies for this runtimeEvent, or all runtime events
                var policies =
                    Configuration.RuntimePolicies.Where(
                        policy => policy.ExecuteOn.HasFlag(runtimeEvent));

                var policyContext = new RuntimePolicyContext(frameworkProvider.RequestMetadata, Configuration.Logger, frameworkProvider.RuntimeContext);
                foreach (var policy in policies)
                {
                    var policyResult = RuntimePolicy.Off;
                    try
                    {
                        policyResult = policy.Execute(policyContext);

                        if (policyResult != RuntimePolicy.On)
                        {
                            logger.Debug("RuntimePolicy set to '{0}' by IRuntimePolicy of type '{1}' during RuntimeEvent '{2}'.", policyResult, policy.GetType(), runtimeEvent);
                        }
                    }
                    catch (Exception exception)
                    {
                        logger.Warn("Exception when executing IRuntimePolicy of type '{0}'. RuntimePolicy is now set to 'Off'.", exception, policy.GetType());
                    }

                    // Only use the lowest policy allowed for the request
                    if (policyResult < finalResult)
                    {
                        finalResult = policyResult;
                    }
                }
            }

            // store result for request
            requestStore.Set(Constants.RuntimePolicyKey, finalResult);
            return(finalResult);
        }
Exemplo n.º 10
0
        private RuntimePolicy DetermineRuntimePolicy(RuntimeEvent runtimeEvent, RuntimePolicy maximumAllowedPolicy)
        {
            if (maximumAllowedPolicy == RuntimePolicy.Off)
            {
                return(maximumAllowedPolicy);
            }

            var frameworkProvider = Configuration.FrameworkProvider;
            var logger            = Configuration.Logger;

            // only run policies for this runtimeEvent
            var policies =
                Configuration.RuntimePolicies.Where(
                    policy => policy.ExecuteOn.HasFlag(runtimeEvent));

            var policyContext = new RuntimePolicyContext(frameworkProvider.RequestMetadata, Configuration.Logger, frameworkProvider.RuntimeContext);

            foreach (var policy in policies)
            {
                var policyResult = RuntimePolicy.Off;
                try
                {
                    policyResult = policy.Execute(policyContext);

                    if (policyResult != RuntimePolicy.On)
                    {
                        logger.Debug("RuntimePolicy set to '{0}' by IRuntimePolicy of type '{1}' during RuntimeEvent '{2}'.", policyResult, policy.GetType(), runtimeEvent);
                    }
                }
                catch (Exception exception)
                {
                    logger.Warn("Exception when executing IRuntimePolicy of type '{0}'. RuntimePolicy is now set to 'Off'.", exception, policy.GetType());
                }

                // Only use the lowest policy allowed for the request
                if (policyResult < maximumAllowedPolicy)
                {
                    maximumAllowedPolicy = policyResult;
                }

                // If the policy indicates Glimpse is Off, then we stop processing any other runtime policy
                if (maximumAllowedPolicy == RuntimePolicy.Off)
                {
                    break;
                }
            }

            return(maximumAllowedPolicy);
        }
Exemplo n.º 11
0
    private void EventManager_OnSubEventOccuring(RuntimeEvent ge, RuntimeSubEvent se)
    {
        if (!ge.eventRef.useSubEventMessages)
        {
            return;
        }
        int    index;
        string message;

        Debug.Log(se.eventRef.label + " Starting");

        index   = Random.Range(0, se.eventRef.startingMessage.Length);
        message = se.eventRef.startingMessage[index];
        MessageBox.DisplayMessage(se.eventRef.label, message);
    }
Exemplo n.º 12
0
        private RuntimePolicy DetermineAndStoreAccumulatedRuntimePolicy(RuntimeEvent runtimeEvent)
        {
            var frameworkProvider = Configuration.FrameworkProvider;
            var requestStore      = frameworkProvider.HttpRequestStore;

            // First determine the maximum allowed policy to start from. This is or the current stored runtime policy for this
            // request, or if none can be found, the default runtime policy set in the configuration
            var maximumAllowedPolicy = requestStore.Contains(Constants.RuntimePolicyKey)
                                     ? requestStore.Get <RuntimePolicy>(Constants.RuntimePolicyKey)
                                     : Configuration.DefaultRuntimePolicy;

            maximumAllowedPolicy = DetermineRuntimePolicy(runtimeEvent, maximumAllowedPolicy);

            // store result for request
            requestStore.Set(Constants.RuntimePolicyKey, maximumAllowedPolicy);
            return(maximumAllowedPolicy);
        }
Exemplo n.º 13
0
    private void EventManager_OnEventOccuring(RuntimeEvent ge)
    {
        if (ge.eventRef.useSubEventMessages)
        {
            return;
        }
        int    index;
        string message;

        Debug.Log(ge.eventRef.name + " Starting");

        if (ge.ID < onEventStarts.Count)
        {
            onEventStarts[ge.ID].Invoke();
        }

        index   = Random.Range(0, ge.eventRef.startingMessage.Length);
        message = ge.eventRef.startingMessage[index];
        MessageBox.DisplayMessage(ge.eventRef.name, message);
    }
Exemplo n.º 14
0
 private bool HasOffRuntimePolicy(RuntimeEvent policyName)
 {
     var policy = GetRuntimePolicy(policyName);
     if (policy.HasFlag(RuntimePolicy.Off))
     {
         return true;
     }
     return false;
 }
Exemplo n.º 15
0
        private RuntimePolicy GetRuntimePolicy(RuntimeEvent runtimeEvent)
        {
            var frameworkProvider = Configuration.FrameworkProvider;
            var requestStore = frameworkProvider.HttpRequestStore;

            // Begin with the lowest policy for this request, or the lowest policy per config
            var finalResult = requestStore.Contains(Constants.RuntimePolicyKey)
                             ? requestStore.Get<RuntimePolicy>(Constants.RuntimePolicyKey)
                             : Configuration.DefaultRuntimePolicy;

            if (!finalResult.HasFlag(RuntimePolicy.Off))
            {
                var logger = Configuration.Logger;

                // only run policies for this runtimeEvent, or all runtime events
                var policies =
                    Configuration.RuntimePolicies.Where(
                        policy => policy.ExecuteOn.HasFlag(runtimeEvent));

                var policyContext = new RuntimePolicyContext(frameworkProvider.RequestMetadata, Configuration.Logger, frameworkProvider.RuntimeContext);
                foreach (var policy in policies)
                {
                    var policyResult = RuntimePolicy.Off;
                    try
                    {
                        policyResult = policy.Execute(policyContext);

                        if (policyResult != RuntimePolicy.On)
                        {
                            logger.Debug("RuntimePolicy set to '{0}' by IRuntimePolicy of type '{1}' during RuntimeEvent '{2}'.", policyResult, policy.GetType(), runtimeEvent);
                        }
                    }
                    catch (Exception exception)
                    {
                        logger.Warn("Exception when executing IRuntimePolicy of type '{0}'. RuntimePolicy is now set to 'Off'.", exception, policy.GetType());
                    }

                    // Only use the lowest policy allowed for the request
                    if (policyResult < finalResult)
                    {
                        finalResult = policyResult;
                    }
                }
            }

            // store result for request
            requestStore.Set(Constants.RuntimePolicyKey, finalResult);
            return finalResult;
        }
Exemplo n.º 16
0
 private void RaiseRuntimeEvent(RuntimeEvent runtimeEvent)
 {
     runtimeEvent.Context = RuntimeContext;
     RuntimeContext.RaiseRuntimeEvent(runtimeEvent);
 }
Exemplo n.º 17
0
 protected abstract void OnRaiseRuntimeEvent(RuntimeEvent runtimeEvent);
Exemplo n.º 18
0
 public EventHandlerBindingStrategy(RuntimeEvent @event) : base(@event)
 {
 }
Exemplo n.º 19
0
 protected EventHandlerBindingStrategyBase(RuntimeEvent @event)
 {
     Assert.Argument(@event, nameof(@event)).NotNull();
     _event = @event;
 }
Exemplo n.º 20
0
 public void RaiseRuntimeEvent(RuntimeEvent runtimeEvent)
 => OnRaiseRuntimeEvent(runtimeEvent);
Exemplo n.º 21
0
        private void ExecuteTabs(RuntimeEvent runtimeEvent)
        {
            var runtimeContext = Configuration.FrameworkProvider.RuntimeContext;
            var frameworkProviderRuntimeContextType = runtimeContext.GetType();
            var messageBroker = Configuration.MessageBroker;

            // Only use tabs that either don't specify a specific context type, or have a context type that matches the current framework provider's.
            var runtimeTabs =
                Configuration.Tabs.Where(
                    tab =>
                    tab.RequestContextType == null ||
                    frameworkProviderRuntimeContextType.IsSubclassOf(tab.RequestContextType) ||
                    tab.RequestContextType == frameworkProviderRuntimeContextType);

            var supportedRuntimeTabs = runtimeTabs.Where(p => p.ExecuteOn.HasFlag(runtimeEvent));
            var tabResultsStore = TabResultsStore;
            var logger = Configuration.Logger;

            foreach (var tab in supportedRuntimeTabs)
            {
                TabResult result;
                var key = CreateKey(tab);
                try
                {
                    var tabContext = new TabContext(runtimeContext, GetTabStore(key), logger, messageBroker);
                    var tabData = tab.GetData(tabContext);

                    var tabSection = tabData as TabSection;
                    if (tabSection != null)
                    {
                        tabData = tabSection.Build();
                    }

                    result = new TabResult(tab.Name, tabData);
                }
                catch (Exception exception)
                {
                    result = new TabResult(tab.Name, exception.ToString());
                    logger.Error(Resources.ExecuteTabError, exception, key);
                }

                if (tabResultsStore.ContainsKey(key))
                {
                    tabResultsStore[key] = result;
                }
                else
                {
                    tabResultsStore.Add(key, result);
                }
            }
        }
Exemplo n.º 22
0
 public static void RemoveEvent(RuntimeEvent re)
 {
     runtimeEvents.Remove(re);
 }
Exemplo n.º 23
0
        public EventListSource(RuntimeEvent @event)
        {
            this.@event = @event;

            eventHandler = @event.CreateDelegate(this, HandleOwnerEventMethodInfo);
        }
Exemplo n.º 24
0
        private RuntimePolicy DetermineAndStoreAccumulatedRuntimePolicy(RuntimeEvent runtimeEvent)
        {
            var frameworkProvider = Configuration.FrameworkProvider;
            var requestStore = frameworkProvider.HttpRequestStore;

            // First determine the maximum allowed policy to start from. This is or the current stored runtime policy for this
            // request, or if none can be found, the default runtime policy set in the configuration
            var maximumAllowedPolicy = requestStore.Contains(Constants.RuntimePolicyKey)
                                     ? requestStore.Get<RuntimePolicy>(Constants.RuntimePolicyKey)
                                     : Configuration.DefaultRuntimePolicy;

            maximumAllowedPolicy = DetermineRuntimePolicy(runtimeEvent, maximumAllowedPolicy);

            // store result for request
            requestStore.Set(Constants.RuntimePolicyKey, maximumAllowedPolicy);
            return maximumAllowedPolicy;
        }
Exemplo n.º 25
0
 public EventHandlerBindingStrategyBase(RuntimeEvent @event)
 {
     Assert.Argument(@event, "event").NotNull();
     this.@event = @event;
 }
Exemplo n.º 26
0
        private RuntimePolicy DetermineRuntimePolicy(RuntimeEvent runtimeEvent, RuntimePolicy maximumAllowedPolicy)
        {
            if (maximumAllowedPolicy == RuntimePolicy.Off)
            {
                return maximumAllowedPolicy;
            }

            var frameworkProvider = Configuration.FrameworkProvider;
            var logger = Configuration.Logger;

            // only run policies for this runtimeEvent
            var policies =
                Configuration.RuntimePolicies.Where(
                    policy => policy.ExecuteOn.HasFlag(runtimeEvent));

            var policyContext = new RuntimePolicyContext(frameworkProvider.RequestMetadata, Configuration.Logger, frameworkProvider.RuntimeContext);
            foreach (var policy in policies)
            {
                var policyResult = RuntimePolicy.Off;
                try
                {
                    policyResult = policy.Execute(policyContext);

                    if (policyResult != RuntimePolicy.On)
                    {
                        logger.Debug("RuntimePolicy set to '{0}' by IRuntimePolicy of type '{1}' during RuntimeEvent '{2}'.", policyResult, policy.GetType(), runtimeEvent);
                    }
                }
                catch (Exception exception)
                {
                    logger.Warn("Exception when executing IRuntimePolicy of type '{0}'. RuntimePolicy is now set to 'Off'.", exception, policy.GetType());
                }

                // Only use the lowest policy allowed for the request
                if (policyResult < maximumAllowedPolicy)
                {
                    maximumAllowedPolicy = policyResult;
                }

                // If the policy indicates Glimpse is Off, then we stop processing any other runtime policy
                if (maximumAllowedPolicy == RuntimePolicy.Off)
                {
                    break;
                }
            }

            return maximumAllowedPolicy;
        }
Exemplo n.º 27
0
 public EventListCommandTrigger(RuntimeEvent @event)
 {
     _event        = @event;
     _eventHandler = @event.CreateDelegate(this, HandleOwnerEventMethodInfo);
 }
Exemplo n.º 28
0
 private bool HasOffRuntimePolicy(RuntimeEvent policyName)
 {
     var policy = DetermineAndStoreAccumulatedRuntimePolicy(policyName);
     if (policy.HasFlag(RuntimePolicy.Off))
     {
         return true;
     }
     return false;
 }
Exemplo n.º 29
0
 private bool HasOffRuntimePolicy(RuntimeEvent policyName)
 {
     var policy = DetermineAndStoreAccumulatedRuntimePolicy(policyName);
     return policy.HasFlag(RuntimePolicy.Off);
 }