Esempio n. 1
0
        // Constructor
        public MediatorColleague(SnapViewDirector the_svd)
        {
            svd = the_svd;

            // Default to isValid == false
            Changed();
        }
            // Loop over the constraint properties
            public void loop_over_constraintVM(SnapViewDirector svd)
            {
                // Loop over properties in ViewModel looking for BaseConstraintViewModel objects
                foreach (var prop in typeof(PlayerStatViewModel).GetProperties())
                {
                    if (prop.GetValue(this) is BaseConstraintViewModel)
                    {
                        BaseConstraintViewModel bvm = (BaseConstraintViewModel)prop.GetValue(this);

                        // Generate a concrete ConstraintMC based on this viewmodel
                        //  Two purposes for this:
                        //      i) Use it to search for an exisiting Constraint in the svd
                        //     ii) If this constraint is active in the viewmodel, this new MC will be attached to the svd
                        ConstraintMC cmc_vm = bvm.generate_ConstraintMC(svd);

                        // Search for ConstraintMC matching this one - look for underlying action type matching.
                        ConstraintMC cmc_svd = svd.get_matching_ConstraintMC(cmc_vm);

                        // If we found a ConstraintMC with the same underlying Constraint
                        // then detach it from the svd to prepare for the new one.
                        // Or we don't need a constraint of this type at all if this constraint is disabled in the viewmodel
                        // In either case we need to detach it.
                        if (cmc_svd != null)
                        {
                            svd.Detach(cmc_svd);
                        }

                        // Now the existing svd version is detached if found, we attach the new one if needed
                        if (bvm.active)
                        {
                            svd.Attach(cmc_vm);
                        }
                    } //if BaseConstraintViewModel
                }     //foreach
            }         //method
Esempio n. 3
0
        // Generate ConstraintMC
        public override ConstraintMC generate_ConstraintMC(SnapViewDirector svd)
        {
            Field f = svd.findInDict(FieldDictionary.fname_homeAway);
            HomeAwayConstraintAdapter adapter = new HomeAwayConstraintAdapter(f, IsHome);

            return(new ConstraintMC(svd, adapter.adaptee));
        }
Esempio n. 4
0
        // Generate ConstraintMC
        public override ConstraintMC generate_ConstraintMC(SnapViewDirector svd)
        {
            Field f = svd.findInDict(FieldDictionary.fname_Gameweek);
            // Adapter needed to convert ints to strings
            GameweekConstraintAdapter adapter = new GameweekConstraintAdapter(f, min, max);

            return(new ConstraintMC(svd, adapter.adaptee));
        }
Esempio n. 5
0
        // Generate ConstraintMC
        public override ConstraintMC generate_ConstraintMC(SnapViewDirector svd)
        {
            // This should not be hardcoded - but factored out
            Field f = svd.findInDict(FieldDictionary.fname_minsPlayed);
            MinsPlayedConstraintAdapter adapter = new MinsPlayedConstraintAdapter(f, val);

            return(new ConstraintMC(svd, adapter.adaptee));
        }
Esempio n. 6
0
        public MCAction(SnapViewDirector svd, BaseAction a)
            : base(svd)
        {
            action = a;

            // This next line is very important: call the "Changed()" method of the MediatorColleague which
            // in via the SnapViewDirector sets the snapview isvalid flag to false.
            Changed();
        }
Esempio n. 7
0
        public SnapView loadData(SnapViewDirector svd)
        {
            // Create root level snapview here (passing in the SnapViewDirector)
            _initial_SnapView = new SnapView(svd);

            // Initialise it
            XmlInit svInit = new XmlInit();

            svInit.initSnapView(_initial_SnapView);

            return(_initial_SnapView);
        }
Esempio n. 8
0
        // Constructor default at the moment
        public SnapView(SnapViewDirector svd) : base(svd)
        {
            // First lines here are what belongs in the constructor.

            // Create the table - initial size of 100, but List<> can grow so this doesn't matter too much.
            table = new List <SVRow>(100);

            //actions = new LinkedList<BaseAction>();

            //filters = new LinkedList<BaseFilter>(); // initial assumption is 10 filters. Will grow as necessary.

            // isValid default to true for snapview (different to actions)
            isValid = true;
        }//snapView constructor
Esempio n. 9
0
        // ***************
        // Constructors
        // ***************

        // Copy constructor to Clone this snapview only used by FootyStatInit to save a copy right at the start.
        public SnapView(SnapViewDirector svd, SnapView previous_sv) : base(svd)
        {
            // Copy the table (DEEP COPY) because the table will be different for all users.
            table = new List <SVRow>(100);
            foreach (SVRow row in previous_sv.table)
            {
                table.Add(row);
            }

            // Shallow copy the dict because this is the same for all.
            dict = previous_sv.dict;

            // isValid default to true for snapview (different to actions)
            isValid = true;
        }
Esempio n. 10
0
        // Initialise the svd
        public void init_svd()
        {
            // Only the initial init if there is not already an entry for the svd in the current session:
            if (GetFromSession <SnapViewDirector>("svd") == null)
            {
                // Order is important as snapview needs svd in its constructor -> So create it before snapview
                SnapViewDirector svd_local = new SnapViewDirector();

                SnapView snapview = null;

                // If the _initial_SnapView static member is null - read from disk (once per app instance)
                // Otherwise copy the _initial_SnapView (once per new session)
                if (_initial_SnapView == null)
                {
                    snapview = loadData(svd_local);
                }
                else
                {
                    // Copy the initial snapview (contains a deep copy of the table, but shallow copy of the dict)
                    snapview = new SnapView(svd_local, _initial_SnapView);
                }

                // And register the snapview with the director
                svd_local.Attach(snapview);


                // Set this for the current session
                SetInSession("svd", svd_local);
            }
            //else
            //{
            //    // If init has been called, but an svd already exists - reinitialise this svd.
            //    // (This occurs if the user closes the window in the session, and navigates to the root SelectPlayer page)

            //    // The setter automatically cleans out an exisiting svd in the session if its there.
            //    svd = new SnapViewDirector();

            //    // Property getter.
            //    SnapViewDirector svd_ref = svd;


            //    SnapView snapview = new SnapView(svd, _initial_SnapView);
            //    svd.Attach(snapview);
            //}
        }
Esempio n. 11
0
 public CommandInvoker(SnapViewDirector the_svd)
 {
     svd          = the_svd;
     command_list = new List <Command>();
 }
Esempio n. 12
0
 // Constructor
 // Supplying this with an IndexingAction behaviour is what makes this behave like an "Index"
 public IndexMC(SnapViewDirector svd, IndexingAction a)
     : base(svd, a)
 {
 }
Esempio n. 13
0
 public CreateFilterCommand(SnapViewDirector svd, string the_filter_field_name, string the_filter_value)
     : base(svd)
 {
     filter_field_name = the_filter_field_name;
     filter_value      = the_filter_value;
 }
Esempio n. 14
0
 public UpdateConstraintsAndAllStats_CS(SnapViewDirector svd)
     : base(svd)
 {
 }
Esempio n. 15
0
 // Constructor
 // Supplying this with BaseFilter behaviour (action) is what
 // makes this behave like a filter
 public FilterMC(SnapViewDirector svd, BaseFilter a)
     : base(svd, a)
 {
 }
Esempio n. 16
0
 public CommandStrategy(SnapViewDirector svd)
 {
     invoker  = new CommandInvoker(svd);
     receiver = svd;
 }
Esempio n. 17
0
 public Command(SnapViewDirector svd)
 {
     reciever = svd;
 }
 public CreateTotallingActionCommand(SnapViewDirector svd, string s)
     : base(svd)
 {
     field_name = s;
 }
        // This class heirarchy implements the Factory Method DP
        //  - But the full functionality is not used (i.e., we know the concrete factory classes in the client)
        //  - For the future, the full DP functionality can be utilised by putting creation steps common to all MediatorColleagues in
        //    a base class method (e.g., makeMC) in this class which polymorphically calls derived class createMC methods)
        //  - Then the interface would be makeMC instead of createMC

        public MediatorColleagueFactory(SnapViewDirector the_svd)
        {
            svd = the_svd;
        }
 // Interface for creating ConstraintMC
 public abstract ConstraintMC generate_ConstraintMC(SnapViewDirector svd);
Esempio n. 21
0
 public UpdateIndex_CS(SnapViewDirector svd)
     : base(svd)
 {
 }
Esempio n. 22
0
 public UpdateAllStats_CS(SnapViewDirector svd)
     : base(svd)
 {
 }
Esempio n. 23
0
 public UpdateIndexAndFilter_CS(SnapViewDirector receiver)
     : base(receiver)
 {
 }
Esempio n. 24
0
 public SingleInputMCActionFactory(SnapViewDirector svd)
     : base(svd)
 {
 }
Esempio n. 25
0
 // >>>>>>>>>>> NOTE: because these are made in factories - should this be protected?
 // Explicitly giveing this a BaseConstraint is what makes it
 // a ConstratinMC
 public ConstraintMC(SnapViewDirector svd, BaseConstraint a)
     : base(svd, a)
 {
 }
 public SimpleMCActionFactory(SnapViewDirector svd)
     : base(svd)
 {
 }
Esempio n. 27
0
        public static MediatorColleague create_simple_MC(SnapViewDirector svd, string mc_name, string field_name)
        {
            SimpleMCActionFactory factory = new SimpleMCActionFactory(svd);

            return(factory.createMC(mc_name, new SimpleActionMC_Input(field_name)));
        }
Esempio n. 28
0
        public static MediatorColleague create_doubleInput_MC(SnapViewDirector svd, string mc_name, string field_name, string par1, string par2)
        {
            DoubleInputMCActionFactory factory = new DoubleInputMCActionFactory(svd);

            return(factory.createMC(mc_name, new DoubleInputActionMC_Input(field_name, par1, par2)));
        }
Esempio n. 29
0
 public Filter_CS(SnapViewDirector receiver)
     : base(receiver)
 {
 }
Esempio n. 30
0
 public CreateIndexCommand(SnapViewDirector svd, string s)
     : base(svd)
 {
     field_name = s;
 }