public void DescribeEndpoint5() { var mock = new Mock <DescribeEndpointServiceImpl>(); int status = 200; string jsonContent = "{\"RequestId\":\"RequestId\",\"Endpoints\":{\"Endpoint\":[{\"Id\":\"Id\",\"Endpoint\":\"Endpoint\",\"ServiceCode\":\"ServiceCode\"},{\"Id\":\"Id\",\"Endpoint\":\"Endpoint\",\"ServiceCode\":\"ServiceCode\",\"Type\":\"endpointType\"}]}}"; HttpResponse response = new HttpResponse(); byte[] content = Encoding.GetEncoding("UTF-8").GetBytes(jsonContent); response.ContentType = FormatType.JSON; response.Content = content; response.Status = status; response.Encoding = null; mock.Setup(foo => foo.GetResponse( It.IsAny <HttpRequest>() )).Returns(response); DescribeEndpointServiceImpl instance = mock.Object; Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); var result = instance.DescribeEndpoint( "regionId", "serviceCode", "endpointType", credential, locationConfig ); Assert.NotNull(result); Assert.Equal("Endpoint", result.Endpoint); Assert.Equal("RequestId", result.RequestId); }
// Update is called once per frame void Update() { if (!Application.isPlaying) { LocationConfig cfg = locationConfig; if (cfg == null) { return; } Vector3 origin = transform.position; float radius = cfg.locationRadius; Debug.DrawLine(origin + new Vector3(radius, 0, 0), origin - new Vector3(radius, 0, 0)); Debug.DrawLine(origin + new Vector3(0, radius, 0), origin - new Vector3(0, radius, 0)); Debug.DrawLine(origin + new Vector3(0, 0, radius), origin - new Vector3(0, 0, radius)); foreach (GeneratorSpawnInfo generatorSpawn in cfg.generatorSpawns) { Debug.DrawLine(origin, origin + generatorSpawn.location); } return; } }
public void RegionId() { var instance = LocationConfig.createLocationConfig("RegionId", "Product", "Endpoint"); instance.RegionId = "setRegionId"; Assert.Equal("setRegionId", instance.RegionId); }
public Endpoint GetEndpoint(String regionId, String product, String serviceCode, String endpointType, Credential credential, LocationConfig locationConfig) { if (serviceCode == null) { return(null); } Endpoint endpoint = null; DescribeEndpointResponse response = describeEndpointService.DescribeEndpoint(regionId, serviceCode, endpointType, credential, locationConfig); if (response == null) { return(endpoint); } ISet <String> regionIds = new HashSet <String>(); regionIds.Add(regionId); List <ProductDomain> productDomainList = new List <ProductDomain>(); productDomainList.Add(new ProductDomain(product, response.Endpoint)); endpoint = new Endpoint(response.RegionId, regionIds, productDomainList); return(endpoint); }
public void GetEndpointWhenResponseIsNull() { DescribeEndpointResponse response = null; var mock = new Mock <DescribeEndpointService>(); //String regionId, String serviceCode, String endpointType,Credential credential,LocationConfig locationConfig mock.Setup(foo => foo.DescribeEndpoint( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Credential>(), It.IsAny <LocationConfig>() )).Returns(response); DescribeEndpointService describeEndpointService = mock.Object; RemoteEndpointsParser instance = new RemoteEndpointsParser(); instance.SetDescribeEndpointService(describeEndpointService); Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); var result = instance.GetEndpoint("regionId", "product", "serviceCode", "endpointType", credential, locationConfig); Assert.Null(result); }
public void Product() { var instance = LocationConfig.createLocationConfig("RegionId", "Product", "Endpoint"); instance.Product = "setProduct"; Assert.Equal("setProduct", instance.Product); }
public void GetEndpointWhenResponseIsNotNull() { DescribeEndpointResponse response = new DescribeEndpointResponse(); response.RegionId = "RegionId"; response.Endpoint = "Endpoint"; var mock = new Mock <DescribeEndpointService>(); mock.Setup(foo => foo.DescribeEndpoint( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Credential>(), It.IsAny <LocationConfig>() )).Returns(response); DescribeEndpointService describeEndpointService = mock.Object; RemoteEndpointsParser instance = new RemoteEndpointsParser(); instance.SetDescribeEndpointService(describeEndpointService); Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); var result = instance.GetEndpoint("regionId", "product", "serviceCode", "endpointType", credential, locationConfig); Assert.IsType <Endpoint>(result); Assert.NotNull(result); Assert.Equal("RegionId", result.Name); Assert.NotEmpty(result.ProductDomains); Assert.NotEmpty(result.RegionIds); }
public void Endpoint() { LocationConfig instance = LocationConfig.createLocationConfig("RegionId", "Product", "Endpoint"); instance.Endpoint = "setEndpoint"; Assert.Equal("setEndpoint", instance.Endpoint); }
private DefaultProfile(ICredentialProvider icredential) { this.icredential = icredential; this.iendpoints = new InternalEndpointsParser(); this.remoteProvider = RemoteEndpointsParser.InitRemoteEndpointsParser(); this.locationConfig = new LocationConfig(); }
public async Task <Endpoint> GetEndpointAsync(String regionId, String product, String locationProduct, Credential credential, LocationConfig locationConfig) { if (null == locationProduct) { return(null); } var response = await describeEndpointService.DescribeEndpointAsync(regionId, locationProduct, credential, locationConfig); if (null == response) { return(null); } var regionIds = new HashSet <String> { regionId }; var productDomainList = new List <ProductDomain> { new ProductDomain(product, response.Endpoint) }; var endpoint = new Endpoint(response.RegionId, regionIds, productDomainList); return(endpoint); }
private DefaultProfile(String regionId) { this.locationConfig = new LocationConfig(); this.iendpoints = new InternalEndpointsParser(); this.remoteProvider = RemoteEndpointsParser.InitRemoteEndpointsParser(); this.regionId = regionId; }
public LevelConfig() { WorldScreenHeight = Camera.main.orthographicSize * 2f; WorldScreenWidth = WorldScreenHeight / Screen.height * Screen.width; PlayerConfig = new PlayerConfig(); PlayerConfig.Scale = WorldScreenWidth * PlayerConfig.Scale; PlayerConfig.Speed = WorldScreenWidth * PlayerConfig.Speed; LocationConfig = new LocationConfig(); LocationConfig.Height = WorldScreenHeight * 2 * LocationConfig.Height; LocationConfig.Width = WorldScreenWidth * 2 * LocationConfig.Width; CameraConfig = new CameraConfig(); CameraConfig.BorderMove = 1 - 2 * CameraConfig.BorderMove; EnemyConfig = new EnemyConfig(); EnemyConfig.Scale = WorldScreenWidth * EnemyConfig.Scale; EnemyConfig.Speed = WorldScreenWidth * EnemyConfig.Speed; EnemyConfig.AggroRadius = WorldScreenWidth * EnemyConfig.AggroRadius; EnemyConfig.BounceDistance = WorldScreenWidth * EnemyConfig.BounceDistance; ProjectileConfig = new ProjectileConfig(); ProjectileConfig.Width = WorldScreenWidth * ProjectileConfig.Width; ProjectileConfig.Height = WorldScreenWidth * ProjectileConfig.Height; ProjectileConfig.Speed = WorldScreenWidth * ProjectileConfig.Speed; }
public async Task <Endpoint> GetEndpointAsync(string regionId, string product, string serviceCode, string endpointType, Credential credential, LocationConfig locationConfig, CancellationToken cancellationToken = default(CancellationToken)) { if (serviceCode == null) { return(null); } var response = await describeEndpointService.DescribeEndpointAsync(regionId, serviceCode, endpointType, credential, locationConfig, cancellationToken).ConfigureAwait(false); if (response == null) { return(null); } ISet <string> regionIds = new HashSet <string>(); regionIds.Add(regionId); var productDomainList = new List <ProductDomain>(); productDomainList.Add(new ProductDomain(product, response.Endpoint)); return(new Endpoint(response.RegionId, regionIds, productDomainList)); }
public void DescribeEndpoint4() { var mock = new Mock <DescribeEndpointServiceImpl>(); int status = 500; HttpResponse response = new HttpResponse(); byte[] content = Encoding.GetEncoding("UTF-8").GetBytes("{\"Code\":\"ServiceError\",\"Message\":\"ThisIsMessage\",\"RequestId\":\"ThisIsRequestId\",\"AccessKeyId\":\"MockAccessKeyId\",\"AccessKeySecret\":\"\",\"SecurityToken\":\"\",\"Expiration\":\"" + DateTimeMock.getNowDateTimeString() + "\"}"); response.ContentType = FormatType.JSON; response.Content = content; response.Status = status; response.Encoding = null; mock.Setup(foo => foo.GetResponse( It.IsAny <HttpRequest>() )).Returns(response); DescribeEndpointServiceImpl instance = mock.Object; Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); var result = instance.DescribeEndpoint( "regionId", "serviceCode", "endpointType", credential, locationConfig ); Assert.Null(result); }
public void GetEndpointWhenResponseIsNotNull() { var response = new DescribeEndpointResponse(); response.RegionId = "RegionId"; response.Endpoint = "Endpoint"; var mock = new Mock <DescribeEndpointService>(); mock.Setup(foo => foo.DescribeEndpoint( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Credential>(), It.IsAny <LocationConfig>() )).Returns(response); var instance = new RemoteEndpointsParser(); var credential = new Credential(); var locationConfig = new LocationConfig(); var result = instance.GetEndpoint("regionId", "product", "serviceCode", "endpointType", credential, locationConfig); Assert.Null(result); }
private DefaultProfile(String region, Credential creden) { iendpoints = new InternalEndpointsParser(); this.remoteProvider = RemoteEndpointsParser.InitRemoteEndpointsParser(); credential = creden; this.regionId = region; this.locationConfig = new LocationConfig(); }
private DefaultProfile(string region, ICredentialProvider icredential) { iendpoints = new InternalEndpointsParser(); this.icredential = icredential; regionId = region; locationConfig = new LocationConfig(); remoteProvider = RemoteEndpointsParser.InitRemoteEndpointsParser(); }
private DefaultProfile(String region, Credential creden, IEndpointsProvider provider) { this.iendpoints = provider; this.credential = creden; this.regionId = region; this.locationConfig = new LocationConfig(); this.remoteProvider = RemoteEndpointsParser.InitRemoteEndpointsParser(); }
public void ShowPanel(LocationConfig locationConfig) { gameObject.SetActive(true); GetComponent <Animator>().SetBool("Show", true); titleText.text = locationConfig.name; descriptionText.text = locationConfig.description; image.sprite = Resources.Load <Sprite>(locationConfig.url); }
public override void Entry(IModHelper helper) { _config = helper.ReadConfig <LocationConfig>(); var events = helper.Events; //Events events.GameLoop.DayStarted += OnDayStarted; // Will be used to clear majority of the maps. events.Player.Warped += OnWarped; //Will control other areas, example mines }
private DefaultProfile(ICredentialProvider icredential, String region, FormatType format) { this.regionId = region; this.acceptFormat = format; this.icredential = icredential; this.iendpoints = new InternalEndpointsParser(); this.remoteProvider = RemoteEndpointsParser.InitRemoteEndpointsParser(); this.locationConfig = new LocationConfig(); }
public DescribeEndpointResponse DescribeEndpoint(String regionId, String locationProduct, Credential credential, LocationConfig locationConfig, String locationEndpointType) { if (isEmpty(locationProduct)) { return(null); } DescribeEndpointRequest request = new DescribeEndpointRequest(); request.AcceptFormat = FormatType.JSON; request.Id = regionId; request.RegionId = locationConfig.RegionId; request.LocationProduct = locationProduct; if (isEmpty(locationEndpointType)) { request.EndpointType = DEFAULT_ENDPOINT_TYPE; } else { request.EndpointType = locationEndpointType; } ProductDomain domain = new ProductDomain(locationConfig.Product, locationConfig.Endpoint); try { HttpRequest httpRequest = request.SignRequest(signer, credential, FormatType.JSON, domain); HttpResponse httpResponse = HttpResponse.GetResponse(httpRequest); if (httpResponse.isSuccess()) { String data = System.Text.Encoding.UTF8.GetString(httpResponse.Content); DescribeEndpointResponse response = getEndpointResponse(data, request.EndpointType); if (null == response || isEmpty(response.Endpoint)) { return(null); } return(response); } AcsError error = readError(httpResponse, FormatType.JSON); if (500 <= httpResponse.Status) { Console.WriteLine("Invoke_Error, requestId: " + error.RequestId + "; code: " + error.ErrorCode + "; Msg: " + error.ErrorMessage); return(null); } Console.WriteLine("Invoke_Error, requestId: " + error.RequestId + "; code: " + error.ErrorCode + "; Msg: " + error.ErrorMessage); return(null); } catch (Exception e) { Console.WriteLine("Invoke Remote Error,Msg" + e.Message); return(null); } }
public void createLocationConfig() { var instance = LocationConfig.createLocationConfig("RegionId", "Product", "Endpoint"); Assert.IsType <LocationConfig>(instance); Assert.Equal("RegionId", instance.RegionId); Assert.Equal("Product", instance.Product); Assert.Equal("Endpoint", instance.Endpoint); }
public void GetEndpointWhenServiceCodeIsNull() { RemoteEndpointsParser instance = new RemoteEndpointsParser(); Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); var result = instance.GetEndpoint("regionId", "product", null, "endpointType", credential, locationConfig); Assert.Null(result); }
public SiteLocation(LocationConfig locationConfig, IServiceProvider serviceProvider) { Regex regex; switch (locationConfig.LocationType) { case LocationType.None: case LocationType.NoRegex: Match = httpContext => httpContext.Request.Path.Value.StartsWith(locationConfig.Location); break; case LocationType.Equal: Match = httpContext => httpContext.Request.Path.Value.Equals(locationConfig.Location); break; case LocationType.Regex: regex = new Regex(locationConfig.Location); Match = httpContext => regex.IsMatch(httpContext.Request.Path.Value); break; case LocationType.RegexCaseInsensitive: regex = new Regex(locationConfig.Location, RegexOptions.IgnoreCase); Match = httpContext => regex.IsMatch(httpContext.Request.Path.Value); break; default: throw new ArgumentOutOfRangeException(); } var directiveBuilder = new DirectiveBuilder(serviceProvider); var directiveManager = serviceProvider.GetService <DirectiveManager>(); foreach (var directiveConfig in locationConfig.Directives) { if (!directiveConfig.TryGetProperty("type", out var property)) { continue; } string directiveName = property.GetString(); if (string.IsNullOrEmpty(directiveName)) { throw new NullReferenceException("Directive name is empty or invalid."); } if (directiveManager.TryGetDirective(property.GetString(), out var directiveType)) { directiveBuilder.UseDirective(directiveType, directiveConfig); } else { throw new UnknownDirectiveException($"Unknown directive '{directiveName}', missing plugin?"); } } _directiveDelegate = directiveBuilder.Build(); }
/// <summary>Read config data from a content pack.</summary> /// <param name="contentPack">The content pack to load.</param> public ContentPackData Load(IContentPack contentPack) { LocationConfig config = this.ReadConfig(contentPack); if (config == null) { return(null); } return(this.ValidateData(contentPack, config)); }
public DescribeEndpointResponse DescribeEndpoint(string regionId, string serviceCode, string endpointType, Credential credential, LocationConfig locationConfig) { if (string.IsNullOrEmpty(serviceCode)) { return(null); } if (string.IsNullOrEmpty(endpointType)) { endpointType = DEFAULT_ENDPOINT_TYPE; } var request = new DescribeEndpointRequest { AcceptFormat = FormatType.JSON, Id = regionId, RegionId = locationConfig.RegionId, LocationProduct = serviceCode, SecurityToken = credential.SecurityToken, EndpointType = endpointType }; var signer = Signer.GetSigner(new LegacyCredentials(credential)); var domain = new ProductDomain(locationConfig.Product, locationConfig.Endpoint); var httpRequest = request.SignRequest(signer, credential, FormatType.JSON, domain); httpRequest.SetConnectTimeoutInMilliSeconds(100000); httpRequest.SetReadTimeoutInMilliSeconds(100000); var httpResponse = GetResponse(httpRequest); if (httpResponse.isSuccess()) { var data = Encoding.UTF8.GetString(httpResponse.Content); var response = GetEndpointResponse(data, endpointType); if (response == null || string.IsNullOrEmpty(response.Endpoint)) { return(null); } return(response); } var error = ReadError(httpResponse, FormatType.JSON); if (500 <= httpResponse.Status) { return(null); } return(null); }
public HttpLocationManager(JToken defaultConfig, JObject locationConfigs) { DefaultConfig = new LocationConfig(null, defaultConfig as JArray, this, true); Locations = new List <LocationConfig>(); if (locationConfigs == null) { return; } foreach (var(key, value) in locationConfigs) { Locations.Add(new LocationConfig(key, value as JArray, this)); } }
public void DescribeEndpoint2() { DescribeEndpointServiceImpl instance = new DescribeEndpointServiceImpl(); Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); // When endpointType is null or empty var result = instance.DescribeEndpoint( "regionId", "serviceCode", null, credential, locationConfig ); Assert.Null(result); }
public void DescribeEndpoint1() { var instance = new DescribeEndpointServiceImpl(); var credential = new Credential(); var locationConfig = new LocationConfig(); // When serviceCode is null or empty var result = instance.DescribeEndpoint( "regionId", null, "endpointType", credential, locationConfig ); Assert.Null(result); }