Mono.CSharp.TypeManager.GetPredefinedProperty C# (CSharp) Method

GetPredefinedProperty() public static method

public static GetPredefinedProperty ( System.TypeSpec t, string name, Mono.CSharp.Location loc, System.TypeSpec type ) : PropertySpec
t System.TypeSpec
name string
loc Mono.CSharp.Location
type System.TypeSpec
return PropertySpec
	public static PropertySpec GetPredefinedProperty (TypeSpec t, string name, Location loc, TypeSpec type)
	{
		return GetPredefinedMember (t, MemberFilter.Property (name, type), false, loc) as PropertySpec;
	}

Usage Example

Example #1
0
        public override void Emit(TypeContainer tc)
        {
            base.Emit(tc);

            if (has_extension_method)
            {
                PredefinedAttributes.Get.Extension.EmitAttribute(Builder);
            }

            // FIXME: Does this belong inside SRE.AssemblyBuilder instead?
            PredefinedAttribute pa = PredefinedAttributes.Get.RuntimeCompatibility;

            if (pa.IsDefined && (OptAttributes == null || !OptAttributes.Contains(pa)))
            {
                ConstructorInfo ci = TypeManager.GetPredefinedConstructor(
                    pa.Type, Location.Null, Type.EmptyTypes);
                PropertyInfo [] pis = new PropertyInfo [1];
                pis [0] = TypeManager.GetPredefinedProperty(pa.Type,
                                                            "WrapNonExceptionThrows", Location.Null, TypeManager.bool_type);
                object [] pargs = new object [1];
                pargs [0] = true;
                Builder.SetCustomAttribute(new CustomAttributeBuilder(ci, new object [0], pis, pargs));
            }

            if (declarative_security != null)
            {
                MethodInfo add_permission   = typeof(AssemblyBuilder).GetMethod("AddPermissionRequests", BindingFlags.Instance | BindingFlags.NonPublic);
                object     builder_instance = Builder;

                try {
                    // Microsoft runtime hacking
                    if (add_permission == null)
                    {
                        Type assembly_builder = typeof(AssemblyBuilder).Assembly.GetType("System.Reflection.Emit.AssemblyBuilderData");
                        add_permission = assembly_builder.GetMethod("AddPermissionRequests", BindingFlags.Instance | BindingFlags.NonPublic);

                        FieldInfo fi = typeof(AssemblyBuilder).GetField("m_assemblyData", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
                        builder_instance = fi.GetValue(Builder);
                    }

                    object[] args = new object [] { declarative_security [SecurityAction.RequestMinimum],
                                                    declarative_security [SecurityAction.RequestOptional],
                                                    declarative_security [SecurityAction.RequestRefuse] };
                    add_permission.Invoke(builder_instance, args);
                }
                catch {
                    Report.RuntimeMissingSupport(Location.Null, "assembly permission setting");
                }
            }
        }