Beispiel #1
0
 public void ExportTo(XmlTextWriter xmlWriter, HasVersionRange defaultVersions)
 {
     xmlWriter.WriteStartElement("message");
     xmlWriter.WriteAttributeString("name", Name);
     xmlWriter.WriteAttributeString("static", myIsStatic.ToString());
     if (myIsCoroutine)
     {
         xmlWriter.WriteAttributeString("coroutine", "True");
     }
     ExportVersionRange(xmlWriter, defaultVersions);
     if (myUndocumented)
     {
         xmlWriter.WriteAttributeString("undocumented", "True");
     }
     if (!string.IsNullOrEmpty(myDescription))
     {
         xmlWriter.WriteAttributeString("description", myDescription);
     }
     if (!string.IsNullOrEmpty(myDocPath))
     {
         xmlWriter.WriteAttributeString("path", myDocPath.Replace(@"\", "/"));
     }
     WriteParameters(xmlWriter);
     WriteReturns(xmlWriter);
     xmlWriter.WriteEndElement();
 }
Beispiel #2
0
        protected void ImportVersionRange(XElement element, HasVersionRange defaults)
        {
            var attr = element.Attribute("minimumVersion");

            MinimumVersion = attr != null?Version.Parse(attr.Value) : defaults.MinimumVersion;

            attr           = element.Attribute("maximumVersion");
            MaximumVersion = attr != null?Version.Parse(attr.Value) : defaults.MaximumVersion;
        }
Beispiel #3
0
 protected void ExportVersionRange(XmlTextWriter xmlWriter, HasVersionRange defaults)
 {
     if (myMinimumVersion > defaults.myMinimumVersion)
     {
         xmlWriter.WriteAttributeString("minimumVersion", myMinimumVersion.ToString(2));
     }
     if (myMaximumVersion < defaults.myMaximumVersion)
     {
         xmlWriter.WriteAttributeString("maximumVersion", myMaximumVersion.ToString(2));
     }
 }
Beispiel #4
0
 public void ExportTo(XmlTextWriter xmlWriter, HasVersionRange defaultVersions)
 {
     xmlWriter.WriteStartElement("type");
     xmlWriter.WriteAttributeString("kind", Kind);
     xmlWriter.WriteAttributeString("name", Name);
     xmlWriter.WriteAttributeString("ns", Namespace);
     ExportVersionRange(xmlWriter, defaultVersions);
     xmlWriter.WriteAttributeString("path", myDocPath.Replace(@"\", "/"));
     foreach (var eventFunction in myEventFunctions.OrderBy(f => f.OrderingString))
     {
         eventFunction.ExportTo(xmlWriter, defaultVersions);
     }
     xmlWriter.WriteEndElement();
 }
Beispiel #5
0
        public static UnityApiType ImportFrom(XElement element, HasVersionRange apiVersions)
        {
            var ns   = element.Attribute("ns").Value;
            var name = element.Attribute("name").Value;
            var kind = element.Attribute("kind").Value;
            var path = element.Attribute("path").Value;
            var type = new UnityApiType(ns, name, kind, path, new Version(0, 0));

            type.ImportVersionRange(element, apiVersions);
            foreach (var message in element.Descendants("message"))
            {
                type.myEventFunctions.Add(UnityApiEventFunction.ImportFrom(message, type));
            }
            return(type);
        }
Beispiel #6
0
        public void ExportTo(XmlTextWriter xmlWriter, HasVersionRange defaultVersions)
        {
            // We can get duplicates when merging fixes. E.g. We read a fixed version from an existing api.xml
            // then read in a broken version from the actual documentation, and fix that broken one up, and there's
            // a duplicate
            TrimDuplicates();

            xmlWriter.WriteStartElement("type");
            xmlWriter.WriteAttributeString("kind", Kind);
            xmlWriter.WriteAttributeString("name", Name);
            xmlWriter.WriteAttributeString("ns", Namespace);
            ExportVersionRange(xmlWriter, defaultVersions);
            xmlWriter.WriteAttributeString("path", myDocPath.Replace(@"\", "/"));
            foreach (var eventFunction in myEventFunctions.OrderBy(f => f.OrderingString))
            {
                eventFunction.ExportTo(xmlWriter, this);
            }
            xmlWriter.WriteEndElement();
        }
Beispiel #7
0
        public static UnityApiEventFunction ImportFrom(XElement message, HasVersionRange versions)
        {
            var name                  = message.Attribute("name").Value;
            var isStatic              = bool.Parse(message.Attribute("static").Value);
            var coroutineAttribute    = message.Attribute("coroutine");
            var isCoroutine           = coroutineAttribute != null && bool.Parse(coroutineAttribute.Value);
            var description           = message.Attribute("description")?.Value;
            var path                  = message.Attribute("path")?.Value;
            var undocumentedAttribute = message.Attribute("undocumented");
            var isUndocumented        = undocumentedAttribute != null && bool.Parse(undocumentedAttribute.Value);
            var returns               = message.Descendants("returns").First();
            var type                  = returns.Attribute("type").Value;
            var isArray               = bool.Parse(returns.Attribute("array").Value);
            var returnType            = new ApiType(type + (isArray ? "[]" : string.Empty));
            var function              = new UnityApiEventFunction(name, isStatic, isCoroutine, returnType, new Version(int.MaxValue, 0), description,
                                                                  path, isUndocumented);

            function.ImportVersionRange(message, versions);
            foreach (var parameter in message.Descendants("parameter"))
            {
                function.myParameters.Add(UnityApiParameter.ImportFrom(parameter));
            }
            return(function);
        }