/// <summary>
        /// Builds an Instruction using the information stored in the InstructionBlueprint.
        /// </summary>
        /// <param name="target">The object that the returned Instruction will execute on</param>
        /// <param name="currentTime">The current time to use as an offset for the Instruction's Time of execution</param>
        /// <throws exception="ArgumentException">If target's type is not this InstructionBlueprint's TargetType</throws>
        /// <throws exception="NullReferenceException">If this InstructionBlueprint was fully initialized before this call to BuildInstruction.</throws>
        /// <returns>An Instruction created from this InstructionBlueprint's information</returns>
        #endregion
        public GenericInstruction BuildInstruction(object target, double currentTime)
        {
            GenericInstruction toReturn;


            //Make sure the target is a compatible type
#if WINDOWS_8
            if (!TargetType.GetTypeInfo().IsAssignableFrom(target.GetType().GetTypeInfo()))
#else
            if (!TargetType.IsInstanceOfType(target))
#endif
            {
                throw new ArgumentException("This InstructionBlueprint's TargetType is " + TargetType + " and doesn't match the argument's type, " +
                                            target.GetType());
            }
            else if (String.IsNullOrEmpty(MemberName) || MemberType == null)
            {
                throw new NullReferenceException("The InstructionBlueprint " + " has not been fully initialized and therefore cannot be made into an Instruction.");
            }
            else
            {
                mFourObjectArray[0] = target;
                mFourObjectArray[1] = MemberName;
                mFourObjectArray[2] = MemberValue;
                mFourObjectArray[3] = Time + currentTime;

                toReturn = mCurrentConstructor.Invoke(mFourObjectArray) as GenericInstruction;
            }
            return(toReturn);
        }
Beispiel #2
0
 internal void CheckType(IRegistrable registrable)
 {
     if (registrable == null)
     {
         throw new ArgumentNullException(nameof(registrable));
     }
     if (!TargetType.IsInstanceOfType(registrable))
     {
         throw new ArgumentException($"type not match, required: {TargetType}, given: {registrable.GetType()}");
     }
 }
Beispiel #3
0
        void IAttachedObject.AttachTo(BindableObject bindable)
        {
            IsSealed = true;

            if (bindable == null)
            {
                throw new ArgumentNullException("bindable");
            }
            if (!TargetType.IsInstanceOfType(bindable))
            {
                throw new InvalidOperationException("bindable not an instance of AssociatedType");
            }
            OnAttachedTo(bindable);
        }
Beispiel #4
0
 public virtual bool CanSetValue(object value)
 {
     return
         (TargetType.IsValueType && value != null && TargetType.IsInstanceOfType(value) ||
          !TargetType.IsValueType && (value == null || TargetType.IsInstanceOfType(value)));
 }