Example #1
0
        // map value indices to actual values and create a Variation
        private static Variation IndicesToVariation(Model model, IList <int> indices)
        {
            Variation v = new Variation();

            for (int i = 0; i < indices.Count; i++)
            {
                v.Add(model.Parameters[i].Name, model.Parameters[i][indices[i]]);
            }

            return(v);
        }
Example #2
0
        // map value indices to actual values and create a Variation
        private static Variation IndicesToVariation <T>(Model <T> model, VariationIndexTagPair pair) where T : new ()
        {
            Variation v = new Variation(pair.Tag);

            for (int i = 0; i < pair.Indices.Length; i++)
            {
                var value = model.Parameters[i].GetAt(pair.Indices[i]) is ParameterValueBase ?
                            ((ParameterValueBase)model.Parameters[i].GetAt(pair.Indices[i])).GetValue() : model.Parameters[i].GetAt(pair.Indices[i]);
                v.Add(model.Parameters[i].Name, value);
            }

            return(v);
        }
Example #3
0
        // map value indices to actual values and create a Variation
        private static Variation IndicesToVariation(Model model, VariationIndexTagPair pair)
        {
            Variation v = new Variation(pair.Tag);

            for (int i = 0; i < pair.Indices.Length; i++)
            {
                var value = model.Parameters[i][pair.Indices[i]] is ParameterValue ?
                            ((ParameterValue)model.Parameters[i][pair.Indices[i]]).Value : model.Parameters[i][pair.Indices[i]];
                v.Add(model.Parameters[i].Name, value);
            }

            return(v);
        }
Example #4
0
        /// <summary>
        /// Initializes a single object from a variation.
        /// </summary>
        /// <param name="variation">The source variation.</param>
        /// <returns>The initialized object.</returns>
        public T AssignParameterValues(Variation variation)
        {
            T value = new T();

            foreach (string parameterName in variation.Keys)
            {
                if (propertiesMap.ContainsKey(parameterName))
                {
                    PropertyInfo propertyInfo = propertiesMap[parameterName];
                    propertyInfo.SetValue(value, variation[parameterName], null);
                }
            }
            return(value);
        }
Example #5
0
 /// <summary>
 /// Returns the value of this parameter in this variation.
 /// </summary>
 /// <param name="v">The variation.</param>
 /// <returns>The value.</returns>
 public T GetValue(Variation v)
 {
     return((T)v[Name]);
 }