예제 #1
0
 public static T DeserializeObject <T>(string jsonString, Interfaces.IClientQueryRepository proxyRepository)
 {
     return(JsonConvert.DeserializeObject <T>(jsonString, new JsonSerializerSettings()
     {
         ContractResolver = new ProxyDeserializeContractResolver(proxyRepository),
         TypeNameHandling = TypeNameHandling.Auto
     }));
 }
예제 #2
0
        public static async Task <T> GetByIdFromCollection <T>(this Interfaces.IClientQueryRepository repository, string id) where T : Interfaces.IHaveId
        {
            var entities = await repository.Get <T>();

            if (entities == null)
            {
                return(default(T));
            }
            return(entities.FirstOrDefault(x => x.Id == id));
        }
 /// <summary>
 /// Special serializer for derived types
 /// </summary>
 private JsonSerializer DerivedTypesSerializer(Interfaces.IClientQueryRepository repository = null) => LazyInitializer.EnsureInitialized(ref _derivedTypesSerializer,
                                                                                                                                         () =>
                                                                                                                                         JsonSerializer.Create(new JsonSerializerSettings()
 {
     ContractResolver = new InterfaceContractResolver(typeof(Interfaces.IInheritable)),
     Converters       = new JsonConverter[]
     {
         new StringEnumConverter(),
         new ProxyDeserializeConverter(repository)
     },
     NullValueHandling = NullValueHandling.Ignore,
     TypeNameHandling  = TypeNameHandling.Objects,
 }));
        /// <summary>
        /// Sequential steps to build full client context
        /// </summary>
        public async Task Build(Context context, Interfaces.IClientQueryRepository repository)
        {
            _             = context ?? throw new ArgumentNullException("context");
            _             = repository ?? throw new ArgumentNullException("repository");
            context.Users = await repository.Get <Subjects.User>();

            context.Groups = await repository.Get <Subjects.Group>();

            context.Dates = await repository.Get <Date>();

            context.CalendarTypes = await repository.Get <CalendarType>();

            context.Calendars = await repository.Get <Calendar>();

            context.Events = await repository.Get <Event>();

            context.Comments = await repository.Get <Comment>();

            context.Occurences = await repository.Get <Occurence>();

            context.ReadRecords = await repository.Get <ReadRecord>();

            context.IsBuilt = true;
        }