本文整理汇总了C#中ValueSet.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ValueSet.Add方法的具体用法?C# ValueSet.Add怎么用?C# ValueSet.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValueSet
的用法示例。
在下文中一共展示了ValueSet.Add方法的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: 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;
}
示例3: SendMessageToServer
private async void SendMessageToServer(string message)
{
var command = new ValueSet();
command.Add("Command", "Bridge");
command.Add("SendToServer", message);
var response = await _appServiceConnection.SendMessageAsync(command);
}
示例4: 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
}
}
示例5: Connection_RequestReceived
private async void Connection_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
{
var reqDeferral = args.GetDeferral();
var message = args.Request.Message;
var result = new ValueSet();
if (args.Request.Message.ContainsKey("service"))
{
var serviceName = message["service"] as string;
if (serviceName.Equals("add", StringComparison.OrdinalIgnoreCase))
{
if (message.ContainsKey("a") && message.ContainsKey("b"))
{
result.Add("result", Add((int)message["a"], (int)message["b"]));
}
}
else if (serviceName.Equals("sub", StringComparison.OrdinalIgnoreCase))
{
if (message.ContainsKey("a") && message.ContainsKey("b"))
{
result.Add("result", Sub((int)message["a"], (int)message["b"]));
}
}
else
{
result.Add("result", 0);
}
}
await args.Request.SendResponseAsync(result);
reqDeferral.Complete();
}
示例6: AppServiceConnection_RequestReceived
private async void AppServiceConnection_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
{
var msgDef = args.GetDeferral();
var msg = args.Request.Message;
var returnData = new ValueSet();
var command = msg["Command"] as string;
switch (command) {
case "UI":
returnData.Add("sketch-test", "X.Extension.ThirdParty.Backgrounds.UI.Test");
returnData.Add("sketch-home", "X.Extension.ThirdParty.Backgrounds.UI.Home");
break;
case "RandomBackground":
Random rnd = new Random();
returnData.Add("filename", $"bkg0{rnd.Next(1, 5)}.jpg");
break;
case "Spritesheet":
returnData.Add("spritesheet-img", "bkg-spritesheet.jpg");
returnData.Add("spritesheet-xml", "bkg-spritesheet.xml");
break;
}
await args.Request.SendResponseAsync(returnData);
msgDef.Complete();
}
示例7: ConstructMessage
public static ValueSet ConstructMessage(string tag, string content)
{
var valueSet = new ValueSet();
valueSet.Add(MessageTag, tag);
valueSet.Add(MessageContent, content);
return valueSet;
}
示例8: PostBookAsync
public async void PostBookAsync()
{
var message = new ValueSet();
message.Add("command", "POST");
string json = new Book { Title = NewBookTitle, Publisher = NewBookPublisher }.ToJson();
message.Add("book", json);
string result = await SendMessageAsync(message);
}
示例9: AppServiceConnection_RequestReceived
private async void AppServiceConnection_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
{
var message = args.Request.Message;
string command = (string)message["Command"];
switch (command)
{
case "GetSynonym":
{
var messageDeferral = args.GetDeferral();
string term = (string)message["Term"];
// Call the synonyms service
SynonymApi api = new SynonymApi(BING_KEY);
var returnMessage = new ValueSet();
try
{
var synonyms = await api.GetSynonymsAsync(term);
if ((synonyms != null) && (synonyms.Count() > 0))
{
//Set a result to return to the caller
//Serialize the IEnumerable<string> to Json so we can insert into ValueSet
returnMessage.Add("Result", JSONHelper.SerializeObject(synonyms));
}
else
{
// Report an error back to the caller
returnMessage.Add("Error", "No results found");
}
}
catch (Exception ex)
{
// Error accessing the service
// Report an error back to the caller
returnMessage.Add("Error", "Synonyms Service not available " + ex.Message + " term=" + term);
}
var responseStatus = await args.Request.SendResponseAsync(returnMessage);
messageDeferral.Complete();
break;
}
case "Quit":
{
//Service was asked to quit. Give us service deferral
//so platform can terminate the background task
_serviceDeferral.Complete();
break;
}
}
}
示例10: ReturnResult
private void ReturnResult()
{
if (pfrArgs != null)
{
var values = new ValueSet();
values.Add("TimeStamp", DateTime.Now.ToString());
values.Add("Authorized", (IdBlock.Text == "danvy").ToString());
pfrArgs.ProtocolForResultsOperation.ReportCompleted(values);
}
}
示例11: OnOpenAnotherAppWithDataClicked
private async void OnOpenAnotherAppWithDataClicked(object sender, RoutedEventArgs e)
{
LauncherOptions options = new LauncherOptions();
options.TargetApplicationPackageFamilyName = "8a1341de-3acd-4d5a-91f2-98d9cd2c1c6e_e8f4dqfvn1be6";
ValueSet data = new ValueSet();
data.Add("Customer", "Contoso");
data.Add("Price", "25");
await Launcher.LaunchUriAsync(new Uri("invoice:"), options, data);
}
示例12: OnRequestReceived
async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
{
//Get a deferral so we can use an awaitable API to respond to the message
var messageDeferral = args.GetDeferral();
try
{
var input = args.Request.Message;
int minValue = (int)input["minvalue"];
int maxValue = (int)input["maxvalue"];
//Create the response
var result = new ValueSet();
result.Add("result", randomNumberGenerator.Next(minValue, maxValue));
//Send the response
await args.Request.SendResponseAsync(result);
}
finally
{
//Complete the message deferral so the platform knows we're done responding
messageDeferral.Complete();
}
}
示例13: pickerBtb_Click
private async void pickerBtb_Click(object sender, RoutedEventArgs e)
{
//Set a result to return to the caller
var returnMessage = new ValueSet();
server = new HttpServer(8080);
server.StartServer();
returnMessage.Add("Status", "Success");
// var myPictures = await StorageLibrary.GetLibraryAsync(Windows.Storage.KnownLibraryId.Pictures);
var picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
picker.FileTypeFilter.Add(".jpg");
picker.FileTypeFilter.Add(".jpeg");
picker.FileTypeFilter.Add(".png");
StorageFile file = await picker.PickSingleFileAsync();
if (file != null)
{
// Application now has read/write access to the picked file
Log("Picked photo: " + file.Path, "Success");
server.FilePath = file.Path;
}
else
{
Log("Operation cancelled.", "Error");
}
}
示例14: 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;
}
示例15: 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()
});
}
}