/// <summary> /// Attempts to create a distribution's constructor. If the constructor /// parameter's aren't valid, this method fails and returns false. /// </summary> /// /// <param name="info">The constructor's reflection information.</param> /// <param name="distribution">The distribution that owns this constructor.</param> /// <param name="constructor">The created distribution constructor.</param> /// /// <returns>True if the constructor could be created; false otherwise.</returns> /// public static bool TryParse(ConstructorInfo info, DistributionViewModel distribution, out ConstructorViewModel constructor) { constructor = new ConstructorViewModel(info, distribution); foreach (var param in info.GetParameters()) { ParameterViewModel viewModel; if (!ParameterViewModel.TryParse(param, constructor, out viewModel)) { return(false); } constructor.Parameters.Add(viewModel); } return(true); }
/// <summary> /// Attempts to create a constructor's parameter. If the parameter doesn't /// qualify as a valid parameter to be used in the automatic distribution /// construction, the method fails and returns false. /// </summary> /// /// <param name="info">The parameter's reflection information.</param> /// <param name="owner">The constructor that should own this parameter.</param> /// <param name="parameter">The created distribution parameter.</param> /// /// <returns>True if the parameter could be created; false otherwise.</returns> /// public static bool TryParse(ParameterInfo info, ConstructorViewModel owner, out ParameterViewModel parameter) { parameter = null; DoubleRange range; if (!DistributionManager.TryGetRange(info, out range)) { return(false); } double value; if (!DistributionManager.TryGetDefault(info, out value)) { return(false); } parameter = new ParameterViewModel(info, owner, range, value); return(true); }
/// <summary> /// Attempts to create a constructor's parameter. If the parameter doesn't /// qualify as a valid parameter to be used in the automatic distribution /// construction, the method fails and returns false. /// </summary> /// /// <param name="info">The parameter's reflection information.</param> /// <param name="owner">The constructor that should own this parameter.</param> /// <param name="parameter">The created distribution parameter.</param> /// /// <returns>True if the parameter could be created; false otherwise.</returns> /// public static bool TryParse(ParameterInfo info, ConstructorViewModel owner, out ParameterViewModel parameter) { parameter = null; DoubleRange range; if (!DistributionManager.TryGetRange(info, out range)) return false; double value; if (!DistributionManager.TryGetDefault(info, out value)) return false; parameter = new ParameterViewModel(info, owner, range, value); return true; }