Exemple #1
0
        public IDataTransformer Get(string type)
        {
            IDataTransformer transformer = basetable.Get(type);

            if (transformer != null)
            {
                return(transformer);
            }

            instancetransformers.TryGetValue(type, out transformer);
            return(transformer);
        }
Exemple #2
0
        IJavaData ReduceObject(JavaObject @object, HashSet <JavaObject> visited)
        {
            if (visited.Contains(@object))
            {
                return(@object);
            }
            visited.Add(@object);

            foreach (JavaField field in @object.Fields)
            {
                if (field.Value is JavaArray)
                {
                    ReduceArray((JavaArray)field.Value, visited);
                }
                else if (field.Value is JavaObject)
                {
                    field.Value = ReduceObject((JavaObject)field.Value, visited);
                }
            }

            for (int i = @object.Custom.Count - 1; i >= 0; --i)
            {
                IJavaData data = @object.Custom[i];
                if (data is JavaArray)
                {
                    ReduceArray((JavaArray)data, visited);
                }
                else if (data is JavaObject)
                {
                    @object.Custom[i] = ReduceObject((JavaObject)data, visited);
                }
            }

            visited.Remove(@object);

            IDataTransformer transformer = transformationtable.Get(@object.Type);

            if (transformer == null)
            {
                return(@object);
            }

            return(transformer.Convert(@object));
        }