CsDebugScript.CodeGen.UserTypes.UserTypeFactory.FindTransformation C# (CSharp) Method

FindTransformation() private method

Tries to match transformation for the specified type.
private FindTransformation ( Symbol type, UserType ownerUserType ) : UserTypeTransformation
type Symbol The type.
ownerUserType UserType The owner user type.
return UserTypeTransformation
        internal UserTypeTransformation FindTransformation(Symbol type, UserType ownerUserType)
        {
            // Find first transformation that matches the specified type
            string originalFieldTypeString = type.Name;
            var transformation = typeTransformations.FirstOrDefault(t => t.Matches(originalFieldTypeString));

            if (transformation == null)
                return null;

            // Create type converter function for the transformation
            Func<string, string> typeConverter = null;

            typeConverter = (inputType) =>
            {
                var tr = typeTransformations.FirstOrDefault(t => t.Matches(inputType));

                if (tr != null)
                {
                    return tr.TransformType(inputType, ownerUserType.ClassName, typeConverter);
                }

                UserType userType;

                if (GetUserType(type.Module, inputType, out userType))
                {
                    return userType.NonSpecializedFullClassName;
                }

                return "Variable";
            };

            return new UserTypeTransformation(transformation, typeConverter, ownerUserType, type);
        }