// Set the constant value on this property. public void SetConstant(Object defaultValue) { try { type.StartSync(); FieldBuilder.ValidateConstant(returnType, defaultValue); lock (typeof(AssemblyBuilder)) { FieldBuilder.ClrFieldSetConstant (privateData, defaultValue); } } finally { type.EndSync(); } }
// Set a default constant value for this parameter. public virtual void SetConstant(Object defaultValue) { Type paramType; int position; try { type.StartSync(); position = Position; if (position == 0) { if (method is MethodInfo) { paramType = ((MethodInfo)method).ReturnType; } else { paramType = typeof(void); } } else { paramType = ((method.GetParameters())[position - 1]) .ParameterType; } FieldBuilder.ValidateConstant(paramType, defaultValue); lock (typeof(AssemblyBuilder)) { FieldBuilder.ClrFieldSetConstant (privateData, defaultValue); } } finally { type.EndSync(); } }