private static MaterialParameterSetter CreateSetter(EffectParameter parameter) { if (string.IsNullOrEmpty(parameter.Semantic)) return null; var parameterType = new ParameterType(parameter.ParameterType, parameter.ColumnCount, parameter.RowCount); Type type; if (!ParameterTypeMappings.TryGetValue(parameterType, out type)) { #if WINDOWS Trace.TraceWarning("An automatic setter could not be created for the Material parameter \"{0}\", with semantic \"{1}\".", parameter.Name, parameter.Semantic); #endif } Debug.Assert(type != null, "type != null"); var typeName = type.Name; if (parameter.Elements.Count > 0) typeName += "[]"; Type setterType; if (_setterTypeMappings.TryGetValue(typeName, out setterType)) return Activator.CreateInstance(setterType, parameter) as MaterialParameterSetter; else return null; }
public bool Equals(ParameterType obj) { return Type == obj.Type && Rows == obj.Rows && Columns == obj.Columns; }
private static MaterialParameterSetter CreateSetter(EffectParameter parameter) { if (string.IsNullOrEmpty(parameter.Semantic)) return null; var parameterType = new ParameterType(parameter.ParameterType, parameter.ColumnCount, parameter.RowCount); Type type; if (!ParameterTypeMappings.TryGetValue(parameterType, out type)) throw new InvalidOperationException(string.Format("An automatic setter could not be created for the Material parameter \"{0}\", with semantic \"{1}\".", parameter.Name, parameter.Semantic)); var typeName = type.Name; if (parameter.Elements.Count > 0) typeName += "[]"; Type setterType; if (_setterTypeMappings.TryGetValue(typeName, out setterType)) return Activator.CreateInstance(setterType, parameter) as MaterialParameterSetter; else return null; }