public CustomerPresenter(IView view, IBankAccount bankaccount)
 {
     View = view;
     Account = bankaccount;
     AccountConcrete = bankaccount as BankAccount;
     IsViewInjected = true;
 }
예제 #2
0
        /// <summary>
        ///     向UI窗口里插入一个可智能查询的View
        /// </summary>
        /// <param name="dockableManager"></param>
        /// <param name="plugin"></param>
        /// <param name="model"></param>
        /// <param name="bindingAction"></param>
        public static object AddCusomView(IDockableManager dockableManager, string pluginName, IView model)
        {
            if (dockableManager == null || model == null)
                return null;
            object view1 = model.UserControl;
            FrmState frm;
            frm = model.FrmState;

            XFrmWorkAttribute first = PluginProvider.GetFirstPlugin(typeof(ICustomView), pluginName);

            if (first != null)
            {
                var view2 = PluginProvider.GetObjectInstance(first.MyType) as ICustomView;
                if (view2 != null)
                {
                    view1 = view2;
                    frm = view2.FrmState;
                }
            }
            if (view1 == null)
                return null;
            XFrmWorkAttribute attr = PluginProvider.GetPluginAttribute(model.GetType());

            dockableManager.AddDockAbleContent(
                frm, view1, new[] { pluginName, attr.LogoURL, attr.Description });
            dockableManager.ViewDictionary.Last().Model = model;
            return view1;
        }
 public void ReleaseView(ControllerContext controllerContext, IView view)
 {
     IDisposable disposable = view as IDisposable;
     if (disposable == null)
         return;
     disposable.Dispose();
 }
예제 #4
0
파일: PlayGame.cs 프로젝트: henceee/1DV607
        public PlayGame(Game game, IView view)
        {
            a_game = game;
            a_view = view;

            a_game.AddSubscribers(this);
        }
예제 #5
0
        // tunnelX, tunnelZ is the coordinate of tunnel crown
        // h is the height of tunnel
        //
        public static List<Result> StrataOnTunnel(double tunnelX, double tunnelZ, double h,
            IView profileView, string stLayerID, Setting setting)
        {
            IGraphicsLayer gLayerSt = profileView.getLayer(stLayerID);
            if (gLayerSt == null)
                return null;

            List<Result> results = new List<Result>();

            Project prj = Globals.project;
            Domain geology = prj.getDomain(DomainType.Geology);
            DGObjectsCollection stratum = geology.getObjects("Stratum");
            var stratumList = stratum.merge();
            foreach (DGObject obj in stratumList)
            {
                Stratum strata = obj as Stratum;
                IGraphicCollection gc = gLayerSt.getGraphics(strata);

                if (gc == null)
                    continue;

                Result result = StratumOnTunnel(tunnelX, tunnelZ, h, gc, profileView.spatialReference);
                if (result != null)
                {
                    result.StratumObj = gLayerSt.getObject(gc[0]);
                    if (result.Depth > 0 || setting.AllStrata)
                        results.Add(result);
                }
            }
            return results;
        }
		public bool CanAccept(ILayout layout, IView view)
		{
			IEnumerable<string> acceptableViewNames = (IEnumerable<string>)acceptableViewNamesPerLayout[layout.Name];
			if (acceptableViewNames == null)
				return layout.Name == view.Name;
			return acceptableViewNames.Contains(view.Name);
		}
예제 #7
0
        public UpdateContentItemAction(IView view, IController con, ContentItem item, PropertyDescriptor property, object previousValue)
        {
            _view = view;
            _con = con;

            _state = ContentItemState.Get(item);

            var name = property.Name;
            var value = previousValue;

            if (name == "Importer")
            {
                name = "ImporterName";
                value = ((ImporterTypeDescription)value).TypeName;
            }

            if (name == "Processor")
            {
                name = "ProcessorName";
                value = ((ProcessorTypeDescription)value).TypeName;
            }

            var field = _state.GetType().GetMember(name).SingleOrDefault() as FieldInfo;
            if (field == null)
            {
                if (!_state.ProcessorParams.ContainsKey(name))
                    throw new Exception();

                _state.ProcessorParams[name] = value;
            }
            else
            {
                field.SetValue(_state, value);
            }
        }
예제 #8
0
        /// <summary>
        /// Creates a new instance of the specific presenter type, for the specified
        /// view type and instance.
        /// </summary>
        /// <param name="presenterType">The type of presenter to create.</param>
        /// <param name="viewType">The type of the view as defined by the binding that matched.</param>
        /// <param name="viewInstance">The view instance to bind this presenter to.</param>
        /// <returns>An instantitated presenter.</returns>
        public IPresenter Create(Type presenterType, Type viewType, IView viewInstance)
        {
            if (presenterType == null)
                throw new ArgumentNullException("presenterType");

            if (viewType == null)
                throw new ArgumentNullException("viewType");

            if (viewInstance == null)
                throw new ArgumentNullException("viewInstance");

            var buildMethod = GetBuildMethod(presenterType, viewType);

            try
            {
                return (IPresenter)buildMethod.Invoke(null, new[] { viewInstance });
            }
            catch (Exception ex)
            {
                var originalException = ex;

                if (ex is TargetInvocationException && ex.InnerException != null)
                    originalException = ex.InnerException;

                throw new InvalidOperationException
                (
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "An exception was thrown whilst trying to create an instance of {0}. Check the InnerException for more information.",
                        presenterType.FullName),
                    originalException
                );
            }
        }
예제 #9
0
 public WinFormsMvp.IPresenter Create(Type presenterType, Type viewType, IView viewInstance)
 {
     using (var scope = ObjectHost.Host.BeginLifetimeScope())
     {
         return scope.Resolve(presenterType, new NamedParameter("view", viewInstance)) as IPresenter;
     }
 }
예제 #10
0
 protected string GetViewKey(IView view)
 {
     foreach (var pair in _views)
         if (pair.Value == view)
             return pair.Key;
     return null;
 }
예제 #11
0
 public Presenter(IView view,ILogger log)
 {
     _view = view;
     _log = log;
     this._view.Loaded += OnLoaded;
     this._view.ErrorOccured += OnError;
 }
예제 #12
0
 public Presenter(IStabilityModel model, IView view)
 {
     _model = model;
     _view = view;
     _view.ViewUpdated += ViewOnViewUpdated;
     _view.DeviceCmdEvent += ViewOnDeviceCmdEvent;
 }
예제 #13
0
        public ViewModel(IView view)
        {
            _view = view;

            StartCmd = new RelayCommand(Start, () => _subscription == null);
            StopCmd = new RelayCommand(Stop, () => _subscription != null);
        }
        public IPresenter Create(Type presenterType, Type viewType, IView viewInstance)
        {
            if (presenterType == null)
                throw new ArgumentNullException("presenterType");
            if (viewType == null)
                throw new ArgumentNullException("viewType");
            if (viewInstance == null)
                throw new ArgumentNullException("viewInstance");

            if (!container.Model.HasImplementationsFor(presenterType))
            {
                lock (registerLock)
                {
                    if (!container.Model.HasImplementationsFor(presenterType))
                    {
                        container.Configure(x => x.For(presenterType).HybridHttpOrThreadLocalScoped().Use(presenterType).Named(presenterType.Name));
                    }
                }
            }

            var args = new ExplicitArguments();
            args.Set("view");
            args.SetArg("view", viewInstance);

            return (IPresenter)container.GetInstance(presenterType, args);
        }
예제 #15
0
        /// <summary>
        /// Creates the specified Presenter type. Called by the Web Forms MVP Framework.
        /// </summary>
        /// <param name="presenterType">Type of the presenter. Must be of type EPiPresenter<TView, TPageDataType> and the type arguments must be of the same type as the View and View Page Data Type, respectively.</param>
        /// <param name="viewType">Type of the view. Must be a subclass of EPiView.</param>
        /// <param name="viewInstance">The view instance. Must be a child of EPiView.</param>
        /// <returns></returns>
        public IPresenter Create(Type presenterType, Type viewType, IView viewInstance)
        {
            // Validate the View
            if (!typeof(IEPiView).IsAssignableFrom(viewType))
                throw new InvalidCastException("This kernel can (and should) only create a presenter if the View implements IEPiView. Got " + viewType);

            var epiView = viewInstance as IEPiView; // Unchecked cast is ok sicne we check it above.
            if (epiView.CurrentPage == null)
                throw new NullReferenceException("CurrentPage property of the viewInstance was null. The presenter needs a proper page data to render. ");

            Type pageDataType = GetPageDataType(epiView);

            Type genericPresenterViewType = GetGenericPresenterViewType(viewType);

            // Validate and check the Presenter type.
            var pageDataPresenterType = typeof(EPiPageDataPresenter<,>).MakeGenericType(new Type[] { genericPresenterViewType, pageDataType });
            if (presenterType.IsSubclassOf(pageDataPresenterType))
            {
                // Check if the Presenter has a usable constructor.
                if (!CanCreatePageDataPresenterInstance(viewType, pageDataType, presenterType))
                    throw new NullReferenceException("Did not find a suitable constructor on the presenter of type " + presenterType +
                                                     ". "
                                                     + "The presenter constructor requires two parameters, the FIRST one accepting a " +
                                                     viewType + " and a the SECOND one a " + pageDataType + ".");
                return
                    (IPresenter) CreatePageDataPresenterInstance(presenterType, (TypedPageData) epiView.CurrentPage, viewType, epiView);
            }
            return (IPresenter)CreatePresenterInstance(presenterType, viewType, epiView);
        }
        private static ViewComponentContext GetViewComponentContext(IView view, Stream stream)
        {
            var actionContext = new ActionContext(GetHttpContext(), new RouteData(), new ActionDescriptor());
            var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
            var viewContext = new ViewContext(
                actionContext,
                view,
                viewData,
                Mock.Of<ITempDataDictionary>(),
                TextWriter.Null,
                new HtmlHelperOptions());

            var writer = new StreamWriter(stream) { AutoFlush = true };

            var viewComponentDescriptor = new ViewComponentDescriptor()
            {
                Type = typeof(object),
            };

            var viewComponentContext = new ViewComponentContext(
                viewComponentDescriptor,
                new Dictionary<string, object>(),
                new HtmlTestEncoder(),
                viewContext,
                writer);

            return viewComponentContext;
        }
예제 #17
0
        public BackupForm(IBackupPresenter presenter, IView mainview)
            : base(mainview)
        {
            InitializeComponent();

            this.presenter = presenter;
        }
		/*============================================================================*/
		/* Private Functions                                                          */
		/*============================================================================*/
		
		private void HandleRemoveView (IView view)
		{
			if (_viewRemoved != null)
			{
				_viewRemoved(view);
			}
		}
예제 #19
0
        public BoxEntry(IView view)
        {
            if (view == null) throw new ArgumentNullException("view");

            this.view = view;
            dataAccess = new SqlDataAccess(ConfigurationManager.ConnectionStrings["DbConnection"].ConnectionString);
        }
예제 #20
0
        public IPresenter Create(Type presenterType, Type viewType, IView viewInstance)
        {
            // If a PresenterBinding attribute is applied directly to a view and the ViewType
            // property is not explicitly set, it will be defaulted to the view type. In a
            // user control example, this will be a type like ASP.usercontrols_mycontrol_ascx.
            // If we register it into the container using this type, and then try and resolve
            // a presenter like Presenter<IView> unity will throw an exception because it
            // doesn't use covariance when resolving dependencies. To get around this, we
            // look at the generic type argument on the presenter type (in this case, IView)
            // and register the view instance against that instead.
            if (viewType == viewInstance.GetType())
            {
                viewType = FindPresenterDescribedViewTypeCached(presenterType, viewInstance);
            }

            var presenterScopedContainer = container.CreateChildContainer();
            presenterScopedContainer.RegisterInstance(viewType, viewInstance);

            var presenter = (IPresenter)presenterScopedContainer.Resolve(presenterType);

            lock (presentersToContainersSyncLock)
            {
                presentersToContainers[presenter] = presenterScopedContainer;
            }

            return presenter;
        }
예제 #21
0
        public Presenter(IModel model, IView view)
        {
            this.model = model;
            this.view = view;

            RegisterEventListeners();
        }
예제 #22
0
        public ViewContext(ControllerContext controllerContext, IView view, ViewDataDictionary viewData, TempDataDictionary tempData)
            : base(controllerContext) {
            if (controllerContext == null) {
                throw new ArgumentNullException("controllerContext");
            }
            if (view == null) {
                throw new ArgumentNullException("view");
            }
            if (viewData == null) {
                throw new ArgumentNullException("viewData");
            }
            if (tempData == null) {
                throw new ArgumentNullException("tempData");
            }

            View = view;
            ViewData = viewData;
            TempData = tempData;

            // propagate FormContext, e.g. inside a template
            ViewContext originalViewContext = controllerContext as ViewContext;
            if (originalViewContext != null) {
                FormContext = originalViewContext.FormContext;
            }
        }
        public UpdateProjectAction(IView view, IController con, PipelineProject item, PropertyDescriptor property, object previousValue)
        {
            _view = view;
            _con = con;

            _state = ProjectState.Get(item);

            switch (property.Name)
            {
                case "OutputDir":
                    _state.OutputDir = (string)previousValue;
                    break;
                case "IntermediateDir":
                    _state.IntermediateDir = (string)previousValue;
                    break;
                case "References":
                    _state.References = new List<string>((List<string>)previousValue);
                    _referencesChanged = true;
                    break;
                case "Platform":
                    _state.Platform = (TargetPlatform)previousValue;
                    break;
                case "Profile":
                    _state.Profile = (GraphicsProfile)previousValue;
                    break;
                case "Config":
                    _state.Config = (string)previousValue;
                    break;
                case "OriginalPath":
                    _state.OriginalPath = (string)previousValue;
                    break;
            }
        }
        public void AttributeBasedPresenterDiscoveryStrategy_GetBindings_MultipleViewsWithNoAttributes()
        {
            // Arrange
            var strategy = new AttributeBasedPresenterDiscoveryStrategy();
            var hosts = new object[0];
            var view1 = new View1();
            var view2 = new View2();
            var views = new IView[] { view1, view2 };

            // Act
            var results = strategy.GetBindings(hosts, views).ToArray();

            // Assert
            CollectionAssert.AreEqual(new[]
                {
                    new PresenterDiscoveryResult
                    (
                        new[] {view1},
                        @"AttributeBasedPresenterDiscoveryStrategy:
- could not find a [PresenterBinding] attribute on view instance WebFormsMvp.UnitTests.Binder.AttributeBasedPresenterDiscoveryStrategyTests.GetBindings_MultipleViewsWithNoAttributes+View1",
                        new PresenterBinding[0]
                    ),
                    new PresenterDiscoveryResult
                    (
                        new[] {view2},
                        @"AttributeBasedPresenterDiscoveryStrategy:
- could not find a [PresenterBinding] attribute on view instance WebFormsMvp.UnitTests.Binder.AttributeBasedPresenterDiscoveryStrategyTests.GetBindings_MultipleViewsWithNoAttributes+View2",
                        new PresenterBinding[0]
                    )
                },
                results
            );
        }
        public ResolvedUrls(IView view)
        {
            if(view == null)
                throw new ArgumentNullException("view");

            this._view = view;
        }
예제 #26
0
   public CommandServicePresenter(IView view, IService service,
 ICommandExecutor executor)
   {
       _view = view;
         _service = service;
         _executor = executor;
   }
예제 #27
0
 public ViewModel(IView view)
 {
     model = new Model();
     this.view = view;
     view.btnPressed += btnPressed;
     view.onBtnPressed += onBtnPressed;
 }
예제 #28
0
파일: View.cs 프로젝트: zh423328/RunAway
    /// <summary>
    /// 注册消息
    /// </summary>
    /// <param name="view"></param>
    /// <param name="messages"></param>
    protected void RegisterMessage(IView view, List<string> messages) 
    {
        if (messages == null || messages.Count == 0) 
            return;

        Controller.Instance.RegisterViewCommand(view, messages.ToArray());
    }
예제 #29
0
		protected override IView[] GetViews(IView view)
		{
			MonoBehaviour mono = view as MonoBehaviour;
			Component[] components = mono.GetComponentsInChildren (typeof(IView), true);
			IView[] views = components.Cast<IView>().ToArray();
			return views;
		}
        /// <summary>Constructor.</summary>
        /// <param name="divHost">The control host DIV.</param>
        /// <param name="control">The logical IView control (null if not available).</param>
        /// <param name="htmlElement">The control content (supplied by the test class. This is the control that is under test).</param>
        /// <param name="displayMode">The sizing strategy to use for the control.</param>
        /// <param name="allViews">The Collection of all controls.</param>
        public ControlWrapperView(
            jQueryObject divHost, 
            IView control, 
            jQueryObject htmlElement, 
            ControlDisplayMode displayMode, 
            IEnumerable allViews) : base(divHost)
        {
            // Setup initial conditions.
            this.control = control;
            this.htmlElement = htmlElement;
            this.displayMode = displayMode;
            this.allViews = allViews;
            index = divHost.Children().Length; // Store the order position of the control in the host.
            events = Common.Events;

            // Create the wrapper DIV.
            divRoot = Html.CreateDiv();
            divRoot.CSS(Css.Position, Css.Absolute);
            divRoot.AppendTo(divHost);

            // Insert the content.
            htmlElement.CSS(Css.Position, Css.Absolute);
            htmlElement.AppendTo(divRoot);

            // Wire up events.
            events.ControlHostSizeChanged += OnHostResized;

            // Finish up.
            UpdateLayout();
        }
예제 #31
0
 protected override IPresenter Create(IView view)
 {
     return(new AssessmentFactorPresenter(view));
 }
예제 #32
0
 public TicTacToePresenter(IView <TicTacToeBoard> view) : base(view)
 {
 }
예제 #33
0
 public Controller(IView theView, Model theModel)
 {
     myView  = theView;
     myModel = theModel;
     myDeck  = myModel.AssignDeck();
 }
예제 #34
0
 IVisualElementRenderer CreateRenderer(IView view)
 {
     return(Internals.Registrar.Registered.GetHandlerForObject <IVisualElementRenderer>(view)
            ?? new DefaultRenderer());
 }
 private void RenderCurrentView()
 {
     this.CurrentView        = this.CurrentController.GetView(this.Username);
     this.currentOptionIndex = DEFAULT_INDEX;
     this.forumViewer.RenderView(this.CurrentView);
 }
예제 #36
0
 private void RaiseUnloaded(IView view)
 {
     // Yes, invoke events right after each other
     InvokeViewLoadEvent(view, ViewLoadStateEvent.Unloading);
     InvokeViewLoadEvent(view, ViewLoadStateEvent.Unloaded);
 }
예제 #37
0
 protected override IPresenter Create(IView view, IPresentationEntity presentationEntity)
 {
     return(new AssessmentFactorPresenter(view, presentationEntity));
 }
예제 #38
0
파일: ViewStack.cs 프로젝트: xubinvc/Catel
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewStack" /> class.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="isViewLoaded">if set to <c>true</c>, the view is loaded.</param>
 public ViewStack(IView view, bool isViewLoaded)
     : this(view, isViewLoaded, null)
 {
 }
예제 #39
0
 internal void RegisterView(IView view)
 {
     measureToViewMap.RegisterView(view, clock);
 }
예제 #40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WeakViewInfo"/> class.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="isViewLoaded">if set to <c>true</c>, the view is already loaded.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="view"/> is <c>null</c>.</exception>
        public WeakViewInfo(IView view, bool isViewLoaded = false)
        {
            Argument.IsNotNull("view", view);

            Initialize(view, isViewLoaded);
        }
예제 #41
0
        protected override void PresentOnMainThread <TInput, TOutput>(ViewModel <TInput, TOutput> viewModel, IView sourceView)
        {
            UIViewController viewController = ViewControllerLocator.GetViewController(viewModel);

            viewController.ModalPresentationStyle = UIModalPresentationStyle.Custom;
            viewController.TransitioningDelegate  = fromBottomTransitionDelegate;

            UIViewController topmostViewController = FindPresentedViewController();

            topmostViewController.PresentViewController(viewController, true, null);
        }
예제 #42
0
        //命令执行,带有业务相关的Clear逻辑
        public void Execute(object parameter)
        {
            IView view = parameter as IView;

            view?.Clear();
        }
예제 #43
0
 public override void AddSubItemView(ISubPresenterItem subPresenterItem, IView viewToAdd)
 {
     UpdateEditControl(viewToAdd);
 }
예제 #44
0
 public override void RegisterView(IView view)
 {
     this.statsManager.RegisterView(view);
 }
예제 #45
0
 public void UpdateChartControl(IView view)
 {
     splitter.Panel2.FillWith(view);
 }
예제 #46
0
 public SelectProjectViewModel(IView view)
     : base(view)
 {
     this.projects      = new CollectionView(ProjectService.GetAllProjects());
     this.selectCommand = new DelegateCommand(this.SelectCommandHandler);
 }
예제 #47
0
        protected override bool HasMediator(IView view, Type mediatorType)
        {
            MonoBehaviour mono = view as MonoBehaviour;

            return(mono.GetComponent(mediatorType) != null);
        }
예제 #48
0
 public void UpdateEditControl(IView view)
 {
     splitter.Panel1.FillWith(view);
 }
예제 #49
0
 protected override void OnSetView(IView view)
 {
     mainWindow = (IMainWindow)view;
 }
예제 #50
0
        /// Create a new Mediator object based on the mediatorType on the provided view
        protected override object CreateMediator(IView view, Type mediatorType)
        {
            MonoBehaviour mono = view as MonoBehaviour;

            return(mono.gameObject.AddComponent(mediatorType));
        }
예제 #51
0
 public MqttPropertyGrid(XmlNode dataModel, IView view)
 {
     _node     = dataModel;
     this.view = view;
     type      = "MQTT";
 }
예제 #52
0
 public EmailListViewModel(IView view, List <EmailItem> emailList, int dealerID)
 {
     _view = view;
     Init(emailList, dealerID);
     view.SetDataContext(this);
 }
예제 #53
0
 public HttpPutPropertyGrid(XmlNode dataModel, IView view)
 {
     _node     = dataModel;
     this.view = view;
 }
예제 #54
0
 public MainWindowViewModel(IView view) : base(null)
 {
     SetView(view);
     ChemicalAnalysis.CreateParamtersDictionary();
     Initialize();
 }
예제 #55
0
 public static void UpdateAutomationId(this FrameworkElement platformView, IView view) =>
 AutomationProperties.SetAutomationId(platformView, view.AutomationId);
예제 #56
0
 public LoadInjectorGridBase GetConfigGrid(XmlNode dataModel, IView view)
 {
     return(new MqttPropertyGrid(dataModel, view));
 }
예제 #57
0
 public static void UpdateOpacity(this FrameworkElement platformView, IView view)
 {
     platformView.Opacity = view.Visibility == Visibility.Hidden ? 0 : view.Opacity;
 }
예제 #58
0
 public static void UpdateIsEnabled(this FrameworkElement platformView, IView view) =>
 (platformView as Control)?.UpdateIsEnabled(view.IsEnabled);
예제 #59
0
 /// <summary>在线用户连接监测 从视图(多表)内获取本表</summary>
 public static A8OnlineUserConstr FromIView(IView view)
 {
     return((A8OnlineUserConstr)IView.GetITable(view, "A8OnlineUserConstr"));
 }
예제 #60
0
 public static void UpdateBackground(this FrameworkElement platformView, IView view)
 {
     platformView?.UpdatePlatformViewBackground(view);
 }