이것은 F #에서 처음 시도한 것입니다. 아직도 많이 읽어야한다는 것을 알고 있습니다.하지만 이러한 어려움은 내가 읽어야 할 다음 부분을 이해하는 데 도움이됩니다. 지금까지 나는 첫 번째 도전 과제 중 일부를 해결할 수있었습니다. 그래서 기다려주십시오 ......F # 사용 문서와 동일한 네임 스페이스가없는 요소에 어떻게 액세스합니까?
XML 문서는 다음과 같습니다
<BuildCollection xmlns="http://schemas.datacontract.org/2004/07/BuildModels" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
...
<PostEvents xmlns:a="http://schemas.datacontract.org/2004/07/BuildModels.Events">
<a:EventBase i:type="a:ExternalProcess">
<a:Description>Structuring assemblies</a:Description>
어떻게 ".......에"로 시작하는 요소에 액세스합니까? C#에서
내가 이런 식으로 할 것 : 나 '(: "메인"코드 블록에서
module PostBuildInstructions
open System.Xml.Linq
open System.Linq
let xn s = XName.Get(s)
let PostBuildInstructions (xdoc: System.Xml.Linq.XDocument) =
xdoc.Root.Elements(xn "PostEvents").Elements().Where(e => e.)
let ExecutePostBuildInstructions buildDescriptor =
let "I need to enumerate the post build events here"
내가이 시작 :
foreach (var postBuildEventElement in
document
.Root.Element(ns + "PostEvents")
.Elements()
.Where(_ => _.Name.LocalName == "EventBase"))
을 지금까지 F에 # I이 있습니다 xn
기능의 사용은의 사용에 해당하지
open Log
[<EntryPoint>]
let main argv =
TryLogArgs argv
ReadPostBuildInstructions |> ExecutePostBuildInstructions
log "Press enter to exit"
System.Console.ReadLine() |> ignore
0 // return an integer exit code
F #의 람다 식은 'fun x -> ...'로 작성되었습니다. 봤습니까? –
나는 램다에 대해 묻지 않습니다. 예, 나는 그 질문이 아니기 때문에 lamdas가 아니라 내 질문을 봤다. –
F # 코드에는'.Where (e => e.) '가 있습니다. 그것은 람다 표현식이 F #에서 작성된 방식이 아닙니다. –