private static XDocument LoadConfigFromResource() { XDocument xDoc = null; TextAsset awsEndpoints = null; Action action = () => { awsEndpoints = Resources.Load(CONFIG_FILE) as TextAsset; using (Stream stream = new MemoryStream(awsEndpoints.bytes)) { using (StreamReader reader = new StreamReader(stream)) { xDoc = XDocument.Load(reader); } } }; if (UnityInitializer.IsMainThread()) { action(); } else { ManualResetEvent e = new ManualResetEvent(false); UnityRequestQueue.Instance.ExecuteOnMainThread(() => { action(); e.Set(); }); e.WaitOne(); } return(xDoc); }
private static XDocument LoadConfigFromResource() { XDocument xDoc = null; TextAsset awsConfig = null; Action action = delegate { awsConfig = (Resources.Load("awsconfig") as TextAsset); if (awsConfig != null && awsConfig.get_bytes().Count() > 0) { using (Stream stream = new MemoryStream(awsConfig.get_bytes())) { using (StreamReader textReader = new StreamReader(stream)) { xDoc = XDocument.Load(textReader); } } } }; if (UnityInitializer.IsMainThread()) { action(); } else { ManualResetEvent e = new ManualResetEvent(initialState: false); UnityRequestQueue.Instance.ExecuteOnMainThread(delegate { action(); e.Set(); }); e.WaitOne(); } return(xDoc); }
static void LoadEndpointDefinitionsFromEmbeddedResource() { Action action = () => { TextAsset awsEndpoints = Resources.Load(REGIONS_FILE) as TextAsset; using (Stream stream = new MemoryStream(awsEndpoints.bytes)) { using (StreamReader reader = new StreamReader(stream)) { ReadEndpointFile(stream); } } awsEndpoints = Resources.Load(REGIONS_CUSTOMIZATIONS_FILE) as TextAsset; using (Stream stream = new MemoryStream(awsEndpoints.bytes)) { using (StreamReader reader = new StreamReader(stream)) { ReadEndpointFile(stream); } } }; if (UnityInitializer.IsMainThread()) { action(); } else { ManualResetEvent e = new ManualResetEvent(false); UnityRequestQueue.Instance.ExecuteOnMainThread(() => { action(); e.Set(); }); e.WaitOne(); } }