ApiParser.UnityApi.AddType C# (CSharp) Method

AddType() public method

public AddType ( string ns, string name, string kind, string docPath, System.Version apiVersion ) : UnityApiType
ns string
name string
kind string
docPath string
apiVersion System.Version
return UnityApiType
        public UnityApiType AddType(string ns, string name, string kind, string docPath, Version apiVersion)
        {
            UpdateSupportedVersion(apiVersion);

            foreach (var type in myTypes)
            {
                if (type.Namespace == ns && type.Name == name)
                {
                    // We don't actually use kind, but let's be aware of any issues
                    if (type.Kind != kind)
                    {
                        Console.WriteLine($"WARNING: Kind has changed from `{type.Kind}` to `{kind}` for `{name}`");
                    }

                    return type;
                }
            }

            var unityApiType = new UnityApiType(ns, name, kind, docPath, apiVersion);
            myTypes.Add(unityApiType);
            return unityApiType;
        }

Usage Example

示例#1
0
        private void ParseFile(string filename, Version apiVersion)
        {
            var document = ApiNode.Load(filename);
            var section  = document?.SelectOne(@"//div.content/div.section");
            var header   = section?.SelectOne(@"div.mb20.clear");
            var name     = header?.SelectOne(@"h1.heading.inherit"); // Type or type member name
            var ns       = header?.SelectOne(@"p");                  // "class in {ns}"

            // Only interested in types at this point
            if (name == null || ns == null)
            {
                return;
            }

            // Only types that have messages
            var messages = section.Subsection("Messages").ToArray();

            if (messages.Length == 0)
            {
                return;
            }

            var match   = NsRegex.Match(ns.Text);
            var clsType = match.Groups["type"].Value;
            var nsName  = match.Groups["namespace"].Value;

            var unityApiType = api.AddType(nsName, name.Text, clsType, filename, apiVersion);

            foreach (var message in messages)
            {
                var eventFunction = ParseMessage(message, apiVersion, nsName);
                unityApiType.MergeEventFunction(eventFunction, apiVersion);
            }
        }
All Usage Examples Of ApiParser.UnityApi::AddType