本文整理汇总了C#中global.Get方法的典型用法代码示例。如果您正苦于以下问题:C# global.Get方法的具体用法?C# global.Get怎么用?C# global.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类global
的用法示例。
在下文中一共展示了global.Get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUser
private object GetUser(Type modelType, string facebookId, global::Facebook.FacebookClient client)
{
var user = facebookUserStorageService.GetUser(facebookId);
//TODO: (ErikPo) Fill in the other half of this condition
if (user == null/* or this is the first time the app has started */)
{
object userFields = client.Get("me" + (!String.IsNullOrEmpty(fields) ? "?fields=" + fields.Replace(" ", String.Empty) : facebookService.GetFields(modelType)));
if (modelType == typeof(FacebookUser))
{
return new FacebookUser { Data = userFields };
}
else if (modelType == typeof(object))
{
return (dynamic)userFields;
}
user = (FacebookUser)Activator.CreateInstance(modelType);
user.Data = userFields;
var facebookFields = GetUserFields(modelType);
PropertyInfo userProperty;
string facebookFieldName;
object fieldValue;
foreach (var field in facebookFields)
{
if (field.Value != null && field.Value.Ignore)
{
continue;
}
userProperty = field.Key;
facebookFieldName = field.Value != null ? field.Value.JsonField : String.Empty;
if (!String.IsNullOrEmpty(facebookFieldName))
{
fieldValue = GetFBFieldValue(userFields, facebookFieldName.Split('.'));
}
else
{
fieldValue = GetFBFieldValue(userFields, new[] { userProperty.Name });
}
if (fieldValue != null)
{
userProperty.SetValue(user, fieldValue, null);
}
}
facebookUserStorageService.AddUser(user);
}
return user;
}
示例2: LoadObjects
private object LoadObjects(global::Facebook.FacebookClient client, Type modelType, string userFacebookId, string query)
{
dynamic objects = Activator.CreateInstance(modelType);
dynamic objectList = client.Get(query);
var genericType = GetGenericType(modelType);
if (objects.Count == 0)
{
foreach (var obj in objectList.data)
{
dynamic o = Activator.CreateInstance(genericType);
o.FacebookId = obj.Id;
o.FacebookUserId = userFacebookId;
o.Data = obj;
ApplyFields(o, obj);
objects.Add(o);
facebookObjectStorageService.AddObject((FacebookObject)o);
}
}
else
{
// add, edit
foreach (var obj in objectList.data)
{
dynamic o = FindById(objects, obj.id);
if (o == null)
{
o = Activator.CreateInstance(genericType);
o.FacebookId = obj.Id;
o.FacebookUserId = userFacebookId;
o.Data = obj;
ApplyFields(o, obj);
objects.Add(o);
facebookObjectStorageService.AddObject((FacebookObject)o);
continue;
}
ApplyFields(o, obj);
facebookObjectStorageService.UpdateObject((FacebookObject)o);
}
// remove
var removeCount = 0;
for (var i = 0; i < (objects.Count - removeCount); i++)
{
var obj = objects[i - removeCount];
var foundObject = false;
foreach (var newObject in objectList.data)
{
if (obj.FacebookId == newObject.id)
{
foundObject = true;
break;
}
}
if (foundObject)
{
objects.RemoveAt(i - removeCount);
i--;
removeCount++;
}
}
}
return objects;
}