我想在iOS默认Map App中的两个位置之间实现get direction功能,我试过这个
Class itemClass = [MKMapItem class];
if (itemClass && [itemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) {
// Use iOS 6 maps
NSString *latString = @"23.0300";
NSString *longString = @"72.5800";
CLLocationCoordinate2D ctrpoint;
ctrpoint.latitude = [latString doubleValue];
ctrpoint.longitude = [longString doubleValue];
MKPlacemark *placemark2 = [[MKPlacemark alloc] initWithCoordinate:ctrpoint addressDictionary:nil];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark2];
[mapItem openInMapsWithLaunchOptions:nil];
}
Run Code Online (Sandbox Code Playgroud)
但它显示方向错误如下:
我甚至打开了地图应用程序,找到了我当前的位置,在离我所在位置最近的地图上添加了一个图钉,并且获取方向仍然无效.
此外,"总之,即使在本机应用程序中,Get Direction也无法正常工作"任何人都可以帮助我实现这一目标吗?
我有这个简单的表格报告,其中包含许多不同类型的列.
但是当使用rtf(word)扩展名打印报告时
带有数字或日期的列 appears on the report.
带有阿拉伯语内容的列appear on the report.
但是在使用PDF扩展名打印报告时
带有数字或日期的列 appears on the report.
带有阿拉伯语内容的列不是 appear on the report.
我尝试了许多不同的字体和更改的属性,如PDF嵌入和PDF编码.这样做的正确方法是什么?
我正在使用 Mockito 和 JUnit 测试企业级应用程序。这是将产品添加到我拥有的产品 offline-repository-class-test 中的离线存储库类的方法的代码:
@Mock
private InitialData initialData;
@InjectMocks
private ProductRepositoryOffline pro;
@Test
public void testPersistProduct() {
Product product = new Product(0, "", "", "", 0.0, true, "", 0, /*Product type*/null, "", 0, 0);
ArrayList<Product> productList = new ArrayList<Product>();
//productList.add(product);
Mockito.when(initialData.getProducts()).thenReturn(productList);
pro.persistProduct(product);
assertEquals(pro.getProducts().get(0), product);
}
Run Code Online (Sandbox Code Playgroud)
这依赖于类中的以下方法:
它正在测试的方法ProductRepositoryOffline:
@Override
public void persistProduct(Product pr) {
initialData.addProduct(pr);
}
Run Code Online (Sandbox Code Playgroud)
初始数据
private ArrayList<Product> products = new ArrayList<Product>();
public void addProduct(Product product) {
products.add(product);
}
Run Code Online (Sandbox Code Playgroud)
我想问的问题是,pro.persistProduct(product)除非我已经将产品添加到ArrayList,否则不persistProduct …
我在一个部分中检索具有不同对象类型的JSON.我把这部分视为动态.
我需要从这个对象获取数据,所以我创建了类似于动态数据的类,如下所示:
public class SpecificObject1
{
public string Title{get; set;}
public object[] ViewElements{get; set}
public object AnyAttributes{get; set;}
}
Run Code Online (Sandbox Code Playgroud)
以下是我想将其转换为此特定对象的方法:
var @switch = new Dictionary<Type, Action> {
{ typeof(x), () => jsonObj.Some = jsonObj.Some as SpecificObject1},
{ typeof(y), () => ......}
};
Run Code Online (Sandbox Code Playgroud)
使用as返回null进行转换.
编辑:将属性更改为真实属性
动态包含:
AnyAttributes: {object}
Title: "title"
ViewElements: object[0]
Run Code Online (Sandbox Code Playgroud) 假设我有一个类型的实体IList<MyClass>,我想要映射到类型列表,IList<MyMappedClass>同时保持相同的底层集合类型.
我的意思是,如果该实例恰好是类型List<MyClass>应该映射到List<MyMappedClass>和ObservableCollection<MyClass>到ObservableCollection<MyMappedClass>.
到目前为止我所做的是我可以找到这样的列表的泛型类型:
Type listType = myList.GetType(); //myList type: List<T> or ObservableCollection<T>
Type listItemType = listType.GetGenericArguments()[0];
Run Code Online (Sandbox Code Playgroud)
我知道我可以这样做:
Type myListType = typeof(List<>).MakeGenericType(listItemType );
Run Code Online (Sandbox Code Playgroud)
我不能这样做:
Type myListType = myList.GetType().MakeGenericType(listItemType );
Run Code Online (Sandbox Code Playgroud)
因为它已经是通用的.我要找的是以下内容:
Type myListType = myList.GetType().GotNonGenericType().MakeGenericType(listItemType );
Run Code Online (Sandbox Code Playgroud)
哪里GotNonGenericType()是我正在寻找的功能的占位符.
我是C#的初学者,我正在努力做到以下几点:
我创建了一个词典: _innerProducts = new Dictionary<string, string>();
然后另一个字典来存储第一个字典: _KitProducts = new Dictionary<string, Dictionary<string, string>>();
第一个(_ innerProducts)包含我从和.xml文件中收集的大约15个产品属性,而TKey是产品代码.
收集我调用的所有属性后:
_KitProducts.Add(_innerProducts["cProd"], _innerProducts);
Run Code Online (Sandbox Code Playgroud)
当我通过调试观察它时,它的工作正常,我可以看到:
问题是我不能使用与第一个_innerProducts"cProd" 相同的TKey添加另一组属性,因此在foreach中我将一个_innerProducts.Clear();放在最后.
问题是当我清除它时,它不仅清除了当前的_innerProducts,它还清除了_KitProducts的TValue:
我不确定这是因为那些"引用"而不是我读过的"按价值"讲座(记得我刚开始),所以在这种情况下该怎么做?
这将是很多这样的情况,我知道我将需要存储它(但我仍然没有学习实体框架,正在研究它),而那,我只是存储在字典中学习目的.
谢谢,抱歉英语,不是我的主要语言.
我正在尝试运行一个简单的 selenium 脚本,它打开 chrome 驱动程序以导航到 url。下面是我的代码:
WebDriver driver =new ChromeDriver();
driver.get("http://www.google.com");
WebElement element=driver.findElement(By.name("q"));
element.sendKeys("Cheese!!!");
element.submit();
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
Run Code Online (Sandbox Code Playgroud)
在运行代码时,我收到以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/logging/LoggingHandler
at Main.main(Main.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.logging.LoggingHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
Run Code Online (Sandbox Code Playgroud)
我的 pom 文件具有以下依赖项:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.4.0</version>
</dependency> …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 API 调用的响应映射到 Product 对象。我似乎找不到正确的方法。
响应的结构如下:
{
"data": [
{
"id": 1,
"name": "keyboard",
"details": {
"parent": 1,
"price": 50,
"other": "info"
}
},
{
"id": 2,
"name": "mouse",
"details": {
"parent": 2,
"other": "info",
"price": 20
}
}
],
"total-records": 2,
"more": "something"
}
Run Code Online (Sandbox Code Playgroud)
无法保证回复详细信息的顺序。(详细说明价格)。我试图将上面的对象映射到一个仅包含以下属性的新对象:
{
"id": 1,
"name": "keyboard",
"price": 50
},
{
"id": 2,
"name": "mouse",
"price": 20
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Angular 和 Observables 来获取数据。现在我正在获取值,对其进行映射,并且可以仅获取详细信息或第一级对象属性,例如data.id或data.name。然而,获取价格等详细信息对我来说有点令人困惑。
我研究了很多关于 mergemap、flatmap、甚至 lodash 的知识,并花了无数个小时试图弄清楚,但我似乎找不到正确的方法。
我可以在地图组合中使用过滤器来实现此目的吗?任何信息都受到高度赞赏。
到目前为止,这是我的代码:
{
"data": [ …Run Code Online (Sandbox Code Playgroud)我有这个代码,它采用格式为255.255.255.255的IP地址(字符串),并需要对这些数字(此处未发布)执行一些后处理,但必须将字符串转换为整数数组.
我在这里使用了split()方法,但它没有给我结果.我在sp上做了正则表达式的其他答案,但没有一个对我有效.
import java.util.Scanner;
public class Main{
public static void main(String args[]){
String text;
Scanner take=new Scanner(System.in);
text=take.nextLine();
String data[]=text.split(".",4);
for(String w:data){
System.out.println(w);
}
take.close();
}
}
Run Code Online (Sandbox Code Playgroud)
我已尝试输入12.36.26.25
但它输出36.26.25,应该是12 36 26 25
我想ArrayList从给定的字符串中删除单词中所有出现的单词。
我的相框上有3个按钮。一个添加单词,第二个删除单词,第三个显示单词。
我有一个名称为文本框和名称为textvalue数组列表mylist
我用了:
textValue = text.getText().toLowerCase().trim();
if (mylist.contains(textValue)) {
mylist.removeAll(Arrays.asList(textValue));
label.setText("All occurrences of " + textValue + "removed");
} else {
label.setText("Word not found.");
}
Run Code Online (Sandbox Code Playgroud)
如果我举个例子:mark和MARK,它仍然只会删除mark。
我也尝试过:
textValue = text.getText().toLowerCase().trim();
for (String current : mylist) {
if (current.equalsIgnoreCase(textValue)) {
mylist.removeAll(Collections.singleton(textValue));
label.setText("All occurrences of " + textValue + " removed");
} else {
label.setText("Word not found.");
}
}
Run Code Online (Sandbox Code Playgroud)