小编Rus*_*yev的帖子

将List <object>转换为List <Type>,Type在运行时已知

我正在实现某种反序列化,并在下一个问题上挣扎:

我有List<object>System.Reflection.Field,这是FieldType可以List<string>,List<int>或者List<bool>,所以我需要从转换List<object>到该类型.

public static object ConvertList(List<object> value, Type type)
{
   //type may be List<int>, List<bool>, List<string>
}
Run Code Online (Sandbox Code Playgroud)

我可以单独编写每个案例,但应该有更好的方法使用反射.

c# system.reflection

14
推荐指数
3
解决办法
2万
查看次数

在没有显示通知的情况下,在Google Play游戏中默默地解锁成就

我正在使用谷歌播放服务,在我的安卓游戏中取得的成就(它实际上是统一的,但并不重要).

为了解锁成就我使用插件调用unlock(GoogleApiClient apiClient,String id)方法.当成就设置为已完成时,Google会显示自己的通知,如下所示: 通知.

我需要默默地解锁成就,而不显示此通知.有什么可以隐藏的吗?

android achievements google-play-services

5
推荐指数
1
解决办法
3410
查看次数

Angular 6如何通过管道进行http调用

我有一个 HTTP 服务,它使用 HttpClient 进行 API 调用:

//provider.service.ts
export interface Lesson {
    id?: number,
    name: string,
    type: LessonType,
    teacher_data: string,
    student_data: string
}

export class ProviderService {
    constructor(private http: HttpClient) {}

    postLesson(form): Observable<Lesson> {        
        const body = this.getFormUrlEncoded(form.value);
        return this.http.post<Lesson>('/api/lesson/', body, this.postHttpOptions);
    }
}
Run Code Online (Sandbox Code Playgroud)

我有一个使用此 ProviderService 的组件,如下所示:

onSubmit():void {
    this.providerService.createLesson(lessonForm).subscribe(result=> {
        console.log(result);
        //do my stuff
      });
    }
  }
Run Code Online (Sandbox Code Playgroud)

它工作得很好,一切都很好。现在我想做一个LessonService,让所有http 调用都通过该服务。它将缓存结果、发出更改等。

我是这样写的:

//updated lessons.component.ts
    onSubmit():void {
        this.LessonsService.createLesson(this.lessonForm).subscribe(result=> {
            console.log(result);
            //do my stuff
        });
    }

//lessons.service.ts
export class LessonsService {
    constructor(private http: …
Run Code Online (Sandbox Code Playgroud)

angular2-observables angular

5
推荐指数
1
解决办法
3万
查看次数