Ejemplo n.º 1
0
 private MethodAttributes QueryPropertyAccessRights(TypeBuilder parentNS)
 {
     if (alwaysInstanceMethod)
     {
         return(CodeGenerationUtils.PublicGetter());
     }
     return(parentNS == rootType?CodeGenerationUtils.StaticPublicGetter() : CodeGenerationUtils.PublicGetter());
 }
Ejemplo n.º 2
0
        private void CreateMetaDataStructure(IEnumerable <ByNameGrouping> typesGroupesByName)
        {
            var metaInfoType = CreateMetaInfoProperty(typesGroupesByName);
            var constructorOfMetaInfoType = metaInfoType.GetConstructors().Single();

            var property = CodeGenerationUtils.DefineProperty(rootType, MetaDataProperty, metaInfoType);

            var getterMethod = CodeGenerationUtils.GetterMethodFor(rootType, property, CodeGenerationUtils.StaticPublicGetter());
            var lambda       = Expression.Lambda(typeof(Func <>).MakeGenericType(metaInfoType),
                                                 Expression.New(constructorOfMetaInfoType), new ParameterExpression[0]);

            lambda.CompileToMethod(getterMethod);
        }