Esempio n. 1
0
        public static void CopyValuesFrom(IFunction source, IFunction target)
        {
            if (source.Arguments.Count != target.Arguments.Count)
            {
                throw new ArgumentException("Number of arguments in source and target do not match.", "source");
            }
            if (source.Components.Count != target.Components.Count)
            {
                throw new ArgumentException("Number of components in source and target do not match.", "source");
            }
            if (source.Arguments.Count != 1)
            {
                throw new ArgumentException("only support for 1 argument.", "source");
            }
            target.Clear();
            target.Arguments[0].SetValues(source.Arguments[0].Values);
            var values = source.Arguments[0].Values;

            foreach (var value in values)
            {
                // How to do this more efficient?
                for (int i = 0; i < source.Components.Count; i++)
                {
                    target.Components[i][value] = source.Components[i][value];
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Clear a function ; using it for rewriting a function to prevent changes of calling functions
 /// </summary>
 /// <param name="f">function</param>
 public static void ClearMethod(IFunction f)
 {
     f.Clear();
 }