示例#1
0
        private void Activating(IActivatingEventArgs <object> e)
        {
            var matchingAttachments = conventionManager.FindMatchingAttachments(e.Instance).Select(e.Context.Resolve);

            foreach (var attachment in matchingAttachments)
            {
                AttachmentHelper.Attach(attachment, e.Instance);
            }
        }
示例#2
0
 public ActionResult Attachments(DocumentAttachments attach)
 {
     if (ModelState.IsValid)
     {
         attach.FileUploadId = (int)TempData["File"];
         helper.Attach(attach);
         return(RedirectToAction("Details", "Documents", new { id = attach.FileUploadId }));
     }
     return(View(attach));
 }
示例#3
0
        public void GeneratorPopulatesPeopleList2()
        {
            var viewModel  = new ListViewModel();
            var attachment = new ListGeneratorAttachment();

            // Initialize data generator
            Randomizer.Seed = new Random(12345);

            AttachmentHelper.Attach(attachment, viewModel);

            Approvals.VerifyAll(viewModel.People, "People", p => $"{p.FirstName} {p.LastName} {p.Address} {p.PhoneNumber}");
        }
示例#4
0
        public void Configure(IEnumerable <Type> views, IEnumerable <Type> viewModels, IEnumerable <Type> attachments, IConventionManager conventionManager)
        {
            container.PropertyDependencySelector = new PropertyInjectionDisabler();

            foreach (var type in views.Concat(viewModels).Concat(attachments))
            {
                container.Register(type);
            }

            container.Initialize(registration => viewModels.Contains(registration.ServiceType), (factory, instance) =>
            {
                var matchingAttachments = conventionManager.FindMatchingAttachments(instance)
                                          .SelectMany(factory.GetAllInstances);
                foreach (var attachment in matchingAttachments)
                {
                    AttachmentHelper.Attach(attachment, instance);
                }
            });
        }