当前位置: 首页>>代码示例>>C#>>正文


C# global.Get方法代码示例

本文整理汇总了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;
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:52,代码来源:FacebookUserModelBinder.cs

示例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;
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:65,代码来源:FacebookObjectModelBinder.cs


注:本文中的global.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。