- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
您好,我正在为 Windows 和 Mac 开发一个注册到 uri 方案的应用程序
static void RegisterURI()
{
if (Environment.OSVersion.Platform.ToString() == "Unix") //I'll never use it on any linux machine so it should be OK
{
//What should I put HERE ??
}
else
{
//on récupère le chemin de l'assembly
string MyPos = System.Reflection.Assembly.GetAssembly(typeof(Program)).Location;
var protocol = Registry.ClassesRoot
.CreateSubKey("serialcodereader");
protocol.SetValue("", "URL:Lancer l'écouteur de liseuse de code barre COM");
protocol.SetValue("URL Protocol", "");
var icon = protocol.CreateSubKey("DefaultIcon");
icon.SetValue("", MyPos + ",1");
var command = protocol.CreateSubKey("shell").CreateSubKey("open").CreateSubKey("command");
command.SetValue("", '"' + MyPos + '"');
}
}
这是我在 Windows 上使用的代码,但我如何在 OSX 上使用它?
ps:很高兴知道:我一生中从未使用过任何 Mac 甚至 Iphone,所以对那些奇怪的动物保持简单 :-)
最佳答案
我正在从事类似的工作。我确实建议浪费一些时间来检查这个:NSBundle.MainBundle.InfoDictionary.ToString()
并检查此源代码:https://github.com/mono/monodevelop/blob/master/main/src/addins/MacPlatform/MacPlatform.cs因为他们使用 NSBundle 结构在运行时更改它。
一旦找到解决方案,我会尽快与您分享。
我找到了一个实用的解决方案。
我的项目.ini
[project]
CFBundleExecutable=ExecutableName
CFBundleName="Human Readable Executable Name"
CFBundleVersion="1.0"
REV_DOMAIN="com.sample"
URLScheme="myapp"
# src is where Mono left your executable
src='/Users/myself/Projects/MyApp/MyApp/bin/Release/'
CFBundleURLIconFile='appicons.icns'
使用示例:
$ build-mac-app.sh myProject
这将生成一个扩展名为“.app”的文件夹以及运行它所需的所有内容。首先,记得运行它以便 MacOS 进行关联,其次,注意方案的使用,因为如果您在其他开发中使用了 url 方案,它将失败或打开其他应用程序。
HTML 测试文件
clique para testar o assinador
构建器脚本
我最初是用 pt-br 写的,因为它最初是今天开发的,供内部使用
#!/bin/bash
echo ""
echo "EDortta/build-mac-app.sh"
echo "Construtor de aplicativos para MacOSx"
echo "Este script usa a saída gerada por MonoDevelop C#/Gtk"
echo "e produz um Mac App Bundle pronto para ser distribuido"
echo "------------------------------------------------------"
if [ -f "$1" ]; then
config="$1"
CFBundleExecutable=`cat $config | sed -n '/\[project\]/,/\[.*\]/p' | awk -F= '/CFBundleExecutable/{print $2}' | tr -d '"' | tr -d "'"`
CFBundleName=`cat $config | sed -n '/\[project\]/,/\[.*\]/p' | awk -F= '/CFBundleName/{print $2}' | tr -d '"' | tr -d "'"`
CFBundleVersion=`cat $config | sed -n '/\[project\]/,/\[.*\]/p' | awk -F= '/CFBundleVersion/{print $2}' | tr -d '"' | tr -d "'"`
REV_DOMAIN=`cat $config | sed -n '/\[project\]/,/\[.*\]/p' | awk -F= '/REV_DOMAIN/{print $2}' | tr -d '"' | tr -d "'"`
CFBundleURLIconFile=`cat $config | sed -n '/\[project\]/,/\[.*\]/p' | awk -F= '/CFBundleURLIconFile/{print $2}' | tr -d '"' | tr -d "'"`
URLScheme=`cat $config | sed -n '/\[project\]/,/\[.*\]/p' | awk -F= '/URLScheme/{print $2}' | tr -d '"' | tr -d "'"`
src=`cat $config | sed -n '/\[project\]/,/\[.*\]/p' | awk -F= '/src/{print $2}' | tr -d '"' | tr -d "'"`
echo "src=$src"
if [ ! -d "$CFBundleExecutable.app" ]; then
mkdir "$CFBundleExecutable.app"
rsync -rvt mac-skel/* "$CFBundleExecutable.app/"
sed -i -e "s/%CFBundleExecutable%/$CFBundleExecutable/g" "$CFBundleExecutable.app/Contents/Info.plist"
sed -i -e "s/%CFBundleName%/$CFBundleName/g" "$CFBundleExecutable.app/Contents/Info.plist"
sed -i -e "s/%CFBundleVersion%/$CFBundleVersion/g" "$CFBundleExecutable.app/Contents/Info.plist"
sed -i -e "s/%REV_DOMAIN%/$REV_DOMAIN/g" "$CFBundleExecutable.app/Contents/Info.plist"
sed -i -e "s/%URLScheme%/$URLScheme/g" "$CFBundleExecutable.app/Contents/Info.plist"
sed -i -e "s/%CFBundleURLIconFile%/$CFBundleURLIconFile/g" "$CFBundleExecutable.app/Contents/Info.plist"
if [ -f "$CFBundleExecutable.app/Contents/Info.plist-e" ]; then
rm -f "$CFBundleExecutable.app/Contents/Info.plist-e"
fi
if [ -f "$CFBundleURLIconFile" ]; then
cp "$CFBundleURLIconFile" "$CFBundleExecutable.app/Contents/Resources/$CFBundleExecutable.icns"
fi
mv "$CFBundleExecutable.app/Contents/MacOS/appname.sh" "$CFBundleExecutable.app/Contents/MacOS/$CFBundleExecutable.sh"
cp -r "$src/" "$CFBundleExecutable.app/Contents/MacOS/"
sed -i -e "s/%CFBundleExecutable%/$CFBundleExecutable/g" "$CFBundleExecutable.app/Contents/MacOS/$CFBundleExecutable.sh"
sed -i -e "s/%CFBundleName%/$CFBundleName/g" "$CFBundleExecutable.app/Contents/MacOS/$CFBundleExecutable.sh"
if [ -f "$CFBundleExecutable.app/Contents/MacOS/$CFBundleExecutable.sh-e" ]; then
rm -f "$CFBundleExecutable.app/Contents/MacOS/$CFBundleExecutable.sh-e"
fi
chmod +x "$CFBundleExecutable.app/Contents/MacOS/$CFBundleExecutable.sh"
else
echo "$CFBundleExecutable.app já existe"
echo "Por favor, considere remover a pasta"
fi
else
echo "Indique o seu projeto C#/GTK"
echo "Caso precise de um exemplo, use project-sample.ini"
fi
幕后结构
在“build-mac-app.sh”和应用程序图标(从项目或其他来源移动或复制)的同一位置,有一个包含这些文件的 mac-skel 文件夹:
mac-skel/
└── Contents
├── Info.plist
├── MacOS
│ └── appname.sh
└── Resources
mac-skel/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>pt-br</string>
<key>CFBundleExecutable</key>
<string>MacOS/%CFBundleExecutable%.sh</string>
<key>CFBundleIconFile</key>
<string>../Resources/%CFBundleExecutable%.icns</string>
<key>CFBundleIdentifier</key>
<string>%REV_DOMAIN%.%CFBundleExecutable%</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>%CFBundleName%</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>%CFBundleVersion%</string>
<key>CFBundleSignature</key>
<string>xmmd</string>
<key>CFBundleVersion</key>
<string>%CFBundleVersion%</string>
<key>NSAppleScriptEnabled</key>
<string>NO</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLIconFile</key>
<string>%CFBundleURLIconFile%</string>
<key>CFBundleURLName</key>
<string>%REV_DOMAIN%.%CFBundleExecutable%</string>
<key>CFBundleURLSchemes</key>
<array>
<string>%URLScheme%</string>
</array>
<key>CFBundleURLTypes</key>
<string>Editor</string>
</dict>
</array>
</dict>
</plist>
mac-skel/Contents/MacOS/appname.sh这是从之前显示的博客中截取的
#!/bin/sh
#get the bundle's MacOS directory full path
DIR=$(cd "$(dirname "$0")"; pwd)
#change these values to match your app
EXE_PATH="$DIR\%CFBundleExecutable%.exe"
PROCESS_NAME="%CFBundleExecutable%"
BUNDLENAME="%CFBundleName%"
#set up environment
MONO_FRAMEWORK_PATH=/Library/Frameworks/Mono.framework/Versions/Current
export DYLD_FALLBACK_LIBRARY_PATH="$DIR:$MONO_FRAMEWORK_PATH/lib:/lib:/usr/lib"
export PATH="$MONO_FRAMEWORK_PATH/bin:$PATH"
#mono version check
REQUIRED_MAJOR=2
REQUIRED_MINOR=4
VERSION_TITLE="$BUNDLENAME Não pode ser aberta"
VERSION_MSG="$BUNDLENAME requer o Framework Mono versão $REQUIRED_MAJOR.$REQUIRED_MINOR ou posterior."
DOWNLOAD_URL="http://www.go-mono.com/mono-downloads/download.html"
MONO_VERSION="$(mono --version | grep 'Mono JIT compiler version ' | cut -f5 -d\ )"
MONO_VERSION_MAJOR="$(echo $MONO_VERSION | cut -f1 -d.)"
MONO_VERSION_MINOR="$(echo $MONO_VERSION | cut -f2 -d.)"
if [ -z "$MONO_VERSION" ] \
|| [ $MONO_VERSION_MAJOR -lt $REQUIRED_MAJOR ] \
|| [ $MONO_VERSION_MAJOR -eq $REQUIRED_MAJOR -a $MONO_VERSION_MINOR -lt $REQUIRED_MINOR ]
then
osascript \
-e "set question to display dialog \"$VERSION_MSG\" with title \"$VERSION_TITLE\" buttons {\"Cancelar\", \"Baixar...\"} default button 2" \
-e "if button returned of question is equal to \"Baixar...\" then open location \"$DOWNLOAD_URL\""
echo "$VERSION_TITLE"
echo "$VERSION_MSG"
exit 1
fi
#get an exec command that will work on the current OS version
OSX_VERSION=$(uname -r | cut -f1 -d.)
if [ $OSX_VERSION -lt 9 ]; then # If OSX version is 10.4
MONO_EXEC="exec mono"
else
MONO_EXEC="exec -a \"$PROCESS_NAME\" mono"
fi
#create log file directory if it doesn't exist
LOG_FILE="$HOME/Library/Logs/$BUNDLENAME/$BUNDLENAME.log"
mkdir -p "`dirname \"$LOG_FILE\"`"
#run app using mono
$MONO_EXEC $MONO_OPTIONS "$EXE_PATH" $* 2>&1 1> "$LOG_FILE"
关于c# - 将 Mono 应用程序注册到 OSX 上的 Uri 方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19453829/
使用 ruby 1.9.2-p290。我在尝试解析如下 URI 时遇到问题: require 'uri' my_uri = "http://www.anyserver.com/getdata?anyp
根据 http://tools.ietf.org/html/rfc3986和 http://en.wikipedia.org/wiki/Uniform_resource_identifier , UR
如何在文本 block 中发现 URI? 这个想法是将这样的文本运行变成链接。如果只考虑 http(s) 和 ftp(s) 方案,这很容易做到;但是,我猜测一般问题(考虑 tel、mailto 和其他
我的一些网址上有一些特殊字符。例如: http://blabla.com/title/?t=burası 当我从其他页面提供指向该页面的链接时,我使用: URI.encode(s) 产生这个链接: /
我在 Windows Mobile 上使用紧凑型框架/C#。 在我的应用程序中,我通过序列化对象并使用 HttpWebRequest/POST 请求向上发送信息来将数据上传到服务器。在服务器上,发布数
我正在做一个实验,我发现将 Canvas 转换为 blob,然后转换为数据 URI 会导致与直接从 Canvas 获取数据 URI 不同的 URI。打开时的内容在两个 URI 上几乎相同。 使用 bl
我正在尝试在 Rails 3 中实现 OAuth 提供程序。当我尝试授权客户端应用程序时,出现此错误。我正在使用 RESTful auth 插件和 pelles OAuth 插件。当我通过 Rails
我有一个编码的 UI 测试方法: public void MyTestMethod() { string baseUrl = "www.google.com"; GlobalVaria
我知道这是一个常见的错误,我正在使用一个已知的解决方案,但它仍然给我同样的错误: require 'open-uri' url = "http://website.com/dirs/filex[a]"
我正在尝试使用 .NET 中的 HttpClient 来使用 Web 服务,并且在我完成了 msdn 中提到的所有步骤之后 o 出现以下异常:提供了无效的请求 URI。请求 URI 必须是绝对 URI
我正在尝试检索文件的 URI。该文件存储在: /storage/emulated/0/AppName/FileName.png 如果我使用 Uri.fromFile(file),我得到的是 file:
我想知道 (SIP) URI 中的不同参数分隔符表示什么? 部分以;分隔,例如: . 其他用?隔开和 & ,例如: 最佳答案 SIP 分隔符规则来自RFC 2396 RFC 3986 已弃用.但是在
我想调用decodeUrl(...),我这样做是: import "dart:uri"; main() { decodeUrl("str"); } 但是现在有了最新的Dart-SDK,它会报告
在 URI 中,空格可以编码为 + .既然如此,那么在创建具有国际前缀的 tel URI 时是否应该对前导加号进行编码? 哪个更好?两者在实践中都有效吗? Call me Call me 最佳答案 不
我试图弄清楚电子邮件地址的格式是否可以说符合 URI 的定义,但到目前为止我还没有找到明确的确认。我希望有人可以在这里为我提供一些见解。预先感谢:) 最佳答案 是的,但带有“mailto:”前缀。 U
因此,我尝试将 ID 参数附加到 URI 的末尾,当用户单击我的列表中的项目时,用户将被发送到该 URI。我的代码如下: public void onItemClick(AdapterView par
这是 Converting file path to URI 的后续问题. 考虑: require 'uri' uri = URI.join('file:///', '/home/user/dir1/
我在 pl/sql 中创建了一个名为 tester 的包。但我收到以下消息。 绝对URI中的相对路径:java.net.URI.checkPath(URI.java:1823) --Package D
我在 gitlab 上有一个 git repo,使用私有(private) pod 和其他公共(public) pod,下面是我的 Podfile source 'git@gitlab.mycompa
我正在尝试将我的 Rails 应用程序推送到 heroku 上,我正在使用 heroku RedisToGo 附加组件我经历过这个tutorial并完成了那里提到的所有步骤。 但是在推送 heroku
我是一名优秀的程序员,十分优秀!