protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         ObjectFactory.BuildUp(this);
     }
 }
예제 #2
0
        public Statusbar()
        {
            ObjectFactory.BuildUp(this);

            InitializeComponent();

            ClearStatus();
        }
예제 #3
0
        public IJob NewJob(TriggerFiredBundle bundle)
        {
            Type jobType = bundle.JobDetail.JobType;
            var  job     = ObjectFactory.GetInstance(jobType) as IJob;

            ObjectFactory.BuildUp(job);
            return(job);
        }
예제 #4
0
        public PackageButtonsPanel()
        {
            ObjectFactory.BuildUp(this);

            InitializeComponent();

            btnUpdate.Click           += BtnUpdateClick;
            btnInstallUninstall.Click += BtnInstallUninstallClick;
        }
예제 #5
0
 public PackagesBaseGrid()
 {
     _bindingsource = new BindingSource();
     ObjectFactory.BuildUp(this);
     InitializeComponent();
     DoLayout();
     packagesGrid.DataSource = _bindingsource;
     searchButton.Click     += SearchButtonClick;
 }
예제 #6
0
 public void BuildUp(object target)
 {
     try
     {
         ObjectFactory.BuildUp(target);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #7
0
        protected override IEnumerable <FilterAttribute> GetActionAttributes(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
        {
            IEnumerable <FilterAttribute> filters = base.GetActionAttributes(controllerContext, actionDescriptor);

            foreach (FilterAttribute filter in filters)
            {
                ObjectFactory.BuildUp(filter);
            }

            return(filters);
        }
예제 #8
0
        public PackageVersionPanel()
        {
            ObjectFactory.BuildUp(this);

            InitializeComponent();
            ClearPanel();

            linkGalleryDetails.LinkClicked += OnGalleryDetailsClicked;
            linkLicense.LinkClicked        += OnLiscenseClicked;
            linkProjectSite.LinkClicked    += OnProjectSiteClicked;
            linkAbuse.LinkClicked          += OnAbuseClicked;
        }
예제 #9
0
        public IEnumerable <Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
        {
            IEnumerable <Filter> filters = base.GetFilters(controllerContext, actionDescriptor);

            foreach (Filter filter in filters)
            {
                // Injects the instance with Structuremap's dependencies
                Log.Information(filter.Instance.GetType().Name);
                ObjectFactory.BuildUp(filter.Instance);
            }

            return(filters);
        }
예제 #10
0
        public int AddTask(IBackgroundTask task)
        {
            int id = ++_id;

            Tasks[id] = task;

            Task.Run(() =>
            {
                ObjectFactory.BuildUp(task);
                task.DoTask();
            });

            return(id);
        }
        public override IController CreateController(RequestContext requestContext, string controllerName)
        {
            try
            {
                var controllerType = base.GetControllerType(requestContext, controllerName);
                var controller     = ObjectFactory.GetInstance(controllerType) as IController;
                ObjectFactory.BuildUp(controller);
                return(controller);
            }
            catch (Exception ex)
            {
                Logger.InfoException("Default controller logic is being used.", ex);

                //Use the default logic.);
                return(base.CreateController(requestContext, controllerName));
            }
        }
예제 #12
0
        public void Test()
        {
            ObjectFactory.Initialize(x => {
                x.ForConcreteType <SomeDbRepository>().Configure.
                Ctor <string>("connectionString").Is("some connection string");

                //x.ForConcreteType<SomeWebPage>().Configure.
                //  SetterDependency<SomeDbRepository>().Is<SomeDbRepository>();

                x.Policies.SetAllProperties(o => o.OfType <SomeDbRepository>());
            });

            var webPage = new SomeWebPage();

            ObjectFactory.BuildUp(webPage);

            webPage.DbRepository.ConnectionString.ShouldEqual("some connection string");
        }
예제 #13
0
        // WebApi

        public IEnumerable <System.Web.Http.Filters.FilterInfo> GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor)
        {
            if (_webApiProviders != null)
            {
                IEnumerable <System.Web.Http.Filters.IFilterProvider> filterProviders = _webApiProviders;
                IEnumerable <System.Web.Http.Filters.FilterInfo>      filters         = filterProviders.SelectMany(x => x.GetFilters(configuration, actionDescriptor)).ToList();

                foreach (System.Web.Http.Filters.FilterInfo filter in filters)
                {
                    // Injects the instance with Structuremap's dependencies
                    Log.Information(filter.Instance.GetType().Name);
                    ObjectFactory.BuildUp(filter.Instance);
                }

                return(filters);
            }
            else
            {
                // _webApiProviders will be null for something
                return(null);
            }
        }
        public void create_a_setter_rule_and_see_it_applied_in_BuildUp_through_ObjectFactory()
        {
            var theGateway = new DefaultGateway();

            ObjectFactory.Initialize(x => {
                x.For <IGateway>().Use(theGateway);

                // First we create a new Setter Injection Policy that
                // forces StructureMap to inject all public properties
                // where the PropertyType is IGateway
                x.Policies.SetAllProperties(y => { y.OfType <IGateway>(); });
            });

            // Create an instance of BuildUpTarget1
            var target = new BuildUpTarget1();

            // Now, call BuildUp() on target, and
            // we should see the Gateway property assigned
            ObjectFactory.BuildUp(target);

            target.Gateway.ShouldBeTheSameAs(theGateway);
        }
예제 #15
0
        public void Test()
        {
            ObjectFactory.Initialize(x =>
            {
                x.UseDefaultStructureMapConfigFile = false;

                x.ForConcreteType <SomeDbRepository>().Configure.
                WithCtorArg("connectionString").EqualTo("some connection string");

                //x.ForConcreteType<SomeWebPage>().Configure.
                //  SetterDependency<SomeDbRepository>().Is<SomeDbRepository>();

                x.SetAllProperties(o => o.OfType <SomeDbRepository>());
            });

            var dbRepository =
                ObjectFactory.GetInstance <SomeDbRepository>();

            var webPage = new SomeWebPage();

            ObjectFactory.BuildUp(webPage);

            webPage.DbRepository.ConnectionString.ShouldEqual("some connection string");
        }
예제 #16
0
        public override object GetResult()
        {
            DataTable dt     = DataFactory.GetResult() as DataTable;
            List <T>  result = new List <T>();
            T         obj;
            IFactory  objFactory = new ObjectFactory();
            Type      objectType = typeof(T);

            foreach (DataRow dr in dt.Rows)
            {
                obj = objFactory.BuildUp <T>();
                AttributeHelper.GetProperty(objectType, TableAttr.PrimaryKeyInfo.PropertyName).SetValue(obj, dr[TableAttr.PrimaryKeyInfo.FieldName]);
                foreach (var mapInfo in TableAttr.Maps)
                {
                    if (dr[mapInfo.Value.FieldName] is DBNull)
                    {
                        continue;
                    }
                    objectType.GetProperty(mapInfo.Value.PropertyName).SetValue(obj, dr[mapInfo.Value.FieldName], null);
                }
                result.Add(obj);
            }
            return(result);
        }
 public MyControl()
 {
     this.InitializeComponent();
     ObjectFactory.BuildUp(this);
 }
 protected DependencyUserControl()
 {
     ObjectFactory.BuildUp(this);
 }
예제 #19
0
 public static void BuildUp(object target)
 {
     ObjectFactory.BuildUp(target);
 }
 public BasePage()
 {
     // instruct StructureMap to resolve dependencies
     ObjectFactory.BuildUp(this);
 }
예제 #21
0
 protected BaseCommand()
 {
     ObjectFactory.BuildUp(this);
 }
 public override void RuntimeInitialize(MethodBase method)
 {
     // Initialize the SessionFactory according to the container configuration.
     ObjectFactory.BuildUp(this);
 }
예제 #23
0
 public BasePage()
 {
     ObjectFactory.BuildUp(this);
 }
예제 #24
0
 protected StructureMapPageBase()
 {
     ObjectFactory.BuildUp(this);
 }
예제 #25
0
        public PackageExtraInformationPanel()
        {
            ObjectFactory.BuildUp(this);

            InitializeComponent();
        }
예제 #26
0
 protected override void OnPreInit(EventArgs e)
 {
     ObjectFactory.BuildUp(this);
     base.OnPreInit(e);
 }
예제 #27
0
        public PackageRunPanel()
        {
            ObjectFactory.BuildUp(this);

            InitializeComponent();
        }
예제 #28
0
 public BaseApiControler()
 {
     ObjectFactory.BuildUp(this);
 }
예제 #29
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ObjectFactory.BuildUp(this);
     this.Do_Load(sender, e);
     //template method, to enable subclasses to mimic "Page_load" event
 }