Esempio n. 1
0
        public MGridOdataAdapter(ODataClient pClient, string pNamespace, string pCollection, string[] pExpands = null)
        {
            mClient        = pClient;
            CollectionName = pCollection;
            Namespace      = pNamespace;
            Expands        = pExpands;

            if (!Namespace.EndsWith("."))
            {
                Namespace += ".";
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name">Nome do tipo que será processado.</param>
        /// <param name="mappingNamespace">Namespace informado no mapeamento.</param>
        /// <param name="mappingAssembly">Assembly informado no mapeamento.</param>
        public TypeInfo(string name, string mappingNamespace, string mappingAssembly)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            if (!string.IsNullOrEmpty(mappingNamespace))
            {
                Namespace = mappingNamespace;
            }
            if (!string.IsNullOrEmpty(mappingAssembly))
            {
                Assembly = mappingAssembly;
            }
            var parts1 = name.Split(',');

            for (int i = 0; i < parts1.Length; i++)
            {
                parts1[i] = parts1[i].Trim();
            }
            var parts2 = parts1[0].Split('.');

            for (int i = 0; i < parts2.Length; i++)
            {
                parts2[i] = parts2[i].Trim();
            }
            if (parts2.Length > 1)
            {
                Name = ElementMapping.Last(parts2);
                var aux = string.Join(".", parts2, 0, parts2.Length - 1);
                if (parts1.Length > 1 || string.IsNullOrEmpty(Namespace))
                {
                    Namespace = aux;
                    Assembly  = parts1[1];
                    return;
                }
                else if (aux.IndexOf(Namespace) < 0)
                {
                    Namespace += (Namespace.EndsWith(".") ? "" : ".") + aux;
                }
            }
            else
            {
                Name = name;
            }
            if (parts1.Length > 1 && string.IsNullOrEmpty(Assembly))
            {
                Assembly = parts1[1];
            }
        }
Esempio n. 3
0
        protected void SetName()
        {
            string name = String.Empty;

            if (!String.IsNullOrWhiteSpace(LocalName))
            {
                if (!String.IsNullOrWhiteSpace(Namespace))
                {
                    name = Namespace;
                    if (!Namespace.EndsWith(MetaObjectConstant.NamespaceSeparator))
                    {
                        name += MetaObjectConstant.NamespaceSeparator;
                    }
                }
                name += LocalName;
            }

            Name = name;
        }
Esempio n. 4
0
        private void InvokeSoap11(object[] parameters)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);

            request.Method      = "POST";
            request.ContentType = "text/xml; charset=utf-8";

            string soapAction;

            if (Namespace.EndsWith("/"))
            {
                soapAction = "SOAPAction: " + Namespace + MethodName;
            }
            else
            {
                soapAction = "SOAPAction: " + Namespace + "/" + MethodName;
            }
            request.Headers.Add(soapAction);

            using (Stream s = request.GetRequestStream())
            {
                XmlTextWriter xtw = new XmlTextWriter(s, System.Text.Encoding.UTF8);

                xtw.WriteStartElement("soap", "Envelope", soapEnvelopeNamespace);
                xtw.WriteStartElement("Body", soapEnvelopeNamespace);
                xtw.WriteStartElement(MethodName, Namespace);
                for (int i = 0; i < Parameters.Count; ++i)
                {
                    xtw.WriteElementString(Parameters[i].Name, Convert.ToString(parameters[i]));
                }
                xtw.WriteEndElement();
                xtw.WriteEndElement();
                xtw.WriteEndElement();
                xtw.Flush();
            }

            WebResponse response = request.GetResponse();

            response.Close();
        }
Esempio n. 5
0
        private byte[] PrepareSoap11Request(HttpWebRequest request, object[] parameters)
        {
            request.Method      = "POST";
            request.ContentType = "text/xml; charset=" + Encoding.WebName;

            if (Namespace.EndsWith("/", StringComparison.Ordinal))
            {
                request.Headers["SOAPAction"] = Namespace + MethodName;
            }
            else
            {
                request.Headers["SOAPAction"] = Namespace + "/" + MethodName;
            }

            using (var ms = new MemoryStream())
            {
                var xtw = XmlWriter.Create(ms, new XmlWriterSettings
                {
                    Encoding = Encoding
                });

                xtw.WriteStartElement("soap", "Envelope", SoapEnvelopeNamespace);
                xtw.WriteStartElement("Body", SoapEnvelopeNamespace);
                xtw.WriteStartElement(MethodName, Namespace);
                var i = 0;

                foreach (var par in Parameters)
                {
                    xtw.WriteElementString(par.Name, Convert.ToString(parameters[i], CultureInfo.InvariantCulture));
                    i++;
                }

                xtw.WriteEndElement(); // methodname
                xtw.WriteEndElement(); // Body
                xtw.WriteEndElement(); // soap:Envelope
                xtw.Flush();

                return(ms.ToArray());
            }
        }
Esempio n. 6
0
        public virtual void ResolveTypeNameConflicts(ISet <string> namespaceNames)
        {
            ISet <string> memberNames = new HashSet <string>(MemberNames.Values);

            while (memberNames.Contains(Name) || namespaceNames.Contains(FrameworkFullyQualifiedName) || Namespace.EndsWith($".{Name}", StringComparison.InvariantCulture))
            {
                Name += "_";
            }
        }
Esempio n. 7
0
        public ScrapedClass(string url)
        {
            using (var client = new HttpClient())
            {
                var data = client.GetStringAsync(url).Result;
                var doc  = new HtmlDocument {
                    OptionFixNestedTags = true
                };
                doc.LoadHtml(data);

                //Parses the inheritance tree
                var inheritanceTree = doc.DocumentNode.SelectNodes("//div[@class='inheritance']/ul[@class='Swift']/li/code");
                if (inheritanceTree != null)
                {
                    for (var i = 1; i < inheritanceTree.Count; i++)
                    {
                        if (inheritanceTree[i].SelectSingleNode("./a") == null)
                        {
                            //The current node isn't a link
                            Inherits = inheritanceTree[i - 1].RealInnerText().Trim();
                        }
                    }
                }
                else
                {
                    Inherits = null;
                }

                //Parses the conformance
                var conformsTo =
                    doc.DocumentNode.SelectNodes("//div[@class='conforms-to']/ul/li[@class='Swift']/code");
                ConformsTo = conformsTo == null ? new string[0] : conformsTo.Select(node => node.RealInnerText().Trim());

                //Parses the name
                Name       = doc.DocumentNode.SelectSingleNode("//h1[@class='chapter-name']").RealInnerText().Replace(" ", "").Trim().Replace("Reference", "");
                CSharpName = Name;

                //Parses the namespace from the "Import Statement" section
                var importStatement =
                    doc.DocumentNode.SelectSingleNode(
                        "//div[@class='z-module-import half']/code[@class='code-voice Swift']");
                if (importStatement != null)
                {
                    try
                    {
                        Namespace = importStatement.RealInnerText().Split("import ")[1].Split(' ')[0].Trim()
                                    .Replace(" ", "");
                        if (Namespace.EndsWith("Reference"))
                        {
                            Namespace = Namespace.Replace("Reference", "");
                        }
                    }
                    catch
                    {
                        Namespace = "";
                    }
                }

                //Parses the description
                var description =
                    doc.DocumentNode.SelectSingleNode("//section[@class='z-class-description section']/p")
                    .RealInnerText().Replace("More...", "").Trim();

                Description = description ?? "";
                if (Description == "")
                {
                    var desc =
                        doc.DocumentNode.SelectSingleNode("//section[@class='z-protocol-description section']/p")
                        .RealInnerText().Replace("More...", "").Trim();

                    Description = desc ?? "";
                }

                //Parses the iOSVersion
                iOSVersion = ParseAvailability(doc);

                //Parses the members within the class
                var members = doc.DocumentNode.SelectNodes("//section[@class='section task-group-section']//ul[@class='task-group-list']/li[@class='item symbol']");
                Members = new List <ScrapedMember>();
                if (members != null)
                {
                    foreach (var member in members)
                    {
                        Members.Add(ScrapeMember(member));
                    }
                }
            }
        }