我正在尝试在Metro Style App便携式库中的类上定义和检索自定义属性.
就像是
[AttributeUsage(AttributeTargets.Class)]
public class FooAttribute : Attribute
{
}
[Foo]
public class Bar
{
}
class Program
{
static void Main(string[] args)
{
var attrs = CustomAttributeExtensions.GetCustomAttribute<FooAttribute>(typeof(Bar));
}
}
Run Code Online (Sandbox Code Playgroud)
这适用于普通的4.5,但在一个便携式图书馆中,它针对地铁风格的应用程序,它告诉我
Cannot convert type 'System.Type' to 'System.Reflection.MemberInfo'
Run Code Online (Sandbox Code Playgroud)
谢谢
c# custom-attributes system.reflection portable-class-library windows-runtime
我有 ac# 应用程序,可以在谷歌日历中创建事件。出于其自身目的,它控制事件的 UID,有时想要删除并重新创建事件。
当尝试重新创建与已删除事件具有相同 UID 的事件时,会收到“远程服务器返回错误:(409) 冲突”。
我可以通过将“?showdeleted=true&showhidden=true”附加到请求 URL 来查看已删除的事件。
但是,我在 API 中没有看到任何允许我在检索已删除事件后取消删除的内容。
有什么建议么?
更新:
尝试杰伊的建议我有类似的东西
var service = new CalendarService();
service.setUserCredentials("XXX", "XXX");
var query = new CalendarQuery { Uri = new Uri("http://www.google.com/calendar/feeds/default/owncalendars/full") };
var cal = service.Query(query).Entries
.Select (e => new { Title = e.Title.Text, Uri = e.SelfUri,
Id = e.SelfUri.Content.Split('/').Last () } )
.Single (e => e.Title == calendarName);
var eventQuery = new EventQuery(string.Format(@"http://www.google.com/calendar/feeds/{0}/private/full?showdeleted=true&showhidden=true", cal.Id));
var evs = service.Query(eventQuery).Entries.Cast<EventEntry>().ToList();
evs[0].Status = EventEntry.EventStatus.CONFIRMED;
service.Update(ev[0]);
Run Code Online (Sandbox Code Playgroud)
它给我“远程服务器返回错误:(404)未找到。”
我正在评估一个大数据项目,我们需要从各种互联网来源(ftp、api 等)提取大量大数据集,进行轻量转换和轻量数据质量/健全性检查(例如:行和列检查),并将其推向下游。目前的焦点是批量的,但预计会支持流式传输。易于大规模支持是一项重要要求。
我们正在研究 Apache Nifi 和 Gobblin,它们的意图似乎重叠。哪种用例最适合哪个平台?它们如何符合上述用例?
谢谢!
在下面的代码中,每次按键都会触发 onSubmitEditing 事件。奇怪的是,如果我注释掉 onChangeText 事件,有时 onSubmitEditing 似乎只在返回时触发,视情况而定。
有人能够解释我将如何(a) 即使在调用 onChangeText 时也能正确触发 onSubmitEditing,或者 (b) 在 onSubmitEditing 事件中检索文本输入的值。
render() {
return (
<View style={styles.container}>
<TextInput
onChangeText={text => this.setState({ text })}
onSubmitEditing={
console.log(`onSubmitEditing: ${this.state.text}`)
}
placeholder="Enter Text..."
returnKeyType="done"
returnKeyLabel="done"
/>
</View>
);
}
Run Code Online (Sandbox Code Playgroud)
我在用
"expo": "^32.0.0",
"react": "16.5.0",
"react-native": "0.57.1",
Run Code Online (Sandbox Code Playgroud)
谢谢!
更新:这似乎有效
onSubmitEditing={a => console.log(`onSubmitEditing: ${this.state.text}`) }
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我了解发生了什么吗?
我刚刚开始尝试使用“任务”而不是线程,并尝试实现一个具有后台“清理”任务的对象,只要该对象正在使用,该任务每 5 分钟运行一次,但不应阻止垃圾收集。
一些粗略的东西(这显然不起作用......)
public class Foo : IDisposable
{
private CancellationTokenSource _tokenSource = new CancellationTokenSource();
public Foo()
{
Cleanup();
}
public void Dispose()
{
_tokenSource.Cancel();
}
public void Cleanup()
{
Task.Delay(TimeSpan.FromSeconds(5), _tokenSource.Token).ContinueWith(t =>
{
//Do Work
if (!_tokenSource.IsCancellationRequested)
{
Cleanup();
}
}, TaskContinuationOptions.NotOnCanceled);
}
}
Run Code Online (Sandbox Code Playgroud)
正确的实施方法是什么?
编辑 为了回答 I3arnon 的问题,我使用 IDisposable 因为当我完成对象时,我希望它被垃圾收集。比如没有下面的f.Dispose()(取消任务,f好像不是Garbage Collected,或者cleanup任务取消了。有没有更好的实现方式?
var f = new Foo();
var r = new WeakReference(f);
Thread.Sleep(TimeSpan.FromSeconds(15));
f.Dispose();
f = null;
System.GC.Collect();
Thread.Sleep(TimeSpan.FromSeconds(5));
Console.WriteLine(r.IsAlive);
Run Code Online (Sandbox Code Playgroud) c# ×3
apache-nifi ×1
async-await ×1
bigdata ×1
c#-5.0 ×1
etl ×1
gobblin ×1
javascript ×1
react-native ×1