当前位置: 首页>>代码示例>>C#>>正文


C# ValueSet.Add方法代码示例

本文整理汇总了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();
					}
				}
			}
		}
开发者ID:ericzile,项目名称:win10demo,代码行数:25,代码来源:LauncherView.xaml.cs

示例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;
        }
开发者ID:acasquete,项目名称:app-to-app-uwp,代码行数:31,代码来源:InventoryService.cs

示例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);
 }
开发者ID:Quantzo,项目名称:IotRouter,代码行数:7,代码来源:SerialBridge.cs

示例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
            }
        }
开发者ID:falafelsoftware,项目名称:InterApplicationCommunication,代码行数:25,代码来源:PerimeterBreachAppService.cs

示例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();
		}
开发者ID:oudoulj,项目名称:win10demo,代码行数:30,代码来源:CalculatorService.cs

示例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();
        }
开发者ID:liquidboy,项目名称:X,代码行数:26,代码来源:CallService.cs

示例7: ConstructMessage

        public static ValueSet ConstructMessage(string tag, string content)
        {
            var valueSet = new ValueSet();
            valueSet.Add(MessageTag, tag);
            valueSet.Add(MessageContent, content);

            return valueSet;
        }
开发者ID:sunnycase,项目名称:TomatoMusic,代码行数:8,代码来源:AudioRpc.cs

示例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);
 }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:8,代码来源:BooksViewModel.cs

示例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;
          }
      }
    }
开发者ID:Ronacs,项目名称:WinDevCamp,代码行数:56,代码来源:SynonymsServiceTask.cs

示例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);
			}
		}
开发者ID:ericzile,项目名称:win10demo,代码行数:10,代码来源:MainPage.xaml.cs

示例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);
        }
开发者ID:Janisku7,项目名称:Windows10-Samples,代码行数:11,代码来源:MainPage.xaml.cs

示例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();
            }
        }
开发者ID:mweilb,项目名称:SampleCode,代码行数:25,代码来源:RandomNumberGeneratorTask.cs

示例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");
            }
        }
开发者ID:nudaca,项目名称:simplehttpserver.uwp,代码行数:28,代码来源:MainPage.xaml.cs

示例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;
        }
开发者ID:qmatteoq,项目名称:dotNetSpainConference2016,代码行数:25,代码来源:MainPage.xaml.cs

示例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()
                });
            }
        }
开发者ID:MaedaNoriyuki,项目名称:WinDevHOLs,代码行数:60,代码来源:MainPage.xaml.cs


注:本文中的ValueSet.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。