本文整理汇总了C#中PluginResult类的典型用法代码示例。如果您正苦于以下问题:C# PluginResult类的具体用法?C# PluginResult怎么用?C# PluginResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PluginResult类属于命名空间,在下文中一共展示了PluginResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeviceStatus_PowerSourceChanged
private void DeviceStatus_PowerSourceChanged(object sender, EventArgs e)
{
isPlugged = DeviceStatus.PowerSource.ToString().CompareTo("External") == 0;
PluginResult result = new PluginResult(PluginResult.Status.OK, GetCurrentBatteryStateFormatted());
result.KeepCallback = true;
DispatchCommandResult(result);
}
示例2: execute_statment
public void execute_statment(string options)
{
string callbackId;
options = options.Replace("{}", ""); /// empty objects screw up the Deserializer
try
{
/// query params
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
/// to test maybe is not an integer but a JSONObject
EntryExecuteStatment entryExecute = JSON.JsonHelper.Deserialize<EntryExecuteStatment>(args[0]);
string query = entryExecute.query;
/// to test not sure that's work
List<object> param = entryExecute.param;
callbackId = args[1];
if (mbTilesActions != null && mbTilesActions.isOpen())
{
string result = mbTilesActions.executeStatment(query, param);
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
pluginResult.Message = result;
DispatchCommandResult(pluginResult, callbackId);
}
else
{
DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION), callbackId);
}
}
catch (Exception)
{
DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
}
}
示例3: close
public void close(string options = "")
{
if (browser != null)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
if (frame != null)
{
PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
if (page != null)
{
Grid grid = page.FindName("LayoutRoot") as Grid;
if (grid != null)
{
grid.Children.Remove(browser);
}
page.ApplicationBar = null;
}
}
browser = null;
string message = "{\"type\":\"exit\"}";
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
result.KeepCallback = false;
this.DispatchCommandResult(result);
});
}
}
示例4: Reclaim
async public void Reclaim(string options)
{
PluginResult result;
if (barcodeScanner != null)
{
claimedBarcodeScanner = await barcodeScanner.ClaimScannerAsync();
if (claimedBarcodeScanner != null)
{
await claimedBarcodeScanner.EnableAsync();
claimedBarcodeScanner.DataReceived += DataReceived;
result = new PluginResult(PluginResult.Status.NO_RESULT);
result.KeepCallback = true;
}
else
{
result = new PluginResult(PluginResult.Status.ERROR, "Barcode Scanner could not get claimed");
}
}
else
{
result = new PluginResult(PluginResult.Status.ERROR, "Barcode Scanner Object not exists");
}
DispatchCommandResult(result);
}
示例5: pickContact
public void pickContact(string arguments)
{
string[] args = JSON.JsonHelper.Deserialize<string[]>(arguments);
// Use custom contact picker because WP8 api doesn't provide its' own
// contact picker, only PhoneNumberChooser or EmailAddressChooserTask
var task = new ContactPickerTask();
var desiredFields = JSON.JsonHelper.Deserialize<string[]>(args[0]);
task.Completed += delegate(Object sender, ContactPickerTask.PickResult e)
{
if (e.TaskResult == TaskResult.OK)
{
string strResult = e.Contact.ToJson(desiredFields);
var result = new PluginResult(PluginResult.Status.OK)
{
Message = strResult
};
DispatchCommandResult(result);
}
if (e.TaskResult == TaskResult.Cancel)
{
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Operation cancelled."));
}
};
task.Show();
}
示例6: start
public void start(string options)
{
// Register power changed event handler
DeviceStatus.PowerSourceChanged += powerChanged;
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
result.KeepCallback = true;
DispatchCommandResult(result);
}
示例7: DispatchCommandResult
public void DispatchCommandResult(PluginResult result)
{
if (this.OnCommandResult != null)
{
this.OnCommandResult(this, result);
this.OnCommandResult = null;
}
}
示例8: start
public void start(string options)
{
// Register power changed event handler
DeviceStatus.PowerSourceChanged += powerChanged;
#if WP8
battery.RemainingChargePercentChanged += Battery_RemainingChargePercentChanged;
#endif
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
result.KeepCallback = true;
DispatchCommandResult(result);
}
示例9: DispatchCommandResult
public void DispatchCommandResult(PluginResult result)
{
if (this.OnCommandResult != null)
{
this.OnCommandResult(this, result);
if (!result.KeepCallback)
{
this.Dispose();
}
}
}
示例10: Method
public void Method(string options)
{
string upperCase = JSON.JsonHelper.Deserialize<string[]>(options)[0].ToUpper();
PluginResult result;
if (upperCase != "")
{
result = new PluginResult(PluginResult.Status.OK, upperCase);
} else
{
result = new PluginResult(PluginResult.Status.ERROR, upperCase);
}
DispatchCommandResult(result);
}
示例11: download
public void download(string options)
{
string url;
string filePath;
string callbackId;
try
{
url = JSON.JsonHelper.Deserialize<string[]>(options)[0];
filePath = JSON.JsonHelper.Deserialize<string[]>(options)[1];
callbackId = JSON.JsonHelper.Deserialize<string[]>(options)[2];
}
catch (ArgumentException ex)
{
XLog.WriteError("download arguments occur Exception JSON_EXCEPTION " + ex.Message);
DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
return;
}
string workspace = this.app.GetWorkSpace();
string target = XUtils.ResolvePath(workspace, filePath);
if (null == target)
{
FileTransfer.FileTransferError error = new FileTransfer.FileTransferError(FILE_NOT_FOUND_ERR, url, filePath, 0);
PluginResult result = new PluginResult(PluginResult.Status.ERROR, error);
DispatchCommandResult(result);
return;
}
String abstarget = XUtils.BuildabsPathOnIsolatedStorage(target);
if (!url.StartsWith("http://"))
{
FileTransfer.FileTransferError error = new FileTransfer.FileTransferError(INVALID_URL_ERR, url, filePath, 0);
PluginResult result = new PluginResult(PluginResult.Status.ERROR, error);
DispatchCommandResult(result);
return;
}
EventHandler<PluginResult> DispatchPluginResult = delegate(object sender, PluginResult result)
{
DispatchCommandResult(result, callbackId);
};
FileTransferManager.AddFileTranferTask(url, abstarget, workspace,
DispatchPluginResult, COMMAND_DOWNLOAD);
}
示例12: Band
public void Band(string options)
{
string title = "";
string message = "";
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
title = args[0].ToString();
message = args[1].ToString();
PluginResult result;
if (title != "" && message != "")
{
result = new PluginResult(PluginResult.Status.OK, args);
} else
{
result = new PluginResult(PluginResult.Status.ERROR, args);
}
DispatchCommandResult(result);
}
示例13: TaskCompleted
/// <summary>
/// Handler for barcode scanner task.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The scan result.</param>
private void TaskCompleted(object sender, BarcodeScannerTask.ScanResult e)
{
PluginResult result;
switch (e.TaskResult)
{
case TaskResult.OK:
result = new PluginResult(PluginResult.Status.OK);
result.Message = JsonHelper.Serialize(new BarcodeResult(e.Barcode));
break;
case TaskResult.Cancel:
// If scan is cancelled we return PluginResult.Status.OK with Message contains cancelled: true
// See plugin docs https://github.com/MSOpenTech/BarcodeScanner#using-the-plugin
result = new PluginResult(PluginResult.Status.OK);
result.Message = JsonHelper.Serialize(new BarcodeResult());
break;
default:
result = new PluginResult(PluginResult.Status.ERROR);
break;
}
this.DispatchCommandResult(result);
}
示例14: Enable
async public void Enable(string options)
{
PluginResult result;
if (barcodeScanner == null)
{
barcodeScanner = await Windows.Devices.PointOfService.BarcodeScanner.GetDefaultAsync();
if (claimedBarcodeScanner == null)
{
claimedBarcodeScanner = await barcodeScanner.ClaimScannerAsync();
if (claimedBarcodeScanner != null)
{
await claimedBarcodeScanner.EnableAsync();
claimedBarcodeScanner.DataReceived += DataReceived;
result = new PluginResult(PluginResult.Status.NO_RESULT);
result.KeepCallback = true;
}
else
{
result = new PluginResult(PluginResult.Status.ERROR, "Barcode Scanner could not get claimed");
}
}
else
{
result = new PluginResult(PluginResult.Status.ERROR, "Claimed Barcode Scanner Object already there");
}
}
else
{
result = new PluginResult(PluginResult.Status.ERROR, "Barcode Scanner Object already there");
}
DispatchCommandResult(result);
}
示例15: browser_Navigating
void browser_Navigating(object sender, NavigatingEventArgs e)
{
string message = "{\"type\":\"loadstart\",\"url\":\"" + e.Uri.OriginalString + "\"}";
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
result.KeepCallback = true;
this.DispatchCommandResult(result, NavigationCallbackId);
}