static int RunNew(NewOptions opts) { var wallet = CreateWallet(opts.DbName, opts.Type, opts.ShowSql); wallet.Save(); return(0); }
//[XmlInclude(typeof(BuildFarmCapability)), XmlInclude(typeof(BuildBarrackCapability)), XmlInclude(typeof(BuildBowWorkshopCapability)), XmlInclude(typeof(BuildTowerCapability)), XmlInclude(typeof(BuildPeasantCapability)), XmlInclude(typeof(BuildArcherCapability))] public static void Main(string[] args) { var buildingTypes = new string[5] {"Farm", "Barrack","BowWorkshop","Tower","Blacksmith" }; var unitTypes = new string[4] { "Peasant", "Archer", "Clubman", "SwordFighter" }; UIBLC uW = new UIBLC(); uW.BuildingTypes = buildingTypes; uW.UnitTypes = unitTypes; Serialize(uW); Starting s = new Starting(); s.Resources = 200; Serialize(s); NewOptions options = new NewOptions(); options.FarmBuildings = new string[1] { "Barrack" }; options.FarmUnits = new string[1] { "Peasant" }; options.BarrackBuildings = new string[1] { "BowWorkshop" }; //options.BarrackUnits = new string[1] { "Clubman" }; options.BowWorkshopBuildings = new string[1] { "Tower" }; options.BowWorkshopUnits = new string[1] { "Archer" }; //options.TowerBuildings = new string[1] { "Blacksmith" }; //options.BlacksmithUnits = new string[1] { "SwordFighter" }; Serialize(options); //var map = new Map(); //map = map.Run(16, 16); //SerialMap(map); }
internal GlobalOptions(NewOptions options) { Requires.NotNull(options, nameof(options)); this.IndentSize = options.IndentSize; this.TabSize = options.TabSize; this.UsingTabs = options.UsingTabs; this.OptionalRuleMap = new OptionalRuleMap(options.RuleGroupsToDisable); }
private void HandleNew(NewOptions options) { container.RegisterInstance(options); container.RegisterInstance <Options>(options); IVerbHandler handler = container.Resolve <NewHandler>(); handler.Run(); }
internal GlobalOptions(NewOptions options) { Requires.NotNull(options, nameof(options)); this.IndentSize = options.IndentSize; this.TabSize = options.TabSize; this.UsingTabs = options.UsingTabs; this.OptionalRuleMap = new OptionalRuleMap(options.RuleGroupsToDisable); }
protected void CreateProjectFile(string fileName) { var options = new NewOptions { ConnectionString = Fixture.ConnectionString, Name = fileName, }; NewOptionsHandler.Handle(options); }
private void New(NewOptions o) { var pubKey = CreateSwapper().NewPubkey(); Console.WriteLine("Transfer this pubkey to the other party:"); Console.WriteLine(Separator); DataToTransfer = pubKey.ToHex(); Console.WriteLine(DataToTransfer); Console.WriteLine(Separator); }
private static int New(NewOptions options) { var serializer = CreateSerializer(); using (var streamWriter = new StreamWriter(_contentFileName)) using (var jsonWriter = new JsonTextWriter(streamWriter)) { serializer.Serialize(jsonWriter, new ContentFile()); } return(0); }
/// <summary> /// Creates one or several records of a file, ina asynchronous way with XML input and output format. /// </summary> /// <param name="filename">The file name where the records are going to be created.</param> /// <param name="records">Buffer of records to write. Inside this string are the recordIds, and the records.</param> /// <param name="newOptions">Object with write options for the new record(s), including recordIdType, readAfter, calculated, dictionaries, conversion, formatSpec, originalRecords.</param> /// <param name="xmlFormat">Different XML output formats.</param> /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param> /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param> /// <returns>The results of the operation.</returns> /// <remarks> /// Inside the records argument, the records always must be specified. But the recordIds only must be specified when <see cref="NewOptions"/> argument is null, or when the <see cref="RecordIdType"/> argument of the <see cref="NewOptions"/> constructor is null. /// </remarks> public Task <string> NewAsync(string filename, string records, NewOptions newOptions = null, XML_FORMAT xmlFormat = XML_FORMAT.XML, string customVars = "", int receiveTimeout = 0) { var task = new Task <string>(() => { return(this.New(filename, records, newOptions, xmlFormat, customVars, receiveTimeout)); }); task.Start(); return(task); }
static int RunNew(NewOptions opts) { var cfg = GetWalletConfig(opts.Node, opts.Mainnet, opts.DbName, opts.ShowSql); var wallet = CreateWallet(cfg, opts.Type); if (wallet == null) { return(1); } wallet.Save(); return(0); }
/// <summary> /// Creates one or several records of a file, synchronously only. /// </summary> /// <param name="filename">The file name where the records are going to be created.</param> /// <param name="records">Buffer of records to write. Inside this string are the recordIds, and the records. Use StringFunctions.ComposeNewBuffer (Linkar.Strings library) function to compose this string.</param> /// <param name="newOptions">Object with write options for the new record(s), including recordIdType, readAfter, calculated, dictionaries, conversion, formatSpec, originalRecords.</param> /// <param name="inputFormat">Indicates in what format you wish to send the resultant writing data: MV, XML or JSON.</param> /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the Read, New, Update and Select operations: MV, XML, XML_DICT, XML_SCH, JSON, JSON_DICT or JSON_SCH.</param> /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param> /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param> /// <returns>The results of the operation.</returns> /// <remarks> /// Inside the records argument, the records always must be specified. But the recordIds only must be specified when <see cref="NewOptions"/> argument is null, or when the <see cref="RecordIdType"/> argument of the <see cref="NewOptions"/> constructor is null. /// </remarks> public string New(string filename, string records, NewOptions newOptions = null, DATAFORMAT_TYPE inputFormat = DATAFORMAT_TYPE.MV, DATAFORMATCRU_TYPE outputFormat = DATAFORMATCRU_TYPE.MV, string customVars = "", int receiveTimeout = 0) { string newArgs = OperationArguments.GetNewArgs(filename, records, newOptions, customVars); byte opCode = (byte)OPERATION_CODE.NEW; byte byteInputFormat = (byte)inputFormat; byte byteOutputFormat = (byte)outputFormat; string connectionInfo = this._ConnectionInfo.ToString(); string result = Linkar.ExecutePersistentOperation(this._ConnectionInfo, opCode, newArgs, byteInputFormat, byteOutputFormat, receiveTimeout); return(result); }
/// <summary> /// Compose the 3 items (CUSTOMVARS, OPTIONS and INPUTDATA) of the New operation. /// </summary> /// <param name="filename">The file name where the records are going to be created.</param> /// <param name="records">Buffer of records to write. Inside this string are the recordIds, and the records. Use StringFunctions.ComposeNewBuffer (Linkar.Strings library) function to compose this string.</param> /// <param name="newOptions">Object with write options for the new record(s), including recordIdType, readAfter, calculated, dictionaries, conversion, formatSpec, originalRecords.</param> /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param> /// <returns>A string ready to be used in Linkar.ExecuteDirectOperation and Linkar.ExecutePersistentOperation.</returns> public static string GetNewArgs(string filename, string records, NewOptions newOptions, string customVars) { if (newOptions == null) { newOptions = new NewOptions(); } string options = newOptions.ToString(); string inputData = filename + DBMV_Mark.AM + records; string cmdArgs = customVars + ASCII_Chars.US_str + options + ASCII_Chars.US_str + inputData; return(cmdArgs); }
/// <summary> /// Method that gets executed on the "new" command /// </summary> /// <param name="options">The arguments that have been provided with the "new" command</param> /// <returns><see cref="EXIT_SUCCESS"/> and <see cref="EXIT_FAILURE"/> for being successful and failing respectively</returns> private static int New(NewOptions options) { //TODO: this should probably create a new Program instance, with just the properties that it needs UndertaleData data = UndertaleData.CreateNew(); // If stdout flag is set, write new data to stdout and quit if (options.Stdout) { if (options.Verbose) { Console.WriteLine("Attempting to write new Data file to STDOUT..."); } using MemoryStream ms = new MemoryStream(); UndertaleIO.Write(ms, data); Console.OpenStandardOutput().Write(ms.ToArray(), 0, (int)ms.Length); Console.Out.Flush(); if (options.Verbose) { Console.WriteLine("Successfully wrote new Data file to STDOUT."); } return(EXIT_SUCCESS); } // If not STDOUT, write to file instead. Check first if we have permission to overwrite if (options.Output.Exists && !options.Overwrite) { Console.Error.WriteLine($"'{options.Output}' already exists. Pass --overwrite to overwrite"); return(EXIT_FAILURE); } // We're not writing to STDOUT, and overwrite flag was given, so we write to specified file. if (options.Verbose) { Console.WriteLine($"Attempting to write new Data file to '{options.Output}'..."); } using FileStream fs = options.Output.OpenWrite(); UndertaleIO.Write(fs, data); if (options.Verbose) { Console.WriteLine($"Successfully wrote new Data file to '{options.Output}'."); } return(EXIT_SUCCESS); }
public void Run(NewOptions options) { var domainConfigFile = $"{options.Domain}.auth.yml"; var zoneConfigFile = $"{options.Domain}.zone.yml"; var domainConfig = new DomainConfiguration { ZoneOrigin = options.Domain, DomainToken = "domain-token-here" }; var zoneConfig = new ZoneConfiguration { ZoneOrigin = options.Domain }; _parser.CreateConfiguration(domainConfigFile, domainConfig); _parser.CreateConfiguration(zoneConfigFile, zoneConfig); }
private static int New(NewOptions opts) { var directory = new AdrDirectory(opts.Directory); var newEntry = AdrEntry.CreateNew(opts.Title); var current = AdrFile.Save(directory, newEntry); Console.WriteLine("Created {0}", current.FilePath); if (opts.SupersedesAdr != null) { var referenced = directory.GetRecord(opts.SupersedesAdr.Value); if (referenced != null) { current.Entry.AppendStatus($"Supersedes {referenced.AsLink()}"); referenced.Entry.AppendStatus($"Superseded by {current.AsLink()}"); current.Save(); referenced.Save(); } else { Console.WriteLine("{0} not found", opts.SupersedesAdr); return(1); } } if (opts.AmendsAdr != null) { var referenced = directory.GetRecord(opts.AmendsAdr.Value); if (referenced != null) { current.Entry.AppendStatus($"Amends {referenced.AsLink()}"); referenced.Entry.AppendStatus($"Amended by {current.AsLink()}"); current.Save(); referenced.Save(); } else { Console.WriteLine("{0} not found", opts.AmendsAdr); return(1); } } return(0); }
public static void Serialize(NewOptions no) { XmlSerializer serializer = new XmlSerializer(typeof(NewOptions)); // WARNING !!! You might need to change this link in order to make this project work using (TextWriter writer = new StreamWriter(@"C:/Users/Andrei/Source/Repos/uWarcraft/Uwarcraft/Serialization/newoptions.xml")) { serializer.Serialize(writer, no); } }
static private int VerbNew(NewOptions opts) { WriteVersion(); // Handle defaults if (opts.ApplicationName == "") { opts.ApplicationName = opts.ProductName; } if (opts.HardwareName == "") { opts.HardwareName = opts.ProductName; } if (opts.SerialNumber == "") { opts.SerialNumber = opts.ApplicationNumber.ToString(); } if (opts.OrderNumber == "") { opts.OrderNumber = opts.ApplicationNumber.ToString(); } // checks bool lFail = false; if (opts.ApplicationNumber > 65535) { Console.WriteLine("ApplicationNumber has to be less than 65536!"); lFail = true; } if (opts.SerialNumber.Contains("-")) { Console.WriteLine("SerialNumber must not contain a dash (-) character!"); lFail = true; } if (opts.OrderNumber.Contains("-")) { Console.WriteLine("OrderNumber must not contain a dash (-) character!"); lFail = true; } if (lFail) { return(1); } // create initial xml file string lXmlFile = ""; var assembly = Assembly.GetEntryAssembly(); var resourceStream = assembly.GetManifestResourceStream("MultiplyChannels.NewDevice.xml"); using (var reader = new StreamReader(resourceStream, Encoding.UTF8)) { lXmlFile = reader.ReadToEnd(); } lXmlFile = lXmlFile.Replace("%ApplicationName%", opts.ApplicationName); lXmlFile = lXmlFile.Replace("%ApplicationNumber%", opts.ApplicationNumber.ToString()); lXmlFile = lXmlFile.Replace("%ApplicationVersion%", opts.ApplicationVersion.ToString()); lXmlFile = lXmlFile.Replace("%HardwareName%", opts.HardwareName); lXmlFile = lXmlFile.Replace("%HardwareVersion%", opts.HardwareVersion.ToString()); lXmlFile = lXmlFile.Replace("%SerialNumber%", opts.SerialNumber); lXmlFile = lXmlFile.Replace("%OrderNumber%", opts.OrderNumber); lXmlFile = lXmlFile.Replace("%ProductName%", opts.ProductName); lXmlFile = lXmlFile.Replace("%MaskVersion%", opts.MaskVersion); lXmlFile = lXmlFile.Replace("%MediumTypes%", opts.MediumTypes); Console.WriteLine("Creating xml file {0}", opts.XmlFileName); File.WriteAllText(opts.XmlFileName, lXmlFile); return(VerbCreate(opts)); }
private void btnSave_Click(object sender, EventArgs e) { //Get current customer //Customer clkcustomer = GetCurrentRecord(); //if (clkcustomer != null) //{ // GetRecord(ref clkcustomer); // //Save or create new item // if (clkcustomer.Status != LinkarMainClass.StatusTypes.NEW) // { // string ge = ""; // //Call the WriteItem method from CLkCustomer // clkcustomer.WriteRecord(out ge, ""); // if (!string.IsNullOrEmpty(ge)) // { // MessageBox.Show(ge.Replace(DBMV_Mark.VM_str, "\r\n")); // } // else // { // ChangeBarStatus(false, false); // } // } // else // { // string ge = ""; // //Call the NewItem method from CLkCustomer // clkcustomer.NewRecord(out ge, ""); // if (!string.IsNullOrEmpty(ge)) // { // MessageBox.Show(ge.Replace(DBMV_Mark.VM_str, "\r\n")); // } // else // { // ChangeBarStatus(false, false); // } // } //} Customer clkcustomer = GetCurrentRecord(); if (clkcustomer != null) { List <Customer> lstupd = new List <Customer>(); GetRecord(ref clkcustomer); lstupd.Add(clkcustomer); string error; bool optimisticLock = false; bool readAfter = false; bool calculated = false; bool conversion = false; bool formatSpec = false; bool originalBuffer = false; string dataOrg = ""; string customVars = ""; Exception exErr = null; if (isNew) { try { RecordIdType recordIdType = new RecordIdType(); NewOptions newOptions = new NewOptions(recordIdType, readAfter, calculated, conversion, formatSpec, originalBuffer); List <Customer> lstCustomers = this._LinkarClt.New(filename, lstupd, newOptions, customVars); } catch (Exception ex) { exErr = ex; } } else { try { UpdateOptions updateOptions = new UpdateOptions(optimisticLock, readAfter, calculated, conversion, formatSpec, originalBuffer); List <Customer> lstCustomers = this._LinkarClt.Update(filename, lstupd, updateOptions, dataOrg, customVars); } catch (Exception ex) { exErr = ex; } } if (exErr != null) { string msgErr = FormDemo.GetExceptionInfo(exErr); MessageBox.Show(this, msgErr, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } ChangeBarStatus(false, false); isNew = false; } }
private int RunNew(NewOptions options) { engine.InitializeBlog(); return(0); }
/// <summary> /// Merges the field with a secondary field, if possible. /// </summary> /// <param name="SecondaryField">Secondary field to merge with.</param> /// <returns>If merger was possible.</returns> public bool Merge(Field SecondaryField) { if (this.var != SecondaryField.var || this.label != SecondaryField.label || this.description != SecondaryField.description || this.postBack != SecondaryField.postBack || this.description != SecondaryField.description || this.required != SecondaryField.required || (this.dataType == null) ^ (SecondaryField.dataType == null) || (this.validationMethod == null) ^ (SecondaryField.validationMethod == null) || (this.options == null) ^ (SecondaryField.options == null)) { return(false); } if (this.dataType != null && !this.dataType.Equals(SecondaryField.dataType)) { return(false); } if (this.validationMethod != null && !this.validationMethod.Equals(SecondaryField.validationMethod)) { return(false); } this.readOnly |= SecondaryField.readOnly; this.notSame |= SecondaryField.notSame; int i, c; if (this.options != null) { KeyValuePair <string, string> O1; KeyValuePair <string, string> O2; c = this.options.Length; bool OptionsDifferent = (c == SecondaryField.options.Length); if (!OptionsDifferent) { for (i = 0; i < c; i++) { O1 = this.options[i]; O2 = SecondaryField.options[i]; if (O1.Key != O2.Key || O1.Value != O2.Value) { OptionsDifferent = true; break; } } } if (OptionsDifferent) { List <KeyValuePair <string, string> > NewOptions = null; for (i = 0; i < c; i++) { O1 = this.options[i]; O2 = SecondaryField.options[i]; if (O1.Key == O2.Key && O1.Value == O2.Value) { if (NewOptions == null) { NewOptions = new List <KeyValuePair <string, string> >(); } NewOptions.Add(O1); } if (NewOptions == null) { return(false); } this.options = NewOptions.ToArray(); } } } if (!this.notSame) { if ((c = this.valueStrings.Length) != SecondaryField.valueStrings.Length) { this.notSame = true; } else { for (i = 0; i < c; i++) { if (this.valueStrings[i] != SecondaryField.valueStrings[i]) { this.notSame = true; break; } } } } return(true); }
/// <summary> /// Creates one or several records of a file, synchronously only. /// </summary> /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param> /// <param name="filename">The file name where the records are going to be created.</param> /// <param name="records">Buffer of records to write. Inside this string are the recordIds, and the records. Use StringFunctions.ComposeNewBuffer (Linkar.Strings library) function to compose this string.</param> /// <param name="newOptions">Object with write options for the new record(s), including recordIdType, readAfter, calculated, dictionaries, conversion, formatSpec, originalRecords.</param> /// <param name="inputFormat">Indicates in what format you wish to send the resultant writing data: MV, XML or JSON.</param> /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the Read, New, Update and Select operations: MV, XML, XML_DICT, XML_SCH, JSON, JSON_DICT or JSON_SCH.</param> /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param> /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param> /// <returns>The results of the operation.</returns> /// <remarks> /// Inside the records argument, the records always must be specified. But the recordIds only must be specified when <see cref="NewOptions"/> argument is null, or when the <see cref="RecordIdType"/> argument of the <see cref="NewOptions"/> constructor is null. /// </remarks> public static string New(CredentialOptions credentialOptions, string filename, string records, NewOptions newOptions = null, DATAFORMAT_TYPE inputFormat = DATAFORMAT_TYPE.MV, DATAFORMATCRU_TYPE outputFormat = DATAFORMATCRU_TYPE.MV, string customVars = "", int receiveTimeout = 0) { string newArgs = OperationArguments.GetNewArgs(filename, records, newOptions, customVars); byte opCode = (byte)OPERATION_CODE.NEW; byte byteInputFormat = (byte)inputFormat; byte byteOutputFormat = (byte)outputFormat; string result = Linkar.ExecuteDirectOperation(credentialOptions, opCode, newArgs, byteInputFormat, byteOutputFormat, receiveTimeout); return(result); }