示例#1
0
 public static void PopulateFromRequest(this ITaskParameters task, DashboardRequest request)
 {
     foreach (var property in task.GetType().GetProperties().Where(x => x.CanWrite))
     {
         SetProperty(request, property, task);
     }
 }
示例#2
0
        public async Task <bool> Run(ITaskParameters parameters)
        {
            if (parameters == null)
            {
                throw new NullReferenceException();
            }

            using (var db = new SomeGameDbContext(parameters.GetService <IMetadataProvider>(), string.Empty))
            {
                var created = db.Database.EnsureCreated();

                var player = new Player()
                {
                    ReferencedItem = new ReferencedItem()
                };

                var playerSet = db.Set <Player>();

                var entry = playerSet.Add(player);
                db.SaveChanges();

                player = playerSet.FirstOrDefault();
                var id = player.Id;
                var o  = id;
            }

            return(true);
        }
示例#3
0
        private static Job CreateJob(ITaskParameters taskParameters)
        {
            var methodInfo        = typeof(ITaskDispatcher).GetMethod("Dispatch");
            var makeGenericMethod = methodInfo.MakeGenericMethod(taskParameters.GetType());
            var job = new Job(typeof(ITaskDispatcher), makeGenericMethod, taskParameters, null, null);

            return(job);
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConsoleTask"/> class
        /// with specified task parameters.
        /// </summary>
        /// <param name="parameters">An <see cref="ITaskParameters"/> object
        /// containing essential task informations.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="parameters"/> is null.
        /// </exception>
        public ConsoleTask(ITaskParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            this.parameters = parameters;
        }
示例#5
0
        protected internal TaskDetailsPage(ITaskParameters taskParameters, TaskDispatcherPagesOptions options, List <Type> genericTypeOptions = null)
        {
            _taskParameters     = taskParameters;
            _genericTypeOptions = genericTypeOptions;
            _options            = options;
            var type = _taskParameters.GetType();

            _pageHeader          = type.Name.Replace("`1", "");
            _displayName         = type.GetCustomAttribute <DisplayNameAttribute>()?.DisplayName ?? taskParameters.ToString();
            _displayDescription  = type.GetCustomAttribute <DescriptionAttribute>()?.Description;
            _displayErrorDetails = type.GetCustomAttribute <ErrorImplicationDetailsAttribute>()?.Details;
        }
示例#6
0
        public async Task <bool> Run(ITaskParameters parameters)
        {
            var playerType = parameters.Exports.Get <Player, UnrealMetadataProvider, UnrealTypeInfo>();

            var templateFactory = parameters.GetService <UnrealTemplateFactory>();
            var template        = templateFactory.Create <UnrealClassTemplate>(playerType);

            template.ModuleName = "SomeGame";

            const string filePath     = @"C:\Temp\Out.txt";
            var          fileTemplate = new UnrealHeaderTemplate(template);

            fileTemplate.AddGeneratedHeaderInclude(filePath);

            File.WriteAllText(filePath, fileTemplate.Print());

            return(true);
        }
示例#7
0
        public ITaskResult SetParameters(ITaskParameters taskParameters)
        {
            Ensure.That(taskParameters).IsNotNull();

            var parameters = (ManufacturingParameters)taskParameters;
            return SetManufacturingParameters(parameters);
        }
示例#8
0
 public async Task PostTask(ITaskParameters parameters)
 {
 }
示例#9
0
 public async Task <bool> Run(ITaskParameters parameters)
 {
     return(true);
 }
示例#10
0
 public async Task PreTask(ITaskParameters parameters)
 {
 }
示例#11
0
 public bool Authorize(DashboardContext context, ITaskParameters taskParameters)
 {
     return(new Random().Next(1) == 1);
 }
示例#12
0
文件: ShipTask.cs 项目: andy-uq/Echo
 public abstract ITaskResult SetParameters(ITaskParameters taskParameters);
示例#13
0
        private static void SetProperty(DashboardRequest request, PropertyInfo propertyInfo, ITaskParameters searchObject)
        {
            var value = Task.Run(() => request.GetFormValuesAsync(propertyInfo.Name)).Result.FirstOrDefault();

            if (value == null)
            {
                return;
            }

            var propertyType = Nullable.GetUnderlyingType(propertyInfo.PropertyType) ??
                               propertyInfo.PropertyType;
            var propertyValue = ConvertFromInvariantString(propertyType, value);

            propertyInfo.SetValue(searchObject, propertyValue, null);
        }