Browse Source

Merge branch 'master' into feature-proposal

pull/285/head
Sebastian 8 years ago
parent
commit
bae64ac93d
  1. 2
      src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository.cs
  2. 2
      src/Squidex.Domain.Users/IUserEvents.cs
  3. 4
      src/Squidex.Domain.Users/NoopUserEvents.cs
  4. 8
      src/Squidex.Infrastructure/Orleans/J.cs
  5. 17
      src/Squidex.Infrastructure/Orleans/JExtensions.cs
  6. 23
      src/Squidex.Infrastructure/Orleans/J{T}.cs
  7. 2
      src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs
  8. 11
      src/Squidex/Config/Domain/SerializationServices.cs
  9. 3
      src/Squidex/Config/Domain/StoreServices.cs
  10. 5
      src/Squidex/Config/Orleans/ClientWrapper.cs
  11. 2
      src/Squidex/Config/Orleans/SiloWrapper.cs
  12. 4
      src/Squidex/app/framework/angular/forms/jscript-editor.component.ts
  13. 2
      src/Squidex/app/framework/angular/forms/transform-input.directive.ts
  14. 5
      src/Squidex/app/shared/components/markdown-editor.component.ts
  15. 5
      src/Squidex/app/shared/components/rich-editor.component.ts

2
src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository.cs

@ -130,7 +130,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
await Collection.Find(x => x.SchemaIdId == schemaId && ids.Contains(x.Id) && x.IsDeleted == false).Only(x => x.Id)
.ToListAsync();
return ids.Except(contentEntities.Select(x => Guid.Parse(x["id"].AsString))).ToList();
return ids.Except(contentEntities.Select(x => Guid.Parse(x["_id"].AsString))).ToList();
}
public async Task<IContentEntity> FindContentAsync(IAppEntity app, ISchemaEntity schema, Guid id)

2
src/Squidex.Domain.Users/IUserEvents.cs

@ -12,5 +12,7 @@ namespace Squidex.Domain.Users
public interface IUserEvents
{
void OnUserRegistered(IUser user);
void OnConsentGiven(IUser user);
}
}

4
src/Squidex.Domain.Users/NoopUserEvents.cs

@ -11,6 +11,10 @@ namespace Squidex.Domain.Users
{
public sealed class NoopUserEvents : IUserEvents
{
public void OnConsentGiven(IUser user)
{
}
public void OnUserRegistered(IUser user)
{
}

8
src/Squidex.Infrastructure/Orleans/J.cs

@ -6,15 +6,15 @@
// ==========================================================================
using System.Threading.Tasks;
using Newtonsoft.Json;
#pragma warning disable SA1401 // Fields must be private
namespace Squidex.Infrastructure.Orleans
{
public static class J
{
public static JsonSerializer Serializer = new JsonSerializer();
public static J<T> AsJ<T>(this T value)
{
return new J<T>(value);
}
public static J<T> Of<T>(T value)
{

17
src/Squidex.Infrastructure/Orleans/JExtensions.cs

@ -1,17 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
namespace Squidex.Infrastructure.Orleans
{
public static class JExtensions
{
public static J<T> AsJ<T>(this T value)
{
return new J<T>(value);
}
}
}

23
src/Squidex.Infrastructure/Orleans/J{T}.cs

@ -8,6 +8,7 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Orleans.CodeGeneration;
using Orleans.Serialization;
@ -17,6 +18,8 @@ namespace Squidex.Infrastructure.Orleans
{
public struct J<T>
{
private static readonly JsonSerializer DefaultSerializer = JsonSerializer.CreateDefault();
public T Value { get; }
[JsonConstructor]
@ -56,11 +59,13 @@ namespace Squidex.Infrastructure.Orleans
{
using (Profile.Method(nameof(J)))
{
var jsonSerializer = GetSerializer(context);
var stream = new MemoryStream();
using (var writer = new JsonTextWriter(new StreamWriter(stream)))
{
J.Serializer.Serialize(writer, input);
jsonSerializer.Serialize(writer, input);
writer.Flush();
}
@ -77,6 +82,8 @@ namespace Squidex.Infrastructure.Orleans
{
using (Profile.Method(nameof(J)))
{
var jsonSerializer = GetSerializer(context);
var outLength = context.StreamReader.ReadInt();
var outBytes = context.StreamReader.ReadBytes(outLength);
@ -84,9 +91,21 @@ namespace Squidex.Infrastructure.Orleans
using (var reader = new JsonTextReader(new StreamReader(stream)))
{
return J.Serializer.Deserialize(reader, expected);
return jsonSerializer.Deserialize(reader, expected);
}
}
}
private static JsonSerializer GetSerializer(ISerializerContext context)
{
try
{
return context?.ServiceProvider?.GetService<JsonSerializer>() ?? DefaultSerializer;
}
catch
{
return DefaultSerializer;
}
}
}
}

2
src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs

@ -123,6 +123,8 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account
await userManager.UpdateAsync(user);
userEvents.OnConsentGiven(user);
return RedirectToReturnUrl(returnUrl);
}

11
src/Squidex/Config/Domain/SerializationServices.cs

@ -20,7 +20,6 @@ using Squidex.Domain.Apps.Events;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.MongoDb;
namespace Squidex.Config.Domain
{
@ -74,16 +73,14 @@ namespace Squidex.Config.Domain
ConfigureJson(DefaultJsonSettings, TypeNameHandling.Auto);
DefaultJsonSerializer = JsonSerializer.Create(DefaultJsonSettings);
BsonJsonConvention.Register(DefaultJsonSerializer);
}
public static IServiceCollection AddMySerializers(this IServiceCollection services)
{
services.AddSingletonAs(t => FieldRegistry);
services.AddSingletonAs(t => DefaultJsonSettings);
services.AddSingletonAs(t => DefaultJsonSerializer);
services.AddSingletonAs(t => TypeNameRegistry);
services.AddSingleton(FieldRegistry);
services.AddSingleton(DefaultJsonSettings);
services.AddSingleton(DefaultJsonSerializer);
services.AddSingleton(TypeNameRegistry);
return services;
}

3
src/Squidex/Config/Domain/StoreServices.cs

@ -30,6 +30,7 @@ using Squidex.Domain.Users.MongoDb.Infrastructure;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Migrations;
using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.States;
using Squidex.Infrastructure.UsageTracking;
using Squidex.Shared.Users;
@ -44,6 +45,8 @@ namespace Squidex.Config.Domain
{
["MongoDB"] = () =>
{
BsonJsonConvention.Register(SerializationServices.DefaultJsonSerializer);
var mongoConfiguration = config.GetRequiredValue("store:mongoDb:configuration");
var mongoDatabaseName = config.GetRequiredValue("store:mongoDb:database");
var mongoContentDatabaseName = config.GetOptionalValue("store:mongoDb:contentDatabase", mongoDatabaseName);

5
src/Squidex/Config/Orleans/ClientWrapper.cs

@ -10,6 +10,7 @@ using System.Net;
using Orleans;
using Orleans.Configuration;
using Orleans.Runtime;
using Squidex.Config.Domain;
using Squidex.Domain.Apps.Entities;
using Squidex.Infrastructure;
@ -31,6 +32,10 @@ namespace Squidex.Config.Orleans
{
options.ClusterId = "squidex";
})
.ConfigureServices((context, services) =>
{
services.AddMySerializers();
})
.ConfigureApplicationParts(builder =>
{
builder.AddApplicationPart(SquidexEntities.Assembly);

2
src/Squidex/Config/Orleans/SiloWrapper.cs

@ -53,8 +53,6 @@ namespace Squidex.Config.Orleans
silo = new Lazy<ISiloHost>(() =>
{
J.Serializer = SerializationServices.DefaultJsonSerializer;
var hostBuilder = new SiloHostBuilder()
.UseDashboard(options => options.HostSelf = false)
.AddStartupTask<Bootstrap<IContentSchedulerGrain>>()

4
src/Squidex/app/framework/angular/forms/jscript-editor.component.ts

@ -9,7 +9,7 @@ import { AfterViewInit, Component, ElementRef, forwardRef, ViewChild } from '@an
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Subject } from 'rxjs';
import { ResourceLoaderService } from '@app/framework/internal';
import { ResourceLoaderService, Types } from '@app/framework/internal';
declare var ace: any;
@ -40,7 +40,7 @@ export class JscriptEditorComponent implements ControlValueAccessor, AfterViewIn
}
public writeValue(obj: any) {
this.value = obj + '';
this.value = Types.isString(obj) ? obj : '';
if (this.aceEditor) {
this.setValue(this.value);

2
src/Squidex/app/framework/angular/forms/transform-input.directive.ts

@ -71,7 +71,7 @@ export class TransformInputDirective implements ControlValueAccessor {
}
public writeValue(obj: any) {
const normalizedValue = this.transformValue(obj + '');
const normalizedValue = this.transformValue(Types.isString(obj) ? obj : '');
this.renderer.setProperty(this.element.nativeElement, 'value', normalizedValue);
}

5
src/Squidex/app/shared/components/markdown-editor.component.ts

@ -11,7 +11,8 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import {
AssetDto,
ModalView,
ResourceLoaderService
ResourceLoaderService,
Types
} from '@app/shared/internal';
declare var SimpleMDE: any;
@ -54,7 +55,7 @@ export class MarkdownEditorComponent implements ControlValueAccessor, AfterViewI
}
public writeValue(obj: any) {
this.value = obj + '';
this.value = Types.isString(obj) ? obj : '';
if (this.simplemde) {
this.simplemde.value(this.value);

5
src/Squidex/app/shared/components/rich-editor.component.ts

@ -11,7 +11,8 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import {
AssetDto,
ModalView,
ResourceLoaderService
ResourceLoaderService,
Types
} from '@app/shared/internal';
declare var tinymce: any;
@ -112,7 +113,7 @@ export class RichEditorComponent implements ControlValueAccessor, AfterViewInit,
}
public writeValue(obj: any) {
this.value = obj + '';
this.value = Types.isString(obj) ? obj : '';
if (this.tinyEditor) {
this.tinyEditor.setContent(this.value);

Loading…
Cancel
Save