public static void CopyParametersFromWithInnerObjects(this IParametrizedObject @this, IParametrizedObject other)
        {
            Contract.Requires(@this.GetType().Equals(other.GetType()));

            @this.CopyParametersFrom(other);

            foreach (var objectPair
                     in Enumerable.Zip(@this.GetInnerParametrizedObjects(), other.GetInnerParametrizedObjects(), (o1, o2) => new { O1 = o1, O2 = o2 }))
            {
                objectPair.O1.ParametrizedObject.CopyParametersFromWithInnerObjects(objectPair.O2.ParametrizedObject);
            }

            @this.ParametersChanged();
        }
        public static void SetParametersFromSnapshotWithInnerObjects(this IParametrizedObject @this, ParametersSnapshot snapshot)
        {
            @this.SetParametersFromSnapshot(snapshot);

            Dictionary <string, ParametersSnapshot> snapshots = snapshot.InnerSnapshots.ToDictionary(s => s.ParentFieldName, s => s);

            foreach (InnerParametrizedObject io in @this.GetInnerParametrizedObjects())
            {
                if (snapshots.ContainsKey(io.ParentFieldName))
                {
                    io.ParametrizedObject.SetParametersFromSnapshotWithInnerObjects(snapshots[io.ParentFieldName]);
                }
            }

            @this.ParametersChanged();
        }
        public static void SetParametersFromSnapshot(this IParametrizedObject @this, ParametersSnapshot snapshot)
        {
            Dictionary <string, string> parameterValues = snapshot.ParameterValues.ToDictionary(pvp => pvp.Name, pvp => pvp.Value);

            foreach (Parameter parameter in @this.GetParameters())
            {
                if (parameterValues.ContainsKey(parameter.Field.Name))
                {
                    if (parameter.IsEnum)
                    {
                        parameter.SetValue(Enum.Parse(parameter.FieldType, parameterValues[parameter.Field.Name]));
                    }
                    else
                    {
                        parameter.SetValue(Convert.ChangeType(parameterValues[parameter.Field.Name], parameter.FieldType, CultureInfo.InvariantCulture));
                    }
                }
            }

            @this.ParametersChanged();
        }