示例#1
0
        /// <summary>
        /// Returns the column data based on the given name.
        /// If the column is not found, returns null.
        /// </summary>
        public static IArray <T> GetColumnData <T>(this Document doc, EntityTable table, string name)
        {
            if (table == null)
            {
                return(null);
            }

            var type = typeof(T);

            if (type == typeof(DVector2))
            {
                var mcd = doc.GetMultiColumnData <double>(table, $"{name}.X", $"{name}.Y");
                return(mcd?[0].Zip(mcd[1], (x, y) => new DVector2(x, y)) as IArray <T>);
            }

            if (type == typeof(Vector2))
            {
                var mcd = doc.GetMultiColumnData <float>(table, $"{name}.X", $"{name}.Y");
                return(mcd?[0].Zip(mcd[1], (x, y) => new Vector2(x, y)) as IArray <T>);
            }

            if (type == typeof(DVector3))
            {
                var mcd = doc.GetMultiColumnData <double>(table, $"{name}.X", $"{name}.Y", $"{name}.Z");
                return(mcd?[0].Zip(mcd[1], mcd[2], (x, y, z) => new DVector3(x, y, z)) as IArray <T>);
            }

            if (type == typeof(Vector3))
            {
                var mcd = doc.GetMultiColumnData <float>(table, $"{name}.X", $"{name}.Y", $"{name}.Z");
                return(mcd?[0].Zip(mcd[1], mcd[2], (x, y, z) => new Vector3(x, y, z)) as IArray <T>);
            }

            if (type == typeof(DVector4))
            {
                var mcd = doc.GetMultiColumnData <double>(table, $"{name}.X", $"{name}.Y", $"{name}.Z", $"{name}.Z");
                return(mcd?[0].Zip(mcd[1], mcd[2], mcd[3], (x, y, z, w) => new DVector4(x, y, z, w)) as IArray <T>);
            }

            if (type == typeof(Vector4))
            {
                var mcd = doc.GetMultiColumnData <float>(table, $"{name}.X", $"{name}.Y", $"{name}.Z", $"{name}.Z");
                return(mcd?[0].Zip(mcd[1], mcd[2], mcd[3], (x, y, z, w) => new Vector4(x, y, z, w)) as IArray <T>);
            }

            if (type == typeof(DAABox))
            {
                var mcd = doc.GetMultiColumnData <DVector3>(table, $"{name}.Min", $"{name}.Max");
                return(mcd?[0].Zip(mcd[1], (x, y) => new DAABox(x, y)) as IArray <T>);
            }

            if (type == typeof(AABox))
            {
                var mcd = doc.GetMultiColumnData <Vector3>(table, $"{name}.Min", $"{name}.Max");
                return(mcd?[0].Zip(mcd[1], (x, y) => new AABox(x, y)) as IArray <T>);
            }

            return(doc.GetColumnData <T>(table?.GetColumn(name)));
        }