protected override void ExecuteCmdlet() { base.ExecuteCmdlet(); Guid id = _repository.AddAttribute(Entity, InputObject); if (PassThru) { WriteObject(_repository.GetAttribute(id)); } }
protected void WriteAttribute(AttributeMetadata attribute) { attribute.LogicalName = Name; attribute.DisplayName = new Label(DisplayName, CrmContext.Language); attribute.Description = new Label(Description ?? string.Empty, CrmContext.Language); AttributeRequiredLevel requiredLevel = AttributeRequiredLevel.ApplicationRequired; if (Required == CrmRequiredLevel.Required) { requiredLevel = AttributeRequiredLevel.ApplicationRequired; } if (Required == CrmRequiredLevel.Recommended) { requiredLevel = AttributeRequiredLevel.Recommended; } if (Required == CrmRequiredLevel.Optional) { requiredLevel = AttributeRequiredLevel.None; } attribute.RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel); if (CanModifyAdditionalSettings.HasValue) { attribute.CanModifyAdditionalSettings = new BooleanManagedProperty(CanModifyAdditionalSettings.Value); } if (IsAuditEnabled.HasValue) { attribute.IsAuditEnabled = new BooleanManagedProperty(IsAuditEnabled.Value); } if (IsCustomizable.HasValue) { attribute.IsCustomizable = new BooleanManagedProperty(IsCustomizable.Value); } if (IsRenameable.HasValue) { attribute.IsRenameable = new BooleanManagedProperty(IsRenameable.Value); } if (IsSecured.HasValue) { attribute.IsSecured = IsSecured.Value; } if (IsValidForAdvancedFind.HasValue) { attribute.IsValidForAdvancedFind = new BooleanManagedProperty(IsValidForAdvancedFind.Value); } if (!string.IsNullOrWhiteSpace(SchemaName)) { attribute.SchemaName = SchemaName; } else { attribute.SchemaName = Name; } if (_context != null) { _context.SetParametersOnAttribute(attribute); } Guid id = _repository.AddAttribute(Entity, attribute); if (PassThru) { WriteObject(_repository.GetAttribute(id)); } }