/// <summary> /// Returns or creates an instance of the MetadataSerivce. The paramters will only be used when the singleton is not already created. /// </summary> /// <param name="accesskey"></param> /// <param name="cachedirPath"></param> /// <returns></returns> public static IMetadataService Instance(string accesskey, string cachedirPath) { if (null == mDSMetadata) { lock (syncRoot) { if (null == mDSMetadata) { mDSMetadata = new MDSMetadata(accesskey, cachedirPath); } } } return(mDSMetadata); }
public static IMetadataService ConformanceInstance(string accesskey, string cachedirPath, string origin, HttpClient httpClient = null) { if (null == ConformanceMetadata) { lock (syncRoot) { if (null == ConformanceMetadata) { _origin = origin; ConformanceMetadata = new MDSMetadata(accesskey, cachedirPath, httpClient); } } } return(ConformanceMetadata); }
public static IMetadataService ConformanceInstance(string accesskey, string cachedirPath, string origin) { if (null == ConformanceMetadata) { lock (syncRoot) { if (null == ConformanceMetadata) { var httpWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("https://fidoalliance.co.nz/mds/getEndpoints"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var sw = new System.IO.StreamWriter(httpWebRequest.GetRequestStream())) { var req = new { endpoint = origin }; sw.Write(JsonConvert.SerializeObject(req)); sw.Flush(); sw.Close(); } var httpResponse = (System.Net.HttpWebResponse)httpWebRequest.GetResponse(); using (var sr = new System.IO.StreamReader(httpResponse.GetResponseStream())) { var response = JsonConvert.DeserializeObject <MDSGetEndpointResponse>(sr.ReadToEnd()); _endpoints = response.Result; } ConformanceMetadata = new MDSMetadata(accesskey, cachedirPath); } } } return(ConformanceMetadata); }