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;
        }
 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);
        }
        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);
        }
        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);
        }
        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");
        }
        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);
 }
 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
 }