Merge branch 'develop' of github.com:Microsoft/winsdkfb into develop

This commit is contained in:
Austin Diviness 2016-07-20 15:09:42 -07:00
Родитель e3bcd1d1e4 385f4b68df
Коммит 0c742330e7
12 изменённых файлов: 132 добавлений и 16 удалений

Просмотреть файл

@ -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;
};
}
}

Просмотреть файл

@ -38,7 +38,7 @@ using namespace winsdkfb::Graph;
using namespace Platform;
using namespace Windows::Data::Json;
using namespace Windows::Foundation::Collections;
<#
<#
if (bindable)
{
#>
@ -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++)
{
@ -118,7 +122,7 @@ void <#= className #>::<#= propName #>::set(<#= rtType #> value)
}
#>
Object^ <#= className #>::FromJson(
String^ JsonText
String^ JsonText
)
{
<#= className #>^ result = ref new <#= className #>;
@ -178,11 +182,38 @@ 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)
{
// No field names matched any known properties for this class.
// No field names matched any known properties for this class.
// Even if it *is* an object of our type, it's not useful.
result = nullptr;
}
@ -190,7 +221,7 @@ Object^ <#= className #>::FromJson(
}
return result;
}
<#
<#
if (bindable)
{
#>
@ -200,7 +231,7 @@ void <#= className #>::NotifyPropertyChanged(
)
{
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
Windows::UI::Core::CoreDispatcherPriority::Normal,
ref new Windows::UI::Core::DispatchedHandler([this, prop]()
{
PropertyChangedEventArgs^ args = ref new PropertyChangedEventArgs(prop);

Просмотреть файл

@ -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>