Skip to content

Commit

Permalink
Update FreebaseProvider.fs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Guerra committed Mar 2, 2014
1 parent 1ab7064 commit 84bef21
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions src/Freebase/FreebaseProvider.fs
Original file line number Diff line number Diff line change
Expand Up @@ -487,34 +487,29 @@ type public FreebaseTypeProvider(config : TypeProviderConfig) as this =
/// and DataTypes classes.
do theServiceType.AddMembers <|
let domainCategories = getDomainCategories()
try
[ for domainCategory in domainCategories do
if domainCategory.Domains |> Array.exists (fun c -> not c.DomainHidden) then
if not (domainCategory.DomainCategoryId.Id.StartsWith("/user/")) &&
not (domainCategory.Domains |> Array.forall (fun c -> c.DomainId.Id.StartsWith("/user/"))) then
let domainCategoryName = domainCategory.Name.Replace("&amp;", "and")
let t = ProvidedTypeDefinition(domainCategoryName,baseType=Some fbRuntimeInfo.FreebaseDomainCategoryType,HideObjectMethods=true)
t.AddXmlDoc (xmlDoc (sprintf "Represents the objects of the domain category '%s' defined in the web data store organized by type" domainCategory.Name))
t.AddMembersDelayed(fun () ->
[ for domainInfo in domainCategory.Domains do
if not domainInfo.DomainHidden then
let domainName = domainInfo.DomainName
let domainTypeName = typeNameForDomainObjects domainName
let domainType = theDomainObjectsClass.GetNestedType (domainTypeName, BindingFlags.Public ||| BindingFlags.NonPublic)
let propertyName = tidyName domainName
let pi = ProvidedProperty(propertyName, domainType, IsStatic=false,
GetterCode = (fun args -> Expr.Call(args.[0], getDomainById,[Expr.Value(domainInfo.DomainId.Id)])))
pi.AddXmlDocDelayed (fun () -> blurbOfId domainInfo.DomainId |> xmlDoc)
yield pi])
theDomainObjectsClass.AddMember t
let p = ProvidedProperty(domainCategoryName, t, IsStatic=false,
GetterCode = (fun args -> Expr.Call(args.[0], getDomainCategoryById,[Expr.Value(domainCategory.DomainCategoryId.Id)])))
p.AddXmlDocDelayed (fun () -> xmlDoc (sprintf "Contains the objects of the domain category '%s' defined in the web data store organized by type" domainCategory.Name))
yield p ]
with e ->
match e with
| :? FreebaseWebException as e when e.Domain = "usageLimits" && e.Reason = "keyInvalid" -> failwithf "Invalid API Key: %A" fb.ApiKey
| _ -> reraise()
[ for domainCategory in domainCategories do
if domainCategory.Domains |> Array.exists (fun c -> not c.DomainHidden) then
if not (domainCategory.DomainCategoryId.Id.StartsWith("/user/")) &&
not (domainCategory.Domains |> Array.forall (fun c -> c.DomainId.Id.StartsWith("/user/"))) then
let domainCategoryName = domainCategory.Name.Replace("&amp;", "and")
let t = ProvidedTypeDefinition(domainCategoryName,baseType=Some fbRuntimeInfo.FreebaseDomainCategoryType,HideObjectMethods=true)
t.AddXmlDoc (xmlDoc (sprintf "Represents the objects of the domain category '%s' defined in the web data store organized by type" domainCategory.Name))
t.AddMembersDelayed(fun () ->
[ for domainInfo in domainCategory.Domains do
if not domainInfo.DomainHidden then
let domainName = domainInfo.DomainName
let domainTypeName = typeNameForDomainObjects domainName
let domainType = theDomainObjectsClass.GetNestedType (domainTypeName, BindingFlags.Public ||| BindingFlags.NonPublic)
let propertyName = tidyName domainName
let pi = ProvidedProperty(propertyName, domainType, IsStatic=false,
GetterCode = (fun args -> Expr.Call(args.[0], getDomainById,[Expr.Value(domainInfo.DomainId.Id)])))
pi.AddXmlDocDelayed (fun () -> blurbOfId domainInfo.DomainId |> xmlDoc)
yield pi])
theDomainObjectsClass.AddMember t
let p = ProvidedProperty(domainCategoryName, t, IsStatic=false,
GetterCode = (fun args -> Expr.Call(args.[0], getDomainCategoryById,[Expr.Value(domainCategory.DomainCategoryId.Id)])))
p.AddXmlDocDelayed (fun () -> xmlDoc (sprintf "Contains the objects of the domain category '%s' defined in the web data store organized by type" domainCategory.Name))
yield p ]

theServiceTypesClass.AddMembers [theServiceType; theDomainObjectsClass ]

Expand Down

0 comments on commit 84bef21

Please sign in to comment.