/// <summary> /// Request ship params. /// </summary> public IEnumerator Request() { isDone = false; string uri = Constant.BaseUrl + url; www = UnityWebRequest.Get(uri); yield return(www.Send()); if (www.isError) { Debug.Log(www.error); www.Dispose(); //清理数据 www = null; //设为空 } else { Debug.Log(www.downloadHandler.text); InstanceJson instanceJson = JsonTool.JsonToClass <InstanceJson> (www.downloadHandler.text); if (instanceJson.status == true) { Dictionary <string, InstanceResp> resp = instanceJson.resp; //回调 this._callback(null, resp); } } isDone = true; }
private static void GetMetadataNetworkInterfacesTest(NetworkInterfacesJson[] input, Dictionary <PhysicalAddress, List <IPAddress> > expected) { InstanceJson instance = MetadataJsonHelpers.GetInstanceMetadataJson(networkInterfaces: input); MetadataJson metadata = MetadataJsonHelpers.GetMetadataJson(instance: instance); Assert.Equal <Dictionary <PhysicalAddress, List <IPAddress> > >(expected, Reader.GetMetadata(metadata)); }
private static MetadataJson CreateTestMetadata(string windowsKeys, bool disableAccountManager = false) { AttributesJson attributes = MetadataJsonHelpers.GetAttributesJson( windowsKeys: windowsKeys, disableAccountsManager: disableAccountManager); InstanceJson instance = MetadataJsonHelpers.GetInstanceMetadataJson(attributes: attributes); return(MetadataJsonHelpers.GetMetadataJson(instance: instance)); }
private static MetadataJson CreateTestMetadata(string[] forwardAddresses, bool disableAddressManager = true) { AttributesJson attributes = MetadataJsonHelpers.GetAttributesJson( disableAddressManager: disableAddressManager); InstanceJson instance = MetadataJsonHelpers.GetInstanceMetadataJson( attributes, new[] { MetadataJsonHelpers.GetNetworkInterfacesJson(inputIPs: forwardAddresses) }); return(MetadataJsonHelpers.GetMetadataJson(instance: instance)); }
public static InstanceJson GetInstanceMetadataJson( AttributesJson attributes = null, NetworkInterfacesJson[] networkInterfaces = null) { InstanceJson instanceJson = new InstanceJson { Attributes = attributes ?? GetAttributesJson(), NetworkInterfaces = networkInterfaces ?? new NetworkInterfacesJson[] { GetNetworkInterfacesJson() } }; return(instanceJson); }
public static MetadataJson GetMetadataJson( InstanceJson instance = null, ProjectJson project = null) { MetadataJson metadataJson = new MetadataJson { Instance = instance ?? GetInstanceMetadataJson(), Project = project ?? GetProjectMetadataJson() }; return(metadataJson); }