public ModifierType[] GetModifiersOn <ModifierType>(IModifiable modifiable) where ModifierType : IModifier
        {
            ModifierMap         modifiers    = FindOrCreateModifierDictionary(modifiable);
            List <ModifierType> modifierList = FindOrCreateModifierList(modifiers, typeof(ModifierType)) as List <ModifierType>;

            return(modifierList.ToArray());
        }
Пример #2
0
 public override bool SetValue(IModifiable source, string input, out string validationError)
 {
     validationError = null;
     //TODO: Add validations for this.
     Setter(source, input);
     return(true);
 }
Пример #3
0
        /// <summary>
        /// An immediate identity insert with identity_insert on just for this single entity, unless queued is true.  Queued identity insert entities are inserted if nothing given.
        /// </summary>
        /// <param name="sqlEntity"></param>
        public void IdentityInsert(TSqlEntity sqlEntity = null, Boolean queued = false)
        {
            if (sqlEntity == null)
            {
                FlushIdentityInserts();
                return;
            }

            // Queue identity insert...
            IModifiable modifiableEntity = sqlEntity as IModifiable;

            if (modifiableEntity != null)
            {
                modifiableEntity.CreatedDate  = NowDateTime;
                modifiableEntity.ModifiedDate = NowDateTime;
            }
            else if (sqlEntity is ICreatable)
            {
                ((ICreatable)sqlEntity).CreatedDate = NowDateTime;
            }
            var insertColumns = $"{GetIdentityInsertColumns()},{InsertColumns()}";
            var insertValues  = $"{GetIdentityInsertValues(sqlEntity)},{GetInsertValues(sqlEntity)}";

            QueuedIdentityInserts.Append(QueueIdentityInsertColumnsPattern.FormatX(TableName, insertColumns, insertValues));

            if (!queued)
            {
                FlushIdentityInserts();
            }
        }
Пример #4
0
        public ModifierType[] GetModifiersOn <ModifierType>(IModifiable modifiable) where ModifierType : class, IModifier
        {
            ModifierMap  modifiers    = FindOrCreateModifierDictionary(modifiable);
            ModifierList modifierList = FindOrCreateModifierList(modifiers, typeof(ModifierType));

            return(Convert <ModifierType>(modifierList));
        }
Пример #5
0
 public void Unregister(IModifiable source)
 {
     _damage.Unregister(source);
     _interval.Unregister(source);
     _range.Unregister(source);
     _attacksPerInterval.Unregister(source);
 }
Пример #6
0
 public void Modify(IModifiable modifiable)
 {
     if (invitee.CanInvite)
     {
         modifiable.AddValue("actions", new Action("invite", "/invitations/invite/"));
     }
 }
Пример #7
0
 private void Awake()
 {
     if (targetComponent)
     {
         target = targetComponent;
     }
 }
Пример #8
0
 public AccessorInfo(AccessorDeclarationSyntax decl, IModifiable parent)
 {
     _modifiers = decl.Modifiers.ParseModifiers()
                  .WithDefaultVisibility(parent.Modifiers.First());
     Type = decl.Keyword.ToString().StartsWith("get") ?
            AccessorType.Getter : AccessorType.Setter;
 }
Пример #9
0
 /// <summary>
 /// SaveNewCar method
 /// </summary>
 /// <remarks>
 /// Save the new modified vehicle in file
 /// </remarks>
 /// <param name="imb">The new modified vehicle</param>
 public void SaveNewCar(IModifiable imb)
 {
     this.imb = imb;
     modlist.Add(imb);
     modlist.ReadFromFile(false);
     modlist.SaveInFile(false);
 }
Пример #10
0
        public void Remove(IModifiable modifiable, IModifier modifier)
        {
            ModifierMap      modifiers    = FindOrCreateModifierDictionary(modifiable);
            List <IModifier> modifierList = FindOrCreateModifierList(modifiers, modifier.ModifierType);

            modifierList.Remove(modifier);
        }
Пример #11
0
 /// <summary>
 /// Appliance of <see cref="IModifiable"/>'s <see cref="IModifier"/>s
 /// </summary>
 /// <param name="modifiable"></param>
 public static void Apply(IModifiable modifiable)
 {
     modifiable.DefaultModifier.Apply(modifiable);
     foreach (var modifier in modifiable.Modifiers)
     {
         modifier.Apply(modifiable);
     }
 }
Пример #12
0
        /// <summary>
        /// Final method.
        /// </summary>
        /// <remarks>
        /// The main method of that class that initialize the components in the form.
        /// </remarks>
        /// <param name="imb">The modifiable vehicle.</param>
        public Final(IModifiable imb)
        {
            InitializeComponent();
            this.FormClosing += ThisForm_FormClosing; //check if the red "X" is pressed
            ShowAllModifiedVehicles(imb);

            
        }
        public void Init()
        {
            modifier   = Substitute.For <IModifier>();
            modifiable = Substitute.For <IModifiable>();

            modifier.ModifierType.Returns(typeof(IModifier));

            activeModifications = new ActiveModifications();
        }
Пример #14
0
        /// <summary>
        /// Sets modified time property.
        /// </summary>
        /// <param name="entity">Entity.</param>
        public static void SetModifiedTime(this IModifiable entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            entity.ModifiedTime = SharedLib.InternalDate.Now;
        }
Пример #15
0
 /// <summary>
 /// Modify method.
 /// </summary>
 /// <remarks>
 /// The main method of that class that initialize the components in the form.
 /// </remarks>
 /// <param name="iVehicle">The selected vehicle from the previos form</param>
 /// <param name="modList">List with all stock vehicles</param>
 /// <param name="sName">The name of the user (buyer)</param>
 /// <param name="cBudget">The budget of the user</param>
 public Modify(int iVehicle, ModifiableList modList, string sName, Budget cBudget)
 {
     InitializeComponent();
     this.FormClosing += ThisForm_FormClosing; //check if the red "X" is pressed
     Debug.WriteLine("ListSize() in Modify: " + modList.ListSize()); // the size of the list in this form
     imb = modList.GetObjectFromList(iVehicle);
     this.sName = sName;
     this.cBudget = cBudget;
     Modify_Load();
 }
Пример #16
0
        public void Initialize(ModifierParameters p, Game game)
        {
            Game         = game;
            SourceCard   = p.SourceCard;
            SourceEffect = p.SourceEffect;
            Owner        = p.Owner;
            X            = p.X;

            InitializeLifetimes(p.IsStatic);
            Initialize();
        }
        public virtual void SetValue(object value)
        {
            IModifiable modifiable = this.GetModifiable();

            if (modifiable == null)
            {
                return;
            }

            modifiable.SetValue(value);
        }
Пример #18
0
        /// <inheritdoc />
        public override void OnAttach(IModifiable modifiable)
        {
            base.OnAttach(modifiable);
            if (modifiable is ModifiableValue <T> )
            {
                return;
            }

            Debug.LogError($"Trying to attach {this} with type {TargetType} to {modifiable} which is incompatible. Expected ModifiableValue<{TargetType}>");
            Detach();
        }
        public virtual void SetValue <TValue>(TValue value)
        {
            IModifiable modifiable = this.GetModifiable();

            if (modifiable == null)
            {
                return;
            }

            modifiable.SetValue <TValue>(value);
        }
Пример #20
0
        ModifierMap FindOrCreateModifierDictionary(IModifiable modifiable)
        {
            ModifierMap modifiers;

            if (!activeModifications.TryGetValue(modifiable, out modifiers))
            {
                modifiers = new ModifierMap();
                activeModifications.Add(modifiable, modifiers);
            }

            return(modifiers);
        }
Пример #21
0
        /// <summary>
        /// Sets the parent then calls <see cref="OnAttach"/>
        /// </summary>
        /// <param name="modifiable">the modifiable attached to</param>
        internal void OnAttach_Internal(IModifiable modifiable)
        {
            Debug.Log($"{Duration}");
            Parent = modifiable;

            if (!(Duration > 0))
            {
                return;
            }

            Task.Delay(Mathf.RoundToInt(Duration * 1000)).ContinueWith(t => Detach());
        }
Пример #22
0
        public IModifier[] GetModifiersOn(IModifiable modifiable)
        {
            ModifierMap      modifiers    = FindOrCreateModifierDictionary(modifiable);
            List <IModifier> modifierList = new List <IModifier>();

            foreach (var modifierTypeList in modifiers)
            {
                modifierList.AddRange(modifierTypeList.Value);
            }

            return(modifierList.ToArray());
        }
Пример #23
0
 // create an instance, bound to the given text box, using the given parser
 // to set the given property.
 public TextBinding(TextBox box, Parser <D> parser, string propertyName, IModifiable notify)
 {
     Parse = parser;
     Info  = typeof(T).GetProperty(propertyName);
     if (Info == null)
     {
         throw new ArgumentException(string.Format("property {0} not valid", propertyName));
     }
     TextBox            = box;
     box.LostFocus     += delegate(object sender, EventArgs args) { SetValue(); };
     box.Validating    += Validator;
     NotificationTarget = notify;
 }
Пример #24
0
 public AdminModifyField(StandardHeldPrompt previous, Client client, IModifiable target, ModifiableParser parser) : base(previous, null, client)
 {
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     if (parser == null)
     {
         throw new ArgumentNullException("parser");
     }
     objectToModify = target;
     fieldParser    = parser;
 }
Пример #25
0
        public ShapeRadioButtonBinding(RadioButton button, int shape, IModifiable toNotify)
        {
            Button       = button;
            Shape        = shape;
            NotifyTarget = toNotify;

            Button.Click += new EventHandler(delegate(object sender, EventArgs args) { if (Line != null && Line.Shape != Shape)
                                                                                       {
                                                                                           Line.Shape = Shape;
                                                                                           NotifyTarget.SetModified(true);
                                                                                       }
                                             });
        }
Пример #26
0
        public override string GetValue(IModifiable source)
        {
            ISaveable value = Getter(source);

            if (value == null)
            {
                return("null");
            }
            else
            {
                return(value.GetType().Name + " " + value.GetSaveID());
            }
        }
Пример #27
0
        public override bool SetValue(IModifiable source, string input, out string validationError)
        {
            //CanBeNull is false, so input should never be null.
            int value;

            if (int.TryParse(input, out value))
            {
                Setter(source, value);
                validationError = null;
                return(true);
            }
            validationError = "Not a valid number.";
            return(false);
        }
        public void GetModifiersOn_Pass()
        {
            Init();

            IModifiable modifiable2 = Substitute.For <IModifiable>();
            IModifier   modifier2   = Substitute.For <IModifier>();

            modifier2.ModifierType.Returns(typeof(IModifier));

            activeModifications.Add(modifiable, modifier);
            activeModifications.Add(modifiable2, modifier2);

            Assert.AreSame(modifier2, activeModifications.GetModifiersOn(modifiable2)[0]);
        }
Пример #29
0
        /// <summary>
        /// ShowAllModifiedVehicles method.
        /// </summary>
        /// <remarks>
        /// Save the last modified vehicles in a file and then read all the saved vehicles 
        /// and show them on the screen.
        /// </remarks>
        /// <param name="imb"></param>
        private void ShowAllModifiedVehicles(IModifiable imb)
        {
            //save the last modivified vehicle
            autoshow.SaveNewCar(imb); 
            modlist = autoshow.ShowAll();

            //get each object in that list
            for (int i = 0; i < modlist.ListSize(); i++)        
            {
                imb = modlist.GetObjectFromList(i);
                //print the object in textbox.
                txtHistory.AppendText(imb.ToString());
                txtHistory.AppendText(Environment.NewLine);

            }

        }
Пример #30
0
        public IEnumerator ResetLifetimeTestPass()
        {
            DateTime modificationTime = DateTime.UtcNow;
            TimeSpan elapsedTime      = new TimeSpan(0);
            float    lifetime         = 2;

            IModifiable                 modifiable     = Substitute.For <IModifiable>();
            Modifier <IModifiable>      simpleModifier = Substitute.For <Modifier <IModifiable> >();
            AliveModifier <IModifiable> aliveModifier  = new AliveModifier <IModifiable>(simpleModifier, lifetime);

            //Setup When...Do for modifier
            simpleModifier.
            When(modifier => modifier.Modify(modifiable)).
            Do(modifier => modifiable.OnModificationApplied(simpleModifier));

            simpleModifier.
            When(modifier => modifier.Revert(modifiable)).
            Do(modifier => modifiable.OnModificationReverted(simpleModifier));

            //Setup When...Do for modifiable
            modifiable.
            When(spyModifiable => spyModifiable.OnModificationApplied(simpleModifier)).
            Do(spyModifiable => modificationTime = DateTime.UtcNow);

            modifiable.
            When(spyModifiable => spyModifiable.OnModificationReverted(simpleModifier)).
            Do(spyModifiable => elapsedTime = DateTime.UtcNow.Subtract(modificationTime));

            aliveModifier.Modify(modifiable);

            yield return(new WaitForSeconds(lifetime - 1));

            aliveModifier.Reset();
            modificationTime = DateTime.UtcNow;

            yield return(new WaitForSeconds(lifetime - 1));

            Assert.Zero(elapsedTime.Seconds);

            yield return(new WaitForSeconds(lifetime));

            Assert.NotZero(elapsedTime.Seconds);

            Assert.Greater(elapsedTime.TotalSeconds, lifetime);
        }
Пример #31
0
        /// <summary>
        /// cmbVehicleType_SelectedIndexChanged method
        /// </summary>
        /// <remarks>
        /// Method that is called everytime when the user choose different type of vehicle.
        /// It's finding all objects of the selected type and put them in dropdown menu.
        /// </remarks>
        /// <param name="sender">A reference to the control/object that raised the event.</param>
        /// <param name="e">The event data.</param>
        private void cmbVehicleType_SelectedIndexChanged(object sender, EventArgs e)
        {
            Debug.WriteLine("Selected vehicle is: " + Convert.ToString(cmbVehicleType.Text)); // check the selected item        
            cmbVehicleModel.Items.Clear(); //clear the second combobox
            lblModel.Visible = true;
            cmbVehicleModel.Visible = true;

            for (int i = 0; i < modlist.ListSize(); i++)        //get each object in that list
            {
                imb = modlist.GetObjectFromList(i); 
                string strSelectedType = Convert.ToString(imb.GetType());  // the type of the returned object

                if (strSelectedType == "VehicleTuning." + cmbVehicleType.Text) //check if the returned object is from the same type as the selected one
                { 
                    cmbVehicleModel.Items.Add(imb.Model.ToString());
                    iSelectedObject = i;
                }
            }
        }
Пример #32
0
        public AdminSelectModify(StandardHeldPrompt previous, Client client, IModifiable target) : base(previous, null, client)
        {
            objectToModify = target;
            Metadata meta = Metadata.LoadedClasses[target.GetType()];

            ModifiableParser[] parsers = meta.GetModifyParsers();
            string             quit    = "Quit";

            foreach (ModifiableParser parser in parsers)
            {
                string parserName = parser.Name(target);
                if (parserName.Equals(quit, StringComparison.InvariantCultureIgnoreCase))
                {
                    parserName = "Field" + parserName;
                }
                AddOption(parser.Description(target), ModifyField, parser, parserName);
            }
            AddOption("Finished editing this object.", EndThisPromptOption, null, quit);
        }
Пример #33
0
        private void SetSourceValue <T>(IModifiable modifier, T value)
        {
            if (this.converter == null && typeof(T).Equals(this.sourceProxy.Type))
            {
                modifier.SetValue(value);
                return;
            }

            object safeValue = value;

            if (this.converter != null)
            {
                safeValue = this.converter.ConvertBack(safeValue);
            }

            safeValue = this.sourceProxy.Type.ToSafe(safeValue);

            modifier.SetValue(safeValue);
        }
Пример #34
0
        public void ModifiableModificationMade_Pass()
        {
            IModifiable            modifiable = Substitute.For <IModifiable>();
            Modifier <IModifiable> modifier   = Substitute.For <Modifier <IModifiable> >();

            bool isModifiableModified = false;

            modifiable.
            When(spyModifiable => spyModifiable.OnModificationApplied(modifier)).
            Do(spyModifiable => isModifiableModified = true);

            modifier.
            When(spyModifier => spyModifier.Modify(modifiable)).
            Do(spyModifier => modifiable.OnModificationApplied(modifier));


            modifier.Modify(modifiable);

            Assert.IsTrue(isModifiableModified);
        }
Пример #35
0
        //public virtual Boolean Exists(String filter = "", SqlParameter[] filterParameters = null, String selectColumns = null)
        //{
        //	selectColumns = selectColumns ?? SelectAllColumns();
        //	return SelectQuery(selectColumns, filter, filterParameters, null, new Paging(1)).HasRows;
        //}

        public void Insert(TSqlEntity sqlEntity)
        {
            if (SaveChangesTransactionally)
            {
                Context.BeginTransaction();
            }

            IModifiable modifiableEntity = sqlEntity as IModifiable;

            if (modifiableEntity != null)
            {
                modifiableEntity.CreatedDate  = NowDateTime;
                modifiableEntity.ModifiedDate = NowDateTime;
            }
            else if (sqlEntity is ICreatable)
            {
                ((ICreatable)sqlEntity).CreatedDate = NowDateTime;
            }

            InsertCore(sqlEntity, InsertColumns(), GetInsertValues(sqlEntity));
        }
        public override bool MouseUpHandler(object sender, ActionEventArgs e)
        {
            if (Modiafiable is ISelectable && Modiafiable != null)
            {
                try
                {
                   // ExecuteMoveCommand();
                }
                catch { }
                ((ISelectable)Modiafiable).IsSelected = false;
                c1 = null; c2 = null; diff = null; Modiafiable = null;

                _presenter.NotifyViews();
            }
            return true;
        }
Пример #37
0
        /// <summary>
        /// cmbVehicleModel_SelectedIndexChanged method
        /// </summary>
        /// <remarks>
        /// Method that is called everytime when the user choose different model of curent type of vehicle.
        /// It save the number of the selected method and print it's price.
        /// </remarks>
        /// <param name="sender">A reference to the control/object that raised the event.</param>
        /// <param name="e">The event data.</param>
        private void cmbVehicleModel_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < modlist.ListSize(); i++)        //get each object in that list
            {
                imb = modlist.GetObjectFromList(i);
                string strSelectedType = Convert.ToString(imb.Model);  // the type of the returned object

                if (strSelectedType == cmbVehicleModel.Text) //check if the returned object is from the same type as the selected one
                {
                    iSelectedObject = i;
                    Debug.WriteLine("Selected model is: " + imb.Model.ToString());
                    lblPrice.Text = "The price of this vehicle is: " + imb.Price.ToString();
                    break;
                }
            }

        }
Пример #38
0
 /// <summary>
 /// Add method.
 /// </summary>
 /// <remarks>
 /// Add new object of type IModifiable to the list.
 /// </remarks>
 /// <param name="mod"> The new vehicle that should be added into the list</param>
 public void Add(IModifiable mod) {
     vehicles.Add(mod);
 }
        protected override bool DoObjectSelection(object _object)
        {
            if (_object is IModifiable)
            {
                if (Modiafiable == null)
                {

                    Modiafiable = _object as IModifiable;
                    if (_object is ISelectable)
                        ((ISelectable)_object).IsSelected = true;
                }

            }
            return false;
        }