public static bool TryGetVertexTypeData(Type vertexType, [MaybeNullWhen(false)] out VertexTypeData typeData) { var data = _typeDic[vertexType]; Debug.Assert(data is null or VertexTypeData); typeData = Unsafe.As <VertexTypeData>(data); return(typeData != null); }
public static VertexMarshalRegisterResult Register <TVertex>(VertexFieldData[] fields) where TVertex : unmanaged { var type = typeof(TVertex); var ex = CheckVertexLikeType(type); if (ex is not null) { return(VertexMarshalRegisterResult.Error(ex)); } if (fields is null) { ThrowNullArg(nameof(fields)); } var vertexSize = Unsafe.SizeOf <TVertex>(); var typeData = new VertexTypeData(fields, vertexSize); lock (_lockObj) { _typeDic.Add(type, typeData); } return(VertexMarshalRegisterResult.Success); }