Beispiel #1
0
        public static FieldType GetFieldType(HollowDataset dataAccess, string type, string fieldPath)
        {
            TelepathyObjectSchema schema = (TelepathyObjectSchema)dataAccess.GetSchema(type);
            var pathIndexes = GetFieldPathIndex(dataAccess, type, fieldPath);

            for (var i = 0; i < pathIndexes.Length - 1; i++)
            {
                schema = (TelepathyObjectSchema)dataAccess.GetSchema(schema.GetReferencedType(pathIndexes[i]));
            }
            return(schema.GetFieldType(pathIndexes[pathIndexes.Length - 1]));
        }
Beispiel #2
0
        public static int[] GetFieldPathIndex(HollowDataset dataset, string type, string fieldPath)
        {
            var paths       = fieldPath.Split(new[] { "\\." }, StringSplitOptions.None);
            var pathIndexes = new int[paths.Length];
            var refType     = type;

            for (var i = 0; i < paths.Length; i++)
            {
                TelepathyObjectSchema schema = (TelepathyObjectSchema)dataset.GetSchema(refType);
                try
                {
                    pathIndexes[i] = schema.GetPosition(paths[i]);
                    refType        = schema.GetReferencedType(pathIndexes[i]);
                }
                catch (Exception)
                {
                    throw new Exception("Failed create path index for fieldPath=" + fieldPath + ", fieldName=" + paths[i] + " schema=" + schema.Name);
                }
            }

            return(pathIndexes);
        }