// private List<Point3D> GridData { get; set; } //public Point3D PopulateGrid { set { GridData.Add(value); } } public BluePrintXml(BlueprintModel bp, HashSet <Point3D> data) { this.basicData = bp; this.allPoints = data; entityTracked = EntityGenerator(18); SetBlockSubTypes(); }
private void NonUIControl() { using (CommandLineHandler commandLineHandler = new CommandLineHandler(commandLineArguments)) { commandLineHandler.MyBlueprint = masterBlueprint; commandLineHandler.Start(); if (commandLineHandler.MyBlueprint.HasUsableData) { masterBlueprint = commandLineHandler.MyBlueprint; if (GetPointData()) { MessageBox.Show("calcs done..ready to output", "info...", MessageBoxButton.OK, MessageBoxImage.Information); //access writer BluePrintXml writeBlueprint = new BluePrintXml(masterBlueprint, blueprintData); writeBlueprint.MakeBaseStructure(); writeBlueprint.BluePrintFileHandling(); } } else { //"Data...is..bad. ugrh \n" msg } commandLineHandler.Dispose(); } MessageBox.Show("output done.", "Finished.", MessageBoxButton.OK, MessageBoxImage.Information); }
// Create thumbnail of given blueprint private Sprite CreateThumbnail(BlueprintModel blueprint) { // Instantiate ship var parent = Ship.InstantiateShip(blueprint, transform); // Get size of ship var bounds = BlueprintUtilities.GetBounds(blueprint); var highestval = bounds.extents.x > bounds.extents.y ? bounds.extents.x : bounds.extents.y; var thumbnailCameraTransform = thumbnailCamera.gameObject.transform; var originalPosition = thumbnailCameraTransform.position; // Set position thumbnailCameraTransform.position = originalPosition + bounds.center; // Set size of camera to half of the highest value in the size vector of the ship thumbnailCamera.orthographicSize = highestval; // Take snapshot and destroy parent var texture = RTImage(thumbnailCamera); Destroy(parent.gameObject); thumbnailCameraTransform.position = originalPosition; // Create sprite return(Sprite.Create( texture, new Rect(0f, 0f, 800f, 800f), new Vector2(0.5f, 0.5f))); }
private BlueprintModel CreateSimpleBlueprint() { var blueprint = new BlueprintModel { DisplayName = "Sample Blueprint from Unittest", TargetScope = Constants.BlueprintTargetScopes.Subscription, ResourceGroups = new OrdinalStringDictionary <ResourceGroupDefinition> { { "vNicResourceGroup", new ResourceGroupDefinition { DisplayName = "virtual-network-rg", Description = "All virutal network should save under this resource group." } } }, Parameters = new OrdinalStringDictionary <ParameterDefinition> { { "vNetName", new ParameterDefinition { Type = Constants.ParameterDefinitionTypes.String, DisplayName = "default vNet for this subscription.", Description = "default vNet created by this blueprint.", DefaultValue = "defaultPublicVNet" } }, { "defaultLocation", new ParameterDefinition { Type = Constants.ParameterDefinitionTypes.String, DisplayName = "default Location", Description = "default location of resource created by this blueprint.", DefaultValue = "East US" } }, { "defaultCostCenter", new ParameterDefinition { Type = Constants.ParameterDefinitionTypes.String, DisplayName = "default CostCenter", Description = "default CostCenter for this subscription.", DefaultValue = "Contoso/IT/PROD/123456" } } } }; return(blueprint); }
private void RepeatingChunk() { myBLueprintModel = new BlueprintModel(); myBLueprintModel.BlockSize = blockSize; myBLueprintModel.BlockArmour = blockArmour; myBLueprintModel.BlueprintName = blueprintName; myBLueprintModel.BlueprintFilePath = testPath; myBLueprintModel.BlockColour = new Utilities.SeHSV(0, -100, -90); myBLueprintModel.Shape = "circle"; myBLueprintModel.ShapeFraction = "quarter"; myBLueprintModel.Solid = false; myBLueprintModel.SteamId = "123456789"; myBLueprintModel.SteamName = "itsme"; myBLueprintModel.XAxis = 11; myBLueprintModel.YAxis = 12; myBLueprintModel.ZAxis = 13; Assert.IsTrue(myBLueprintModel.HasUsableData); if (myBLueprintModel.HasUsableData) { testData = new HashSet <Point3D>(); testData.Add(new Point3D(0, 0, 0)); testData.Add(new Point3D(1, 0, 0)); testData.Add(new Point3D(2, 0, 0)); testData.Add(new Point3D(0, 1, 0)); Assert.Greater(testData.Count, 0); BluePrintXml mfh = new BluePrintXml(myBLueprintModel, testData); mfh.MakeBaseStructure(); mfh.BluePrintFileHandling(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (masterBlueprint != null) { masterBlueprint.Dispose(); masterBlueprint = null; } } }
protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources if (MyBlueprintModel != null) { MyBlueprintModel.Dispose(); MyBlueprintModel = null; } } }
public static Ship InstantiateShip(BlueprintModel blueprint, Transform parent) { // Create the ship object/entity var shipObject = new GameObject("Ship"); var ship = shipObject.AddComponent <Ship>(); ship.blueprint = blueprint; ship.rb2d = shipObject.AddComponent <Rigidbody2D>(); ship.rb2d.gravityScale = 0f; ship.uBlockList = ship.InstantiateBlueprint(blueprint, parent); // Add the entity to a chunk ChunkManager.Instance.AddEntity(ship); return(ship); }
public Sprite GetThumbnail(BlueprintModel blueprint, bool forceGet = false) { if (!forceGet) { if (spriteCache.ContainsKey(blueprint.GetHashCode())) { return(spriteCache[blueprint.GetHashCode()]); } } var thumbnail = CreateThumbnail(blueprint); spriteCache[blueprint.GetHashCode()] = thumbnail; return(thumbnail); }
public void BeginSEPB() { masterBlueprint = new BlueprintModel(); if (commandLineArguments != null && commandLineArguments.Length > 0) { SetupOutputWindow(); NonUIControl(); outputController.AddTextToCollection("You can safely close this window"); } else { UIControl(); } }
/// <summary> /// Create a PSBlueprint object from a BlueprintModel. /// </summary> /// <param name="model"></param> /// <param name="managementGroupName">Name of the management group the blueprint belongs to.</param> /// <returns>A new PSBlueprint object</returns> internal static PSBlueprint FromBlueprintModel(BlueprintModel model, string scope) { var psBlueprint = new PSBlueprint { Id = model.Id, Name = model.Name, DefinitionLocationId = Utils.GetDefinitionLocationId(scope), Scope = scope, DisplayName = model.DisplayName, Description = model.Description, Status = new PSBlueprintStatus(), TargetScope = PSBlueprintTargetScope.Unknown, Parameters = new Dictionary <string, PSParameterDefinition>(), ResourceGroups = new Dictionary <string, PSResourceGroupDefinition>(), Versions = model.Versions }; if (DateTime.TryParse(model.Status.TimeCreated, out DateTime timeCreated)) { psBlueprint.Status.TimeCreated = timeCreated; } else { psBlueprint.Status.TimeCreated = null; } if (DateTime.TryParse(model.Status.LastModified, out DateTime lastModified)) { psBlueprint.Status.LastModified = lastModified; } else { psBlueprint.Status.LastModified = null; } if (Enum.TryParse(model.TargetScope, true, out PSBlueprintTargetScope targetScope)) { psBlueprint.TargetScope = targetScope; } else { psBlueprint.TargetScope = PSBlueprintTargetScope.Unknown; } foreach (var item in model.Parameters) { var definition = new PSParameterDefinition { Type = item.Value.Type, DisplayName = item.Value.DisplayName, Description = item.Value.Description, StrongType = item.Value.StrongType, DefaultValue = item.Value.DefaultValue, AllowedValues = (item.Value.AllowedValues != null) ? item.Value.AllowedValues.ToList() : null }; psBlueprint.Parameters.Add(item.Key, definition); } foreach (var item in model.ResourceGroups) { psBlueprint.ResourceGroups.Add(item.Key, new PSResourceGroupDefinition { Name = item.Value.Name, Location = item.Value.Location, DisplayName = item.Value.DisplayName, Description = item.Value.Description, StrongType = item.Value.StrongType, DependsOn = item.Value.DependsOn.ToList() }); } return(psBlueprint); }
/// <summary> /// Create a PSBlueprint object from a BlueprintModel. /// </summary> /// <param name="model"></param> /// <param name="scope">Name of the scope the blueprint is under.</param> /// <returns>A new PSBlueprint object</returns> internal static PSBlueprint FromBlueprintModel(BlueprintModel model, string scope) { var psBlueprint = new PSBlueprint { Id = model.Id, Name = model.Name, Scope = scope, DisplayName = model.DisplayName, Description = model.Description, Status = new PSBlueprintStatus(), TargetScope = PSBlueprintTargetScope.Unknown, Parameters = new Dictionary <string, PSParameterDefinition>(), ResourceGroups = new Dictionary <string, PSResourceGroupDefinition>(), Versions = null }; if (model.Versions != null) { var versionsDict = JObject.FromObject(model.Versions).ToObject <Dictionary <string, object> >(); psBlueprint.Versions = versionsDict.Keys.ToArray(); } psBlueprint.Status.TimeCreated = model.Status.TimeCreated; psBlueprint.Status.LastModified = model.Status.LastModified; if (Enum.TryParse(model.TargetScope, true, out PSBlueprintTargetScope targetScope)) { psBlueprint.TargetScope = targetScope; } else { psBlueprint.TargetScope = PSBlueprintTargetScope.Unknown; } foreach (var item in model.Parameters) { var definition = new PSParameterDefinition { Type = item.Value.Type, DisplayName = item.Value.DisplayName, Description = item.Value.Description, StrongType = item.Value.StrongType, DefaultValue = item.Value.DefaultValue, AllowedValues = (item.Value.AllowedValues != null) ? item.Value.AllowedValues.ToList() : null }; psBlueprint.Parameters.Add(item.Key, definition); } foreach (var item in model.ResourceGroups) { psBlueprint.ResourceGroups.Add(item.Key, new PSResourceGroupDefinition { Name = item.Value.Name, Location = item.Value.Location, DisplayName = item.Value.DisplayName, Description = item.Value.Description, StrongType = item.Value.StrongType, DependsOn = item.Value.DependsOn.ToList() }); } if (psBlueprint.Scope.StartsWith("/subscriptions")) { psBlueprint.SubscriptionId = Utils.GetDefinitionLocationId(scope); } else { psBlueprint.ManagementGroupId = Utils.GetDefinitionLocationId(scope); } return(psBlueprint); }
/// <summary> /// Create or update Blueprint definition. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='subscriptionId'> /// azure subscriptionId, which we save the blueprint to. /// </param> /// <param name='blueprintName'> /// name of the blueprint. /// </param> /// <param name='blueprint'> /// Blueprint definition. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <BlueprintModel> CreateOrUpdateInSubscriptionAsync(this IBlueprintsOperations operations, string subscriptionId, string blueprintName, BlueprintModel blueprint, CancellationToken cancellationToken = default(CancellationToken)) { var scope = string.Format(Constants.ResourceScopes.SubscriptionScope, subscriptionId); using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(scope, blueprintName, blueprint, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public void Dispose() { bpm = null; }
/// <summary> /// Create or update a blueprint definition. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='scope'> /// The scope of the resource. Valid scopes are: management group (format: /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), /// subscription (format: '/subscriptions/{subscriptionId}'). For blueprint /// assignments management group scope is reserved for future use. /// </param> /// <param name='blueprintName'> /// Name of the blueprint definition. /// </param> /// <param name='blueprint'> /// Blueprint definition. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <BlueprintModel> CreateOrUpdateAsync(this IBlueprintsOperations operations, string scope, string blueprintName, BlueprintModel blueprint, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(scope, blueprintName, blueprint, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
private void Initialise() { masterBlueprint = new BlueprintModel(); progressIndicator = new Progress <MyTaskProgressReporter>(ReportProgress); }
/// <summary> /// Create or update a blueprint definition. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='scope'> /// The scope of the resource. Valid scopes are: management group (format: /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), /// subscription (format: '/subscriptions/{subscriptionId}'). For blueprint /// assignments management group scope is reserved for future use. /// </param> /// <param name='blueprintName'> /// Name of the blueprint definition. /// </param> /// <param name='blueprint'> /// Blueprint definition. /// </param> public static BlueprintModel CreateOrUpdate(this IBlueprintsOperations operations, string scope, string blueprintName, BlueprintModel blueprint) { return(operations.CreateOrUpdateAsync(scope, blueprintName, blueprint).GetAwaiter().GetResult()); }
/// <summary> /// Create or update Blueprint definition. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='managementGroupName'> /// azure managementGroup name, which we save the blueprint to. /// </param> /// <param name='blueprintName'> /// name of the blueprint. /// </param> /// <param name='blueprint'> /// Blueprint definition. /// </param> public static BlueprintModel CreateOrUpdateInManagementGroup(this IBlueprintsOperations operations, string managementGroupName, string blueprintName, BlueprintModel blueprint) { var scope = string.Format(Constants.ResourceScopes.ManagementGroupScope, managementGroupName); return(operations.CreateOrUpdateAsync(scope, blueprintName, blueprint).GetAwaiter().GetResult()); }
public void init() { bpm = new BlueprintModel(); System.Diagnostics.Trace.WriteLine("setep complete"); }
public PSBlueprint CreateOrUpdateBlueprint(string scope, string name, BlueprintModel bp) { return(PSBlueprint.FromBlueprintModel(blueprintManagementClient.Blueprints.CreateOrUpdate(scope, name, bp), scope)); }
/// <summary> /// Create or update a blueprint definition. /// </summary> /// <param name='scope'> /// The scope of the resource. Valid scopes are: management group (format: /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), /// subscription (format: '/subscriptions/{subscriptionId}'). /// </param> /// <param name='blueprintName'> /// Name of the blueprint definition. /// </param> /// <param name='blueprint'> /// Blueprint definition. /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="CloudException"> /// Thrown when the operation returned an invalid status code /// </exception> /// <exception cref="SerializationException"> /// Thrown when unable to deserialize the response /// </exception> /// <exception cref="ValidationException"> /// Thrown when a required parameter is null /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null /// </exception> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task <AzureOperationResponse <BlueprintModel> > CreateOrUpdateWithHttpMessagesAsync(string scope, string blueprintName, BlueprintModel blueprint, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } if (scope == null) { throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } if (blueprintName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "blueprintName"); } if (blueprint == null) { throw new ValidationException(ValidationRules.CannotBeNull, "blueprint"); } if (blueprint != null) { blueprint.Validate(); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; if (_shouldTrace) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("scope", scope); tracingParameters.Add("blueprintName", blueprintName); tracingParameters.Add("blueprint", blueprint); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}").ToString(); _url = _url.Replace("{scope}", scope); _url = _url.Replace("{blueprintName}", System.Uri.EscapeDataString(blueprintName)); List <string> _queryParameters = new List <string>(); if (Client.ApiVersion != null) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) { _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); } if (Client.AcceptLanguage != null) { if (_httpRequest.Headers.Contains("accept-language")) { _httpRequest.Headers.Remove("accept-language"); } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } if (customHeaders != null) { foreach (var _header in customHeaders) { if (_httpRequest.Headers.Contains(_header.Key)) { _httpRequest.Headers.Remove(_header.Key); } _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); } } // Serialize Request string _requestContent = null; if (blueprint != null) { _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(blueprint, Client.SerializationSettings); _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials if (Client.Credentials != null) { cancellationToken.ThrowIfCancellationRequested(); await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); } // Send Request if (_shouldTrace) { ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); } HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 201) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject <CloudError>(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } catch (JsonException) { // Ignore the exception } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_httpResponse.Headers.Contains("x-ms-request-id")) { ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); } _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw ex; } // Create Result var _result = new AzureOperationResponse <BlueprintModel>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } // Deserialize Response if ((int)_statusCode == 201) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <BlueprintModel>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); } return(_result); }
/// <summary> /// Create or update Blueprint definition. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='subscriptionId'> /// azure subscriptionId, which we save the blueprint to. /// </param> /// <param name='blueprintName'> /// name of the blueprint. /// </param> /// <param name='blueprint'> /// Blueprint definition. /// </param> public static BlueprintModel CreateOrUpdateInSubscription(this IBlueprintsOperations operations, string subscriptionId, string blueprintName, BlueprintModel blueprint) { var scope = string.Format(Constants.ResourceScopes.SubscriptionScope, subscriptionId); return(operations.CreateOrUpdateAsync(scope, blueprintName, blueprint).GetAwaiter().GetResult()); }