Ejemplo n.º 1
0
        private TypeMember ReadAndRegisterMember(Type clrType, int distance)
        {
            var builder = new TypeMemberBuilder();
            var reader  = new ClrTypeReader(clrType, builder, resolver: this, distance);

            _typeMemberByClrType.Add(clrType, builder.GetTemporaryProxy().GetRef());

            if (distance == 0)
            {
                reader.ReadAll();
            }
            else
            {
                reader.ReadNameOnly();
            }

            var finalMember = new RealTypeMember(builder);

            builder.GetMemberSelfReference().Reassign(finalMember);

            return(finalMember);
        }
Ejemplo n.º 2
0
            public static TypeMember BuildType(TypeMemberKind typeKind, string name, Action body)
            {
                var context           = GetContextOrThrow();
                var modifiers         = context.PopStateOrThrow <MemberModifierState>();
                var namespaceState    = context.TryLookupState <NamespaceState>();
                var containingTypeRef = context.TryLookupState <MemberRef <TypeMember> >();

                var builder = new TypeMemberBuilder();

                builder.Namespace     = namespaceState?.Name;
                builder.Name          = name;
                builder.TypeKind      = typeKind;
                builder.DeclaringType = containingTypeRef;

                using (context.PushState(builder.UnderlyingType))
                {
                    body?.Invoke();
                }

                var finalMember = new RealTypeMember(builder);

                builder.GetMemberSelfReference().Reassign(finalMember);
                return(finalMember);
            }