我有以下代码:
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.Start();
IJobDetail job = JobBuilder.Create<EmailJob>().StoreDurably().WithIdentity("J_Email", "J_Mailing").Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("MailTrigger1", "T_Mail1")
.StartNow()
.WithSimpleSchedule(x => x.WithMisfireHandlingInstructionIgnoreMisfires()
.WithIntervalInSeconds(3)
.RepeatForever())
.Build();
ITrigger triggernew = TriggerBuilder.Create()
.WithIdentity("MailTrigger", "T_Mail")
.StartNow()
.WithSimpleSchedule(x => x.WithMisfireHandlingInstructionIgnoreMisfires()
.WithIntervalInSeconds(5)
.RepeatForever())
.Build();
scheduler.ScheduleJob(job,triggernew);
scheduler.ScheduleJob(job,trigger);
Run Code Online (Sandbox Code Playgroud)
我收到以下异常:
Quartz.dll中发生了未处理的"Quartz.ObjectAlreadyExistsException"类型异常
附加信息:无法存储作业:'J_Mailing.J_Email',因为已存在此标识.
但我被告知你可以拥有同一个JOB的多个触发器.也许我做错了什么?
我知道我们可以在chrome app中访问chrome.hid.getDevices().但我也听说过chrome.hid.getDevices()只能在chrome app中使用.
但是我们可以以某种方式访问chrome扩展中的chrome.hid.getDevices().因为我需要使用Content-script注入脚本,以便我可以从Web页面使用我的扩展功能,并且根据我的知识,Content-script只能在Chrome Extension中使用.
是否有任何与网页上的Chrome应用进行通信的示例?
这是我今天面试的一个问题:
"给定一个字符串列表,返回一个只有唯一字符串的列表"
我很好奇Skeet认证的答案是什么.
我自己的答案是
public static List<string> sans_repeats ( List<string> input )
{
Dictoinary<string,int> counter = new Dictionary<string,int>();
List<string> output = new List<string>();
foreach ( string S in input )
{
if ( counter.HasKey(S) ) counter[S] = 1;
else ++count[S];
}
foreach ( KeyValuePair<string,int> entry in counter )
if ( entry.Value == 1 ) output.Add(entry.Key);
return output;
}
Run Code Online (Sandbox Code Playgroud)
和采访说
"嗯,这是一种方法......"
在一个听起来居高临下的声音中,好像我做错了什么.
我已启用 API Cloud Asset API (cloudasset.googleapis.com),但它没有创建 GCP 托管服务帐户service-{projectNumber}@gcp-sa-cloudasset.iam.gserviceaccount.com。我在多个地方读到 GCP 应该创建该帐户。
我曾多次尝试启用/禁用 API,但仍然没有成功。
如果有人知道解决方法,请告诉我:-)
创建一个程序后,我一直在努力将米转换为英尺和英寸,但我最终认为它可以正常工作。
现在我的问题是变量inchesleft是一个整数,我想弄清楚如何使它成为整数,因为我想降低英寸的剩余值,这样我就可以得到6feet 4inches等值。
下面的代码:
double inft, convert, inchesleft, value = 0.3048;
int ft;
string input;
Console.WriteLine("please enter amount of metres");
input = Console.ReadLine();
convert = double.Parse(input);
inft = convert / value;
ft = (int)inft;
inchesleft = convert / value % 1 *12;
Console.WriteLine("{0} feet {1} inches.", ft, inchesleft);
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud) 我所试图做的是不是让两个连续的特殊字符像&*或*$或&&,但它应该允许之间串之类的特殊字符Hello%Mr&.
到目前为止我尝试了什么:
^(([\%\/\\\&\?\,\'\;\:\!\-])\2?(?!\2))+$
Run Code Online (Sandbox Code Playgroud) 有很多示例可以通过自定义属性获取Enum,例如此处 从描述属性获取枚举
public static class EnumEx
{
public static T GetValueFromDescription<T>(string description)
{
var type = typeof(T);
if(!type.IsEnum) throw new InvalidOperationException();
foreach(var field in type.GetFields())
{
var attribute = Attribute.GetCustomAttribute(field,
typeof(DescriptionAttribute)) as DescriptionAttribute;
if(attribute != null)
{
if(attribute.Description == description)
return (T)field.GetValue(null);
}
else
{
if(field.Name == description)
return (T)field.GetValue(null);
}
}
throw new ArgumentException("Not found.", "description");
// or return default(T);
}
}
Run Code Online (Sandbox Code Playgroud)
但问题是你必须硬编码attributeType即 typeof(DescriptionAttribute)) as DescriptionAttribute
我如何将此示例转换为通用扩展,以便我不必硬编码CustomAttributeType.