Beispiel #1
0
        /// <summary>
        /// Start this service
        /// </summary>
        /// <param name="taskScheduler"></param>
        /// <param name="cancellationToken"></param>
        /// <returns>Task</returns>
        public async Task Startup(TaskScheduler taskScheduler, CancellationToken cancellationToken = default)
        {
            var prerequisiteTasks = Prerequisites.Select(node => node._startupTaskCompletionSource.Task).ToArray();

            if (prerequisiteTasks.Length == 1)
            {
                await prerequisiteTasks[0].ConfigureAwait(false);
            }
            else if (prerequisiteTasks.Length > 1)
            {
                await Task.WhenAll(prerequisiteTasks).ConfigureAwait(false);
            }

            switch (Service)
            {
            case IStartupAsync startupAsync:
                await Run(startupAsync.StartupAsync, taskScheduler, _startupTaskCompletionSource, cancellationToken).ConfigureAwait(false);

                break;

            case IStartup startup:
                await Run(startup.Startup, taskScheduler, _startupTaskCompletionSource, cancellationToken).ConfigureAwait(false);

                break;
            }
        }
 private void AddPrerequisiteAssumptions(IOrganizationService service)
 {
     foreach (var assumption in Prerequisites.Select(prereq => (EntityDataAssumptionBaseAttribute)Activator.CreateInstance(prereq))
              .Where(a => !_assumedEntities.Contains(a)))
     {
         assumption.AddAssumedEntitiesWithPreReqInfiniteLoopPrevention(service, _assumedEntities, _currentlyProcessingPreReqs);
     }
 }
 internal override GeneMemento GetMemento()
 {
     return(new GeneMemento(
                nameof(DropColumnGene),
                new Dictionary <string, string>
     {
     },
                Sha256Hash,
                new Dictionary <string, IEnumerable <BigInteger> >
     {
         ["Prerequisites"] = Prerequisites.Select(x => x.Sha256Hash),
         ["Parent"] = new[] { _parent.Sha256Hash }
     }));
 }
 internal override MigrationMemento GetMemento()
 {
     return(new MigrationMemento(
                nameof(UseSchemaMigration),
                new Dictionary <string, string>
     {
         [nameof(DatabaseName)] = DatabaseName,
         [nameof(SchemaName)] = SchemaName
     },
                Sha256Hash,
                new Dictionary <string, IEnumerable <BigInteger> >
     {
         ["Prerequisites"] = Prerequisites.Select(x => x.Sha256Hash)
     }));
 }
Beispiel #5
0
 internal override MigrationMemento GetMemento()
 {
     return(new MigrationMemento(
                nameof(CreatePrimaryKeyMigration),
                new Dictionary <string, string>
     {
     },
                Sha256Hash,
                new Dictionary <string, IEnumerable <BigInteger> >
     {
         ["Prerequisites"] = Prerequisites.Select(x => x.Sha256Hash),
         ["Parent"] = new[] { _parent.Sha256Hash },
         ["Columns"] = _columns.Select(c => c.Sha256Hash).ToArray()
     }));
 }
Beispiel #6
0
 internal override MigrationMemento GetMemento()
 {
     return(new MigrationMemento(
                nameof(CreateTableMigration),
                new Dictionary <string, string>
     {
         [nameof(TableName)] = TableName
     },
                Sha256Hash,
                new Dictionary <string, IEnumerable <BigInteger> >
     {
         ["Prerequisites"] = Prerequisites.Select(x => x.Sha256Hash),
         ["Parent"] = new[] { _parent.Sha256Hash }
     }));
 }
 internal override GeneMemento GetMemento()
 {
     return(new GeneMemento(
                nameof(CustomSqlGene),
                new Dictionary <string, string>
     {
         [nameof(DatabaseName)] = DatabaseName,
         [nameof(Up)] = Up,
         [nameof(Down)] = Down
     },
                Sha256Hash,
                new Dictionary <string, IEnumerable <BigInteger> >
     {
         ["Prerequisites"] = Prerequisites.Select(x => x.Sha256Hash)
     }));
 }
 internal override MigrationMemento GetMemento()
 {
     return(new MigrationMemento(
                nameof(CreateColumnMigration),
                new Dictionary <string, string>
     {
         [nameof(ColumnName)] = ColumnName,
         [nameof(TypeDescriptor)] = TypeDescriptor,
         [nameof(Nullable)] = Nullable ? "true" : "false"
     },
                Sha256Hash,
                new Dictionary <string, IEnumerable <BigInteger> >
     {
         ["Prerequisites"] = Prerequisites.Select(x => x.Sha256Hash),
         ["Parent"] = new[] { _parent.Sha256Hash }
     }));
 }
Beispiel #9
0
 internal override MigrationMemento GetMemento()
 {
     return(new MigrationMemento(
                nameof(CreateForeignKeyMigration),
                new Dictionary <string, string>
     {
         ["CascadeDelete"] = _cascadeDelete ? "true" : "false",
         ["CascaseUpdate"] = _cascadeUpdate ? "true" : "false"
     },
                Sha256Hash,
                new Dictionary <string, IEnumerable <BigInteger> >
     {
         ["Prerequisites"] = Prerequisites.Select(x => x.Sha256Hash),
         ["Parent"] = new[] { _parent.Sha256Hash },
         ["Referencing"] = new[] { _referencing.Sha256Hash }
     }));
 }
    public override float GetCost()
    {
        var prereq_sum      = Prerequisites.Select(p => p.GetCost()).Sum();
        var opt_sum         = DecideFromOptions().GetCost();
        var inv_travel_time = 0f;
        var a = m_Actor.IActor;

        // No extra cost if for travelling to your own inventory
        if (TargetInventory != a.Inventory)
        {
            var path = new NavMeshPath();
            a.NavMeshAgent.CalculatePath(m_TargetInventory.transform.position, path);

            inv_travel_time = path.GetLength();
            Debug.Log(inv_travel_time);
        }

        return(prereq_sum + opt_sum + inv_travel_time);
    }