public static SpaceResponse PostFile(FileStream file, string url, Dictionary <string, string> headers = null) { var apiKey = SpaceConfiguration.GetApiKey(); using (var client = new HttpClient()) { using (var content = new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture))) { content.Add(new StreamContent(file), "upload image", file.Name); client.DefaultRequestHeaders.Add("Authorization", apiKey); if (headers != null) { foreach (KeyValuePair <string, string> entry in headers) { client.DefaultRequestHeaders.Add(entry.Key, entry.Value); } } var response = client.PostAsync(url, content).ConfigureAwait(false).GetAwaiter().GetResult(); var responseText = response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult(); var result = BuildResponseData(response, responseText); return(result); } } }
private static ComponentInstance InstantiateLayout(SpaceConfiguration configs, double width, double length, Polygon rectangle, Transform xform) { ContentConfiguration selectedConfig = null; var orderedKeys = configs.OrderByDescending(kvp => kvp.Value.CellBoundary.Depth * kvp.Value.CellBoundary.Width).Select(kvp => kvp.Key); foreach (var key in orderedKeys) { var config = configs[key]; if (config.CellBoundary.Width < width && config.CellBoundary.Depth < length) { selectedConfig = config; break; } } if (selectedConfig == null) { return(null); } var baseRectangle = Polygon.Rectangle(selectedConfig.CellBoundary.Min, selectedConfig.CellBoundary.Max); var rules = selectedConfig.Rules(); var componentDefinition = new ComponentDefinition(rules, selectedConfig.Anchors()); var instance = componentDefinition.Instantiate(ContentConfiguration.AnchorsFromRect(rectangle.TransformedPolygon(xform))); var allPlacedInstances = instance.Instances; foreach (var item in allPlacedInstances) { if (item is ElementInstance ei && !rectangle.Contains(ei.Transform.Origin)) { } } return(instance); }
private static ComponentInstance InstantiateLayout(SpaceConfiguration configs, double width, double length, Polygon rectangle, Transform xform) { ContentConfiguration selectedConfig = null; var orderedKeys = configs.OrderBy(k => rand.NextDouble()).Select(k => k.Key); foreach (var key in orderedKeys) { var config = configs[key]; if (config.CellBoundary.Width < width && config.CellBoundary.Depth < length) { selectedConfig = config; break; } } if (selectedConfig == null) { return(null); } var baseRectangle = Polygon.Rectangle(selectedConfig.CellBoundary.Min, selectedConfig.CellBoundary.Max); var rules = selectedConfig.Rules(); var componentDefinition = new ComponentDefinition(rules, selectedConfig.Anchors()); var instance = componentDefinition.Instantiate(ContentConfiguration.AnchorsFromRect(rectangle.TransformedPolygon(xform))); return(instance); }
public static HttpRequestMessage GetSpaceRequestMessage(HttpMethod method, object obj, string url) { var apiKey = SpaceConfiguration.GetApiKey(); var request = BuildSpaceRequest(method, obj, url); request.Headers.Add("Authorization", apiKey); var client = new Client(request); client.ApplyUserAgent(); client.ApplyClientData(); return(request); }
public void Populate() { foreach (var Space in ListOfSpaces) { List <GameObject> Configuration = new List <GameObject>(); SpaceConfiguration _spaceConfiguration = new SpaceConfiguration(); _spaceConfiguration.sequence(Space.Function); foreach (var V in _spaceConfiguration.Configuration) { Vector3Int Objectposition = Space.Location + V; GameObject NewObject = Instantiate(Object, Objectposition, Space.Rotation); NewObject.GetComponent <UserFunction>().Function = Space.Function; NewObject.GetComponent <UserFunction>().UserName = Space.UserName; Configuration.Add(NewObject); } ConfigurationIndex.Add(Configuration); } }
private static ComponentInstance InstantiateLayout(SpaceConfiguration configs, double width, double length, Polygon rectangle, Transform xform) { var orderedKeys = configs.OrderByDescending(kvp => kvp.Value.CellBoundary.Depth * kvp.Value.CellBoundary.Width).Select(kvp => kvp.Key); var configsThatFitWell = new List <ContentConfiguration>(); foreach (var key in orderedKeys) { var config = configs[key]; // if it fits if (config.CellBoundary.Width < width && config.CellBoundary.Depth < length) { if (configsThatFitWell.Count == 0) { configsThatFitWell.Add(config); } else { var firstFittingConfig = configsThatFitWell.First(); // check if there's another config that's roughly the same size if (config.CellBoundary.Width.ApproximatelyEquals(firstFittingConfig.CellBoundary.Width, 1.0) && config.CellBoundary.Depth.ApproximatelyEquals(firstFittingConfig.CellBoundary.Depth, 1.0)) { configsThatFitWell.Add(config); } } } } if (configsThatFitWell.Count == 0) { return(null); } var selectedConfig = configsThatFitWell[varietyCounter % configsThatFitWell.Count]; var baseRectangle = Polygon.Rectangle(selectedConfig.CellBoundary.Min, selectedConfig.CellBoundary.Max); var rules = selectedConfig.Rules(); varietyCounter++; var componentDefinition = new ComponentDefinition(rules, selectedConfig.Anchors()); var instance = componentDefinition.Instantiate(ContentConfiguration.AnchorsFromRect(rectangle.TransformedPolygon(xform))); var allPlacedInstances = instance.Instances; return(instance); }