我几年来一直在使用C#和Unity3d,但我刚开始使用.NET编程.我收到错误:
无法隐式将类型' System.Collections.Generic.IEnumerable<URL>
' 转换为' System.Collections.Generic.List<URL>
'.存在显式转换(您是否错过了演员?)
这是我的代码:
namespace TestBrowserHistory
{
public class Test1
{
public Test1()
{
}
static void Main()
{
InternetExplorer myClass = new InternetExplorer();
List<URL> calledList = myClass.GetHistory();
Console.WriteLine("Hello!");
Console.WriteLine(calledList[1]);
Console.ReadLine();
}
}
}
public class InternetExplorer
{
// List of URL objects
public List<URL> URLs { get; set; }
public IEnumerable<URL> GetHistory()
{
// Initiate main object
UrlHistoryWrapperClass urlhistory = new UrlHistoryWrapperClass();
// Enumerate URLs in History
UrlHistoryWrapperClass.STATURLEnumerator enumerator =
urlhistory.GetEnumerator();
// Iterate through the …
Run Code Online (Sandbox Code Playgroud) 我在CentOS上运行Neo4J 1.8嵌入式Java 6.
在JVM崩溃后,我开始得到以下几个例外:
org.neo4j.graphdb.NotFoundException: Unable to load one or more relationships from Node[1169385]. This usually happens when relationships are deleted by someone else just as we are about to load them. Please try again.
at org.neo4j.kernel.impl.core.NodeImpl.loadMoreRelationshipsFromNodeManager(NodeImpl.java:530)
at org.neo4j.kernel.impl.core.NodeImpl.getMoreRelationships(NodeImpl.java:415)
at org.neo4j.kernel.impl.core.NodeImpl.loadInitialRelationships(NodeImpl.java:368)
at org.neo4j.kernel.impl.core.NodeImpl.ensureRelationshipMapNotNull(NodeImpl.java:345)
at org.neo4j.kernel.impl.core.NodeImpl.getAllRelationshipsOfType(NodeImpl.java:195)
at org.neo4j.kernel.impl.core.NodeImpl.getRelationships(NodeImpl.java:247)
at org.neo4j.kernel.impl.core.NodeProxy.getRelationships(NodeProxy.java:92)
at com.bizya.polosvc.neo4j.model.PersonImpl.getAllSelvesNoPropsLoad(PersonImpl.java:1303)
at com.bizya.polosvc.neo4j.model.PathsFinderImpl.findPaths(PathsFinderImpl.java:189)
at com.bizya.polosvc.neo4j.model.PathsFinderImpl.findPaths(PathsFinderImpl.java:49)
at com.bizya.server.services.ReachabilityService.findReachabilities(ReachabilityService.java:82)
at com.bizya.server.widget.BrowsingPageBuilder.buildAdditionalResultsModel(BrowsingPageBuilder.java:97)
at com.bizya.server.widget.ContextBrowsingPageBuilder.buildAdditionalResultsModel(ContextBrowsingPageBuilder.java:81)
at com.bizya.server.widget.ContextBrowsingPageBuilder.buildAdditionalResultsModel(ContextBrowsingPageBuilder.java:71)
at com.bizya.server.widget.servlet.NetworkServlet.doGet(NetworkServlet.java:139)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at com.bizya.server.widget.servlet.MasterWidgetServlet.handleAuthorizedUser(MasterWidgetServlet.java:167)
at com.bizya.server.widget.servlet.MasterWidgetServlet.service(MasterWidgetServlet.java:150)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263)
at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178)
at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
at …
Run Code Online (Sandbox Code Playgroud) 我正在消毒JSON.Net对象,它包含许多数组.这是我目前获得的输出:
"children": [
{
"children": [
{
},
{
}
}
Run Code Online (Sandbox Code Playgroud)
但是,为了便于阅读和比较,我想删除每个大括号和括号之间以及逗号和下一个大括号之间的换行符,所以它看起来像这样:
"children": [ {
"children": [ {
}, {
}
}
Run Code Online (Sandbox Code Playgroud)
我已经用Formatting.Indented
参数消毒了我的JSON ,所以我想知道是否有其他设置我可以更改,以便JSON.Net在没有额外线制动器的情况下消毒,但保留缩进格式.
我有一个简单的 svg 元素,它有元素的子元素:fiddle
<svg xmlns:xlink="http://www.w3.org/1999/xlink">
<g opacity="1" transform="translate(0,0) scale(3,3) rotate(0)">
...
</g>
</svg>
Run Code Online (Sandbox Code Playgroud)
第一个<g>
节点的大小约为 31x42 像素,但<svg>
元素的默认大小为 300x150 像素。我希望 svg 获取其子节点的大小,我该怎么做?添加height=100%
不起作用(它保持在 300x150)。
我收到错误"数据源不能为空.使用:内存:打开内存数据库"
这是我的连接字符串:
// Get Current Users App Data
string documentsFolder = Environment.GetFolderPath
(Environment.SpecialFolder.ApplicationData);
string[] tempstr = documentsFolder.Split('\\');
string tempstr1 = "";
documentsFolder += "\\Google\\Chrome\\User Data\\Default\\History";
if (tempstr[tempstr.Length - 1] != "Local")
{
for (int i = 0; i < tempstr.Length - 1; i++)
{
tempstr1 += tempstr[i] + "\\";
}
documentsFolder = tempstr1 + "Local\\Google\\Chrome\\User Data\\Default\\History";
}
// Check if directory exists
if (Directory.Exists(documentsFolder))
{
// return ExtractUserHistory(documentsFolder);
}
string connectionString;
connectionString = string.Format(@"DataSource={0}", documentsFolder);
Run Code Online (Sandbox Code Playgroud)
这是我的联系:
SQLiteConnection conn = new …
Run Code Online (Sandbox Code Playgroud) 我有一个独特的问题.我的程序从书签JSON文件中获取chrome的书签.我正在使用JSON.net dll.我的问题是,我需要将每个URL都放在正确的文件夹层次结构中,但是,似乎您可以创建一个无限量的文件夹来保存书签.以下是JSON hiarchy的示例:
{
"checksum": "c9e24e7fb3c6cb184fb776e32dd1004e",
"roots": {
"bookmark_bar": {
"children": [ {
{
"children": [ {
"children": [ {
"children": [ {
"children": [ {
"date_added": "12985566069697953",
"id": "225",
"name": "EvasiveURL",
"type": "url",
"url": "evasiveurl.com"
} ],
"date_added": "12991165233108137",
"date_modified": "12991165244676611",
"id": "374",
"name": "NestedFolder2",
"type": "folder"
} ],
"date_added": "12991165215985934",
"date_modified": "12991165215985934",
"id": "373",
"name": "NestedFolder",
"type": "folder"
} ],
"date_added": "12985566069695953",
"date_modified": "12991165219618934",
"id": "204",
"name": "Games",
"type": "folder"
}
Run Code Online (Sandbox Code Playgroud)
这是我目前的代码:
for (int i = 0; o["roots"]["bookmark_bar"]["children"][i] …
Run Code Online (Sandbox Code Playgroud) 基本上..我使用swing制作了一个JDialog.现在我希望它将一个值返回给调用它的JFrame.问题是,每当我调用JDialog的构造函数时,即使我已经设置它也不会阻塞线程setModal(true)
.我错过了一些明显的东西吗?
private final JPanel contentPanel = new JPanel();
private File chosenFile = null;
private JList list;
private File[] files;
public File getInformation()
{
return chosenFile;
}
/**
* Create the dialog.
*/
public PatientPicker(JFrame parent)
{
super(parent);
setModal(true);
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setLocationRelativeTo(parent);
setBounds(100, 100, 450, 396);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
files = new File(ClientInfo.GetAppData() + "/patients").listFiles(new TextFileFilter());
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton okButton = new JButton("OK");
okButton.addMouseListener(new MouseAdapter() …
Run Code Online (Sandbox Code Playgroud) 我创建了一个类来保存comboxbox的内容并加载它们.我使用ObjectOutput
并直接保存模型.问题是,我得到一个例外:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: javax.swing.SpringLayout
Run Code Online (Sandbox Code Playgroud)
我真的不明白为什么会发生这种情况,因为我没有在任何代码中使用SpringLayout(我可以告诉).我甚至设置了一个断点,stream.writeOutput(getModel());
并且getModel()
肯定会返回a DefaultComboboxModel
,所以再次没有提到Spring Layout.
然后我编译了我从这里获得示例的代码,它工作正常.为什么会这样?
class MemComboBox extends JComboBox
{
public static final int MAX_MEM_LEN = 30;
public MemComboBox()
{
super();
setEditable(true);
}
public void add(String item)
{
removeItem(item);
insertItemAt(item, 0);
setSelectedItem(item);
if (getItemCount() > MAX_MEM_LEN)
removeItemAt(getItemCount() - 1);
}
public void load(String fName)
{
try
{
if (getItemCount() > 0)
removeAllItems();
File f = new File(fName);
if (!f.exists())
return;
FileInputStream fStream = new FileInputStream(f);
ObjectInput …
Run Code Online (Sandbox Code Playgroud)