在本文中,我们将给您介绍关于有没有更好的方法可以使用get从带有swift路径的子词典中获取项目?的详细内容,此外,我们还将为您提供关于apt-getupdate,apt-getupgrade,apt
在本文中,我们将给您介绍关于有没有更好的方法可以使用 get 从带有 swift 路径的子词典中获取项目?的详细内容,此外,我们还将为您提供关于apt-get update,apt-get upgrade,apt-get dist-upgrade的作用、Automapper 在使用 ProjectTo
- 有没有更好的方法可以使用 get 从带有 swift 路径的子词典中获取项目?
- apt-get update,apt-get upgrade,apt-get dist-upgrade的作用
- Automapper 在使用 ProjectTo
从带有 EFCore 的 OData 操作访问时扩展所有成员 - Azure Devops - 从带有 tfvc 存储库的 API 下载文件
- CompTIA Security+: Get Certified Get Ahead: SY0-401 Study Guide 免积分下载
有没有更好的方法可以使用 get 从带有 swift 路径的子词典中获取项目?
如何解决有没有更好的方法可以使用 get 从带有 swift 路径的子词典中获取项目?
我正在 Swift 中为 JSON 表单构建自定义渲染器,以与用于我们基于 Web 的应用程序的 JSON 表单架构集成。如果您不熟悉,可以使用两个 JSON 文件生成 UI 表单组件并链接到后端。下面是 JSON 架构和 JSON UI 架构的示例。 JSON 架构提供有关 UI 架构的数据类型的信息。然后为了将两者联系起来,范围提供了 JSON 模式中相关元素的路径。在一个极其简单的模式中,这还不错,但如果 JSON 中有很多嵌套,它就会变得有点愚蠢。我在下面有我的代码,用于通过将范围拆分为其组件然后挖掘字典来访问数据元素。有没有更好、更清洁、更少使用大锤的方法来做到这一点?我怀疑是否存在嵌套更深的数据的情况,但以防万一,只使用递归函数来查看每一层而不必自己进行操作会很好。我确定它存在,只是我没有看到。
在你问“为什么要这样做之前?”答案是那是黄铜交给我的任务,所以......我必须!
JSON 架构:
{
"type": "person","required": [
"age"
],"properties": {
"firstName": {
"type": "string","minLength": 2,"maxLength": 20
},"lastName": {
"type": "string","minLength": 5,"maxLength": 15
},"age": {
"type": "integer","minimum": 18,"maximum": 100
},"gender": {
"type": "string","enum": [
"Male","Female","Undisclosed"
]
},"height": {
"type": "number"
},"dateOfBirth": {
"type": "string","format": "date"
},"rating": {
"type": "integer"
},"committer": {
"type": "boolean"
},"address": {
"type": "object","properties": {
"street": {
"type": "string"
},"streetnumber": {
"type": "string"
},"postalCode": {
"type": "string"
},"city": {
"type": "string"
}
}
}
}
}
JSON 用户界面架构:
{
"type": "VerticalLayout","elements": [
{
"type": "HorizontalLayout","elements": [
{
"type": "Control","scope": "#/properties/firstName"
},{
"type": "Control","scope": "#/properties/lastName"
}
]
},{
"type": "HorizontalLayout","scope": "#/properties/age"
},"scope": "#/properties/dateOfBirth"
}
]
},"scope": "#/properties/height"
},"scope": "#/properties/gender"
},"scope": "#/properties/committer"
}
]
},{
"type": "Group","label": "Address for Shipping T-Shirt","elements": [
{
"type": "HorizontalLayout","elements": [
{
"type": "Control","scope": "#/properties/address/properties/street"
},{
"type": "Control","scope": "#/properties/address/properties/streetnumber"
}
]
},{
"type": "HorizontalLayout","scope": "#/properties/address/properties/postalCode"
},"scope": "#/properties/address/properties/city"
}
]
}
],"rule": {
"effect": "ENABLE","condition": {
"scope": "#/properties/committer","schema": {
"const": true
}
}
}
}
]
}
快速的蛮力方法:
static private func mapJSONSchemaToUISchema(_ uiSchema: JSONUISchemaElement)->JSONSchemaElement? {
guard let scope = uiSchema.scope else {
return nil
}
// separate out the scope string into components by /,starts with #,then properties,then the name of the JSONSchema element,then if it''s nested,it will repeat properties and JSONSchemaElement,with the last element always being the element we would want. There''s a more elegant way to do this,however,this is the brute force for Now.
let scopeComponentPath = scope.components(separatedBy: "/")
if scopeComponentPath.count < 3 {
return nil
} else {
let element = getJSONElementFromPath(scopeComponentPath)
return element
}
}
//iterrates through the JSON Schema to find the correct element based on the path (parsed from the UI Scope) to return the JSON Schema element,even if it''s nested up to 5 layers deep. If we continue to nest beyond 5 layers,this will require addressing.
static private func getJSONElementFromPath(_ stringsPath: [String]) ->JSONSchemaElement? {
print(stringsPath)
switch stringsPath.count {
case 3:
// not nested
return jsonSchemaRootElement.properties?[stringsPath[2]]
case 5:
// nested in first level object
return jsonSchemaRootElement.properties?[stringsPath[2]]?.properties?[stringsPath[4]]
case 7:
// nested in second level object
return jsonSchemaRootElement.properties?[stringsPath[2]]?.properties?[stringsPath[4]]?.properties?[stringsPath[6]]
case 9:
// nested in third level object
return jsonSchemaRootElement.properties?[stringsPath[2]]?.properties?[stringsPath[4]]?.properties?[stringsPath[6]]?.properties?[stringsPath[8]]
case 11:
// nested in fourth level object
return jsonSchemaRootElement.properties?[stringsPath[2]]?.properties?[stringsPath[4]]?.properties?[stringsPath[6]]?.properties?[stringsPath[8]]?.properties?[stringsPath[10]]
case 13:
// nested in fifth level object
return jsonSchemaRootElement.properties?[stringsPath[2]]?.properties?[stringsPath[4]]?.properties?[stringsPath[6]]?.properties?[stringsPath[8]]?.properties?[stringsPath[10]]?.properties?[stringsPath[12]]
case 15:
// nested in sixth level object
return jsonSchemaRootElement.properties?[stringsPath[2]]?.properties?[stringsPath[4]]?.properties?[stringsPath[6]]?.properties?[stringsPath[8]]?.properties?[stringsPath[10]]?.properties?[stringsPath[12]]?.properties?[stringsPath[14]]
default:
print("no elements found in personjsONSchema array")
return nil
}
}
apt-get update,apt-get upgrade,apt-get dist-upgrade的作用
安装或升级系统分下面几个步骤。
第一步,获得最近的软件包的列表;列表中包含一些包的信息,比如这个包是否更新过。
第二步,如果这个包没有发布更新,就不管它;如果发布了更新,就把包下载到电脑上,并安装。
apt-get update对应的就是第一步,得到软件包的列表。
apt-get upgrade 与apt-get dist-upgrade对应的是第二步。
由于包与包之间存在各种依赖关系。upgrade只是简单的更新包,不管这些依赖,它不和添加包,或是删除包;而dist-upgrade可以根据依赖关系的变化,添加包,删除包。
一般在运行upgrade或dist-upgrade之前,先要运行update。
Automapper 在使用 ProjectTo 从带有 EFCore 的 OData 操作访问时扩展所有成员
如何解决Automapper 在使用 ProjectTo<Dto> 从带有 EFCore 的 OData 操作访问时扩展所有成员
我正在尝试使用 Automapper 将 MyClass 类型的 IQueryable 转换为 MyClassDto 类型的 IQueryable。 问题是,即使我为所有成员设置了显式扩展,它仍然会扩展所有导航属性。
动作是这样的:
[HttpGet]
[EnableQuery]
public ActionResult<IQueryable<MyClassDto>> GetCampaigns(ODataQueryOptions<MyClassDto> queryOptions)
{
if (queryOptions.SelectExpand != null)
{
return Ok(_myClassService.AsQueryable().ProjectTo<MyClassDto>(_mapper.ConfigurationProvider,null,queryOptions.SelectExpand.RawExpand.Split('','')));
}
return Ok(_myClassService.AsQueryable().ProjectTo<MyClassDto>(_mapper.ConfigurationProvider);
}
服务方法无非是这样:
public IQueryable<MyClass> AsQueryable() => _dbContext.MyClasses;
以及mapper配置(IAutomapperProfile接口只用于启动时的反射):
public class MyClassMapperConfiguration : Profile,IAutomapperProfile
{
public MyClassMapperConfiguration()
{
CreateMap<MyClass,MyClassDto>().ReverseMap().ForAllMembers(options => options.ExplicitExpansion());
}
}
解决方法
您配置了错误的地图。你的意思是:
CreateMap<MyClass,MyClassDto>().ForAllMembers(options => options.ExplicitExpansion());
CreateMap<MyClassDto,MyClass>();
Azure Devops - 从带有 tfvc 存储库的 API 下载文件
如何解决Azure Devops - 从带有 tfvc 存储库的 API 下载文件
是否可以使用 Rest API 从 Azure DevOps 服务中的 TFVC 存储库下载文件? 我发现很多话题都在谈论使用 Git 存储库下载,但没有使用 TFVC。
解决方法
您可以使用 REST API Items - Get 从 TFVC 存储库获取文件。
GET https://dev.azure.com/{organization}/{project}/_apis/tfvc/items?path={path}&download=true&api-version=6.0
以下是您需要注意的几点:
- path 参数省略了 TFVC 存储库的名称。例如,如果我想获取一个文件
$/{name}/A.txt
,那么我需要设置path=A.txt
。 - 您需要指定文件路径而不是文件夹路径。否则只会返回文件夹信息,不会下载文件。如果要下载多个文件,则需要使用 REST API Items - Get Items Batch。
- 将
download
参数设置为true
以下载文件。否则只返回文件信息,不下载文件。
CompTIA Security+: Get Certified Get Ahead: SY0-401 Study Guide 免积分下载
图书说明:
CompTIA Security + 获得认证 SY0-401 学习指南是对最畅销的 SY0-201 和 SY0-301 学习指南的更新,这些指南帮助数千名读者在第一次参加考试时通过考试。
经过 ProCert Labs 的全面审查,SY0-401 版本已通过 CompTIA 认证的质量内容(CAQC)认证,涵盖了 SY0-401 考试的各个方面。它包括读者在前两个版本中所赞同的相同元素。十一章中的每一章都以易于理解的方式呈现主题,并包括实际安全原则的实际示例。作者使用了他在课堂上磨练的许多相同的类比和解释,帮助数百名学生掌握了 Security + 内容。
您将了解 Security + 考试的重要且相关的安全主题,而不会因不必要的细节而过载。此外,每章都包含一个全面的评论部分,以帮助您专注于重要的事情。
超过 400 个现实的实践测试问题和深入的解释将帮助您测试您对考试的理解和准备情况。本书包括 100 个问题的预测试,100 个问题的测试后,以及每章末尾的练习题。每个练习题都包含一个详细的解释,以帮助您理解问题背后的内容和推理。您第一次参加考试时,您将准备好参加并通过考试。
如果您计划申请任何高级安全认证,本指南还将帮助您奠定安全知识的坚实基础。学习这些材料,您将在其他考试中领先一步。本 SY0-401 学习指南适用于任何对其所在领域感兴趣的 IT 或安全专业人员,对于任何努力掌握 IT 系统安全基础知识的人员都必须阅读
下载地址:CompTIA Security+: Get Certified Get Ahead: SY0-401 Study Guide
更多免积分电子书,请访问:IE 布克斯网
今天关于有没有更好的方法可以使用 get 从带有 swift 路径的子词典中获取项目?的介绍到此结束,谢谢您的阅读,有关apt-get update,apt-get upgrade,apt-get dist-upgrade的作用、Automapper 在使用 ProjectTo
本文标签: