public AttributeBytes(IBytes bytes, AttributeDescriptor descriptor) { Bytes = bytes; Descriptor = descriptor; // Should never happen, but just in case if (Bytes.ByteCount % Descriptor.ItemSize != 0) { throw new Exception("Number of items does not divide by item size properly"); } Count = Bytes.ByteCount / Descriptor.ItemSize; }
public static IAttribute ToAttribute <T>(this IArray <T> xs, AttributeDescriptor desc) where T : struct => new AttributeArray <T>(xs, desc);
public AttributeArray(IArray <T> data, AttributeDescriptor desc) { Data = data; Descriptor = desc; }
public static IEnumerable <IAttribute> AttributesExcept(this IG3D g3d, AttributeDescriptor desc) => g3d.Attributes.Where(attr => !attr.Descriptor.Equals(desc));
public static bool IsSameAttribute(this AttributeDescriptor desc, AttributeDescriptor other) => desc.AttributeType == other.AttributeType && desc.Association == other.Association && desc.AttributeTypeIndex == other.AttributeTypeIndex;
public static IAttribute ToAttribute <T>(this T[] data, AttributeDescriptor desc) where T : struct => data.Pin().ToAttribute(desc);
public static IAttribute ToAttribute(this IBytes bytes, AttributeDescriptor desc) => new AttributeBytes(bytes, desc);
public static string AttributeTypeString(this AttributeType at) => AttributeDescriptor.AttributeTypeToString((int)at);