interface

How do I load fonts with filenames which begin with numbers, via the FontFace interface in Safari

偶尔善良 提交于 2021-02-10 17:08:51
问题 I can't get Safari(11.1) to load font files via the FontFace interface, if those files font names begin with numbers. The same files that show an error in Safari load perfectly fine in Chrome and Firefox. Here is the most simplified version I could create that still produces the error. var fonty = new FontFace('0Test', 'url(fonts/0Test.woff)'); console.log('This will only show if the Font name does not begin with a number'); Checking the Safari(11.1 is the version I'm using) console, you'll

How do I load fonts with filenames which begin with numbers, via the FontFace interface in Safari

我们两清 提交于 2021-02-10 17:04:05
问题 I can't get Safari(11.1) to load font files via the FontFace interface, if those files font names begin with numbers. The same files that show an error in Safari load perfectly fine in Chrome and Firefox. Here is the most simplified version I could create that still produces the error. var fonty = new FontFace('0Test', 'url(fonts/0Test.woff)'); console.log('This will only show if the Font name does not begin with a number'); Checking the Safari(11.1 is the version I'm using) console, you'll

Prevent Cast Between Two Interfaces

本秂侑毒 提交于 2021-02-10 15:40:19
问题 I have an internal class which contains implementation details, including properties, which should not be publicly accessible. I have to pass this class to public callers, and allow them to pass it around, store it, serialize it, or do basically whatever they want with it. The class can be accessed publicly in two different ways. These ways are exposed as two public interfaces. I would like to prevent the user from casting between the two public interfaces. Here is some code to demonstrate

Prevent Cast Between Two Interfaces

孤者浪人 提交于 2021-02-10 15:40:02
问题 I have an internal class which contains implementation details, including properties, which should not be publicly accessible. I have to pass this class to public callers, and allow them to pass it around, store it, serialize it, or do basically whatever they want with it. The class can be accessed publicly in two different ways. These ways are exposed as two public interfaces. I would like to prevent the user from casting between the two public interfaces. Here is some code to demonstrate

Typescript interface from array type

一个人想着一个人 提交于 2021-02-08 14:59:57
问题 I need to force an array to have a specific set of values that should be then the keys of my interface. I can force the array with type SomeProperties = ['prop1', 'prop2', 'prop3']; but I don't know how to force an interface to have those properties. I tried something like type MyInterface = { [key in keyof SomeProperties]: string; } but obviously the keys of an array are just numbers so my interface become interface MyInterface { 0: string; 1: string; 2: string; } instead of the wanted

Why is interface variable instantiation possible?

醉酒当歌 提交于 2021-02-08 13:16:10
问题 As far as I know, interfaces cannot be instantiated. If this is true, why does the below code compile and execute? It allows you to create a variable interface. Why is this possible? Interface: public interface IDynamicCode<out TCodeOut> { object DynamicClassInstance { get; set; } TCodeOut Execute(string value = ""); } InCode: var x = new IDynamicCode<string>[10]; Result: UPDATE: It only happens when array declared. Not a single instance. 回答1: You're not instantiating an interface, but an

Interface method return value of own type

和自甴很熟 提交于 2021-02-08 10:11:12
问题 I am trying to make a method which will take structs of a certain type and do operations on them. However, I need to have a method one can call on an instance of the stuct, and it will return objects of that struct's type. I am getting a compile time error because the return type of the type which implements the interface isn't the same as the interface's method return type, but that's because the interface needs to return values of it's own type. Interface declaration: type GraphNode

Interface method return value of own type

夙愿已清 提交于 2021-02-08 10:10:20
问题 I am trying to make a method which will take structs of a certain type and do operations on them. However, I need to have a method one can call on an instance of the stuct, and it will return objects of that struct's type. I am getting a compile time error because the return type of the type which implements the interface isn't the same as the interface's method return type, but that's because the interface needs to return values of it's own type. Interface declaration: type GraphNode

Passing a collection of interface types to a function

青春壹個敷衍的年華 提交于 2021-02-08 06:36:39
问题 I'm having trouble figuring out the correct way to use interfaces in Go. My function needs to take a map of items that implement a certain method. It looks like this: type foo interface { bar() string } func doSomething(items map[string]foo) { } I'm trying to call this function with a type that implements the foo interface. type baz struct { } func (b baz) bar() string { return "hello" } items := map[string]baz{"a": baz{}} doSomething(items) But I get the following error: cannot use items

Passing a collection of interface types to a function

谁说胖子不能爱 提交于 2021-02-08 06:36:35
问题 I'm having trouble figuring out the correct way to use interfaces in Go. My function needs to take a map of items that implement a certain method. It looks like this: type foo interface { bar() string } func doSomething(items map[string]foo) { } I'm trying to call this function with a type that implements the foo interface. type baz struct { } func (b baz) bar() string { return "hello" } items := map[string]baz{"a": baz{}} doSomething(items) But I get the following error: cannot use items