我需要获得给定项目的类之间的某种依赖关系图,即该特定类使用的所有类。我想知道给定的类正在使用哪些类,以便以后可以在项目中找到它们的文件路径。考虑以下简单示例:
public class Dog: Animal, IBark
{
public void Bark()
{
// Code to bark.
}
public void Fight(Cat cat)
{
// Code to fight cat.
}
}
Run Code Online (Sandbox Code Playgroud)
对于这个具体的例子,我想知道该类Dog
使用了哪些类。所以我想以编程方式访问具有这些依赖项的对象。在这种情况下,该对象将包含IBark
、Animal
和Cat
类/接口以及可能它们各自的文件路径。
这在 C# 中可能吗?我尝试研究 Roslyn API,虽然我可以解析文档并遍历它来查找节点,但我还没有找到一种方法来获取与这些节点相关的元数据,这些元数据可能会给我我正在寻找的内容(例如文件路径) 。这让我想知道是否有更好的方法来解决这个问题。
我有一个带有多轨音频的视频,我需要在 html 中更改此语言
未捕获的类型错误:无法读取未定义的属性“长度”(索引):103(匿名)@(索引):103
这有效:
bastille% perl6 -e 'my @squares = (1...*).map({ $_ ** 2 }); say @squares[0..^10].join: ", "'
1, 4, 9, 16, 25, 36, 49, 64, 81, 100
Run Code Online (Sandbox Code Playgroud)
但是,这不是:
bastille% perl6 -e 'my @squares <== map { $_ ** 2 } <== 1...*; say @squares[0..^10].join: ", "'
Cannot push a lazy list onto a Array
in block <unit> at -e line 1
Run Code Online (Sandbox Code Playgroud)
为什么会抛出?有没有一种方法可以将延迟列表与摘要一起使用?
我正在遵循TypeScript-React-Starter 教程,并在src/index.tsx
. 从教程来看,
const store = createStore<StoreState>(enthusiasm, {
enthusiasmLevel: 1,
languageName: 'I\'m fluent in Math and Klingon'
});
Run Code Online (Sandbox Code Playgroud)
产生错误
Expected 4 type arguments, but got 1.
Run Code Online (Sandbox Code Playgroud)
问题 #136建议使用
import { EnthusiasmAction } from './actions/index';
const store = createStore<StoreState, EnthusiasmAction, any, any>(enthusiasm, {
enthusiasmLevel: 1,
languageName: 'I\'m fluent in Math and Klingon'
});
Run Code Online (Sandbox Code Playgroud)
其他类似的解决方案,但这会产生另一个错误:
Argument of type '(state: StoreState, action: EnthusiasmAction) => StoreState' is not assignable to parameter of type 'Reducer<StoreState, EnthusiasmAction>'.
Types of parameters 'state' …
Run Code Online (Sandbox Code Playgroud) 我的数据由标识符 (srdr_id) 和列表列组成。
dat <- structure(list(srdr_id = c("174136", "174258", "174684"), outcomes = list(
structure(list(outcome_s = c("use_alcohol", "use_cannabis",
"use_cocaine")), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-3L)), structure(list(outcome_s = "use_methamphetamine"), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -1L)), structure(list(
outcome_s = c("use_alcohol", "use_heavy")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -2L)))), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -3L))
> dat
# A tibble: 3 x 2
srdr_id outcomes
<chr> <list>
1 174136 <tibble [3 x 1]> …
Run Code Online (Sandbox Code Playgroud) 我正在寻找编写一个 PHP 脚本来扫描我的 gmail 收件箱,并阅读未读的电子邮件。不需要用户交互。这必须发生在执行 PHP 文件的 cronjob 上。
这甚至可以通过 API 实现吗?Google 的文档绝对糟糕透了,似乎没有任何示例可以让您以编程方式授权登录。他们总是要求用户在 oauth 请求上物理按下允许按钮。
有没有人尝试过简单地登录并列出您的消息而无需人工交互的经验?
我有一个特定的问题,我需要一个可以采用一个或另一个结构的值的变量。我用一个具有接口值的用户字段创建一个userResp结构,但是如果我添加一个函数来返回名为Password的用户的子属性,则会返回错误。user的值将是具有Password属性的结构。
结构:
type userResp struct {
user interface{}
}
Run Code Online (Sandbox Code Playgroud)
功能
func (ur *userResp) password() string {
return ur.user.Password
}
Run Code Online (Sandbox Code Playgroud)
我得到了,ur.user.Password undefined (type interface {} is interface with no methods)
但是界面user
可以是带有Password
字段的Admin或User结构。
任何想法如何执行此操作,我需要使用用户或admin的结构并将其返回。
我不能使用2个函数,因为两种情况下的逻辑都是相同的。我需要用户或管理员的整个结构
使用Python 3:
a = ['(', 'z', 'a', '1', '{']
a.sort()
a
['(', '1', 'a', 'z', '{']
Run Code Online (Sandbox Code Playgroud)
如何对列表进行排序,使字母数字字符位于标点符号之前:
a = ['(', 'z', 'a', '1', '{']
a.custom_sort()
a
['1', 'a', 'z', '(', '{']
Run Code Online (Sandbox Code Playgroud)
(实际上,我并不关心最后两个字符的顺序。)
这似乎很难!
我知道Python会按字母顺序排序,我正在寻找一种人类可读的排序方式。我找到了natsort,但它似乎只处理数字。
有什么办法可以中止 react-native app 上的 fetch 请求吗?
class MyComponent extends React.Component {
state = { data: null };
componentDidMount = () =>
fetch('http://www.example.com')
.then(data => this.setState({ data }))
.catch(error => {
throw error;
});
cancelRequest = () => {
//???
};
render = () => <div>{this.state.data ? this.state.data : 'loading'}</div>;
}
Run Code Online (Sandbox Code Playgroud)
我尝试了课堂上的abort
功能,AbortController
但它不起作用!!
...
abortController = new window.AbortController();
cancelRequest = () => this.abortController.abort();
componentDidMount = () =>
fetch('http://www.example.com', { signal: this.abortController.signal })
....
Run Code Online (Sandbox Code Playgroud)
请任何帮助!
我不知道到底是什么问题,但是当我单击按钮选择控制台中出现错误的图像时,这是我的代码
_checkPermissions = async () => {
try {
const { status } = await Permission.askAsync(Permission.CAMERA);
this.setState({ camera: status });
const { statusRoll } = await Permission.askAsync(Permission.CAMERA_ROLL);
this.setState({ cameraRoll: statusRoll });
} catch (err) {
console.log(err);
}
};
findNewImage = async () => {
try {
this._checkPermissions();
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: "Images",
allowsEditing: true,
quality: 1
});
if (!result.cancelled) {
this.setState({
image: result.uri
});
} else {
console.log("cancel");
}
} catch (err) {
// console.log(err);
}
};
Run Code Online (Sandbox Code Playgroud) react-native ×2
.net-core ×1
android ×1
c# ×1
dplyr ×1
expo ×1
fetch ×1
gmail-api ×1
go ×1
google-api ×1
google-oauth ×1
html ×1
javascript ×1
npm ×1
perl6 ×1
php ×1
purrr ×1
python ×1
r ×1
raku ×1
react-redux ×1
reactjs ×1
redux ×1
roslyn ×1
struct ×1
tostring ×1
typescript ×1