• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IDataStoreContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IDataStoreContext的典型用法代码示例。如果您正苦于以下问题:C# IDataStoreContext类的具体用法?C# IDataStoreContext怎么用?C# IDataStoreContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IDataStoreContext类属于命名空间,在下文中一共展示了IDataStoreContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ImportJson

        private static void ImportJson (IDataStoreContext ctx, WorkspaceUserData data, WorkspaceUserJson json)
        {
            var workspaceId = GetLocalId<WorkspaceData> (ctx, json.WorkspaceId);
            var user = GetByRemoteId<UserData> (ctx, json.UserId, null);

            // Update linked user data:
            if (user == null) {
                user = new UserData () {
                    RemoteId = json.UserId,
                    Name = json.Name,
                    Email = json.Email,
                    DefaultWorkspaceId = workspaceId,
                    ModifiedAt = DateTime.MinValue,
                };
            } else {
                user.Name = json.Name;
                user.Email = json.Email;
            }
            user = ctx.Put (user);

            data.IsAdmin = json.IsAdmin;
            data.IsActive = json.IsActive;
            data.WorkspaceId = workspaceId;
            data.UserId = user.Id;

            ImportCommonJson (data, json);
        }
开发者ID:readiescards,项目名称:mobile,代码行数:27,代码来源:WorkspaceUserJsonConverter.cs


示例2: Import

 public static CommonData Import (this CommonJson json, IDataStoreContext ctx,
                                  Guid? localIdHint = null, CommonData mergeBase = null)
 {
     var type = json.GetType ();
     if (type == typeof (ClientJson)) {
         return Import ((ClientJson)json, ctx, localIdHint, (ClientData)mergeBase);
     } else if (type == typeof (ProjectJson)) {
         return Import ((ProjectJson)json, ctx, localIdHint, (ProjectData)mergeBase);
     } else if (type == typeof (ProjectUserJson)) {
         return Import ((ProjectUserJson)json, ctx, localIdHint, (ProjectUserData)mergeBase);
     } else if (type == typeof (TagJson)) {
         return Import ((TagJson)json, ctx, localIdHint, (TagData)mergeBase);
     } else if (type == typeof (TaskJson)) {
         return Import ((TaskJson)json, ctx, localIdHint, (TaskData)mergeBase);
     } else if (type == typeof (TimeEntryJson)) {
         return Import ((TimeEntryJson)json, ctx, localIdHint, (TimeEntryData)mergeBase);
     } else if (type == typeof (UserJson)) {
         return Import ((UserJson)json, ctx, localIdHint, (UserData)mergeBase);
     } else if (type == typeof (WorkspaceJson)) {
         return Import ((WorkspaceJson)json, ctx, localIdHint, (WorkspaceData)mergeBase);
     } else if (type == typeof (WorkspaceUserJson)) {
         return Import ((WorkspaceUserJson)json, ctx, localIdHint, (WorkspaceUserData)mergeBase);
     }
     throw new InvalidOperationException (String.Format ("Unknown type of {0}", type));
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:25,代码来源:JsonExtensions.cs


示例3: Export

        public WorkspaceUserJson Export (IDataStoreContext ctx, WorkspaceUserData data)
        {
            var userRows = ctx.Connection.Table<UserData> ()
                .Take (1).Where (m => m.Id == data.UserId).ToList ();
            if (userRows.Count == 0) {
                throw new InvalidOperationException (String.Format (
                    "Cannot export data with invalid local relation ({0}#{1}) to JSON.",
                    typeof(UserData).Name, data.UserId
                ));
            }
            var user = userRows [0];
            if (user.RemoteId == null) {
                throw new RelationRemoteIdMissingException (typeof(UserData), data.UserId);
            }

            var workspaceId = GetRemoteId<WorkspaceData> (ctx, data.WorkspaceId);

            return new WorkspaceUserJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                IsAdmin = data.IsAdmin,
                IsActive = data.IsActive,
                Name = user.Name,
                Email = user.Email,
                WorkspaceId = workspaceId,
                UserId = user.RemoteId.Value,
            };
        }
开发者ID:readiescards,项目名称:mobile,代码行数:28,代码来源:WorkspaceUserJsonConverter.cs


示例4: GetTimeEntryTags

 private List<string> GetTimeEntryTags (IDataStoreContext ctx, Guid id)
 {
     if (id == Guid.Empty) {
         return new List<string> (0);
     }
     return ctx.GetTimeEntryTagNames (id);
 }
开发者ID:peeedge,项目名称:mobile,代码行数:7,代码来源:TimeEntryJsonConverter.cs


示例5: Import

        public ClientData Import (IDataStoreContext ctx, ClientJson json, Guid? localIdHint = null, ClientData mergeBase = null)
        {
            var data = GetByRemoteId<ClientData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new ClientMerger (mergeBase) : null;
            if (merger != null && data != null)
                merger.Add (new ClientData (data));

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    ctx.Delete (data);
                    data = null;
                }
            } else if (merger != null || ShouldOverwrite (data, json)) {
                data = data ?? new ClientData ();
                ImportJson (ctx, data, json);

                if (merger != null) {
                    merger.Add (data);
                    data = merger.Result;
                }

                data = ctx.Put (data);
            }

            return data;
        }
开发者ID:readiescards,项目名称:mobile,代码行数:27,代码来源:ClientJsonConverter.cs


示例6: Export

        public ClientJson Export (IDataStoreContext ctx, ClientData data)
        {
            var workspaceId = GetRemoteId<WorkspaceData> (ctx, data.WorkspaceId);

            return new ClientJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                Name = data.Name,
                WorkspaceId = workspaceId,
            };
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:11,代码来源:ClientJsonConverter.cs


示例7: ImportJson

        private static void ImportJson (IDataStoreContext ctx, ProjectUserData data, ProjectUserJson json)
        {
            var projectId = GetLocalId<ProjectData> (ctx, json.ProjectId);
            var userId = GetLocalId<UserData> (ctx, json.UserId);

            data.HourlyRate = json.HourlyRate;
            data.IsManager = json.IsManager;
            data.ProjectId = projectId;
            data.UserId = userId;

            ImportCommonJson (data, json);
        }
开发者ID:readiescards,项目名称:mobile,代码行数:12,代码来源:ProjectUserJsonConverter.cs


示例8: Merge

        private static void Merge (IDataStoreContext ctx, TaskData data, TaskJson json)
        {
            var projectId = GetLocalId<ProjectData> (ctx, json.ProjectId);
            var workspaceId = GetLocalId<WorkspaceData> (ctx, json.WorkspaceId);

            data.Name = json.Name;
            data.IsActive = json.IsActive;
            data.Estimate = json.Estimate;
            data.ProjectId = projectId;
            data.WorkspaceId = workspaceId;

            MergeCommon (data, json);
        }
开发者ID:jblj,项目名称:mobile,代码行数:13,代码来源:TaskJsonConverter.cs


示例9: Export

        public ProjectUserJson Export (IDataStoreContext ctx, ProjectUserData data)
        {
            var projectId = GetRemoteId<ProjectData> (ctx, data.ProjectId);
            var userId = GetRemoteId<UserData> (ctx, data.UserId);

            return new ProjectUserJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                HourlyRate = data.HourlyRate,
                IsManager = data.IsManager,
                ProjectId = projectId,
                UserId = userId,
            };
        }
开发者ID:readiescards,项目名称:mobile,代码行数:14,代码来源:ProjectUserJsonConverter.cs


示例10: Export

        public TaskJson Export (IDataStoreContext ctx, TaskData data)
        {
            var projectId = GetRemoteId<ProjectData> (ctx, data.ProjectId);
            var workspaceId = GetRemoteId<WorkspaceData> (ctx, data.WorkspaceId);

            return new TaskJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                Name = data.Name,
                IsActive = data.IsActive,
                Estimate = data.Estimate,
                ProjectId = projectId,
                WorkspaceId = workspaceId,
            };
        }
开发者ID:jblj,项目名称:mobile,代码行数:15,代码来源:TaskJsonConverter.cs


示例11: Export

 public WorkspaceJson Export (IDataStoreContext ctx, WorkspaceData data)
 {
     return new WorkspaceJson () {
         Id = data.RemoteId,
         ModifiedAt = data.ModifiedAt.ToUtc (),
         Name = data.Name,
         IsPremium = data.IsPremium,
         DefaultRate = data.DefaultRate,
         DefaultCurrency = data.DefaultCurrency,
         OnlyAdminsMayCreateProjects = data.ProjectCreationPrivileges == AccessLevel.Admin,
         OnlyAdminsSeeBillableRates = data.BillableRatesVisibility == AccessLevel.Admin,
         RoundingMode = data.RoundingMode,
         RoundingPercision = data.RoundingPercision,
         LogoUrl = data.LogoUrl,
     };
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:16,代码来源:WorkspaceJsonConverter.cs


示例12: Import

        public TagData Import (IDataStoreContext ctx, TagJson json, Guid? localIdHint = null, bool forceUpdate = false)
        {
            var data = GetByRemoteId<TagData> (ctx, json.Id.Value, localIdHint);

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    ctx.Delete (data);
                    data = null;
                }
            } else if (data == null || forceUpdate || data.ModifiedAt < json.ModifiedAt) {
                data = Merge (ctx, data, json);
                data = ctx.Put (data);
            }

            return data;
        }
开发者ID:jblj,项目名称:mobile,代码行数:16,代码来源:TagJsonConverter.cs


示例13: ImportJson

        private static void ImportJson (IDataStoreContext ctx, UserData data, UserJson json)
        {
            var defaultWorkspaceId = GetLocalId<WorkspaceData> (ctx, json.DefaultWorkspaceId);

            data.Name = json.Name;
            data.Email = json.Email;
            data.StartOfWeek = json.StartOfWeek;
            data.DateFormat = json.DateFormat;
            data.TimeFormat = json.TimeFormat;
            data.ImageUrl = json.ImageUrl;
            data.Locale = json.Locale;
            data.Timezone = json.Timezone;
            data.SendProductEmails = json.SendProductEmails;
            data.SendTimerNotifications = json.SendTimerNotifications;
            data.SendWeeklyReport = json.SendWeeklyReport;
            data.TrackingMode = json.StoreStartAndStopTime ? TrackingMode.StartNew : TrackingMode.Continue;
            data.DefaultWorkspaceId = defaultWorkspaceId;

            ImportCommonJson (data, json);
        }
开发者ID:readiescards,项目名称:mobile,代码行数:20,代码来源:UserJsonConverter.cs


示例14: ImportJson

        private static TagData ImportJson (IDataStoreContext ctx, TagData data, TagJson json)
        {
            var workspaceId = GetLocalId<WorkspaceData> (ctx, json.WorkspaceId);

            if (data == null) {
                // Fallback to name lookup for unsynced tags:
                var rows = ctx.Connection.Table<TagData> ().Take (1)
                    .Where (r => r.WorkspaceId == workspaceId && r.Name == json.Name && r.RemoteId == null);
                data = rows.FirstOrDefault ();
            }

            // As a last chance create new tag:
            data = data ?? new TagData ();

            data.Name = json.Name;
            data.WorkspaceId = workspaceId;

            ImportCommonJson (data, json);

            return data;
        }
开发者ID:readiescards,项目名称:mobile,代码行数:21,代码来源:TagJsonConverter.cs


示例15: Import

        public ClientData Import (IDataStoreContext ctx, ClientJson json, Guid? localIdHint = null, ClientData mergeBase = null)
        {
            var log = ServiceContainer.Resolve<ILogger> ();

            var data = GetByRemoteId<ClientData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new ClientMerger (mergeBase) : null;
            if (merger != null && data != null) {
                merger.Add (new ClientData (data));
            }

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    log.Info (Tag, "Deleting local data for {0}.", data.ToIdString ());
                    ctx.Delete (data);
                    data = null;
                }
            } else if (merger != null || ShouldOverwrite (data, json)) {
                data = data ?? new ClientData ();
                ImportJson (ctx, data, json);

                if (merger != null) {
                    merger.Add (data);
                    data = merger.Result;
                }

                if (merger != null) {
                    log.Info (Tag, "Importing {0}, merging with local data.", data.ToIdString ());
                } else {
                    log.Info (Tag, "Importing {0}, replacing local data.", data.ToIdString ());
                }

                data = ctx.Put (data);
            } else {
                log.Info (Tag, "Skipping import of {0}.", json.ToIdString ());
            }

            return data;
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:39,代码来源:ClientJsonConverter.cs


示例16: Export

        public UserJson Export (IDataStoreContext ctx, UserData data)
        {
            var defaultWorkspaceId = GetRemoteId<WorkspaceData> (ctx, data.DefaultWorkspaceId);

            return new UserJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                Name = data.Name,
                Email = data.Email,
                StartOfWeek = data.StartOfWeek,
                DateFormat = data.DateFormat,
                TimeFormat = data.TimeFormat,
                ImageUrl = data.ImageUrl,
                Locale = data.Locale,
                Timezone = data.Timezone,
                SendProductEmails = data.SendProductEmails,
                SendTimerNotifications = data.SendTimerNotifications,
                SendWeeklyReport = data.SendWeeklyReport,
                StoreStartAndStopTime = data.TrackingMode == TrackingMode.StartNew,
                DefaultWorkspaceId = defaultWorkspaceId,
            };
        }
开发者ID:readiescards,项目名称:mobile,代码行数:22,代码来源:UserJsonConverter.cs


示例17: Export

 public static CommonJson Export (this CommonData data, IDataStoreContext ctx)
 {
     var type = data.GetType ();
     if (type == typeof (ClientData)) {
         return Export ((ClientData)data, ctx);
     } else if (type == typeof (ProjectData)) {
         return Export ((ProjectData)data, ctx);
     } else if (type == typeof (ProjectUserData)) {
         return Export ((ProjectUserData)data, ctx);
     } else if (type == typeof (TagData)) {
         return Export ((TagData)data, ctx);
     } else if (type == typeof (TaskData)) {
         return Export ((TaskData)data, ctx);
     } else if (type == typeof (TimeEntryData)) {
         return Export ((TimeEntryData)data, ctx);
     } else if (type == typeof (UserData)) {
         return Export ((UserData)data, ctx);
     } else if (type == typeof (WorkspaceData)) {
         return Export ((WorkspaceData)data, ctx);
     } else if (type == typeof (WorkspaceUserData)) {
         return Export ((WorkspaceUserData)data, ctx);
     }
     throw new InvalidOperationException (String.Format ("Unknown type of {0}", type));
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:24,代码来源:JsonExtensions.cs


示例18: Export

        public TimeEntryJson Export (IDataStoreContext ctx, TimeEntryData data)
        {
            var userId = GetRemoteId<UserData> (ctx, data.UserId);
            var workspaceId = GetRemoteId<WorkspaceData> (ctx, data.WorkspaceId);
            var projectId = GetRemoteId<ProjectData> (ctx, data.ProjectId);
            var taskId = GetRemoteId<TaskData> (ctx, data.TaskId);
            var tags = GetTimeEntryTags (ctx, data.Id);

            return new TimeEntryJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                Description = data.Description,
                IsBillable = data.IsBillable,
                StartTime = data.StartTime.ToUtc (),
                StopTime = data.StopTime.ToUtc (),
                DurationOnly = data.DurationOnly,
                Duration = EncodeDuration (data),
                Tags = tags,
                UserId = userId,
                WorkspaceId = workspaceId,
                ProjectId = projectId,
                TaskId = taskId,
            };
        }
开发者ID:peeedge,项目名称:mobile,代码行数:24,代码来源:TimeEntryJsonConverter.cs


示例19: ImportJson

        private static void ImportJson (IDataStoreContext ctx, TimeEntryData data, TimeEntryJson json)
        {
            var userId = GetUserLocalId (ctx, json.UserId);
            var workspaceId = GetLocalId<WorkspaceData> (ctx, json.WorkspaceId);
            var projectId = GetLocalId<ProjectData> (ctx, json.ProjectId);
            var taskId = GetLocalId<TaskData> (ctx, json.TaskId);

            data.Description = json.Description;
            data.IsBillable = json.IsBillable;
            data.DurationOnly = json.DurationOnly;
            data.UserId = userId;
            data.WorkspaceId = workspaceId;
            data.ProjectId = projectId;
            data.TaskId = taskId;
            DecodeDuration (data, json);

            ImportCommonJson (data, json);
        }
开发者ID:peeedge,项目名称:mobile,代码行数:18,代码来源:TimeEntryJsonConverter.cs


示例20: ImportJson

 private static void ImportJson (IDataStoreContext ctx, ClientData data, ClientJson json)
 {
     data.Name = json.Name;
     data.WorkspaceId = GetLocalId<WorkspaceData> (ctx, json.WorkspaceId);
     ImportCommonJson (data, json);
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:6,代码来源:ClientJsonConverter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IDataStoreKey类代码示例发布时间:2022-05-24
下一篇:
C# IDataStore类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap