本文整理汇总了C#中ValueSet类的典型用法代码示例。如果您正苦于以下问题:C# ValueSet类的具体用法?C# ValueSet怎么用?C# ValueSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValueSet类属于命名空间,在下文中一共展示了ValueSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LaunchUriForResult_Click
private async void LaunchUriForResult_Click(object sender, RoutedEventArgs e)
{
var protocol = "win10demo2://";
var packageFamilyName = "0df93276-6bbb-46fa-96b7-ec223e226505_cb1hhkscw5m06";
var status = await Launcher.QueryUriSupportAsync(new Uri(protocol), LaunchQuerySupportType.UriForResults, packageFamilyName);
if (status == LaunchQuerySupportStatus.Available)
{
var options = new LauncherOptions
{
TargetApplicationPackageFamilyName = packageFamilyName
};
var values = new ValueSet();
values.Add("TwitterId", "danvy");
var result = await Launcher.LaunchUriForResultsAsync(new Uri(protocol), options, values);
if (result.Status == LaunchUriStatus.Success)
{
var authorized = result.Result["Authorized"] as string;
if (authorized == true.ToString())
{
var dialog = new MessageDialog("You are authorized :)");
await dialog.ShowAsync();
}
}
}
}
示例2: InitializeAppSvc
private async void InitializeAppSvc()
{
string WebServerStatus = "PoolWebServer failed to start. AppServiceConnectionStatus was not successful.";
// Initialize the AppServiceConnection
appServiceConnection = new AppServiceConnection();
appServiceConnection.PackageFamilyName = "PoolWebServer_hz258y3tkez3a";
appServiceConnection.AppServiceName = "App2AppComService";
// Send a initialize request
var res = await appServiceConnection.OpenAsync();
if (res == AppServiceConnectionStatus.Success)
{
var message = new ValueSet();
message.Add("Command", "Initialize");
var response = await appServiceConnection.SendMessageAsync(message);
if (response.Status != AppServiceResponseStatus.Success)
{
WebServerStatus = "PoolWebServer failed to start.";
throw new Exception("Failed to send message");
}
appServiceConnection.RequestReceived += OnMessageReceived;
WebServerStatus = "PoolWebServer started.";
}
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
txtWebServerStatus.Text = WebServerStatus;
});
}
示例3: AddBook
private ValueSet AddBook(string book)
{
BooksRepository.Instance.AddBook(book.ToBook());
var result = new ValueSet();
result.Add("result", "ok");
return result;
}
示例4: OnNavigatedTo
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
Loading.IsActive = true;
AppServiceConnection connection = new AppServiceConnection();
connection.PackageFamilyName = Package.Current.Id.FamilyName;
connection.AppServiceName = "FeedParser";
var status = await connection.OpenAsync();
if (status == AppServiceConnectionStatus.Success)
{
ValueSet data = new ValueSet();
data.Add("FeedUrl", "http://blog.qmatteoq.com/feed/");
var response = await connection.SendMessageAsync(data);
if (response.Status == AppServiceResponseStatus.Success)
{
string items = response.Message["FeedItems"].ToString();
var result = JsonConvert.DeserializeObject<List<FeedItem>>(items);
News.ItemsSource = result;
}
}
Loading.IsActive = false;
}
示例5: NotifyClientsOfPerimeterState
private async Task NotifyClientsOfPerimeterState()
{
var _sensorCurrentValue = _sensorPin.Read();
var messages = new ValueSet(); //name value pair
if (_sensorCurrentValue == GpioPinValue.High)
{
//send perimeter breached
messages.Add("Perimeter Notification", "Breached");
}
else
{
//send perimeter secure
messages.Add("Perimeter Notification", "Secure");
}
//send message to the client
var response = await _connection.SendMessageAsync(messages);
if (response.Status == AppServiceResponseStatus.Success)
{
var result = response.Message["Response"];
//optionally log result from client
}
}
示例6: Accept_Click
private void Accept_Click(object sender, RoutedEventArgs e)
{
ValueSet result = new ValueSet();
result["Status"] = "Success";
result["ProductName"] = productName;
operation.ReportCompleted(result);
}
示例7: InitializeService
private async void InitializeService()
{
_appServiceConnection = new AppServiceConnection
{
PackageFamilyName = "ConnectionService-uwp_5gyrq6psz227t",
AppServiceName = "App2AppComService"
};
// Send a initialize request
var res = await _appServiceConnection.OpenAsync();
if (res == AppServiceConnectionStatus.Success)
{
var message = new ValueSet {{"Command", "Connect"}};
var response = await _appServiceConnection.SendMessageAsync(message);
if (response.Status == AppServiceResponseStatus.Success)
{
InitializeSerialBridge();
//InitializeBluetoothBridge();
_appServiceConnection.RequestReceived += _serialBridge.OnCommandRecived;
//_appServiceConnection.RequestReceived += _bluetoothBridge.OnCommandRecived;
//_appServiceConnection.RequestReceived += _appServiceConnection_RequestReceived;
}
}
}
示例8: CallService_Click
private async void CallService_Click(object sender, RoutedEventArgs e)
{
var connection = new AppServiceConnection();
connection.PackageFamilyName = "041cdcf9-8ef3-40e4-85e2-8f3de5e06155_ncrzdc1cmma1g"; // Windows.ApplicationModel.Package.Current.Id.FamilyName;
connection.AppServiceName = "CalculatorService";
var status = await connection.OpenAsync();
if (status != AppServiceConnectionStatus.Success)
{
var dialog = new MessageDialog("Sorry, I can't connect to the service right now :S");
await dialog.ShowAsync();
return;
}
var message = new ValueSet();
message.Add("service", (OperatorCombo.SelectedValue as ComboBoxItem).Content);
message.Add("a", Convert.ToInt32(ValueABox.Text));
message.Add("b", Convert.ToInt32(ValueBBox.Text));
AppServiceResponse response = await connection.SendMessageAsync(message);
if (response.Status == AppServiceResponseStatus.Success)
{
if (response.Message.ContainsKey("result"))
{
ResultBlock.Text = response.Message["result"].ToString();
}
}
else
{
var dialog = new MessageDialog(string.Format("Opps, I just get an error :S ({0})", response.Status));
await dialog.ShowAsync();
}
}
示例9: Connection_RequestReceived
private async void Connection_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
{
var deferral = args.GetDeferral();
var response = new ValueSet();
bool stop = false;
try
{
var request = args.Request;
var message = request.Message;
if (message.ContainsKey(BackgroundOperation.NewBackgroundRequest))
{
switch ((BackgroundRequest)message[BackgroundOperation.NewBackgroundRequest])
{
default:
stop = true;
break;
}
}
}
finally
{
if (stop)
{
_deferral.Complete();
}
}
}
示例10: LaunchAsync
/// <summary>
/// Launch the pick'n'crop task
/// </summary>
/// <returns>In case of success, a cropped image saved in StorageFile</returns>
public async Task<StorageFile> LaunchAsync()
{
if (CropWidthPixels <= 0 || CropHeightPixels <= 0)
{
throw new ArgumentException("Cannot crop an image with zero or null dimension",
CropWidthPixels <= 0 ? "CropWidthPixels" : "CropHeightPixels");
}
var storageAssembly = typeof(Windows.ApplicationModel.DataTransfer.DataPackage).GetTypeInfo().Assembly;
var storageManagerType =
storageAssembly.GetType("Windows.ApplicationModel.DataTransfer.SharedStorageAccessManager");
var token =
storageManagerType.GetTypeInfo()
.DeclaredMethods.FirstOrDefault(m => m.Name == "AddFile")
.Invoke(storageManagerType, new object[] {OutputFile});
var parameters = new ValueSet
{
{"CropWidthPixels", CropWidthPixels},
{"CropHeightPixels", CropHeightPixels},
{"EllipticalCrop", EllipticalCrop},
{"ShowCamera", ShowCamera},
{"DestinationToken", token}
};
var launcherAssembly = typeof(Launcher).GetTypeInfo().Assembly;
var optionsType = launcherAssembly.GetType("Windows.System.LauncherOptions");
var options = Activator.CreateInstance(optionsType);
var targetProperty = options.GetType().GetRuntimeProperty("TargetApplicationPackageFamilyName");
targetProperty.SetValue(options, "Microsoft.Windows.Photos_8wekyb3d8bbwe");
var launcherType = launcherAssembly.GetType("Windows.System.Launcher");
var launchUriResult = launcherAssembly.GetType("Windows.System.LaunchUriResult");
var asTask = GetAsTask();
var t = asTask.MakeGenericMethod(launchUriResult);
var method = launcherType.GetTypeInfo()
.DeclaredMethods.FirstOrDefault(
m => m.Name == "LaunchUriForResultsAsync" && m.GetParameters().Length == 3);
var mt = method.Invoke(launcherType,
new[] { new Uri("microsoft.windows.photos.crop:"), options, parameters });
var task = t.Invoke(launcherType, new [] { mt });
var result = await (dynamic)task;
string statusStr = result.Status.ToString();
return statusStr.Contains("Success") ? OutputFile : null;
}
示例11: LaunchUriForResult_Click
private async void LaunchUriForResult_Click(object sender, RoutedEventArgs e)
{
var protocol = "win10demo2://";
var packageFamilyName = "041cdcf9-8ef3-40e4-85e2-8f3de5e06155_ncrzdc1cmma1g";
var status = await Launcher.QueryUriSupportAsync(new Uri(protocol), LaunchQuerySupportType.UriForResults, packageFamilyName);
if (status == LaunchQuerySupportStatus.Available)
{
var options = new LauncherOptions
{
TargetApplicationPackageFamilyName = packageFamilyName
};
var values = new ValueSet();
values.Add("TwitterId", "danvy");
var result = await Launcher.LaunchUriForResultsAsync(new Uri(protocol), options, values);
if ((result.Status == LaunchUriStatus.Success) && (result.Result != null))
{
var authorized = result.Result["Authorized"] as string;
if (authorized == true.ToString())
{
var dialog = new MessageDialog("You are authorized :)");
await dialog.ShowAsync();
}
}
}
}
示例12: GetBeersByFilter
public async Task<IEnumerable<Beer>> GetBeersByFilter(string filter)
{
AppServiceConnection connection = new AppServiceConnection();
connection.AppServiceName = "PlainConcepts-appservicesdemo";
connection.PackageFamilyName = "cff6d46b-5839-4bb7-a1f2-e59246de63b3_cb1hhkscw5m06";
AppServiceConnectionStatus connectionStatus = await connection.OpenAsync();
if (connectionStatus == AppServiceConnectionStatus.Success)
{
//Send data to the service
var message = new ValueSet();
message.Add("Command", "GetBeersByFilter");
message.Add("Filter", filter);
//Send message and wait for response
AppServiceResponse response = await connection.SendMessageAsync(message);
if (response.Status == AppServiceResponseStatus.Success)
{
var resultJson = (string)response.Message["Result"];
var list = JsonConvert.DeserializeObject<IEnumerable<Beer>>(resultJson);
return list;
}
}
else
{
//Drive the user to store to install the app that provides the app service
new MessageDialog("Service not installed").ShowAsync();
}
return null;
}
示例13: GetEmployeeById
private async void GetEmployeeById(object sender, RoutedEventArgs e)
{
appServiceConnection = new AppServiceConnection
{
AppServiceName = "EmployeeLookupService",
PackageFamilyName = "3598a822-2b34-44cc-9a20-421137c7511f_4frctqp64dy5c"
};
var status = await appServiceConnection.OpenAsync();
switch (status)
{
case AppServiceConnectionStatus.AppNotInstalled:
await LogError("The EmployeeLookup application is not installed. Please install it and try again.");
return;
case AppServiceConnectionStatus.AppServiceUnavailable:
await LogError("The EmployeeLookup application does not have the available feature");
return;
case AppServiceConnectionStatus.AppUnavailable:
await LogError("The package for the app service to which a connection was attempted is unavailable.");
return;
case AppServiceConnectionStatus.Unknown:
await LogError("Unknown Error.");
return;
}
var items = this.EmployeeId.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
var message = new ValueSet();
for (int i = 0; i < items.Length; i++)
{
message.Add(i.ToString(), items[i]);
}
var response = await appServiceConnection.SendMessageAsync(message);
switch (response.Status)
{
case AppServiceResponseStatus.ResourceLimitsExceeded:
await LogError("Insufficient resources. The app service has been shut down.");
return;
case AppServiceResponseStatus.Failure:
await LogError("Failed to receive response.");
return;
case AppServiceResponseStatus.Unknown:
await LogError("Unknown error.");
return;
}
foreach (var item in response.Message)
{
this.Items.Add(new Employee
{
Id = item.Key,
Name = item.Value.ToString()
});
}
}
示例14: CallService_Click
private async void CallService_Click(object sender, RoutedEventArgs e)
{
var connection = new AppServiceConnection();
connection.PackageFamilyName = "0df93276-6bbb-46fa-96b7-ec223e226505_cb1hhkscw5m06"; // Windows.ApplicationModel.Package.Current.Id.FamilyName;
connection.AppServiceName = "CalculatorService";
var status = await connection.OpenAsync();
if (status != AppServiceConnectionStatus.Success)
{
var dialog = new MessageDialog("Sorry, I can't connect to the service right now :S");
await dialog.ShowAsync();
return;
}
var message = new ValueSet();
message.Add("service", OperatorCombo.Items[OperatorCombo.SelectedIndex]);
message.Add("a", Convert.ToInt32(ValueABox.Text));
message.Add("b", Convert.ToInt32(ValueBBox.Text));
AppServiceResponse response = await connection.SendMessageAsync(message);
if (response.Status == AppServiceResponseStatus.Success)
{
if (response.Message.ContainsKey("result"))
{
ResultBlock.Text = response.Message["result"] as string;
}
}
else
{
var dialog = new MessageDialog(string.Format("Opps, I just get an error :S ({0})", response.Status));
await dialog.ShowAsync();
}
}
示例15: Run
/// <summary>
/// Hệ thống gọi đến hàm này khi association backgroundtask được bật
/// </summary>
/// <param name="taskInstance"> hệ thống tự tạo và truyền vào đây</param>
public async void Run(IBackgroundTaskInstance taskInstance)
{
//System.Diagnostics.Debug.WriteLine("background run");
taskInstance.Canceled += new BackgroundTaskCanceledEventHandler(BackgroundTaskCanceled);
taskInstance.Task.Completed += new BackgroundTaskCompletedEventHandler(BackgroundTaskCompleted);
_backgroundstarted.Set();//
_deferral = taskInstance.GetDeferral();
//Playlist = new BackgroundPlaylist();
_smtc = initSMTC();
this._foregroundState = this.initForegroundState();
BackgroundMediaPlayer.Current.CurrentStateChanged += BackgroundMediaPlayer_CurrentStateChanged;
//Playlist = await BackgroundPlaylist.LoadBackgroundPlaylist("playlist.xml");
Playlist = new BackgroundPlaylist();
Playlist.ListPathsource = await BackgroundPlaylist.LoadCurrentPlaylist(Constant.CurrentPlaylist);
if (_foregroundState != eForegroundState.Suspended)
{
ValueSet message = new ValueSet();
message.Add(Constant.BackgroundTaskStarted, "");
BackgroundMediaPlayer.SendMessageToForeground(message);
}
Playlist.TrackChanged += Playlist_TrackChanged;
BackgroundMediaPlayer.MessageReceivedFromForeground += BackgroundMediaPlayer_MessageReceivedFromForeground;
BackgroundMediaPlayer.Current.MediaEnded +=Current_MediaEnded;
ApplicationSettingHelper.SaveSettingsValue(Constant.BackgroundTaskState, Constant.BackgroundTaskRunning);
isbackgroundtaskrunning = true;
_loopState = eLoopState.None;
}