Esempio n. 1
0
        private SimpleFieldDescription CreateField(TypeName declaredOn, IReflectField field,
                                                   Func <IReflectClass, ITypeDescription> typeLookUp)
        {
            var fieldType = typeLookUp(field.GetFieldType());

            return(SimpleFieldDescription.Create(field.GetName(),
                                                 fieldType, IndexLookUp(declaredOn, field.GetName(), fieldType.TypeName)));
        }
Esempio n. 2
0
        private static SimpleFieldDescription ToFieldDescription(TypeName declaringType, Type fieldType, string name,
                                                                 IDictionary <Type, ITypeDescription> knownTypes, IndexStateLookup indexLookUp)
        {
            var type = knownTypes.TryGet(fieldType)
                       .GetValue(() => Create(fieldType, knownTypes, new ITypeDescription[0], indexLookUp));

            return(SimpleFieldDescription.Create(name, type, indexLookUp(declaringType, name, type.TypeName)));
        }
Esempio n. 3
0
 private static void AddOptionalProperty(TypeBuilder typeBuilder,
                                         SimpleFieldDescription field,
                                         Type type, FieldInfo generatedField)
 {
     if (char.IsLower(field.Name[0]) || char.IsSymbol(field.Name[0]))
     {
         CreateProperty(typeBuilder, field, type, generatedField);
     }
 }
Esempio n. 4
0
 private static void AddOptionalProperty(TypeBuilder typeBuilder,
     SimpleFieldDescription field,
     Type type, FieldInfo generatedField)
 {
     if (char.IsLower(field.Name[0]) || char.IsSymbol(field.Name[0]))
     {
         CreateProperty(typeBuilder, field, type, generatedField);
     }
 }
Esempio n. 5
0
        private static void CreateProperty(TypeBuilder typeBuilder, SimpleFieldDescription field,
                                           Type type, FieldInfo generatedField)
        {
            var propertyName = field.AsPropertyName();
            var property     = typeBuilder.DefineProperty(propertyName,
                                                          PropertyAttributes.HasDefault,
                                                          type, null);

            property.SetGetMethod(CreateGetter(typeBuilder, propertyName, generatedField));
            property.SetSetMethod(CreateSetter(typeBuilder, propertyName, generatedField));
        }
Esempio n. 6
0
        private static void CreateFields(TypeBuilder typeBuilder, SimpleFieldDescription field,
                                         ModuleBuilder modBuilder,
                                         IDictionary <ITypeDescription, Type> typeBuildMap)
        {
            var type           = GetOrCreateType(typeBuildMap, modBuilder, field.Type);
            var generatedField = typeBuilder.DefineField(field.Name,
                                                         type,
                                                         FieldAttributes.Public);

            AddOptionalProperty(typeBuilder, field, type, generatedField);
        }
Esempio n. 7
0
        private static void CreateProperty(TypeBuilder typeBuilder, SimpleFieldDescription field,
            Type type, FieldInfo generatedField)
        {
            var propertyName = field.AsPropertyName();
            var property = typeBuilder.DefineProperty(propertyName,
                                                      PropertyAttributes.HasDefault,
                                                      type, null);

            property.SetGetMethod(CreateGetter(typeBuilder, propertyName, generatedField));
            property.SetSetMethod(CreateSetter(typeBuilder, propertyName, generatedField));
        }
Esempio n. 8
0
 private static void CreateFields(TypeBuilder typeBuilder, SimpleFieldDescription field,
     ModuleBuilder modBuilder,
     IDictionary<ITypeDescription, Type> typeBuildMap)
 {
     var type = GetOrCreateType(typeBuildMap, modBuilder,field.Type);
     var generatedField = typeBuilder.DefineField(field.Name,
                                                  type,
                                                  FieldAttributes.Public);
     AddOptionalProperty(typeBuilder, field, type, generatedField);
 }