public JournalConfiguration(string journalDirectory, string journalFileName, long lengthInBytes, IoType ioType) { JournalDirectory = journalDirectory; JournalFileName = journalFileName; LengthInBytes = lengthInBytes; IoType = ioType; }
public override int GetHashCode() { int hash = 1; if (Topic.Length != 0) { hash ^= Topic.GetHashCode(); } if (MessageFormat.Length != 0) { hash ^= MessageFormat.GetHashCode(); } if (IoType != 0) { hash ^= IoType.GetHashCode(); } if (DeviceId.Length != 0) { hash ^= DeviceId.GetHashCode(); } hash ^= tags_.GetHashCode(); if (Description.Length != 0) { hash ^= Description.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (Topic.Length != 0) { hash ^= Topic.GetHashCode(); } if (MessageFormat.Length != 0) { hash ^= MessageFormat.GetHashCode(); } if (IoType != global::Ubii.Devices.Component.Types.IOType.Publisher) { hash ^= IoType.GetHashCode(); } if (DeviceId.Length != 0) { hash ^= DeviceId.GetHashCode(); } hash ^= tags_.GetHashCode(); if (Description.Length != 0) { hash ^= Description.GetHashCode(); } if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public Connector(string name, IoType iotype = Enums.IoType.Int, bool nonEmpty = false) { Name = name; IoType = iotype; NonEmpty = nonEmpty; Color = Colors.DarkSeaGreen; }
/// <summary> /// Special method that ensures correct input parameters for specified problem from console arguments /// </summary> /// <param name="args">Console arguments</param> /// <returns>Struct defining input parameters</returns> protected override InputData HandleArguments(string[] args) { string fileName; IoType type = GetType(args); int index = type == IoType.Program ? 0 : 1; if (args.Length <= index) { ErrorHandler.TerminateExecution(ErrorCode.NoFileGiven); } if (!TryExtensions(args[index], out fileName)) { ErrorHandler.TerminateExecution(ErrorCode.NoSuchFile, args[index]); } ExecutionTime time; if (args.Length == 1 || index == 1) { time = ExecutionTime.Unlimited; } else { if (!StringTime.Decode(args[1], out time)) { ErrorHandler.TerminateExecution(ErrorCode.InvalidInputParameter, "Time is not well defined: " + args[1] + "."); } } return(new InputData(fileName, time, index == 0)); }
internal IoBlock(BinaryReader reader, IoType type) { this.Count = reader.ReadByte(); this.Type = type; for (var index = 0; index < this.Count; index++) this.ReadIoPair(reader); }
public OutputConnectorViewModel(ElementViewModel element, IoType iotype, string name, Color color) : base(element, iotype, name, color) { Connections = new ObservableCollection <ConnectionViewModel>(); Connections.CollectionChanged += (e, w) => { RaisePropertyChanged("NonEmpty"); }; }
/// <summary> /// Writes the null argument io exception to the stream, then shuts down the game. /// </summary> /// <param name="ane">The ane.</param> /// <param name="elementType">Type of the element.</param> /// <param name="elementNumber">The element number.</param> public static void WriteNullArgumentIoException(ArgumentNullException ane, IoType elementType, int elementNumber) { DefaultLogger.WriteExceptionThenQuit( MessageType.FileIOError, ane, string.Format("file IO argument null exception: io type {0}, elementNumber {1}, xml-line number: {2}", elementType.ToString(), elementNumber)); }
internal IoPair(byte id, IoType type, byte[] value) { this.Id = id; this.Type = type; _value = value; if((int)type!=value.Length) throw new InvalidOperationException("value length is not match with Io type"); }
internal IoBlock(BinaryReader reader, IoType type) { this.Count = reader.ReadByte(); this.Type = type; for (var index = 0; index < this.Count; index++) { this.ReadIoPair(reader); } }
public static string LogInPacket(string id, IoType type, string pw) { string msg = null; msg += "ACK_LOGIN\a"; msg += id.Trim() + "#"; msg += pw.Trim(); return(msg); }
protected void MsgTypeComboChanged(ComboBox msgTypeCombo, IoType ioCategory, ref MssMsgRangeEntryMetadata msgMetadata) { MssMsgType msgType = GetMessageTypeFromCombo(msgTypeCombo); msgMetadata = MsgMetadataFactory.Create(msgType); msgMetadata.AttachToDlg(this, ioCategory); }
internal IoPair(byte id, byte[] value) { this.Id = id; if (!Enum.IsDefined(typeof(IoType), (byte)value.Length)) { throw new InvalidOperationException("value length is not match with Io type"); } this.Type = (IoType)value.Length; _value = value; }
/// <summary> /// Write fatal IO exception, then close down the game. /// </summary> /// <param name="exception"></param> /// <param name="xElement"></param> public static void WriteFatalIOException(Exception exception, XElement xElement, IoType elementType, int elementNumber) { DefaultLogger.WriteExceptionThenQuit( MessageType.FileIOError, exception, string.Format("file IO exception: io type {0}, elementNumber {1}, xElementData: {2}, xml line number: {3}", elementType.ToString(), elementNumber, xElement.Value, xElement.LineNumber())); }
/// <summary> /// Initializes this MssMsgRangeEntryMetadata and sets the default properties for controls on the mapping /// dialog /// </summary> /// <param name="mappingDlg">The mapping dialog this is associated with</param> /// <param name="io">Specifies wheather this associated with the input or output entry fields.</param> public void AttachToDlg(MappingDlg mappingDlg, IoType io) { this.msgRange = new MssMsgRange(); this.msgRange.MsgType = this.MsgType; this.ioCatagory = io; this.mappingDlg = mappingDlg; InitOutMssMsgTypeNames(); //Contains the type combo box that did not trigger the creation of this class ComboBox otherTypeCombo; //For each MSS message type selected for input there are only a subset of MSS message types that are //considered valid output. When the input type changes then the output combo box must be repopulated if (io == IoType.Input) { otherTypeCombo = mappingDlg.outTypeCombo; otherTypeCombo.Items.Clear(); otherTypeCombo.Items.AddRange(outMssMsgTypeNames.ToArray()); //This will cause the output MssMsgRangeEntryMetadata to be created. otherTypeCombo.SelectedIndex = 0; } else if (io == IoType.Output) { otherTypeCombo = mappingDlg.inTypeCombo; } else { //Unknown IO type Debug.Assert(false); return; } MssMsgType otherMsgType = mappingDlg.GetMessageTypeFromCombo(otherTypeCombo); if (io == IoType.Input) { if (this.canSelectSameAsInput) { mappingDlg.outSameAsInCheckBox.Enabled = true; } else { mappingDlg.outSameAsInCheckBox.Checked = false; mappingDlg.outSameAsInCheckBox.Enabled = false; } } SetMappingDlgEntryFieldsDefaultProperties(); SetMappingDlgEntryFieldCustomProperties(); }
internal IoPair(byte id, IoType type, byte[] value) { this.Id = id; this.Type = type; _value = value; if ((int)type != value.Length) { throw new InvalidOperationException("value length is not match with Io type"); } }
public static string UpdateAccountPacket(int id, IoType type, int balance) { string msg = null; msg += "PACK_UPDATEACCOUNT\a"; msg += id.ToString().Trim() + "#"; msg += ((int)type).ToString().Trim() + "#"; msg += balance.ToString(); return(msg); }
protected ConnectorViewModel(ElementViewModel element, IoType iotype, string name, Color color) { Element = element; Name = name; Color = color; IoType = iotype; if (iotype == Enums.IoType.Object) { DirectValue = "me"; } else { DirectValue = "0"; } }
/// <summary> /// Writes an IO message. /// </summary> /// <param name="xElement">The x element.</param> /// <param name="entityNumber">The entity number.</param> public static void WriteIoInformation(XElement xElement, IoType elementType, int elementTypeCount) { // can't write an IO message if the xElement is null if (xElement == null) { WriteFatalIOException(new ArgumentNullException(xElement.ToString()), xElement, elementType, elementTypeCount); } DefaultLogger.DoWrite( _entityIoStream, MessageType.FileIOInfo, true, string.Format("Parsing element, iotype: {0}, element name {1}, xml-line number {2}", elementType.ToString(), xElement.Name, xElement.LineNumber()) ); }
public void Update() { Console.WriteLine(">> 계좌번호 입력하세요."); int id; int.TryParse(Console.ReadLine(), out id); Console.WriteLine(">> [1] 입금 [2]출금 선택하세요"); IoType type = (IoType)int.Parse(Console.ReadLine()); Console.WriteLine(">> 수정 금액"); int balance; int.TryParse(Console.ReadLine(), out balance); BankManager.Bank_Singleton.UpdateAccount(id, type, balance); }
/// <summary> /// Gets a string representing an MssMsgType used by this MappingEntry /// </summary> /// <param name="ioCategory">Specifies wheather to use the type from InMssMsgRange or OutMssMsgRange</param> public string GetReadableMsgType(IoType ioCategory) { if (ioCategory == IoType.Input) { return(MssMsg.MssMsgTypeNames[(int)this.InMssMsgRange.MsgType]); } else if (ioCategory == IoType.Output) { return(MssMsg.MssMsgTypeNames[(int)this.OutMssMsgRange.MsgType]); } else { //Unknown IO type Debug.Assert(false); return(""); } }
public static Dictionary <At2000Io, BinaryIoAttribute> GetSettings( IoType type) { try { return(Enum.GetValues(typeof(At2000Io)).Cast <At2000Io>().Select(x => { var data = new { Type = x, Settings = EnumAttributeCache <At2000Io> .GetCustomAttribute <BinaryIoAttribute>(x) }; return data; }).Where(x => x.Settings != null && x.Settings.IoIoType == type).GroupBy(x => x.Type, x => x.Settings).ToDictionary(x => x.Key, x => x.Single())); } catch (InvalidOperationException ex) { throw new ApplicationException(string.Format("The AT 2000 I/O configuration is not valid. There are duplicate I/O values."), ex); } }
public bool UpdateAccount(int id, IoType type, int balance) { //if (balance <= 0) // return false; try { //1)패킷 생성 string packet = Packet.UpdateAccountPacket(id, type, balance); //2 전송 SendData(packet); return(true); } catch (Exception ex) { Console.WriteLine("[AddAccount에러] " + ex.Message); return(false); } }
public override InputData GetParameters(string[] args) { InputData data = null; switch (args.Length) { case 0: data = ConsoleParameters(); break; case 1: case 2: IoType type = GetType(args); switch (type) { case IoType.Manual: ErrorHandler.TerminateExecution(ErrorCode.EarlyExit, spacer + userManual); break; case IoType.Resource: case IoType.Program: data = HandleArguments(args); break; case IoType.InvalidOption: ErrorHandler.TerminateExecution(ErrorCode.InvalidNumInputParameters, "No such option " + args[0] + spacer + userManual); break; default: throw new ArgumentOutOfRangeException(); } break; default: ErrorHandler.TerminateExecution(ErrorCode.InvalidNumInputParameters, spacer + userManual); break; } return(data); }
public string ReadString(IoType type) { // fill the buffer with chars until we hit EOF, the separator, or \n this._buffer.Length = 0; int ch = this._reader.Read(); while (ch != -1 && (char)ch != this._escaper.Separator[0] && (char)ch != '\n') { this._buffer.Append((char)ch); ch = this._reader.Read(); } var rawValue = this._buffer.ToString(); switch (type) { case IoType.Key: return this._escaper.UnescapeKeyString(rawValue); case IoType.Value: return this._escaper.UnescapeValueString(rawValue); case IoType.Raw: return rawValue; default: throw Throw.InvalidEnumValue(type); } }
public void WriteDateTime(DateTime value, IoType type) { // TODO improve this this.WriteString(value.ToString(), type); }
private static IEnumerable <IoProperty> ReadValues(IoType type, uint values) { Dictionary <At2000Io, BinaryIoAttribute> settings = GetSettings(type); return(settings == null?Enumerable.Empty <IoProperty>() : GetFlags(values, settings).Select(x => IoProperty.Create(x.Key, x.Value ? (byte)1 : (byte)0))); }
private void Ldloc(int index, IoType ioType, RegisterSize registerSize) { _ilBlock.Add(new IlOpCodeLoad(index, ioType, registerSize)); }
public IlOpCodeLoad(int index, IoType ioType, RegisterSize registerSize = 0) { Index = index; IoType = ioType; RegisterSize = registerSize; }
public char ReadChar(IoType type) { var value = this.ReadString(type); Throw.InvalidIf(value.Length != 1, "returned value string was not of length 1!"); return value[0]; }
public byte ReadByte(IoType type) { return byte.Parse(this.ReadString(type)); }
private static void TestEncoderHelper(object value, IEncoder encoder, IDecoder decoder, StreamContext stream, IoType type, Action afterEncode = null) { var inMethod = typeof(IEncoder).GetMethods() .First(m => m.Name.StartsWith("Write") && m.GetParameters()[0].ParameterType == value.GetType()); var outMethod = typeof(IDecoder).GetMethods() .First(m => m.Name.StartsWith("Read") && m.ReturnType == value.GetType()); // write it in inMethod.Invoke(encoder, new[] { value, type }); if (afterEncode != null) { afterEncode(); } // reset the stream for reading stream.writer.Flush(); stream.stream.Flush(); stream.stream.Seek(0, SeekOrigin.Begin); // read it out var outValue = outMethod.Invoke(decoder, new object[] { type }); outValue.ShouldEqual(value); }
public void WriteInt(int value, IoType type) { this.WriteString(value.ToString(), type); }
public void WriteDouble(double value, IoType type) { this.WriteString(value.ToString(), type); }
public ILOpCodeStore(int index, IoType ioType, RegisterSize registerSize = 0) { Index = index; IoType = ioType; RegisterSize = registerSize; }
public DateTime ReadDateTime(IoType type) { return DateTime.Parse(this.ReadString(type)); }
public double ReadDouble(IoType type) { return double.Parse(this.ReadString(type)); }
/// <summary> /// Gets a string representing an MssMsgType used by this MappingEntry /// </summary> /// <param name="ioCategory">Specifies wheather to use the type from InMssMsgRange or OutMssMsgRange</param> public string GetReadableMsgType(IoType ioCategory) { if (ioCategory == IoType.Input) { return MssMsg.MssMsgTypeNames[(int)this.InMssMsgRange.MsgType]; } else if (ioCategory == IoType.Output) { return MssMsg.MssMsgTypeNames[(int)this.OutMssMsgRange.MsgType]; } else { //Unknown IO type Debug.Assert(false); return ""; } }
public int ReadInt(IoType type) { return int.Parse(this.ReadString(type)); }
public long ReadLong(IoType type) { return long.Parse(this.ReadString(type)); }
public InputConnectorViewModel(ElementViewModel element, IoType iotype, string name, Color color) : base(element, iotype, name, color) { }
private void Ldloc(int index, IoType ioType) { _ilBlock.Add(new ILOpCodeLoad(index, ioType, CurrOp.RegisterSize)); }
private void Stloc(int index, IoType ioType) { _ilBlock.Add(new IlOpCodeStore(index, ioType, CurrOp.RegisterSize)); }
public void WriteByte(byte value, IoType type) { this.WriteString(value.ToString(), type); }
private static IEnumerable <IoProperty> ReadEvents(IoType type, uint values) => ReadValues(type, values).Where(x => x.ToBoolean());
public void WriteChar(char value, IoType type) { this.WriteString(value.ToString(), type); }
public void WriteLong(long value, IoType type) { this.WriteString(value.ToString(), type); }
public void WriteString(string value, IoType type) { string safeValue; switch (type) { case IoType.Raw: safeValue = value; break; case IoType.Key: safeValue = this._escaper.EscapeKeyString(value); break; case IoType.Value: safeValue = this._escaper.EscapeValueString(value); break; default: throw Throw.InvalidEnumValue(type); } this._writer.Write(safeValue); }