public DelegateParameterArrayBinding <T> Set <T>(EffectParameter parameter, Action <DelegateParameterArrayBinding <T>, RenderContext, T[]> computeParameter) { DelegateParameterArrayBinding <T> binding; int index = ParameterBindings.IndexOf(parameter); if (index >= 0) { // An effect parameter binding already exists. binding = ParameterBindings[index] as DelegateParameterArrayBinding <T>; if (binding != null) { // Update existing binding. binding.ComputeParameter = computeParameter; } else { // Replace existing binding. binding = new DelegateParameterArrayBinding <T>(Effect, parameter, computeParameter); ParameterBindings[index] = binding; } } else { // Create a new binding. binding = new DelegateParameterArrayBinding <T>(Effect, parameter, computeParameter); CheckHint(binding); ParameterBindings.Add(binding); } return(binding); }
/// <summary> /// Sets a <see cref="ConstParameterArrayBinding{T}"/> for the specified effect parameter. /// </summary> /// <typeparam name="T"> /// The value type. See <see cref="EffectParameterArrayBinding{T}"/>. /// </typeparam> /// <param name="parameter"> /// The effect parameter to which the binding is applied. /// </param> /// <param name="values">The array of values.</param> /// <returns>The <see cref="ConstParameterArrayBinding{T}"/> that has been set.</returns> /// <remarks> /// If an appropriate effect parameter binding for <paramref name="parameter"/> already exists, /// then the existing binding is updated. /// </remarks> /// <exception cref="ArgumentNullException"> /// <paramref name="parameter"/> is <see langword="null"/>. /// </exception> /// <exception cref="EffectBindingException"> /// The value type <typeparamref name="T"/> is not supported. /// </exception> public ConstParameterArrayBinding <T> Set <T>(EffectParameter parameter, T[] values) { ConstParameterArrayBinding <T> binding; int index = ParameterBindings.IndexOf(parameter); if (index >= 0) { // An effect parameter binding already exists. binding = ParameterBindings[index] as ConstParameterArrayBinding <T>; if (binding != null) { // Update existing binding. binding.Values = values; } else { // Replace existing binding. binding = new ConstParameterArrayBinding <T>(Effect, parameter, values); ParameterBindings[index] = binding; } } else { // Create a new binding. binding = new ConstParameterArrayBinding <T>(Effect, parameter, values); CheckHint(binding); ParameterBindings.Add(binding); } return(binding); }