我正在使用推送通知.当我收到通知时,它会附带2个按钮,查看并关闭.如果我点击查看它会打开应用程序,当我点击关闭按钮时,它什么都不做,但应用程序图标上会出现一个徽章编号.然后,当我再次打开我的应用程序时,徽章编号应该消失,但事实并非如此.如果用户点击应用图标,我该如何删除该徽章编号?感谢名单
由于我们有很多生成的代码,一些roslyn分析器对此代码感到疯狂.有没有办法从分析仪中排除一些文件?
在过去的8年里,我一直在C#和Java之间来回走动.
令我印象深刻的是,我完全停止在C#中使用"模板方法"设计模式.实际上,在C#中我已经开始认为这种模式是一种反模式.
http://en.wikipedia.org/wiki/Template_method_pattern
回到Java,我发现这个模式还活着.我仍然认为它看起来很古老,但是我意识到在java中没有别的方法可以做到这一点.Java看起来也很古老;)
既然这会出现,为什么它是反模式?
因此,对于闭包/委托/函数指针,您通常会传递一些函数而不是子类.
所以回到这个问题:
如果您的语言有闭包/委托/功能,您使用模板方法,何时?
delegates closures design-patterns functional-programming function
您可以在下方看到两个简化的摘要,其结果不会发生变化.
模式1,从头开始的对象:
foreach ($recipients as $recipient) {
$message = new Message();
$message->setBody("This is the body of the message.");
$message->setRecipient($recipient);
$transport->sendMessage($message);
$persister->saveToDatabase($message); // Updated line
unset($message);
}
Run Code Online (Sandbox Code Playgroud)
模式2,克隆原型对象:
$prototype = new Message();
$prototype->setBody("This is the body of the message.");
foreach ($recipients as $recipient) {
$message = clone $prototype;
$message->setRecipient($recipient);
$transport->sendMessage($message);
$persister->saveToDatabase($message); // Updated line
unset($message);
}
unset($prototype);
Run Code Online (Sandbox Code Playgroud)
在内存使用,垃圾收集和/或CPU周期方面,对象克隆(模式2)是否提供了从头开始创建对象(模式1)的性能改进?还要考虑大量固定属性(在实例之间不会更改)和大量循环.
更新:我需要在每个循环中使用不同的对象实例.我添加saveToDatabase
了对示例的调用以使其类似,例如,让它为消息提供ID.;)
正如标题所示,我有一个页脚,我想用我的内容移动.基本上,我有一些文本,当浏览器被推到较小的宽度时,内容会在页脚下面,当我希望页脚向下移动内容时.让它不仅仅是保持一个位置.
我已经完成了大部分代码并删除了不需要的定位,但是如果我尝试在.footerwrap上将其设置为0,它会在页面中随机浮动.希望你们能帮忙.
我将链接我的html和CSS,这样你就可以得到一个想法.不幸的是,该网站不是现场,但它可能是一个简单的解决方案.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home</title>
<!--===================================================css links===================================================!-->
<link href='http://fonts.googleapis.com/css?family=Raleway:600,500,400,200' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,900,100,300' rel='stylesheet' type='text/css'>
<link href="css/default_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!--===================================================Header===================================================!-->
<div class="wrapper">
<div class="headerwrap">
<div class="social">
<a href="www.facebook.com"><img class="move" src="images/deviant.png"></a>
<a href="www.facebook.com"><img class="move" src="images/yt.png"/></a>
<a href="www.facebook.com"><img class="move" src="images/fb.png"/></a>
</div><!--close social!-->
<div class="header">
<div class="logo">
<img src="images/logo.png" />
</div><!--close logo-->
</div><!--close header!-->
<div class="menu">
<ul class="menutxt">
<li><a href="index.html">HOME</a></li>
<li><a href="about.html">PORTFOLIO</a></li>
<li><a href="manga.html">CONTACT</a></li>
</ul> …
Run Code Online (Sandbox Code Playgroud) 我正在使用4.5.1 Framewok和VS 2013.我的问题是如果我编写以下内容我的CSS代码不起作用:
.body {
font-family: Verdana, Arial, sans-serif;
font-size: 14px;
background: gainsboro;
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我这样写,它是有效的:
body {
font-family: Verdana, Arial, sans-serif;
font-size: 14px;
background: gainsboro;
}
Run Code Online (Sandbox Code Playgroud)
这可能是什么原因?我看了一些他们正在使用".body"的视频,他们的项目正在运作,但如果我写这个也不行.你能帮助我吗?
列表中的值覆盖在我的程序中.我想使用相同的对象来添加不同的值.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
public class CommonValue {
static int key = 100;
public static void main(String[] args) throws IOException {
HashMap<Integer, ArrayList<String>> map = new HashMap<Integer, ArrayList<String>>();
ArrayList<String> list = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sBuffer = new StringBuffer();
Scanner scan = new Scanner(System.in);
String choice = null;
do {
System.out.println("enter the how many element to add");
int numOfElement = Integer.parseInt(reader.readLine());
String userInput;
int …
Run Code Online (Sandbox Code Playgroud) 每当我单击旋转木马上的图像时,它就会变成蓝色。我该怎么做才能取消呢?发生在此页面上的Firefox:
如何在不使用java中的参数的情况下获取在另一个方法中声明和初始化的值?
public class Value {
void method1()
{
int demo=10;
System.out.println("methd 1"+demo);
}
void method2()
{
System.out.println("method 2"+demo);
}
public static void main(String[] args) {
Value obj = new Value ();
obj.method1();
obj,method2();
}
}
Run Code Online (Sandbox Code Playgroud)
这里变量demo在method1中声明并且现在分配了一个值我需要在方法2中获取demo的值,这可能没有任何参数,全局声明和没有getter setter方法吗?
Traefik完全忽略了"标签"配置.
按照Traefik的主要文档页面,我们可以简单地做到:
#docker-compose.yml
version: '3'
services:
traefik:
image: traefik # The official Traefik docker image
command: --api --docker # Enables the web UI and tells Træfik to listen to docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- ./docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
whoami:
image: emilevauge/whoami # A container that exposes an API to show its IP address
labels:
- "traefik.frontend.rule=Host:whoami.docker.localhost"
Run Code Online (Sandbox Code Playgroud)
然后,运行docker-compose就足够了(没有traefik.toml文件): …
如何在div中居中对象内容?
.parent{
background-color:yellow;
}
.ob{
margin: 0 auto;
}
</style>
<div class="parent">
<object width="400" height="400" class="ob" data="helloworld.swf">
</object>
</div>
Run Code Online (Sandbox Code Playgroud)
提前致谢!