Esempio n. 1
0
        private UnityEventFunction CreateUnityMessage(XmlNode node, string typeName, VersionNormaliser normaliser)
        {
            var name           = node.Attributes?["name"].Value ?? "Invalid";
            var description    = node.Attributes?["description"]?.Value;
            var isStatic       = bool.Parse(node.Attributes?["static"]?.Value ?? "false");
            var isUndocumented = bool.Parse(node.Attributes?["undocumented"]?.Value ?? "false");

            var minimumVersion = normaliser.NormaliseMinimum(ParseVersionAttribute(node, "minimumVersion", "1.0"));
            var maximumVersion = normaliser.NormaliseMaximum(ParseVersionAttribute(node, "maximumVersion", "655356.0"));

            var parameters = EmptyArray <UnityEventFunctionParameter> .Instance;

            var parameterNodes = node.SelectNodes("parameters/parameter");

            if (parameterNodes != null)
            {
                parameters = parameterNodes.OfType <XmlNode>().Select(LoadParameter).ToArray();
            }

            var returnsArray = false;
            var returnType   = PredefinedType.VOID_FQN;
            var returns      = node.SelectSingleNode("returns");

            if (returns != null)
            {
                returnsArray = bool.Parse(returns.Attributes?["array"].Value ?? "false");
                var type = returns.Attributes?["type"]?.Value ?? "System.Void";
                returnType = GetClrTypeName(type);
            }

            return(new UnityEventFunction(name, typeName, returnType, returnsArray, isStatic, description, isUndocumented, minimumVersion, maximumVersion, parameters));
        }
Esempio n. 2
0
        private UnityType CreateUnityType(XmlNode type, VersionNormaliser normaliser)
        {
            var name = type.Attributes?["name"].Value;
            var ns   = type.Attributes?["ns"].Value;

            var minimumVersion = normaliser.NormaliseMinimum(ParseVersionAttribute(type, "minimumVersion", "1.0"));
            var maximumVersion = normaliser.NormaliseMaximum(ParseVersionAttribute(type, "maximumVersion", "655356.0"));

            var typeName     = GetClrTypeName($"{ns}.{name}");
            var messageNodes = type.SelectNodes("message");
            var messages     = EmptyArray <UnityEventFunction> .Instance;

            if (messageNodes != null)
            {
                messages = messageNodes.OfType <XmlNode>().Select(
                    node => CreateUnityMessage(node, typeName.GetFullNameFast(), normaliser)).OrderBy(m => m.Name).ToArray();
            }

            return(new UnityType(typeName, messages, minimumVersion, maximumVersion));
        }
Esempio n. 3
0
        private UnityType CreateUnityType(XmlNode type, VersionNormaliser normaliser)
        {
            var name = type.Attributes?["name"].Value;
            var ns = type.Attributes?["ns"].Value;

            var minimumVersion = normaliser.NormaliseMinimum(ParseVersionAttribute(type, "minimumVersion", "1.0"));
            var maximumVersion = normaliser.NormaliseMaximum(ParseVersionAttribute(type, "maximumVersion", "655356.0"));

            var typeName = GetClrTypeName($"{ns}.{name}");
            var messageNodes = type.SelectNodes("message");
            var messages = EmptyArray<UnityEventFunction>.Instance;
            if (messageNodes != null)
            {
                messages = messageNodes.OfType<XmlNode>().Select(
                    node => CreateUnityMessage(node, typeName.GetFullNameFast(), normaliser)).OrderBy(m => m.Name).ToArray();
            }

            return new UnityType(typeName, messages, minimumVersion, maximumVersion);
        }
Esempio n. 4
0
        private UnityEventFunction CreateUnityMessage(XmlNode node, string typeName, VersionNormaliser normaliser)
        {
            var name = node.Attributes?["name"].Value ?? "Invalid";
            var description = node.Attributes?["description"]?.Value;
            var isStatic = bool.Parse(node.Attributes?["static"]?.Value ?? "false");
            var isUndocumented = bool.Parse(node.Attributes?["undocumented"]?.Value ?? "false");

            var minimumVersion = normaliser.NormaliseMinimum(ParseVersionAttribute(node, "minimumVersion", "1.0"));
            var maximumVersion = normaliser.NormaliseMaximum(ParseVersionAttribute(node, "maximumVersion", "655356.0"));

            var parameters = EmptyArray<UnityEventFunctionParameter>.Instance;

            var parameterNodes = node.SelectNodes("parameters/parameter");
            if (parameterNodes != null)
            {
                parameters = parameterNodes.OfType<XmlNode>().Select(LoadParameter).ToArray();
            }

            var returnsArray = false;
            var returnType = PredefinedType.VOID_FQN;
            var returns = node.SelectSingleNode("returns");
            if (returns != null)
            {
                returnsArray = bool.Parse(returns.Attributes?["array"].Value ?? "false");
                var type = returns.Attributes?["type"]?.Value ?? "System.Void";
                returnType = GetClrTypeName(type);
            }

            return new UnityEventFunction(name, typeName, returnType, returnsArray, isStatic, description, isUndocumented, minimumVersion, maximumVersion, parameters);
        }