private string ConvertChannelUri(DsonTypes.DsonDocument doc, string uri) { string scope; int colonIdx = uri.IndexOf(':'); if (colonIdx >= 0) { scope = Uri.UnescapeDataString(uri.Substring(0, colonIdx)); uri = uri.Substring(colonIdx + 1); } else { scope = null; } string objectUri, query; int questionIdx = uri.IndexOf('?'); if (questionIdx >= 0) { objectUri = uri.Substring(0, questionIdx); query = uri.Substring(questionIdx + 1); } else { objectUri = uri; query = null; } string resolvedObjectUri = doc.ResolveUri(objectUri); DsonTypes.DsonObject obj = doc.Locator.Locate(resolvedObjectUri); string objectName = obj.name; if (obj.id == scope) { //leave out the scope if it's redundant scope = null; } StringBuilder builder = new StringBuilder(); if (scope != null && scope != rootScope) { builder.Append(scope).Append(":"); } builder.Append(objectName); if (query != null) { builder.Append("?").Append(query); } return(builder.ToString()); }
public void ImportFrom(DsonTypes.Modifier modifier) { if (modifier.channel == null) { return; } string scope; DsonTypes.DsonObject parent = modifier.parent.ReferencedObject; if (parent is DsonTypes.Node) { if (parent.id == rootScope) { scope = null; } else { scope = parent.id; } } else { //if parent is not a node, then assume it's a geometry attached to the root node scope = null; } string pathPrefix = ""; if (modifier.presentation?.type?.StartsWith("Modifier/Shape") ?? false) { pathPrefix += "/Shapes"; } if (modifier.region != null) { pathPrefix += "/" + modifier.region; } if (modifier.group != null) { pathPrefix += modifier.group; } string name = modifier.name; if (scope != null) { name = scope + ":" + name; } Import(modifier.channel, "value", name + "?value", pathPrefix); }