зеркало из https://github.com/microsoft/winsdkfb.git
Merge branch 'develop' of github.com:Microsoft/winsdkfb into develop
This commit is contained in:
Коммит
0c742330e7
|
@ -210,14 +210,14 @@
|
|||
<ItemGroup>
|
||||
<PRIResource Include="Resources.resw" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\winsdkfb\winsdkfb_testing_key.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\winsdkfb\winsdkfb_uwp\winsdkfb_uwp\winsdkfb_uwp.vcxproj">
|
||||
<Project>{973a943b-ff77-4267-8f30-f5fe2b7f5583}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\winsdkfb\winsdkfb_testing_key.pfx" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
</Project>
|
|
@ -34,7 +34,6 @@
|
|||
<ClCompile Include="FBPageBindable.cpp" />
|
||||
<ClCompile Include="UserInfo.xaml.cpp" />
|
||||
<ClCompile Include="UserLikes.xaml.cpp" />
|
||||
<ClCompile Include="OptionsPage.xaml.cpp" />
|
||||
<ClCompile Include="Dialogs.xaml.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -47,7 +46,6 @@
|
|||
<ClInclude Include="FBPageBindable.h" />
|
||||
<ClInclude Include="UserInfo.xaml.h" />
|
||||
<ClInclude Include="UserLikes.xaml.h" />
|
||||
<ClInclude Include="OptionsPage.xaml.h" />
|
||||
<ClInclude Include="Dialogs.xaml.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -114,13 +114,18 @@
|
|||
<None Include="..\winsdkfb_testing_key.pfx">
|
||||
<Link>winsdkfb_testing_key.pfx</Link>
|
||||
</None>
|
||||
<None Include="data.json" />
|
||||
<None Include="FBCSObjectImplementation.ttinclude" />
|
||||
<None Include="FBPhoto.tt" />
|
||||
<None Include="FBObject.tt" />
|
||||
<None Include="FBSuccess.tt" />
|
||||
<None Include="FBTestUser.tt" />
|
||||
<None Include="packages.config" />
|
||||
<Content Include="TestData\testJsonPropertySet.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="TestData\testJsonPropertySetNoBuiltInFields.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Utility.ttinclude" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "test_user",
|
||||
"test_boolean": false,
|
||||
"test_num": 4,
|
||||
"test_string": "hello_world",
|
||||
"test_array": [ 2, 3, 5, 7, 11 ],
|
||||
"test_object": {
|
||||
"a": "b",
|
||||
"c": "d"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"test_boolean": false,
|
||||
"test_num": 4,
|
||||
"test_string": "hello_world",
|
||||
"test_array": [ 2, 3, 5, 7, 11 ],
|
||||
"test_object": {
|
||||
"a": "b",
|
||||
"c": "d"
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
//******************************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -700,5 +701,49 @@ namespace FBWinStoreCsTests
|
|||
Assert.IsFalse(likes.HasPrevious);
|
||||
// test with next but no previous
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task testJsonPropertySet()
|
||||
{
|
||||
|
||||
StorageFolder installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
|
||||
StorageFolder jsonFolder = await installedLocation.GetFolderAsync("TestData");
|
||||
StorageFile jsonTestFile = await jsonFolder.GetFileAsync("testJsonPropertySet.json");
|
||||
string text = await FileIO.ReadTextAsync(jsonTestFile);
|
||||
|
||||
FBUser testUser = (FBUser)FBUser.FromJson(text);
|
||||
// member variable
|
||||
Assert.AreEqual(testUser.Name, "test_user");
|
||||
Assert.IsFalse(testUser.Fields.ContainsKey("name"));
|
||||
// boolean field
|
||||
Assert.IsTrue(testUser.Fields.ContainsKey("test_boolean"));
|
||||
Assert.AreEqual(testUser.Fields["test_boolean"], "false");
|
||||
// num field
|
||||
Assert.IsTrue(testUser.Fields.ContainsKey("test_num"));
|
||||
Assert.AreEqual(testUser.Fields["test_num"], "4");
|
||||
// string field
|
||||
Assert.IsTrue(testUser.Fields.ContainsKey("test_string"));
|
||||
Assert.AreEqual(testUser.Fields["test_string"], "hello_world");
|
||||
// array field
|
||||
Assert.IsTrue(testUser.Fields.ContainsKey("test_array"));
|
||||
Assert.AreEqual(testUser.Fields["test_array"], "[2,3,5,7,11]");
|
||||
// object field
|
||||
Assert.IsTrue(testUser.Fields.ContainsKey("test_object"));
|
||||
Assert.AreEqual(testUser.Fields["test_object"], @"{""a"":""b"",""c"":""d""}");
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task testJsonPropertySetNoBuiltInFields()
|
||||
{
|
||||
StorageFolder installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
|
||||
StorageFolder jsonFolder = await installedLocation.GetFolderAsync("TestData");
|
||||
StorageFile jsonTestFile = await jsonFolder.GetFileAsync("testJsonPropertySetNoBuiltInFields.json");
|
||||
string text = await FileIO.ReadTextAsync(jsonTestFile);
|
||||
|
||||
FBUser testUser = (FBUser)FBUser.FromJson(text);
|
||||
Assert.AreNotEqual(testUser, null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,10 @@ namespace winsdkfb
|
|||
Platform::String^ JsonText
|
||||
);
|
||||
|
||||
property Windows::Foundation::Collections::PropertySet^ Fields
|
||||
{
|
||||
Windows::Foundation::Collections::PropertySet^ get();
|
||||
}
|
||||
<#
|
||||
|
||||
foreach (XmlNode child in rootNode.SelectNodes("property"))
|
||||
|
@ -129,6 +133,7 @@ namespace winsdkfb
|
|||
<#
|
||||
}
|
||||
#>
|
||||
Windows::Foundation::Collections::PropertySet^ _fields;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,9 +86,13 @@ using namespace Windows::UI::Xaml::Data;
|
|||
}
|
||||
#>
|
||||
{
|
||||
;
|
||||
_fields = ref new PropertySet();
|
||||
}
|
||||
|
||||
PropertySet^ <#= className #>::Fields::get()
|
||||
{
|
||||
return _fields;
|
||||
}
|
||||
<#
|
||||
for (int i = 0; i < props.Count; i++)
|
||||
{
|
||||
|
@ -178,6 +182,33 @@ Object^ <#= className #>::FromJson(
|
|||
<#
|
||||
}
|
||||
#>
|
||||
else
|
||||
{
|
||||
String^ value = nullptr;
|
||||
|
||||
switch (it->Current->Value->ValueType)
|
||||
{
|
||||
case JsonValueType::Boolean:
|
||||
value = it->Current->Value->GetBoolean().ToString();
|
||||
break;
|
||||
case JsonValueType::Number:
|
||||
value = it->Current->Value->GetNumber().ToString();
|
||||
break;
|
||||
case JsonValueType::String:
|
||||
value = it->Current->Value->GetString();
|
||||
break;
|
||||
case JsonValueType::Array:
|
||||
case JsonValueType::Object:
|
||||
value = it->Current->Value->Stringify();
|
||||
break;
|
||||
}
|
||||
|
||||
if (value)
|
||||
{
|
||||
result->_fields->Insert(key, value);
|
||||
found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
|
|
|
@ -654,8 +654,12 @@ void FBClient::SerializeParameters(
|
|||
auto item = keysThatAreNotString->First();
|
||||
while (item->HasCurrent)
|
||||
{
|
||||
// TODO: Jsonize the object value
|
||||
String^ newValue = dynamic_cast<String^>(parameters->Lookup(item->Current));
|
||||
Object^ val = parameters->Lookup(item->Current);
|
||||
String^ newValue = dynamic_cast<String^>(val);
|
||||
if (!newValue)
|
||||
{
|
||||
newValue = val->ToString();
|
||||
}
|
||||
|
||||
// Replace the existing object with the new Jsonized value
|
||||
parameters->Remove(item->Current);
|
||||
|
|
|
@ -99,7 +99,7 @@ FBSession::FBSession() :
|
|||
login_evt = CreateEventEx(NULL, NULL, 0, DELETE | SYNCHRONIZE);
|
||||
}
|
||||
_APIMajorVersion = 2;
|
||||
_APIMinorVersion = 1;
|
||||
_APIMinorVersion = 6;
|
||||
#if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
|
||||
_webViewRedirectDomain = FACEBOOK_MOBILE_SERVER_NAME;
|
||||
#else
|
||||
|
@ -205,9 +205,12 @@ task<FBResult^> FBSession::GetUserInfo(
|
|||
winsdkfb::FBAccessTokenData^ TokenData
|
||||
)
|
||||
{
|
||||
PropertySet^ parameters = ref new PropertySet();
|
||||
parameters->Insert(L"fields",
|
||||
L"gender,link,first_name,last_name,locale,timezone,email,updated_time,verified,name,id");
|
||||
FBSingleValue^ value = ref new FBSingleValue(
|
||||
"/me",
|
||||
nullptr,
|
||||
parameters,
|
||||
ref new FBJsonClassFactory([](String^ JsonText) -> Object^
|
||||
{
|
||||
return FBUser::FromJson(JsonText);
|
||||
|
|
|
@ -98,6 +98,10 @@
|
|||
<None Include="..\..\FBWinStoreCsTests\FBCSObjectImplementation.ttinclude">
|
||||
<Link>FBCSObjectImplementation.ttinclude</Link>
|
||||
</None>
|
||||
<Content Include="..\..\FBWinStoreCsTests\TestData\testJsonPropertySet.json">
|
||||
<Link>TestData\testJsonPropertySet.json</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="..\..\FBWinStoreCsTests\Utility.ttinclude">
|
||||
<Link>Utility.ttinclude</Link>
|
||||
</None>
|
||||
|
|
Загрузка…
Ссылка в новой задаче