Base solution for your next web application

Activities of "abarref"

Update: in our case it was Syncfusion material.css that had an internal import of Google Fonts.

Hi @dzungle, I'm having the same problem. How did you resolve it? Thanks

Just doing a search and replace of "net5.0" to "net6.0" seems to fix it. The solution is now working for me.

Same issue. Web.Host.csproj has

<TargetFramework>net5.0</TargetFramework>
Answer

Yes, I saw that. I was wondering if there was something similar to the AddOrUpdate method of ConcurrentDictionary. I ended up writing the following extension method:

public static class CacheExtensions
{
    public static TValue GetOrUpdate<TKey, TValue>(this ICache cache, TKey key, Func<TValue> seedFactory, Func<TValue, TValue> updateFactory)
    {
        lock (cache)
        {
            var value = cache.Get(key, k => seedFactory());

            value = updateFactory(value);

            cache.Set(key.ToString(), value);

            return value;
        }
    }
}

Sorry, I ommitted some lines that I thought were not required. This is my full service.extensions.ts:

import {map} from 'rxjs/operators';

export class ClientBase {
    protected transformOptions(options: any) {
        // Change options if required

        // console.log('HTTP call, options: ' + JSON.stringify(options));
        //
        // options.headers.append("myheader", "myvalue");

        // if (options != null) {
        //     options.isServiceProxyRequest = true;
        // }

        // options.responseType = 'json';

        // @ts-ignore
        return Promise.resolve(options);
    }

    protected transformResult<R, U>(url: string, response: R, processor: (response: R) => U) {
        let observable = processor(response);

        // @ts-ignore
        observable = observable.pipe(map((data) => {
            return this.isEmptyObject(data) ? null : data;
        }));

        return observable;
    }

    // Reference: https://stackoverflow.com/a/32108184/1454888
    isEmptyObject(obj) {
        if (obj == null) {
            return true;
        }

        if (obj.constructor === Array || obj.constructor === ArrayBuffer) {
            return false;
        }

        for (let prop in obj) {
            if (obj.hasOwnProperty(prop)) {
                return false;
            }
        }

        return JSON.stringify(obj) === JSON.stringify({});
    }
}

So to avoid those compilation issues I added // @ts-ignore on top of them

Hi @maliming, thanks for your reply.

I found a workaround that implies transforming the nswag proxy response:

service.config.nswag file:

  "extensionCode": "service.extensions.ts",
  "clientBaseClass": "ClientBase",
  "useTransformOptionsMethod": true,
  "useTransformResultMethod": true,
  

service.extenisons.ts file:

...... UPDATED: please view the other answer below

It's not a clean solution but achieves the desired behaviour.

Hi @timmackey, did you find a way to disable those messages?

@alper thanks for the suggestion. I took a look at the source code and found that it is also possible to set it in the appsettings.json as follows:

Regards

Thanks @alper. That works. Is there a way to achieve the same but when the database gets initialized? Because I'm recreating the db a lot at the moment.

Showing 1 to 10 of 15 entries