コード例 #1
0
ファイル: Curie.cs プロジェクト: GTuritto/BrightstarDB
 public static Uri ResolveCurie(Curie c, Dictionary<string, string> mappings)
 {
     if (mappings.Keys.Contains(c.Prefix))
     {
         return new Uri(mappings[c.Prefix] + c.Suffix);
     }
     throw new BrightstarInternalException(String.Format("No mapping found for CURIE prefix '{0}'", c.Prefix));
 }
コード例 #2
0
 public static Uri ResolveCurie(Curie c, Dictionary <string, string> mappings)
 {
     if (mappings.Keys.Contains(c.Prefix))
     {
         return(new Uri(mappings[c.Prefix] + c.Suffix));
     }
     throw new BrightstarInternalException(String.Format("No mapping found for CURIE prefix '{0}'", c.Prefix));
 }
コード例 #3
0
 /// <summary>
 /// Checks whether the supplied identity is a valid Curie and if so resolves it against the supplied namespace mappings
 /// </summary>
 /// <param name="identity"></param>
 /// <returns></returns>
 protected string ResolveIdentity(string identity)
 {
     var curie = new Curie(identity);
     if (curie.IsValidCurie && _namespaceMappings.ContainsKey(curie.Prefix))
     {
         return Curie.ResolveCurie(curie, _namespaceMappings).ToString();
     }
     if (Uri.IsWellFormedUriString(identity, UriKind.Absolute))
     {
         return identity;
     }
     throw new ArgumentException(Strings.InvalidDataObjectIdentity, "identity");
 }
コード例 #4
0
 /// <summary>
 /// The string value can either be a valid absolute URI or a CURIE.
 /// </summary>
 /// <param name="identity">The URI or CURIE that identifies the DataObject</param>
 /// <exception cref="ArgumentException">Thrown if <paramref name="identity"/> could not be parsed as a CURIE or a URI</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="identity"/> is NULL</exception>
 /// <returns></returns>
 public IDataObject MakeDataObject(string identity)
 {
     if (identity == null) throw new ArgumentNullException("identity");
     var curie = new Curie(identity);
     if (curie.IsValidCurie && _namespaceMappings.ContainsKey(curie.Prefix))
     {
         return RegisterDataObject(new DataObject(this, Curie.ResolveCurie(new Curie(identity), _namespaceMappings).ToString()));
     }
     
     Uri uri;
     var validUri = Uri.TryCreate(identity, UriKind.Absolute, out uri);
     if(validUri)
     {
         return RegisterDataObject(new DataObject(this, identity));
     }
     
     throw new ArgumentException(Strings.InvalidDataObjectIdentity, "identity");
 }