/// <summary> /// Invokes this cmdlet's action against all queued items from the pipeline. /// </summary> /// <param name="ids">The Object IDs of all queued items.</param> protected override void PerformMultiOperation(int[] ids) { if (ParameterSetName == ParameterSet.Default) { ExecuteMultiOperation(() => client.SetObjectProperty(ids, Property, Value), $"Setting {GetMultiTypeListSummary()} setting '{Property}' to '{Value}'"); } else if (ParameterSetName == ParameterSet.Dynamic) { var strActions = dynamicParameters.Select(p => $"'{p.Property}' to '{p.Value}'"); var str = string.Join(", ", strActions); ExecuteMultiOperation(() => client.SetObjectProperty(ids, dynamicParameters), $"Setting {GetMultiTypeListSummary()} setting {str}"); } else { if (ParameterSetName == ParameterSet.RawProperty) { var parameter = new CustomParameter(RawProperty, RawValue, ParameterType.MultiParameter); ExecuteMultiOperation(() => client.SetObjectPropertyRaw(ids, parameter), $"Setting {GetMultiTypeListSummary()} setting '{RawProperty}' to '{RawValue}'"); } else { var settingsStr = string.Join(", ", parameters.Select(p => $"'{p.Name}' = '{p.Value}'")); ExecuteMultiOperation(() => client.SetObjectPropertyRaw(ids, parameters.ToArray()), $"Setting {GetMultiTypeListSummary()} settings {settingsStr}"); } } }
internal static void CustomParameterLoadCoordPostHook(CustomParameter __instance, BinaryReader reader) { var dictionary = ReadExtData(reader) ?? new Dictionary <string, PluginData>(); internalCoordinateDictionary.Set(__instance, dictionary); CoordinateReadEvent(__instance); }
/// <summary> /// Invokes this cmdlet's action against the current object in the pipeline. /// </summary> protected override void PerformSingleOperation() { var ids = GetSingleOperationId(Object, Id); if (IsNormalParameterSet) { ExecuteOperation(() => client.SetObjectProperty(ids, Property, Value), $"Setting object {BasicShouldProcessMessage} setting '{Property}' to '{Value}'"); } else if (IsDynamicParameterSet) { var strActions = dynamicParameters.Select(p => $"'{p.Property}' to '{p.Value}'"); var str = string.Join(", ", strActions); ExecuteOperation(() => client.SetObjectProperty(ids, dynamicParameters), $"Setting object {BasicShouldProcessMessage} setting {str}"); } else { if (IsRawPropertyParameterSet) { var parameter = new CustomParameter(RawProperty, RawValue, ParameterType.MultiParameter); ExecuteOperation(() => client.SetObjectPropertyRaw(ids, parameter), $"Setting object {BasicShouldProcessMessage} setting '{RawProperty}' to {RawValue.ToQuotedList()}"); } else { var settingsStr = string.Join(", ", parameters.Select(p => $"{p.Name} = '{p.Value}'")); ExecuteOperation(() => client.SetObjectPropertyRaw(ids, parameters), $"Setting object {BasicShouldProcessMessage} settings {settingsStr}"); } } }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; CategorySet categorySet = new CategorySet(); categorySet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_StructuralFraming)); categorySet.Insert(Category.GetCategory(doc, BuiltInCategory.OST_Floors)); CustomParameter customParameter = new CustomParameter("commentAA", " comments", BindingType.Instance, ParameterType.Text, BuiltInParameterGroup.PG_IDENTITY_DATA, categorySet, true, true); using (Transaction t = new Transaction(doc, "set share parameter")) { t.Start(); DefinitionFile definitionFile = app.OpenSharedParameterFile(); customParameter.CreateParameter(definitionFile, uiapp, "commentCC"); t.Commit(); } return(Result.Succeeded); }
private static void VerifyInsertRestrictions(InsertRestrictionsType insert) { Assert.NotNull(insert); Assert.NotNull(insert.Insertable); Assert.False(insert.Insertable.Value); Assert.NotNull(insert.NonInsertableNavigationProperties); Assert.Equal(2, insert.NonInsertableNavigationProperties.Count); Assert.Equal("abc|RelatedEvents", String.Join("|", insert.NonInsertableNavigationProperties)); Assert.True(insert.IsNonInsertableNavigationProperty("RelatedEvents")); Assert.False(insert.IsNonInsertableNavigationProperty("MyUnknownNavigationProperty")); Assert.Null(insert.QueryOptions); Assert.Null(insert.Permissions); Assert.Null(insert.CustomHeaders); Assert.NotNull(insert.MaxLevels); Assert.Equal(8, insert.MaxLevels.Value); Assert.NotNull(insert.CustomQueryOptions); CustomParameter parameter = Assert.Single(insert.CustomQueryOptions); Assert.Equal("primitive name", parameter.Name); Assert.Equal("http://any3", parameter.DocumentationURL); Assert.NotNull(parameter.ExampleValues); PrimitiveExampleValue example = Assert.Single(parameter.ExampleValues); Assert.Equal("example desc", example.Description); Assert.Equal("example value", example.Value.Value); }
private static void VerifyCustomParameter(CustomParameter parameter) { Assert.NotNull(parameter); Assert.NotNull(parameter.Name); Assert.Equal("odata-debug", parameter.Name); Assert.NotNull(parameter.Description); Assert.Equal("Debug support for OData services", parameter.Description); Assert.NotNull(parameter.DocumentationURL); Assert.Equal("https://debug.html", parameter.DocumentationURL); Assert.NotNull(parameter.Required); Assert.False(parameter.Required.Value); Assert.NotNull(parameter.ExampleValues); Assert.Equal(2, parameter.ExampleValues.Count); // #1 PrimitiveExampleValue value = parameter.ExampleValues[0]; Assert.Null(value.Description); Assert.NotNull(value.Value); Assert.Equal("html", value.Value.Value); // #2 value = parameter.ExampleValues[1]; Assert.Null(value.Description); Assert.NotNull(value.Value); Assert.Equal(new TimeOfDay(3, 4, 5, 6), value.Value.Value); }
internal static void CustomParameterCopyPostHook(CustomParameter __instance, CustomParameter copy) { var isCoordLoad = false; // Detect if this is a coordinate or whole character parameter set var st = new StackTrace(); for (int i = 0; i < 3; i++) { if (st.GetFrame(i).GetMethod().Name.Contains("LoadCoordinate")) { isCoordLoad = true; break; } } if (isCoordLoad) { var c = internalCoordinateDictionary.Get(copy); internalCoordinateDictionary.Set(__instance, c); } else { var c = internalCharaDictionary.Get(copy); internalCharaDictionary.Set(__instance, c); } }
public void InitializeCountRestrictionsWorksWithCsdl() { // Arrange string annotation = @" <Annotation Term=""NS.MyCustomParameter"" > <Record> <PropertyValue Property=""Name"" String=""odata-debug"" /> <PropertyValue Property=""Description"" String=""Debug support for OData services"" /> <PropertyValue Property=""DocumentationURL"" String=""https://debug.html"" /> <PropertyValue Property=""Required"" Bool=""false"" /> <PropertyValue Property=""ExampleValues""> <Collection> <Record> <PropertyValue Property=""Value"" String=""html"" /> </Record> <Record> <PropertyValue Property=""Value"" TimeOfDay=""3:4:5.006"" /> </Record> </Collection> </PropertyValue> </Record> </Annotation>"; IEdmModel model = GetEdmModel(annotation); Assert.NotNull(model); // guard // Act CustomParameter count = model.GetRecord <CustomParameter>(model.EntityContainer, "NS.MyCustomParameter"); // Assert VerifyCustomParameter(count); }
private static void CustomParameterLoadPostHook(CustomParameter __instance, BinaryWriter writer) { CardWriteEvent(__instance); var extendedData = GetAllExtendedData(__instance); WriteExtData(writer, extendedData); }
private static void OnCoordinateBeingLoaded(Human character, CustomParameter coordinateFile) { KoikatuAPI.Logger.LogDebug("Loading coordinate"); foreach (var controller in GetBehaviours(character)) { controller.OnCoordinateBeingLoadedInternal(coordinateFile); } var args = new CoordinateEventArgs(character, coordinateFile); try { CoordinateLoaded?.Invoke(null, args); } catch (Exception e) { KoikatuAPI.Logger.LogError(e); } if (MakerAPI.InsideAndLoaded) { MakerAPI.OnReloadInterface(args); } }
internal static void CustomParameterLoadCoordPostHook(CustomParameter __instance, BinaryWriter writer) { CoordinateWriteEvent(__instance); var extendedData = GetAllExtendedCoordData(__instance); WriteExtData(writer, extendedData); }
/// <summary> /// Invokes this cmdlet's action against the current object in the pipeline. /// </summary> protected override void PerformSingleOperation() { if (ParameterSetName == ParameterSet.Default) { ExecuteOperation(() => client.SetObjectProperty(Object.Id, Property, Value), $"Setting object '{Object.Name}' (ID: {Object.Id}) setting '{Property}' to '{Value}'"); } else if (ParameterSetName == ParameterSet.Dynamic) { var strActions = dynamicParameters.Select(p => $"'{p.Property}' to '{p.Value}'"); var str = string.Join(", ", strActions); ExecuteOperation(() => client.SetObjectProperty(Object.Id, dynamicParameters), $"Setting object '{Object.Name}' (ID: {Object.Id}) setting {str}"); } else { if (ParameterSetName == ParameterSet.RawProperty) { var parameter = new CustomParameter(RawProperty, RawValue, ParameterType.MultiParameter); ExecuteOperation(() => client.SetObjectPropertyRaw(Object.Id, parameter), $"Setting object '{Object.Name}' (ID: {Object.Id}) setting '{RawProperty}' to '{RawValue}'"); } else { var settingsStr = string.Join(", ", parameters.Select(p => $"{p.Name} = '{p.Value}'")); ExecuteOperation(() => client.SetObjectPropertyRaw(Object.Id, parameters), $"Setting object '{Object.Name}' (ID: {Object.Id}) settings {settingsStr}"); } } }
private static void VerifyReadRestrictions(ReadRestrictionsType read) { Assert.NotNull(read); Assert.NotNull(read.Readable); Assert.False(read.Readable.Value); Assert.Null(read.Permissions); Assert.Null(read.CustomHeaders); Assert.NotNull(read.CustomQueryOptions); CustomParameter parameter = Assert.Single(read.CustomQueryOptions); Assert.Equal("root query name", parameter.Name); Assert.Null(parameter.DocumentationURL); Assert.Null(parameter.ExampleValues); // ReadByKeyRestrictions Assert.NotNull(read.ReadByKeyRestrictions); Assert.NotNull(read.ReadByKeyRestrictions.Readable); Assert.True(read.ReadByKeyRestrictions.Readable.Value); Assert.Null(read.ReadByKeyRestrictions.Permissions); Assert.Null(read.ReadByKeyRestrictions.CustomQueryOptions); Assert.NotNull(read.ReadByKeyRestrictions.CustomHeaders); parameter = Assert.Single(read.ReadByKeyRestrictions.CustomHeaders); Assert.Equal("by key head name", parameter.Name); Assert.Null(parameter.DocumentationURL); Assert.Null(parameter.ExampleValues); }
public virtual void AddTraks(CustomParameter para) { para.SplashScreenManager.ShowWaitForm(); string sqlStr = string.Empty; if (DataSource != null) { foreach (DataRow row in DataSource.Rows) { string orderNo = row[0].ToString(); string agentNo = row[1].ToString(); if (string.IsNullOrWhiteSpace(orderNo)) { para.SplashScreenManager.CloseWaitForm(); XtraMessageBox.Show("订单号不能为空", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrWhiteSpace(agentNo)) { para.SplashScreenManager.CloseWaitForm(); XtraMessageBox.Show("DPD单号不能为空", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string str = "0123456789"; string aGawbSign = ""; for (int i = agentNo.Length - 1; i >= 0; i += -1) { if (str.LastIndexOf(agentNo.Substring(i, 1)) != 0) { aGawbSign = agentNo.Substring(i, 1); break; } } if (string.IsNullOrWhiteSpace(aGawbSign)) { //获取最后一位的值 aGawbSign = agentNo.Substring(agentNo.Length - 2, 1); } sqlStr = $"{sqlStr} INSERT INTO tb_SFI_TrackNum (vchar_SFInum, vchar_AGnum, int_AGid, vchar_updateUser, dttm_updateDttm,char_AG_Syn_sign) VALUES ('{orderNo}','{agentNo}',{para.AgentID},'{MainFrm.CurrentUser}',GETDATE(),'{aGawbSign}');"; } if (!string.IsNullOrWhiteSpace(sqlStr)) { if (SQLHelper.UpDateSQL(sqlStr)) { DResult = DialogResult.OK; } else { DResult = DialogResult.Abort; } } } para.SplashScreenManager.CloseWaitForm(); }
void AddParameterIfNotSet(Enum property, PropertyCache cache, object value) { var parameter = new CustomParameter(GetParameterName(property, cache), value?.ToString()); if (!ParameterExists(parameter)) { container.AddParameter(parameter); } }
internal void OnCoordinateBeingSavedInternal(CustomParameter coordinate) { try { OnCoordinateBeingSaved(coordinate); } catch (Exception e) { KoikatuAPI.Logger.LogError(e); } }
private bool ParameterExists(CustomParameter parameter) { if (container.AllowDuplicateParameters) { return(false); } var existingParameters = container.GetParameters(); return(existingParameters.Any(p => p.Name == parameter.Name)); }
/// <summary> /// Get PluginData for a ChaFile for the specified extended save data ID /// </summary> /// <param name="file">ChaFile for which to get extended data</param> /// <param name="id">ID of the data saved to the card</param> /// <returns>PluginData</returns> public static PluginData GetExtendedDataById(CustomParameter file, string id) { if (file == null || id == null) { return(null); } var dict = internalCharaDictionary.Get(file); return(dict != null && dict.TryGetValue(id, out var extendedSection) ? extendedSection : null); }
/// <summary> /// Get extended data of the specified coordinate by using the ID you specified when registering this controller. /// </summary> /// <param name="coordinate">Coordinate you want to get the data from</param> public PluginData GetCoordinateExtendedData(CustomParameter coordinate) { if (coordinate == null) { throw new ArgumentNullException(nameof(coordinate)); } if (ExtendedDataId == null) { throw new ArgumentException(nameof(ExtendedDataId)); } return(ExtendedSave.GetExtendedDataById(coordinate, ExtendedDataId)); }
/// <summary> /// Set PluginData for a ChaFile for the specified extended save data ID /// </summary> /// <param name="file">ChaFile for which to set extended data</param> /// <param name="id">ID of the data to be saved to the card</param> /// <param name="extendedFormatData">PluginData to save to the card</param> public static void SetExtendedDataById(CustomParameter file, string id, PluginData extendedFormatData) { Dictionary <string, PluginData> chaDictionary = internalCharaDictionary.Get(file); if (chaDictionary == null) { chaDictionary = new Dictionary <string, PluginData>(); internalCharaDictionary.Set(file, chaDictionary); } chaDictionary[id] = extendedFormatData; }
public ChaFileLoadedEventArgs(string filename, byte sex, bool face, bool body, bool hair, bool parameter, bool coordinate, Human characterInstance, CustomParameter loadedChaFile) { Filename = filename; Sex = sex; Face = face; Body = body; Hair = hair; Parameter = parameter; Coordinate = coordinate; CharacterInstance = characterInstance; LoadedChaFile = loadedChaFile; }
/// <summary> /// Set extended data to the specified coordinate by using the ID you specified when registering this controller. /// </summary> /// <param name="coordinate">Coordinate you want to set the data to</param> /// <param name="data">Your custom data to be saved to the coordinate card</param> public void SetCoordinateExtendedData(CustomParameter coordinate, PluginData data) { if (coordinate == null) { throw new ArgumentNullException(nameof(coordinate)); } if (ExtendedDataId == null) { throw new ArgumentException(nameof(ExtendedDataId)); } ExtendedSave.SetExtendedDataById(coordinate, ExtendedDataId, data); }
public AmadeusService(HttpClient client, FlightsManagerDb context) { clientId = context.CustomParameters.Where(p => p.Key == "client_id").FirstOrDefault(); clientSecret = context.CustomParameters.Where(p => p.Key == "client_secret").FirstOrDefault(); client.BaseAddress = new Uri("https://test.api.amadeus.com"); this.client = client; var authorizationResponse = Authorize(); bearerToken = authorizationResponse.Result.access_token; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken); }
private static void OnCardBeingSaved(CustomParameter file) { KoikatuAPI.Logger.LogDebug("Character save: " + file.Sex); var gamemode = KoikatuAPI.GetCurrentGameMode(); var chaControl = gamemode == GameMode.Maker ? MakerAPI.GetCharacterControl() : ChaControls.FirstOrDefault(control => control.customParam == file); foreach (var behaviour in GetBehaviours(chaControl)) { behaviour.OnCardBeingSavedInternal(gamemode); } }
internal void OnCoordinateBeingLoadedInternal(CustomParameter coordinate) { try { if (!ControllerRegistration.MaintainCoordinateState) { OnCoordinateBeingLoaded(coordinate); } OnCoordinateBeingLoaded(coordinate, ControllerRegistration.MaintainCoordinateState); } catch (Exception e) { KoikatuAPI.Logger.LogError(e); } }
private static void OnCoordinateBeingSaved(Human character, CustomParameter coordinateFile) { KoikatuAPI.Logger.LogDebug($"Saving coordinate"); foreach (var controller in GetBehaviours(character)) { controller.OnCoordinateBeingSavedInternal(coordinateFile); } try { CoordinateSaving?.Invoke(null, new CoordinateEventArgs(character, coordinateFile)); } catch (Exception e) { KoikatuAPI.Logger.LogError(e); } }
private static void VerifyOperationRestrictions(OperationRestrictionsType operation) { Assert.NotNull(operation); Assert.Null(operation.FilterSegmentSupported); Assert.Null(operation.Permissions); Assert.Null(operation.CustomQueryOptions); Assert.NotNull(operation.CustomHeaders); CustomParameter parameter = Assert.Single(operation.CustomHeaders); Assert.Equal("head name", parameter.Name); Assert.Equal("http://any3", parameter.DocumentationURL); Assert.Equal("head desc", parameter.Description); Assert.True(parameter.Required.Value); Assert.Null(parameter.ExampleValues); }
public string SystemClipboard([FromBody] CustomParameter param) { if (param.content != null && param.content != "") { try { WordDocument document = WordDocument.LoadString(param.content, GetFormatType(param.type.ToLower())); string json = Newtonsoft.Json.JsonConvert.SerializeObject(document); document.Dispose(); return(json); } catch (Exception) { return(""); } } return(""); }
internal static void CoordinateReadEvent(CustomParameter file) { if (!LoadEventsEnabled || CoordinateBeingLoaded == null) { return; } foreach (var entry in CoordinateBeingLoaded.GetInvocationList()) { var handler = (CoordinateEventHandler)entry; try { handler.Invoke(file); } catch (Exception ex) { Logger.LogError($"Subscriber crash in {nameof(ExtendedSave)}.{nameof(CoordinateBeingLoaded)} - {ex}"); } } }
private void InitBinding(DataTable dt) { mvvmContext1.ViewModelType = typeof(InputDataFrmViewModel); var fluentAPI = mvvmContext1.OfType <InputDataFrmViewModel>(); fluentAPI.ViewModel.DataSource = dt; fluentAPI.SetBinding(gridControl1, gv => gv.DataSource, x => x.DataSource); //fluentAPI.SetBinding(this, frm => frm., x => x.isClose); var frm = this; fluentAPI.WithEvent <EventArgs>(btnCancel, "Click").EventToCommand(x => x.CloseForm()); var para = new CustomParameter() { AgentID = agentId, SplashScreenManager = splashScreenManager1 }; fluentAPI.WithEvent(btnOk, "Click").EventToCommand(x => x.AddTraks(null), x => para); fluentAPI.SetBinding(frm, f => f.DialogResult, x => x.DResult); }
public CustomParamControl(Control parent, int index, int left, int top, EventHandler on_change, CustomParameter data) { this.Name = new TextBox(); this.Type = new ComboBox(); this.Value = new TextBox(); this.Name.MaxLength = 15; this.Name.Parent = parent; this.Type.Parent = parent; this.Value.Parent = parent; this.Type.DropDownStyle = ComboBoxStyle.DropDownList; this.Type.Items.AddRange(new object[] { CustomParamType.Int, CustomParamType.Double, CustomParamType.Text }); if (data != null) { this.Name.Text = data.Name; this.Type.SelectedItem = data.Type; this.Value.Text = data.Value; } top += (index * (this.Name.Height + 10)); this.Name.Location = new Point(left, top); this.Type.Location = new Point(left + this.Name.Width + 10, top); this.Value.Location = new Point(this.Type.Left + this.Type.Width + 10, top); this.Name.TextChanged += new EventHandler(on_change); this.Type.SelectedIndexChanged += new EventHandler(on_change); this.Value.TextChanged += new EventHandler(on_change); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="adGroupId">ID of the ad group to which ad is added. /// </param> public void Run(AdWordsUser user, long adGroupId) { // Get the AdGroupAdService. AdGroupAdService service = (AdGroupAdService) user.GetService(AdWordsService.v201601.AdGroupAdService); // Create the text ad. TextAd textAd = new TextAd(); textAd.headline = "Luxury Cruise to Mars"; textAd.description1 = "Visit the Red Planet in style."; textAd.description2 = "Low-gravity fun for everyone!"; textAd.displayUrl = "www.example.com"; // Specify a tracking URL for 3rd party tracking provider. You may // specify one at customer, campaign, ad group, ad, criterion or // feed item levels. textAd.trackingUrlTemplate = "http://tracker.example.com/?season={_season}&promocode={_promocode}&u={lpurl}"; // Since your tracking URL has two custom parameters, provide their // values too. This can be provided at campaign, ad group, ad, criterion // or feed item levels. CustomParameter seasonParameter = new CustomParameter(); seasonParameter.key = "season"; seasonParameter.value = "christmas"; CustomParameter promoCodeParameter = new CustomParameter(); promoCodeParameter.key = "promocode"; promoCodeParameter.value = "NYC123"; textAd.urlCustomParameters = new CustomParameters(); textAd.urlCustomParameters.parameters = new CustomParameter[] { seasonParameter, promoCodeParameter }; // Specify a list of final URLs. This field cannot be set if URL field is // set. This may be specified at ad, criterion and feed item levels. textAd.finalUrls = new string[] { "http://www.example.com/cruise/space/", "http://www.example.com/locations/mars/" }; // Specify a list of final mobile URLs. This field cannot be set if URL // field is set, or finalUrls is unset. This may be specified at ad, // criterion and feed item levels. textAd.finalMobileUrls = new string[] { "http://mobile.example.com/cruise/space/", "http://mobile.example.com/locations/mars/" }; AdGroupAd textAdGroupAd = new AdGroupAd(); textAdGroupAd.adGroupId = adGroupId; textAdGroupAd.ad = textAd; // Optional: Set the status. textAdGroupAd.status = AdGroupAdStatus.PAUSED; // Create the operation. AdGroupAdOperation operation = new AdGroupAdOperation(); operation.@operator = Operator.ADD; operation.operand = textAdGroupAd; AdGroupAdReturnValue retVal = null; try { // Create the ads. retVal = service.mutate(new AdGroupAdOperation[] { operation }); // Display the results. if (retVal != null && retVal.value != null) { AdGroupAd newAdGroupAd = retVal.value[0]; Console.WriteLine("New text ad with ID = {0} and display URL = \"{1}\" was " + "created.", newAdGroupAd.ad.id, newAdGroupAd.ad.displayUrl); Console.WriteLine("Upgraded URL properties:"); TextAd newTextAd = (TextAd) newAdGroupAd.ad; Console.WriteLine(" Final URLs: {0}", string.Join(", ", newTextAd.finalUrls)); Console.WriteLine(" Final Mobile URLs: {0}", string.Join(", ", newTextAd.finalMobileUrls)); Console.WriteLine(" Tracking URL template: {0}", newTextAd.trackingUrlTemplate); Console.WriteLine(" Final App URLs: {0}", string.Join(", ", newTextAd.finalAppUrls.Select(finalAppUrl => finalAppUrl.url).ToArray())); List<string> parameters = new List<string>(); foreach (CustomParameter customParam in newTextAd.urlCustomParameters.parameters) { parameters.Add(string.Format("{0}={1}", customParam.key, customParam.value)); } Console.WriteLine(" Custom parameters: {0}", string.Join(", ", parameters.ToArray())); } else { Console.WriteLine("No text ads were created."); } } catch (Exception e) { throw new System.ApplicationException("Failed to create text ad.", e); } }
private void btnEditCustomParams_Click(object sender, EventArgs e) { var dev = this.cbDevice.SelectedItem as DeviceInfo; var result = "0"; if (dev.CustomParameters != null) result = dev.CustomParameters.Length.ToString(); if (InputBox("Count of custom parameters", "Please enter custom parameters count:", ref result) != DialogResult.OK) return; byte count = 0; if (result != null && result != "") { if (byte.TryParse(result, out count)) { if (count <= 32) { if (count > 0) { var cparams = new CustomParameter[count]; if (dev.CustomParameters != null) { if (count >= dev.CustomParameters.Length) for (var i = 0; i < Math.Max(dev.CustomParameters.Length, count); i++) { if (i < Math.Min(dev.CustomParameters.Length, count)) cparams[i] = new CustomParameter(dev.CustomParameters[i]); else cparams[i] = new CustomParameter(); } else for (var i = 0; i < count; i++) cparams[i] = new CustomParameter(dev.CustomParameters[i]); } else for (var i = 0; i < count; i++) cparams[i] = new CustomParameter(); dev.CustomParameters = cparams; } else dev.CustomParameters = null; this.UpdateCustomParams(); this.UpdateDataPacketText(DateTime.Now.ToUniversalTime()); } else MessageBox.Show("Number of custom parameters must be up to 32"); } else MessageBox.Show("Wrong input"); } }