예제 #1
0
 private JsonSerializerSettings postSettings(IWorkspaceFeatureCollection features)
 => SerializerSettings.For(new FilterPropertiesContractResolver(
                               new List <IPropertiesFilter>
 {
     new IgnoreAttributeFilter <IgnoreWhenPostingAttribute>(),
     new RequiresFeatureAttributeFilter(features)
 }));
예제 #2
0
        private JsonSerializerSettings getSettings(SerializationReason reason, IWorkspaceFeatureCollection features)
        {
            switch (reason)
            {
            case Post:
                return(postSettings(features));

            default:
                return(defaultSettings);
            }
        }
예제 #3
0
 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;
 }
예제 #5
0
 public WorkspaceFeatureCollection(IWorkspaceFeatureCollection entity)
 {
     WorkspaceId = entity.WorkspaceId;
     Features    = entity.Features;
 }
예제 #6
0
        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));
        }
예제 #7
0
        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);
예제 #10
0
 public string Serialize <T>(T data, SerializationReason reason = Default, IWorkspaceFeatureCollection features = null)
 => JsonConvert.SerializeObject(data, Formatting.None, getSettings(reason, features));