public static Guid? GetIDFrom(IAtomCollection collection, ID4 name) { var atom = collection.FindByName(name); byte[] value = null; if (atom != null && atom.TryGetBytes(out value) && value.Length==16) { return ByteArrayToID(value); } else { return null; } }
public static ushort? GetUShortFrom(IAtomCollection collection, ID4 name) { var atom = collection.FindByName(name); ushort value = 0; if (atom != null && atom.TryGetUInt16(out value)) { return value; } else { return null; } }
public static byte? GetByteFrom(IAtomCollection collection, ID4 name) { var atom = collection.FindByName(name); byte value = 0; if (atom != null && atom.TryGetByte(out value)) { return value; } else { return null; } }
public static int? GetIntFrom(IAtomCollection collection, ID4 name) { var atom = collection.FindByName(name); int value = 0; if (atom != null && atom.TryGetInt32(out value)) { return value; } else { return null; } }
public static void SetChanPktType(this IAtomCollection collection, ID4 value) { SetAtomTo(collection, new Atom(Atom.PCP_CHAN_PKT_TYPE, value.GetBytes())); }
public static Atom GetAtomFrom(IAtomCollection collection, ID4 name) { return collection.FindByName(name); }
public static string GetStringFrom(IAtomCollection collection, ID4 name) { string res = null; var atom = collection.FindByName(name); if (atom != null && atom.TryGetString(out res)) { return res; } else { return null; } }
public static IPAddress GetIPAddressFrom(IAtomCollection collection, ID4 name) { var atom = collection.FindByName(name); IPAddress value = null; if (atom != null && atom.TryGetIPv4Address(out value)) { return value; } else { return null; } }
public static ID4? GetID4From(IAtomCollection collection, ID4 name) { var atom = collection.FindByName(name); byte[] value = null; if (atom != null && atom.TryGetBytes(out value) && value.Length==4) { return new ID4(value); } else { return null; } }
public static IAtomCollection GetCollectionFrom(IAtomCollection collection, ID4 name) { var atom = collection.FindByName(name); if (atom != null && atom.HasChildren) { return atom.Children; } else { return null; } }
private void TReg_Click(object sender, EventArgs e) { string s = ID4.Text; // This will create a file named ID4 // at the specified location StreamWriter sw = new StreamWriter("D:\\Semester-03\\OOP\\Project\\Files\\Teacher\\Bio\\" + s + ".txt", true); // To write a line in buffer sw.WriteLine(Fname4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(Lname4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(Eaddress4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(cnic4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(dob4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(cno4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(Haddress4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(nation4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(qua4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(pos4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(degree4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(campus4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(ID4.Text); // To write in output stream sw.Flush(); // To write a line in buffer sw.WriteLine(password4.Text); // To write in output stream sw.Flush(); // To close the stream sw.Close(); s = "Teacher"; // This will create a file named ID4 // at the specified location StreamWriter sx = new StreamWriter("D:\\Semester-03\\OOP\\Project\\Files\\Admin\\Red Zone\\" + s + ".txt", true); // To write a line in buffer sx.WriteLine(ID4.Text); // To write in output stream sx.Flush(); // To write a line in buffer sx.WriteLine(password4.Text); // To write in output stream sx.Flush(); // To close the stream sx.Close(); string message = "Teacher has been registered successfully"; MessageBox.Show(message); Fname4.Clear(); Lname4.Clear(); Eaddress4.Clear(); cnic4.Clear(); dob4.Clear(); cno4.Clear(); Haddress4.Clear(); nation4.Clear(); qua4.Clear(); pos4.Clear(); degree4.Clear(); campus4.Clear(); ID4.Clear(); password4.Clear(); }
static public Atom ReadAtom(this Stream stream) { var header = stream.ReadBytes(8); var name = new ID4(header, 0); if (!BitConverter.IsLittleEndian) Array.Reverse(header, 4, 4); uint len = BitConverter.ToUInt32(header, 4); if ((len & 0x80000000U)!=0) { if ((len&0x7FFFFFFF)>1024) { throw new InvalidDataException("Atom has too many children"); } var children = new AtomCollection(); for (var i=0; i<(len&0x7FFFFFFF); i++) { children.Add(stream.ReadAtom()); } return new Atom(name, children); } else { if (len>1024*1024) { throw new InvalidDataException("Atom length too long"); } var value = stream.ReadBytes((int)len); return new Atom(name, value); } }
static public async Task<Atom> ReadAtomAsync(this Stream stream, CancellationToken cancel_token) { var header = await stream.ReadBytesAsync(8, cancel_token); var name = new ID4(header, 0); if (!BitConverter.IsLittleEndian) Array.Reverse(header, 4, 4); uint len = BitConverter.ToUInt32(header, 4); if ((len & 0x80000000U)!=0) { if ((len&0x7FFFFFFF)>1024) { throw new InvalidDataException("Atom has too many children"); } var children = new AtomCollection(); for (var i=0; i<(len&0x7FFFFFFF); i++) { children.Add(await stream.ReadAtomAsync(cancel_token)); } return new Atom(name, children); } else { if (len>1024*1024) { throw new InvalidDataException("Atom length too long"); } var value = await stream.ReadBytesAsync((int)len, cancel_token); return new Atom(name, value); } }
static void MenuSelection(string selection) { switch (selection) { case "1": { var problem = new ID1(); problem.Start(); break; } case "2": { var problem = new ID2(); problem.Start(); break; } case "3": { var problem = new ID3(); problem.Start(); break; } case "4": { var problem = new ID4(); problem.Start(); break; } case "5": { var problem = new ID5(); problem.Start(); break; } case "6": { var problem = new ID6(); problem.Start(); break; } case "7": { var problem = new ID7(); problem.Start(); break; } case "8": { var problem = new ID8(); problem.Start(); break; } case "9": { var problem = new ID9(); problem.Start(); break; } case "10": { var problem = new ID10(); problem.Start(); break; } case "11": { var problem = new ID11(); problem.Start(); break; } case "12": { var problem = new ID12(); problem.Start(); break; } case "13": { var problem = new ID13(); problem.Start(); break; } case "14": { var problem = new ID14(); problem.Start(); break; } case "266": { var problem = new ID266(); problem.Start(); break; } default: break; } }