Exemple #1
0
        public ScrapedProperty(ScrapedMember baseValues, HtmlNode node) : base(baseValues)
        {
            Description = node.SelectSingleNode("./div[@class='abstract']/p").RealInnerText();
            if (Description.Contains("Returns a dictionary that contains information about the receiver"))
            {
            }
            Deprecated = Description.ToLower().Contains("deprecat");
            var name = Declaration.Split("var ")[1].Split(':')[0].Trim();

            RawName    = name;
            CSharpName = (name.ToUpper()[0] + name.Substring(1)).Trim('`');

            if (new[] { "object", "string", "delegate", "int", "uint", "float", "class", "this", "new" }.Contains(CSharpName))
            {
                CSharpName = "@" + CSharpName;
            }

            var type = Declaration.SplitAtFirstOccurrence(':')[1].Trim().Split('{')[0].Split(';')[0].Trim();

            Type = ScrapedType.ScrapeType(type);

            PublicGetter = true;
            PublicSetter = !(Declaration.Contains("{ get }"));
            Public       = true;

            Static = Declaration.Contains("class var ");
        }
Exemple #2
0
        public ScrapedArray(string type)
        {
            RawSwift = type;

            type       = type.Substring(1, type.Length - 2);
            ValueType  = ScrapeType(type);
            CSharpType = ValueType.CSharpType + "[]";
        }
Exemple #3
0
 public ScrapedStructMember(string declaration)
 {
     Public     = true;
     RawName    = declaration.Split("var ")[1].Split(':')[0].Trim();
     CSharpName = RawName.ToUpper()[0] + RawName.Substring(1);
     Type       = ScrapedType.ScrapeType(declaration.Split(':')[1].Trim().Split(' ')[0]);
     ReadOnly   = declaration.Contains("{ get }");
 }
Exemple #4
0
        public ScrapedDictionary(string type)
        {
            RawSwift = type;

            type       = type.Substring(1, type.Length - 2);
            KeyType    = ScrapeType(type.Split(':')[0].Trim());
            ValueType  = ScrapeType(type.Split(':')[1].Trim());
            CSharpType = "Dictionary<" + KeyType.CSharpType + ", " + ValueType.CSharpType + ">";
        }
        public ScrapedTypedef(ScrapedMember baseValues, HtmlNode node) : base(baseValues)
        {
            Description = node.SelectSingleNode("./div[@class='abstract']/p").RealInnerText();
            Deprecated  = Description.ToLower().Contains("deprecat");
            iOSVersion  = double.Parse(node.SelectSingleNode("./div[@class='availability']/p").RealInnerText().Split("in iOS ")[1].Split(' ')[0]);

            var name = Declaration.Split("typealias ")[1].Split('=')[0].Trim();

            RawName    = name;
            CSharpName = name.ToUpper()[0] + name.Substring(1);
            Alias      = CSharpName;

            var type = Declaration.Split('=')[1].Trim().Split(' ')[0].Trim();

            RealType = ScrapedType.ScrapeType(type);

            Public = true;
            Static = true;
        }
Exemple #6
0
        public ScrapedParameter(string parameter)
        {
            parameter = parameter.Trim();
            var names = parameter.Split(':')[0].Trim().Split(' ');

            Name         = names[0].Trim() == "_" ? names.Last() : names[0];
            InternalName = names.Last();
            Name         = Name.Trim().Trim('`');
            if (new[] { "object", "string", "delegate", "int", "uint", "float", "class", "this", "new", "bool", "char", "double", "short", "long", "event" }.Contains(Name))
            {
                Name = "@" + Name;
            }

            try
            {
                var type = parameter.Substring(parameter.IndexOf(':') + 1).Trim();
                Type = ScrapedType.ScrapeType(type);
            }
            catch
            {
                Type = ScrapedType.ScrapeType("WEIRD");
            }
        }
Exemple #7
0
        public ScrapedMethod(ScrapedMember baseValues, HtmlNode node) : base(baseValues)
        {
            Description = node.SelectSingleNode("./div[@class='abstract']/p").RealInnerText();
            Deprecated  = Description.ToLower().Contains("deprecat");
            IsOptional  = Declaration.Contains("optional ");
            RawName     = Declaration.Split('(')[0].Split("func ").Last().Trim().Trim('`').Trim();
            CSharpName  = RawName.ToUpper()[0] + RawName.Substring(1);

            if (new[] { "object", "string", "delegate", "int", "uint", "float", "class", "this", "new", "event" }.Contains(CSharpName))
            {
                CSharpName = "@" + CSharpName;
            }

            if (Declaration.ToLower().Contains("init("))
            {
                CSharpName = "init";
            }


            var parameters = Declaration.Substring(Declaration.IndexOf('(') + 1);

            parameters = parameters.Substring(0, parameters.LastIndexOf(')'));

            var separatedParameters = ScrapedParameter.ScrapeParameters(parameters);

            Parameters = new List <ScrapedParameter>();
            foreach (var param in separatedParameters)
            {
                Parameters.Add(new ScrapedParameter(param));
            }

            var parameterTableRows = node.SelectNodes("./div[@class='parameters']/table/tbody/tr");

            if (parameterTableRows != null)
            {
                foreach (var row in parameterTableRows)
                {
                    var name       = row.SelectNodes("./td").First().RealInnerText().Trim();
                    var definition = row.SelectNodes("./td").Last().RealInnerText().Trim();
                    if (name != definition)
                    {
                        var matchingParameter = Parameters.FirstOrDefault(param => param.InternalName == name);
                        if (matchingParameter != null)
                        {
                            matchingParameter.Description = definition;
                        }
                    }
                }
            }

            var returns = node.SelectSingleNode("./result-description/p");

            if (returns != null)
            {
                ReturnDescription = returns.RealInnerText().Trim();
            }
            else
            {
                ReturnDescription = null;
            }

            if (Declaration.ToLower().Contains("allocwithzone"))
            {
                var m = 1;
            }

            if (Declaration.Contains("->"))
            {
                var returnType = Declaration.Split("->").Last();
                if (!returnType.EndsWith(")"))
                {
                    ReturnType = ScrapedType.ScrapeType(returnType);
                }
            }
            if (ReturnType == null || ReturnType.CSharpType.Trim() == "")
            {
                ReturnType = ScrapedType.ScrapeType("void");
            }

            var objCDeclaration =
                node.SelectSingleNode("./div[@class='declaration']/div[@class='Objective-C']/p[@class='para']").RealInnerText().Trim();

            if (objCDeclaration.StartsWith("-") || !Declaration.Contains("class "))
            {
                Static = false;
            }
            else
            {
                Static = true;
            }
            Public = true;
        }