我必须为应用程序构建新模型,而不是更好的方法:
使用继承或使用enum作为对象类型:
例如 :
图书
class Book
{
public string Name {get;set;}
public string Author {get;set;}
public int NumberOfPages {get;set;}
}
public class Encyclopedie:Book
{
}
public class Novel:Book
{
}
Run Code Online (Sandbox Code Playgroud)
或更好地使用:
class Book
{
public BookType Type {get;set;}
public string Name {get;set;}
public string Author {get;set;}
public int NumberOfPages {get;set;}
}
public enum BookType
{
Encyclopedie = 0,
Novel = 1,
...
}
Run Code Online (Sandbox Code Playgroud) 有没有办法在单击链接时将浏览器推回到页面顶部?我正在动态更改某些内容,但项目需要用户在加载新内容时从页面顶部开始.
我已经在使用url hash标记来跟踪历史记录.只是寻找某种类型的JavaScript函数来做到这一点.
我实际上有一个应用程序,我用两个设备测试.一台LG GW620,一台三星Spica.我想当用户触摸屏幕时,设备会振动.
事实上,在LG GW620上,当我触摸它时,设备会振动.但是在spica上没有......
我在spica上寻找设置,但振动器是检查,所以我不明白它为什么不振动.
在我的应用程序中,我有: <uses-permission android:name="android.permission.VIBRATE"></uses-permission>
并在代码中:
Vibrator vibrator =(Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(100);
Run Code Online (Sandbox Code Playgroud)
但我认为这不是最好的事情.我希望设备每次点击都会振动,但我不知道是否必须为每个OnClick做一个振动器?或者,如果我只能为所有应用程序执行一个振动器?
特别是为什么它不适用于Spica?
我是Erlang的新手,作为我学习练习的一部分,我想在Erlang中编写一个HTML解析器.
我想从网页中提取某些值,可能使用模式来描述我想要提取的数据.
任何人都可以向我提供一些关于如何在Erlang中解决这个问题的高级建议吗?
我想我需要将文档转换成一堆标记,可能使用有限状态机来跟踪我在嵌套方面的位置以及我在元素中的位置.
假设我有这些接口:
public interface I1 {
void foo();
}
public interface I2 {
void bar();
}
Run Code Online (Sandbox Code Playgroud)
和班级:
public class A extends AParent implements I1, I2 {
// code for foo and bar methods here
}
public class B extends BParent implements I1, I2 {
// code for foo and bar methods here
}
public class C extends CParent implements I1 {
// code for foo method here
}
Run Code Online (Sandbox Code Playgroud)
现在,使用泛型我可以有一个方法,如:
public <T extends I1 & I2> void method(T param) {
param.foo();
param.bar(); …Run Code Online (Sandbox Code Playgroud) 我试图坚持一般的命名约定,如开发类库的设计指南中描述的那些.我将每种类型放入其自己的源文件中(部分类将按照部分类文件的命名约定中所述分成几个文件),使用类型名称作为文件名.
例子:
namespace Demo.Bla // project
{
enum FlowDirection { } // in file FlowDirection.cs
class LayoutManager { } // in file LayoutManager.cs
}
namespace Demo.Bla.LayoutControllers // folder LayoutControllers in project
{
class StackPanelLayoutController { } // in file LayoutControllers/StackPanelLayoutController
}
Run Code Online (Sandbox Code Playgroud)
但我不确定我是否想出了一种聪明的方法来命名包含泛型类的源文件.假设我有以下类,例如:
namespace Demo.Bla.Collections // folder Collections
{
class Map<T> { } // in file Map.cs (obviously)
class Bag { } // in file Bag.cs (obviously)
class Bag<T> : Bag { } // also in file …Run Code Online (Sandbox Code Playgroud) 我有一个Windows应用程序.NET管理许多PDF文件.有些文件已损坏.
2个问题:我会用最糟糕的英语解释...对不起
1.)
如何检测pdf文件是否正确?
我想读PDF的标题和检测是正确的.
var okPDF = PDFCorrect(@"C:\ temp\pdfile1.pdf");
2.)
如何知道文件的byte [](bytearray)是否是PDF文件.
例如,对于ZIP文件,您可以检查前四个字节并查看它们是否与本地标头签名匹配,即以十六进制表示
50 4b 03 04
if(buffer [0] == 0x50 && buffer [1] == 0x4b && buffer [2] == 0x03 && buffer [3] == 0x04)
如果要将其加载到long中,则为(0x04034b50).作者:David Pierson
我希望PDF文件也一样.
byte [] dataPDF = ...
var okPDF = PDFCorrect(dataPDF);
.NET中的任何示例源代码?
iv尝试了许多不同的方法来使这个工作,我得到它基本工作,但我不能得到WaitForExit(); 像他们在这里一样工作......所以我如何将其转换为使用sevenzip?因为我无法让它工作,而且我的SFX是密码使得除了使用程序之外无法访问它们以及添加7z.DLL我无法添加它因为我收到错误:
无法添加对7za.dll的引用.请确保该文件是可访问的,并且它是有效的程序集或COM组件.
string tempFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
System.Diagnostics.Process defrag1 = System.Diagnostics.Process.Start(@"AusLogics_Defrag.exe", string.Format(" -o{0} -y -Pthisisthepass", tempFolder));
defrag1.WaitForExit();
string executableDirectoryName = Path.GetDirectoryName(Application.ExecutablePath);
System.Diagnostics.Process defrag2 = System.Diagnostics.Process.Start(tempFolder + "\\" + "AusLogics_Defrag" + "\\" + "DiskDefrag.exe", "");
defrag2.WaitForExit();
System.IO.Directory.Delete(tempFolder + "\\" + "AusLogics_Defrag", true);
Run Code Online (Sandbox Code Playgroud)
新:好吧这是我到目前为止,但我得到的错误"无法加载7-zip库或内部COM错误!消息:无法加载库"
SevenZipExtractor.SetLibraryPath("7z.dll"); //no idea of this is needed or not
SevenZipCompressor.SetLibraryPath("7z.dll"); //no idea of this is needed or not
string tempFolder = Environment.GerFolderPath(Environment.SpecialFolder.ApplicationData);
SevenZipExtractor defrag = new SevenZipExtractor(@"Programs\Optimize\Auslogics_Defrag.7z");
defrag.ExtracArchive(string.Format("-o{0} -y -PThisisthepass", tempFolder));
Run Code Online (Sandbox Code Playgroud) c# ×4
android ×1
arrays ×1
corrupt ×1
erlang ×1
file ×1
generics ×1
header ×1
html ×1
html-parsing ×1
inheritance ×1
java ×1
javascript ×1
maxlength ×1
modeling ×1
parameters ×1
pdf ×1
php ×1
vibration ×1