Exemplo n.º 1
0
        public async Task OpenAsync(string correlationId)
        {
            var components = _references.GetAll();

            Referencer.SetReferences(this, components);
            await Opener.OpenAsync(correlationId, components);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutReferencer(int id, Referencer referencer)
        {
            if (id != referencer.IdTag)
            {
                return(BadRequest());
            }

            _context.Entry(referencer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ReferencerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        /// <summary>
        /// Puts a new reference into this reference map.
        /// </summary>
        /// <param name="locator">a locator to find the reference by.</param>
        /// <param name="component">a component reference to be added.</param>
        public override void Put(object locator, object component)
        {
            base.Put(locator, component);

            if (_opened)
            {
                Referencer.SetReferencesForOne(ParentReferences, component);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// close all references as an asynchronous operation.
        /// </summary>
        /// <param name="correlationId">a unique transaction id to trace calls across components</param>
        /// <returns>Task.</returns>
        public async Task CloseAsync(string correlationId)
        {
            var components = _references.GetAll();
            await Closer.CloseAsync(correlationId, components);

            Referencer.UnsetReferences(components);

            _references.Clear();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Checks whether the provided entity is stored in the corresponding data store.
        /// </summary>
        /// <param name="entity">The entity to look for in the corresponding data store.</param>
        /// <returns>A boolean value indicating whether the entity was found.</returns>
        public override bool IsStored(IEntity entity)
        {
            bool isStored = false;

            using (LogGroup logGroup = LogGroup.StartDebug("Checking whether the provided entity has already been stored."))
            {
                if (entity == null)
                {
                    throw new ArgumentNullException("entity");
                }

                LogWriter.Debug("Entity type: " + entity.GetType());

                if (EntitiesUtilities.IsReference(entity.GetType()))
                {
                    LogWriter.Debug("Is reference == true");

                    EntityReference reference = (EntityReference)entity;

                    Type type  = EntityState.GetType(reference.Type1Name);
                    Type type2 = EntityState.GetType(reference.Type2Name);

                    LogWriter.Debug("Type 1: " + type.ToString());
                    LogWriter.Debug("Type 2: " + type2.ToString());

                    if (Stores[entity].IsStored(entity))
                    {
                        LogWriter.Debug("Reference object found in store.");

                        isStored = true;
                    }
                    else
                    {
                        LogWriter.Debug("Reference object NOT found. Checking for one with matching properties.");

                        isStored = Referencer.MatchReference(
                            type,
                            reference.Entity1ID,
                            reference.Property1Name,
                            type2,
                            reference.Entity2ID,
                            reference.Property2Name);
                    }
                }
                else
                {
                    LogWriter.Debug("Is reference != true");

                    isStored = Stores[entity].IsStored(entity);
                }
            }

            LogWriter.Debug("Is stored: " + isStored.ToString());

            return(isStored);
        }
        /// <summary>
        /// Removes a previously added reference that matches specified locator. If many
        /// references match the locator, it removes only the first one.When all
        /// references shall be removed, use removeAll() method instead.
        /// </summary>
        /// <param name="locator">a locator to remove reference</param>
        /// <returns>the removed component reference.</returns>
        public override object Remove(object locator)
        {
            var component = base.Remove(locator);

            if (_opened)
            {
                Referencer.UnsetReferencesForOne(component);
            }

            return(component);
        }
        /// <summary>
        /// Closes component and frees used resources.
        /// </summary>
        /// <param name="correlationId">(optional) transaction id to trace execution through call chain.</param>
        public async Task CloseAsync(string correlationId)
        {
            if (_opened)
            {
                _opened = false;
                var components = base.GetAll();
                Referencer.UnsetReferences(components);
            }

            await Task.Delay(0);
        }
        /// <summary>
        /// true if the component has been opened and false otherwise.
        /// </summary>
        /// <param name="correlationId">(optional) transaction id to trace execution through call chain.</param>
        public async Task OpenAsync(string correlationId)
        {
            if (!_opened)
            {
                _opened = true;
                var components = base.GetAll();
                Referencer.SetReferences(this.ParentReferences, components);
            }

            await Task.Delay(0);
        }
        /// <summary>
        /// Removes all component references that match the specified locator.
        /// </summary>
        /// <param name="locator">the locator to remove references by.</param>
        /// <returns>a list, containing all removed references.</returns>
        public override List <object> RemoveAll(object locator)
        {
            var components = base.RemoveAll(locator);

            if (_opened)
            {
                Referencer.UnsetReferences(components);
            }

            return(components);
        }
Exemplo n.º 10
0
 private void Start()
 {
     foreach (Transform child in weaponHolder.swordHolder)
     {
         child.gameObject.SetActive(true);
         if (child.tag == ConstantHandler.WEAPON_TAG)
         {
             Referencer referencer = child.GetComponent <Referencer>();
             referencer.gameObject.SetActive(false);
         }
     }
 }
Exemplo n.º 11
0
    // This script is don't destroy on load (handled by gamestate via gameobject)

    // Pre-initialization
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
            RegisterPlayer();
            RegisterScene();
            RegisterHUDUI();
        }
        else if (instance != this)
        {
            Debug.LogError("Uh oh! Someone tried to create multiple instances of the master referencer!");
        }
    }
Exemplo n.º 12
0
// Start is called before the first frame update

    void loadReferences()
    {
        Referencer referencer = GameObject.FindGameObjectWithTag("Referencer").GetComponent <Referencer>();

        currencyCounter = referencer.currencyCounter;
        velocityText    = referencer.velocityText;
        posText         = referencer.positionText;
        crossHair       = referencer.CrossHair;
        progressText    = referencer.progressText;

        countDownText               = referencer.countDown;
        leaderBoardMenu             = referencer.leaderBoardMenu;
        leaderBoardListingTransform = referencer.leaderBoardListingTransform;
        messagePanel   = referencer.messagePanel;
        boostTimer     = referencer.boostTimer;
        upsideDownText = referencer.upsideDownText;
    }
Exemplo n.º 13
0
        private void Update()
        {
            if (PlayerUI.singleton.isPanel || PlayerUI.singleton.isCutscene)
            {
                return;
            }

            if (currentWeapon == null)
            {
                return;
            }

            foreach (Transform child in weaponHolder.swordHolder)
            {
                if (child.tag == ConstantHandler.WEAPON_TAG)
                {
                    if (child.name.ToUpper() == currentWeapon.name.ToUpper())
                    {
                        child.gameObject.SetActive(true);
                        currentWeaponRef = child.GetComponent <Referencer>();
                    }
                    else
                    {
                        child.gameObject.SetActive(false);
                    }
                }
            }

            if (Input.GetKey(KeyHandler.BlockKey) && !isAttacking)
            {
                Block();
            }
            else
            {
                Unblock();
            }
            if (Input.GetKeyDown(KeyHandler.AttackKey) && !isAttacking && !isBlocking)
            {
                if (currentWeapon.weaponType == WeaponType.Sword)
                {
                    StartCoroutine(StartSwordAttack());
                }
            }
        }
        private async Task RunAsync(string correlationId, CancellationToken token)
        {
            _correlationId = correlationId;

            CaptureErrors();

            //await StartAsync(correlationId, token);

            if (_config == null)
            {
                throw new InvalidStateException(correlationId, "NO_CONFIG", "Container was not configured");
            }

            try
            {
                _logger.Trace(correlationId, "Starting container.");

                // Create references with configured components
                InitReferences(_references);
                _references.PutFromConfig(_config);

                // Reference and open components
                var components = _references.GetAll();
                Referencer.SetReferences(_references, components);
                await Opener.OpenAsync(correlationId, _references.GetAll());

                // Get reference to logger
                _logger = new CompositeLogger(_references);

                // Get reference to container info
                var infoDescriptor = new Descriptor("*", "container-info", "*", "*", "*");
                _info = (ContextInfo)_references.GetOneRequired(infoDescriptor);

                _logger.Info(correlationId, "Container {0} started.", _info.Name);
            }
            catch (Exception ex)
            {
                _references = null;
                _logger.Error(correlationId, ex, "Failed to start container");

                throw;
            }
        }
Exemplo n.º 15
0
        public async Task <ActionResult <Referencer> > PostReferencer(Referencer referencer)
        {
            _context.Referencer.Add(referencer);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ReferencerExists(referencer.IdTag))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetReferencer", new { id = referencer.IdTag }, referencer));
        }
        public async Task StartAsync(string correlationId, CancellationToken token)
        {
            if (Config == null)
            {
                throw new InvalidStateException(correlationId, "NO_CONFIG", "Container was not configured");
            }

            try
            {
                Logger.Trace(correlationId, "Starting container.");

                // Create references with configured components
                InitReferences(References);
                References.PutFromConfig(Config);

                // Reference and open components
                var components = References.GetAll();
                Referencer.SetReferences(References, components);
                await Opener.OpenAsync(correlationId, References.GetAll());

                // Get reference to logger
                Logger = new CompositeLogger(References);

                // Get reference to container info
                var infoDescriptor = new Descriptor("*", "container-info", "*", "*", "*");
                Info = (ContainerInfo)References.GetOneRequired(infoDescriptor);

                Logger.Info(correlationId, "Container {0} started.", Info.Name);
            }
            catch (Exception ex)
            {
                References = null;
                Logger.Error(correlationId, ex, "Failed to start container");

                throw;
            }
        }