コード例 #1
0
ファイル: Tools.cs プロジェクト: brezza92/PixelFarm
        public static TempContext <ShapeBuilder> BorrowShapeBuilder(out ShapeBuilder shapeBuilder)
        {
            if (!Temp <ShapeBuilder> .IsInit())
            {
                Temp <ShapeBuilder> .SetNewHandler(
                    () => new ShapeBuilder(),
                    f => f.Reset());
            }

            TempContext <ShapeBuilder> context = Temp <ShapeBuilder> .Borrow(out shapeBuilder);

            shapeBuilder.InitVxs();//make it ready-to-use
            return(context);
        }
コード例 #2
0
        // GET: Home
        public ActionResult Index()
        {
            TempContext   context = new TempContext();
            List <Person> persons = null;

            using (context)
            {
                persons = context.Persons.Include(x => x.Address.City.Country).ToList();
            }

            ViewBag.AllPersons = persons;
            //ViewData["persons"] = persons;

            return(View());
        }
コード例 #3
0
        public async Task MakeTest()
        {
            using var tempDir       = new TempDir();
            using var contextHolder = TempContext.Create();
            var ctx = contextHolder.Object;

            var outputStream = new MemoryStream();

            var res = await Tar.Make(outputStream, ctx, new[] { tempDir.Path });

            var outputRes = outputStream.ToArray();

            using var zip = new ZipArchive(outputRes.ToStream(), ZipArchiveMode.Read);

            Assert.True(zip.Entries.Count == 4);
        }
コード例 #4
0
        public override async Task UpgradeAsync(DbTransaction?transaction = null, CancellationToken token = default)
        {
            var tempContextOptionsBuilder = new DbContextOptionsBuilder <TempContext>();

            tempContextOptionsBuilder.UseNpgsql(DbProvider.Connection);

            var anotherTempContextOptionsBuilder = new DbContextOptionsBuilder <AnotherTempContext>();

            anotherTempContextOptionsBuilder.UseNpgsql(DbProvider.Connection);

            using (var tempContext = new TempContext(tempContextOptionsBuilder.Options))
                using (var anotherContext = new AnotherTempContext(anotherTempContextOptionsBuilder.Options))
                {
                    // tempContext.Database.UseTransaction(transaction);
                    // anotherContext.Database.UseTransaction(transaction);

                    var request1 = new BackgroundProcessorRequestEntity
                    {
                        CreatedUtc         = DateTime.Now,
                        TimeZoneId         = "temo",
                        Type               = 1,
                        State              = 1,
                        UserId             = 1,
                        ProjectId          = 1,
                        RequestCultureName = "ru"
                    };
                    var request2 = new BackgroundProcessorRequestEntity
                    {
                        CreatedUtc         = DateTime.Now,
                        TimeZoneId         = "temo",
                        Type               = 1,
                        State              = 1,
                        UserId             = 1,
                        ProjectId          = 1,
                        RequestCultureName = "ru"
                    };

                    tempContext.Requests.Add(request1);
                    anotherContext.Requests.Add(request2);

                    await tempContext.SaveChangesAsync();

                    await anotherContext.SaveChangesAsync();
                }
        }
コード例 #5
0
        public ActionResult ShowDetail(int id)
        {
            TempContext context = new TempContext();

            Person person = null;

            using (context)
            {
                person = (from p in context.Persons
                          .Include(x => x.Address.City.Country)
                          where p.PersonId == id
                          select p).FirstOrDefault();
            }

            ViewBag.PersonDetail = person;

            return(PartialView("_DetailView"));
        }
 protected BaseController()
 {
     db              = new TempContext();
     Blog            = db.Blogs.FirstOrDefault();
     Ability         = db.Abilities.FirstOrDefault();
     AboutSpec       = db.AboutSpecs.FirstOrDefault();
     Comment         = db.Comments.FirstOrDefault();
     Portfolio       = db.Portfolios.FirstOrDefault();
     HomeImage       = db.HomeImages.FirstOrDefault();
     Position        = db.Positions.FirstOrDefault();
     Post            = db.Posts.FirstOrDefault();
     SecondBlog      = db.SecondBlogs.FirstOrDefault();
     Service         = db.Services.FirstOrDefault();
     Speciality      = db.Specialities.FirstOrDefault();
     Team            = db.Teams.FirstOrDefault();
     Testimonial     = db.Testimonials.FirstOrDefault();
     Setting         = db.Settings.FirstOrDefault();
     ViewBag.Setting = db.Settings.FirstOrDefault();
 }
コード例 #7
0
 public Repository(TempContext dbContext)
 {
     _dbContext = dbContext;
 }