private JsonSerializerSettings postSettings(IWorkspaceFeatureCollection features) => SerializerSettings.For(new FilterPropertiesContractResolver( new List <IPropertiesFilter> { new IgnoreAttributeFilter <IgnoreWhenPostingAttribute>(), new RequiresFeatureAttributeFilter(features) }));
private JsonSerializerSettings getSettings(SerializationReason reason, IWorkspaceFeatureCollection features) { switch (reason) { case Post: return(postSettings(features)); default: return(defaultSettings); } }
public string Serialize <T>(T data, SerializationReason reason = Default, IWorkspaceFeatureCollection features = null) { try { return(JsonConvert.SerializeObject(data, Formatting.None, getSettings(reason, features))); } catch (Exception e) { throw new SerializationException(typeof(T), e); } }
public RequiresFeatureAttributeFilter(IWorkspaceFeatureCollection featuresCollection) { this.featuresCollection = featuresCollection; }
public WorkspaceFeatureCollection(IWorkspaceFeatureCollection entity) { WorkspaceId = entity.WorkspaceId; Features = entity.Features; }
protected IObservable <T> CreateObservable <T>(Endpoint endpoint, HttpHeader header, T entity, SerializationReason serializationReason, IWorkspaceFeatureCollection features = null) { var body = serializer.Serialize <T>(entity, serializationReason, features); return(CreateObservable <T>(endpoint, header, body)); }
protected IObservable <List <TInterface> > CreateListObservable <TModel, TInterface>(Endpoint endpoint, HttpHeader header, List <TModel> entities, SerializationReason serializationReason, IWorkspaceFeatureCollection features = null) where TModel : class, TInterface { var body = serializer.Serialize(entities, serializationReason, features); return(CreateListObservable <TModel, TInterface>(endpoint, header, body)); }
public static WorkspaceFeatureCollection From(IWorkspaceFeatureCollection entity) => new WorkspaceFeatureCollection(entity);
public static bool IsEnabled(this IWorkspaceFeatureCollection self, WorkspaceFeatureId workspaceFeatureId) => self.Features.Any(f => f.FeatureId == workspaceFeatureId && f.Enabled);
public string Serialize <T>(T data, SerializationReason reason = Default, IWorkspaceFeatureCollection features = null) => JsonConvert.SerializeObject(data, Formatting.None, getSettings(reason, features));