예제 #1
0
        /// <summary>
        /// Create a value wrapper that can contain and bind values. The name need to be registred first
        /// </summary>
        /// <param name="prototypeLoader">a prototype loader (could be null)</param>
        /// <param name="prototype">a prototype that could contains this value (could be null)</param>
        /// <param name="name">the name of the type for this value wrapper</param>
        /// <param name="value">the string text for the value for this wrapper</param>
        /// <returns>a loaded value wrapper</returns>
        public IValueWrapper CreateValue(PrototypeLoader prototypeLoader, PrototypeBase prototype, string name, string value)
        {
            var type = PrototypeLoaderAccess.ParameterTypes[name];

            if (type == null)
            {
                throw new KeyNotFoundException("Parameter type '" + name + "' is not registered");
            }

            var parameter = (IValueWrapper)Activator.CreateInstance(type);

            parameter.Name = name;

            parameter.Value  = PrototypeLoaderAccess.ParameterConverter[name].DynamicInvoke(prototypeLoader, prototype, value);
            parameter.Exists = true;

            return(parameter);
        }
예제 #2
0
 /// <summary>
 /// Transform a value string to the target value using the registered conversion functions
 /// </summary>
 /// <param name="prototypeLoader">a prototype loader (could be null)</param>
 /// <param name="prototype">a prototype that could contains this value (could be null)</param>
 /// <param name="name">the name of the type</param>
 /// <param name="value">the string representation</param>
 /// <returns>converted value</returns>
 public object TransformValue(PrototypeLoader prototypeLoader, PrototypeBase prototype, string name, string value)
 {
     return(PrototypeLoaderAccess.ParameterConverter[name].DynamicInvoke(prototypeLoader, prototype, value));
 }
예제 #3
0
 public static void EffectBase(PrototypeLoader pl, PrototypeBase pb, AnimationEffect e, XmlNode node)
 {
     PrototypeLoader.EffectBase(pl, pb, e, node);
 }
예제 #4
0
 public static void SetParameter(PrototypeLoader pl, string value, IValueWrapper target, PrototypeBase current, bool forceref = false, Delegate customConverter = null)
 {
     pl.SetParameter(value, target, current, forceref, customConverter);
 }