コード例 #1
0
        private IStructProperty <StructProxy> VisitType(
            ITypedMemberDescriptor d,
            TypeTreeParsingContext context)
        {
            Type memberType = d.GetMemberType();

            if (!typeof(IComponentData).IsAssignableFrom(memberType))
            {
                if (memberType.IsEnum)
                {
                    // Same hack as below
                    // TODO: this is a hack until we have code gen
                    var propertyType = typeof(EnumPrimitiveProperty <>).MakeGenericType(memberType);
                    return((IStructProperty <StructProxy>)Activator.CreateInstance(propertyType, d));
                }

                if (PrimitiveTypes.Contains(d.GetMemberType()))
                {
                    var propertyType = typeof(PrimitiveStructProperty <>).MakeGenericType(memberType);
                    return((IStructProperty <StructProxy>)Activator.CreateInstance(propertyType, d));
                }

                if (memberType.IsPrimitive)
                {
                    throw new NotSupportedException($"Primitive field type {memberType} is not supported");
                }
            }

            return(new NestedStructProxyProperty(d)
            {
                PropertyBag = Parse(memberType, d.Name)
            });
        }
コード例 #2
0
 public NestedProxyProperty(ITypedMemberDescriptor member)
     : base(member.Name, null, null, null)
 {
     FieldOffset   = member.GetOffset();
     ComponentType = member.GetMemberType();
     RefAccess     = GetChildRef;
 }
コード例 #3
0
 public NestedStructProxyProperty(ITypedMemberDescriptor member)
     : base(member.Name, null, null, (ByRef m, StructValueStructProperty <StructProxy, StructProxy> property, ref StructProxy c, IPropertyVisitor v) =>
 {
     var val = property.GetValue(ref c);
     m(property, ref c, ref val, v);
 })
 {
     FieldOffset   = member.GetOffset();
     ComponentType = member.GetMemberType();
 }