/// <summary> /// Writes the data for XML serialization. /// </summary> /// <param name="writer">XML Writer.</param> public void WriteXml(XmlWriter writer) { XmlSerializer tripleSerializer = new XmlSerializer(typeof(Triple)); // Serialize Base Uri if (BaseUri != null) { writer.WriteAttributeString("base", BaseUri.AbsoluteUri); } // Serialize Namespace Map writer.WriteStartElement("namespaces"); foreach (String prefix in NamespaceMap.Prefixes) { writer.WriteStartElement("namespace"); writer.WriteAttributeString("prefix", prefix); writer.WriteAttributeString("uri", NamespaceMap.GetNamespaceUri(prefix).AbsoluteUri); writer.WriteEndElement(); } writer.WriteEndElement(); // Serialize Triples writer.WriteStartElement("triples"); foreach (Triple t in Triples) { tripleSerializer.Serialize(writer, t); } writer.WriteEndElement(); }
public VerbInfoMemberPattern(Dictionary <string, TypeDeclaration> typeData, NameLookup nameLookup, NamespaceMap namespaceMap, IServiceProvider provider) { this.typeData = typeData; this.nameLookup = nameLookup; this.namespaceMap = namespaceMap; this.provider = provider; }
/// <summary> /// Reads the data for XML deserialization. /// </summary> /// <param name="reader">XML Reader.</param> public void ReadXml(XmlReader reader) { XmlSerializer tripleDeserializer = new XmlSerializer(typeof(Triple)); reader.Read(); if (reader.Name.Equals("namespaces")) { if (!reader.IsEmptyElement) { reader.Read(); while (reader.Name.Equals("namespace")) { if (reader.MoveToAttribute("prefix")) { String prefix = reader.Value; if (reader.MoveToAttribute("uri")) { Uri u = UriFactory.Create(reader.Value); NamespaceMap.AddNamespace(prefix, u); reader.Read(); } else { throw new RdfParseException("Expected a uri attribute on a <namespace> element"); } } else { throw new RdfParseException("Expected a prefix attribute on a <namespace> element"); } } } } reader.Read(); if (reader.Name.Equals("triples")) { if (!reader.IsEmptyElement) { reader.Read(); while (reader.Name.Equals("triple")) { try { Object temp = tripleDeserializer.Deserialize(reader); Assert((Triple)temp); reader.Read(); } catch { throw; } } } } else { throw new RdfParseException("Expected a <triples> element inside a <graph> element but got a <" + reader.Name + "> element instead"); } }
public void SetPIMapping(string xmlNs, string clrNs, IAssembly assembly) { if (!piMappings.ContainsKey(xmlNs)) { var map = new NamespaceMap(null, assembly, xmlNs, clrNs); piMappings[xmlNs] = map; } }
private void OnItemInteraction(EEInteractableItem item, SLabel label) { AssemblyContents cont = _assemblyMap[_assemblySelected]; NamespaceMap map = cont.Namespaces.FirstOrDefault(n => n.Namespace == _namespaceDropdown.Selected.ReadableName); Type type = map?.Types.FirstOrDefault(t => t.Name == item.Label.ReadableName); SelectedType = type; OnTypeSelected?.Invoke(type); }
NamespaceMap PIFixup(NamespaceMap map) { NamespaceMap piMap; if (piMappings.TryGetValue(map.XMLNamespace, out piMap)) { map.Assembly = piMap.Assembly; map.CLRNamespace = piMap.CLRNamespace; } return(map); }
public void AddToNamespace(String names, EventParser ev) { EventNamespace e = null; if (!NamespaceMap.ContainsKey(names)) { e = new EventNamespace(names); NamespaceMap[names] = e; } else { e = NamespaceMap[names]; } e.events.Add(ev); e.eventmap[ev.GetProperty("id").Value.ToString().Replace(names + ".", "")] = ev; }
private void ResolveXmlNamespaces(object obj) { MarkupObject markupObj = MarkupWriter.GetMarkupObjectFor(obj); string ns = _namespaceCache.GetXmlNamespace(markupObj.ObjectType); string prefix = _namespaceCache.GetPrefixForNamespace(ns); _namespaceMaps[ns] = new NamespaceMap(prefix, ns); foreach (MarkupProperty markupProperty in markupObj.Properties) { if (IsContentProperty(markupObj, markupProperty)) { if (!(markupProperty.Value is String)) { ResolveChildXmlNamespaces(markupProperty); } continue; } if (markupProperty.Value.GetType() == typeof(NullExtension) || markupProperty.IsValueAsString) { continue; } if (!markupProperty.IsComposite) { if (markupProperty.DependencyProperty != null) { string ns1 = _namespaceCache.GetXmlNamespace(markupProperty.DependencyProperty.OwnerType); string prefix1 = _namespaceCache.GetPrefixForNamespace(ns1); if (!string.IsNullOrEmpty(prefix1)) { _namespaceMaps[ns1] = new NamespaceMap(prefix1, ns1); } } } else { string ns2 = _namespaceCache.GetXmlNamespace(markupObj.ObjectType); string prefix2 = _namespaceCache.GetPrefixForNamespace(ns2); _namespaceMaps[ns2] = new NamespaceMap(prefix2, ns2); ResolveChildXmlNamespaces(markupProperty); } } }
/// <summary> /// Gets the prefixed namespace for the given <paramref name="ns"/>. /// </summary> /// <param name="ns">The namespace without the prefix.</param> /// <param name="template">The current code generate template.</param> /// <param name="needFix">The flag indicates whether the namespace need to be fixed now.</param> /// <param name="needGlobalPrefix">The flag indicates whether the namespace need to be added by gloabal prefix.</param> /// <returns>The prefixed namespace for the given <paramref name="ns"/>.</returns> public string GetPrefixedNamespace(string ns, ODataClientTemplate template, bool needFix, bool needGlobalPrefix) { if (ns == null) { return(null); } string prefixedNamespace; if (!NamespaceMap.TryGetValue(ns, out prefixedNamespace)) { prefixedNamespace = ns; } if (needFix) { var segments = prefixedNamespace.Split('.'); prefixedNamespace = string.Empty; var n = segments.Length; for (var i = 0; i < n; ++i) { if (template.LanguageKeywords.Contains(segments[i])) { prefixedNamespace += string.Format(template.FixPattern, segments[i]); } else { prefixedNamespace += segments[i]; } prefixedNamespace += (i == n - 1 ? string.Empty : "."); } } if (needGlobalPrefix) { prefixedNamespace = template.GlobalPrefix + prefixedNamespace; } return(prefixedNamespace); }
private void LoadAssemblyTypes(Assembly ass, int namespaceLevels, Predicate <Type> filter) { Type[] types = UTAssembly.GetTypesFromAssemblies(ass); if (filter != null) { types = types.Where(e => filter(e)).ToArray(); } string[] nsps = UTType.NamespacesFromTypes(types, namespaceLevels); List <NamespaceMap> maps = new List <NamespaceMap>(); foreach (string s in nsps) { NamespaceMap map = new NamespaceMap( s, types.Where(t => t.Namespace == null ? s == "_NoNamespace" : t.Namespace.SeparatorLevelPrune('.', namespaceLevels) == s).ToArray() ); maps.Add(map); } _assemblyMap[ass] = new AssemblyContents(maps.ToArray()); }
public void Add(NamespaceMap map) { CurrentScope.Add(map); }
/// <summary> /// Creates a new Ontology Graph. /// </summary> public OntologyGraph() { NamespaceMap.AddNamespace("owl", UriFactory.Create(NamespaceMapper.OWL)); }
/// <summary> /// Gets the Serialization Information for serializing a Graph. /// </summary> /// <param name="info">Serialization Information.</param> /// <param name="context">Streaming Context.</param> public void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("base", BaseUri.ToSafeString()); info.AddValue("triples", Triples.ToList(), typeof(List <Triple>)); IEnumerable <KeyValuePair <String, String> > ns = from p in NamespaceMap.Prefixes select new KeyValuePair <String, String>(p, NamespaceMap.GetNamespaceUri(p).AbsoluteUri); info.AddValue("namespaces", ns.ToList(), typeof(List <KeyValuePair <String, String> >)); }
private void ResolveXmlNamespaces(object obj) { List <MarkupProperty> propertyElements = new List <MarkupProperty>(); MarkupProperty contentProperty = null; string contentPropertyName = null; MarkupObject markupObj = MarkupWriter.GetMarkupObjectFor(obj); Type objectType = markupObj.ObjectType; string ns = _namespaceCache.GetNamespaceUriFor(objectType); if (!string.IsNullOrWhiteSpace(ns)) { string prefix = _namespaceCache.GetDefaultPrefixFor(ns); _dicNamespaceMap[ns] = new NamespaceMap(prefix, ns); } //Look for CPA info in our cache that keeps contentProperty names per Type //If it doesn't have an entry, go get the info and store it. if (!_contentProperties.ContainsKey(objectType)) { string lookedUpContentProperty = string.Empty; foreach (Attribute attr in markupObj.Attributes) { ContentPropertyAttribute cpa = attr as ContentPropertyAttribute; if (cpa != null) { lookedUpContentProperty = cpa.Name; //Once content property is found, come out of the loop. break; } } _contentProperties.Add(objectType, lookedUpContentProperty); } contentPropertyName = _contentProperties[objectType]; string contentString = string.Empty; foreach (MarkupProperty markupProperty in markupObj.Properties) { if (markupProperty.Name != contentPropertyName) { if (markupProperty.IsValueAsString) { contentString = markupProperty.Value as string; } else if (!markupProperty.IsComposite) { //Bug Fix DX-0120123 if (markupProperty.DependencyProperty != null) { string ns1 = _namespaceCache.GetNamespaceUriFor( markupProperty.DependencyProperty.OwnerType); string prefix1 = _namespaceCache.GetDefaultPrefixFor(ns1); if (!string.IsNullOrWhiteSpace(prefix1)) { _dicNamespaceMap[ns1] = new NamespaceMap(prefix1, ns1); } } } else if (markupProperty.Value.GetType() == _nullType) { } else { propertyElements.Add(markupProperty); } } else { contentProperty = markupProperty; } } if (contentProperty != null || propertyElements.Count > 0 || contentString != string.Empty) { foreach (MarkupProperty markupProp in propertyElements) { string ns2 = _namespaceCache.GetNamespaceUriFor(markupObj.ObjectType); if (!string.IsNullOrWhiteSpace(ns2)) { string prefix2 = _namespaceCache.GetDefaultPrefixFor(ns2); _dicNamespaceMap[ns2] = new NamespaceMap(prefix2, ns2); } ResolveChildXmlNamespaces(markupProp); } if (contentProperty != null) { if (!(contentProperty.Value is String)) { ResolveChildXmlNamespaces(contentProperty); } } } }
private void ResolveXmlNamespaces(object obj) { List<MarkupProperty> propertyElements = new List<MarkupProperty>(); MarkupProperty contentProperty = null; string contentPropertyName = null; MarkupObject markupObj = MarkupWriter.GetMarkupObjectFor(obj); Type objectType = markupObj.ObjectType; string ns = _namespaceCache.GetNamespaceUriFor(objectType); if (!String.IsNullOrEmpty(ns)) { string prefix = _namespaceCache.GetDefaultPrefixFor(ns); _dicNamespaceMap[ns] = new NamespaceMap(prefix, ns); } //Look for CPA info in our cache that keeps contentProperty names per Type //If it doesn't have an entry, go get the info and store it. if (!_contentProperties.ContainsKey(objectType)) { string lookedUpContentProperty = String.Empty; foreach (Attribute attr in markupObj.Attributes) { ContentPropertyAttribute cpa = attr as ContentPropertyAttribute; if (cpa != null) { lookedUpContentProperty = cpa.Name; //Once content property is found, come out of the loop. break; } } _contentProperties.Add(objectType, lookedUpContentProperty); } contentPropertyName = _contentProperties[objectType]; string contentString = String.Empty; foreach (MarkupProperty markupProperty in markupObj.Properties) { if (markupProperty.Name != contentPropertyName) { if (markupProperty.IsValueAsString) { contentString = markupProperty.Value as string; } else if (!markupProperty.IsComposite) { //Bug Fix DX-0120123 if (markupProperty.DependencyProperty != null) { string ns1 = _namespaceCache.GetNamespaceUriFor( markupProperty.DependencyProperty.OwnerType); string prefix1 = _namespaceCache.GetDefaultPrefixFor(ns1); if (!String.IsNullOrEmpty(prefix1)) { _dicNamespaceMap[ns1] = new NamespaceMap(prefix1, ns1); } } } else if (markupProperty.Value.GetType() == _nullType) { } else { propertyElements.Add(markupProperty); } } else { contentProperty = markupProperty; } } if (contentProperty != null || propertyElements.Count > 0 || contentString != String.Empty) { foreach (MarkupProperty markupProp in propertyElements) { string ns2 = _namespaceCache.GetNamespaceUriFor(markupObj.ObjectType); if (!String.IsNullOrEmpty(ns2)) { string prefix2 = _namespaceCache.GetDefaultPrefixFor(ns2); _dicNamespaceMap[ns2] = new NamespaceMap(prefix2, ns2); } ResolveChildXmlNamespaces(markupProp); } if (contentProperty != null) { if (!(contentProperty.Value is String)) { ResolveChildXmlNamespaces(contentProperty); } } } }