Beispiel #1
0
        private static void AddIdentity(XName name, XName index)
        {
            var i = new Identity {
                XmlName    = name,
                JsonName   = name.ToJsonId(),
                ProperName = name.ToProperName(),
                Index      = index
            };

            Context.Add($"{Namespace.Declarations[name.Namespace]}:{name.LocalName}", new JObject {
                { "@id", $"{name.Namespace.NamespaceName}#{name.LocalName}" },
                { "@container", "@index" }
            });

            Context.Add(name.LocalName, new JObject {
                // {"@id", Namespace.Declarations[name.Namespace] + ":" + name.LocalName},
                { "@id", $"{name.Namespace.NamespaceName}#{name.LocalName}" },
                { "@container", "@index" }
            });

            try {
                Context.Add(name.LocalName.ToLowerInvariant(), new JObject {
                    // {"@id", Namespace.Declarations[name.Namespace] + ":" + name.LocalName},
                    { "@id", $"{name.Namespace.NamespaceName}#{name.LocalName}" },
                    { "@container", "@index" }
                });
            } catch (Exception e) {
                Console.WriteLine("AAAG.");
            }
            if (index != null)
            {
                if (Context.Property(index.LocalName) == null)
                {
                    Context.Add(index.LocalName, new JObject {
                        { "@id", Namespace.Declarations[index.Namespace] + ":" + index.LocalName },
                        { "@type", LookupType(index) }
                    });
                }
            }

            if (!_viaJsonName.ContainsKey(i.JsonName))
            {
                _viaJsonName.Add(i.JsonName, i);
            }
            if (!_viaJsonName.ContainsKey(i.ProperName))
            {
                _viaJsonName.Add(i.ProperName, i);
            }

            if (!_viaXname.ContainsKey(i.XmlName))
            {
                _viaXname.Add(i.XmlName, i);
            }
        }
Beispiel #2
0
        private static void AddIdentity(XName name)
        {
            var i = new Identity {
                XmlName    = name,
                JsonName   = name.ToJsonId(),
                ProperName = name.ToProperName(),
                Index      = null
            };

            if (Context.Property(name.LocalName) == null)
            {
                string type = null;
                if (name.Namespace == Namespace.Swid)
                {
                    var element = Schema.Swidtag.XPathSelectElement($@"//xs:attribute[@name=""{name.LocalName}""]", Schema.NamespaceManager);
                    if (element != null)
                    {
                        type = XmlExtensions.GetAttribute(element, "type");

                        if (!type.StartsWith("xs:"))
                        {
                            type = "swid:" + type;
                        }
                    }
                }

                Context.Add(name.LocalName, new JObject {
                    // {"@id", Namespace.Declarations[name.Namespace] + ":" + name.LocalName},
                    { "@id", $"{name.Namespace.NamespaceName}#{name.LocalName}" },
                    { "@type", type ?? "xs:string" }
                });

                Context.Add($"{Namespace.Declarations[name.Namespace]}:{name.LocalName}", new JObject {
                    // {"@id", Namespace.Declarations[name.Namespace] + ":" + name.LocalName},
                    { "@id", $"{name.Namespace.NamespaceName}#{name.LocalName}" },
                    { "@type", type ?? "xs:string" }
                });
            }

            if (!_viaJsonName.ContainsKey(i.JsonName))
            {
                _viaJsonName.Add(i.JsonName, i);
            }
            if (!_viaJsonName.ContainsKey(i.ProperName))
            {
                _viaJsonName.Add(i.ProperName, i);
            }
            if (!_viaXname.ContainsKey(i.XmlName))
            {
                _viaXname.Add(i.XmlName, i);
            }
        }