// Some versions of glade call the menu an internal child, some don't protected override ObjectWrapper ReadInternalChild (ObjectReader reader, XmlElement child_elem) { if (child_elem.GetAttribute ("internal-child") == "menu") return ReadChild (reader, child_elem); else return base.ReadInternalChild (reader, child_elem); }
public void ReadStamp(ObjectReader reader) { TypeModule = reader.Modules.Read(); GenericFullName = reader.PrimitiveReader.ReadString(); Resolve(); }
public override void SetUp() { base.SetUp(); tr = new TestRepository<Repository>(db); reader = db.NewObjectReader(); inserter = db.NewObjectInserter(); }
public override void Read(object input, ObjectReader reader, Writer writer, PartialOptions optionsOverride) { if (writer.CanWrite(input)) writer.Write(input); else base.Read(input, reader, writer, optionsOverride); }
public void ReadStructureStampIfNeeded(ObjectReader reader, VersionToleranceLevel versionToleranceLevel) { if(StampHelpers.IsStampNeeded(this, reader.TreatCollectionAsUserObject)) { ReadStructureStamp(reader, versionToleranceLevel); } }
public override void Read(object input, ObjectReader reader, Writer writer, PartialOptions optionsOverride) { IDictionary dictionary = input as IDictionary; if (dictionary == null) return; if (ReferenceStructure(input, reader, optionsOverride)) return; if (ShouldWriteTypeIdentifier(reader.Options, optionsOverride)) writer.BeginStructure(CurrentTypeResolver.GetTypeIdentifier(Type), reader.GetType()); else writer.BeginStructure(Type); foreach (object key in dictionary.Keys) { // Convert.ToString is in case the keys are numbers, which are represented // as strings when used as keys, but can be indexed with numbers in JavaScript string name = Convert.ToString(key, CultureInfo.InvariantCulture); object value = dictionary[key]; writer.AddProperty(name); ValueTypeDef.ReadObject(value, reader, writer, PartialOptions.Default); } writer.EndStructure(); }
public override void SetUp() { base.SetUp(); db = CreateBareRepository(); reader = db.NewObjectReader(); test = new TestRepository<FileRepository>(db); }
public override void Read(object input, ObjectReader reader, Writer writer, PartialOptions optionsOverride) { if ((optionsOverride.EnumSerialization ?? reader.Options.EnumSerialization) == EnumSerialization.AsString) writer.Write(input.ToString()); else writer.Write((int)input); }
public override void Read(object input, ObjectReader reader, Writer writer, PartialOptions optionsOverride) { if (ReferenceStructure(input, reader, optionsOverride)) return; reader.AddReference(); writer.Write(input); }
public override void Read(object input, ObjectReader reader, Writer writer, PartialOptions optionsOverride) { if (ReferenceStructure(input, reader, optionsOverride)) return; if (ShouldWriteTypeIdentifier(reader.Options, optionsOverride)) writer.BeginStructure(CurrentTypeResolver.GetTypeIdentifier(Type), reader.GetType()); else writer.BeginStructure(Type); for (int i = 0; i < AllSerializableProperties.Length; i++) { PropertyDefinition property = AllSerializableProperties[i]; if (property.MatchesPropertyFilter(reader.Options)) { writer.AddProperty(property.SerializedName); reader.PropertyStack.Push(property); object value = property.GetFrom(input); property.Read(value, reader, writer); reader.PropertyStack.Pop(); } } writer.EndStructure(); }
protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem) { hasLabel = false; if (checkbutton.Child != null) checkbutton.Remove (checkbutton.Child); return base.ReadChild (reader, child_elem); }
protected override void ReadChildren (ObjectReader reader, XmlElement elem) { // Ignore changes in the buttons while loading actionArea.ContentsChanged -= ButtonsChanged; base.ReadChildren (reader, elem); actionArea.ContentsChanged += ButtonsChanged; actionArea.SetActionDialog (this); }
public override void Read(object input, ObjectReader reader, Writer writer, PartialOptions optionsOverride) { Guid? guid = input as Guid?; if (guid == null) writer.WriteNull(); else writer.Write(guid.ToString()); }
public override void Read(ObjectReader reader) { var size = reader.PrimitiveReader.ReadInt32(); nameAsByteArray = reader.PrimitiveReader.ReadBytes(size); Name = Encoding.UTF8.GetString(nameAsByteArray); UnderlyingType = TypeProvider.GetType(Name); }
static void Main(string[] args) { IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Loopback, 4040); Socket ss = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); var productos = new ObservableCollection<Producto>(); for (int i = 0; i < 20; i++) { productos.Add(new Producto() { ProductId = i, Nombre = "Producto servidor" + i, Precio = (decimal)i, CantidadDisponible = i * 10, Descripcion = "The enum keyword is used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list. Usually it is best to" }); } try { ss.Bind(localEndPoint); ss.Listen(10); while (true) { Console.WriteLine("Servidor escuchando por conexiones"); Socket cliente = ss.Accept(); string descCliente = cliente.LocalEndPoint.ToString(); Console.WriteLine("Conexion aceptada " + descCliente); ObjectWriter w = new ObjectWriter(cliente); ObjectReader r = new ObjectReader(cliente); Transacciones transaccion = (Transacciones)r.ReadInt32(); switch (transaccion) { case Transacciones.SolicitarCarrito: Console.WriteLine("\tSolicitud de carrito por: " + descCliente); w.WriteInt32(productos.Count); for (int i = 0; i < productos.Count; i++) { w.WriteObject<Producto>(productos[i]); } break; case Transacciones.RealizarCompra: Console.WriteLine("\tOrden de compra de " + descCliente); Orden o = r.ReadObject<Orden>(); productos[o.ProductId].CantidadDisponible -= o.Cantidad; break; } Console.WriteLine("Conexion terminada " + descCliente); cliente.Shutdown(SocketShutdown.Both); cliente.Close(); } } catch (Exception e) { Console.WriteLine(e.Message); } }
protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem) { if ((string)GladeUtils.GetChildProperty (child_elem, "type", "") == "label_item") { ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"]); expander.LabelWidget = (Gtk.Widget)wrapper.Wrapped; return wrapper; } else return base.ReadChild (reader, child_elem); }
public override void SetUp() { base.SetUp(); tr = new TestRepository<Repository>(db); reader = db.NewObjectReader(); inserter = db.NewObjectInserter(); merger = new DefaultNoteMerger(); noteOn = tr.Blob("a"); baseNote = NewNote("data"); }
protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem) { if ((string)GladeUtils.GetChildProperty (child_elem, "type", "") == "tab") { ObjectWrapper wrapper = reader.ReadObject (child_elem["widget"], this); Gtk.Widget widget = (Gtk.Widget)wrapper.Wrapped; notebook.SetTabLabel (notebook.GetNthPage (notebook.NPages - 1), widget); tabs.Add (widget); return wrapper; } else return base.ReadChild (reader, child_elem); }
protected override ObjectWrapper ReadChild (ObjectReader reader, XmlElement child_elem) { ObjectWrapper ret = null; if (Type == ButtonType.Custom || reader.Format == FileFormat.Glade) { if (button.Child != null) button.Remove (button.Child); ret = base.ReadChild (reader, child_elem); FixupGladeChildren (); } else if (Type == ButtonType.TextAndIcon) ConstructContents (); return ret; }
public override void Read(object input, ObjectReader reader, Writer writer, PartialOptions optionsOverride) { IEnumerable inputArray = input as IEnumerable; if (inputArray == null) return; writer.BeginSequence(); foreach (object item in inputArray) ItemTypeDef.ReadObject(item, reader, writer, optionsOverride); writer.EndSequence(); }
protected override void ReadProperties (ObjectReader reader, XmlElement elem) { string group = (string)GladeUtils.ExtractProperty (elem, "group", ""); bool active = (bool)GladeUtils.ExtractProperty (elem, "active", false); base.ReadProperties (reader, elem); if (group != "") Group = group; else Group = Wrapped.Name; if (active) ((Gtk.RadioToolButton)Wrapped).Active = true; }
internal BaseSearch(ProgressMonitor countingMonitor, ICollection<RevTree> bases, ObjectIdOwnerMap<ObjectToPack> objects, IList<ObjectToPack> edges, ObjectReader or) { progress = countingMonitor; reader = or; baseTrees = Sharpen.Collections.ToArray(bases, new ObjectId[bases.Count]); objectsMap = objects; edgeObjects = edges; alreadyProcessed = new IntSet(); treeCache = new ObjectIdOwnerMap<BaseSearch.TreeWithData>(); parser = new CanonicalTreeParser(); idBuf = new MutableObjectId(); }
public override Encoding ReadEncodingFrom(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var serialized = reader.ReadByte(); if (serialized == EncodingSerialization) { var array = (byte[])reader.ReadValue(); var formatter = new BinaryFormatter(); return (Encoding)formatter.Deserialize(new MemoryStream(array)); } return ReadEncodingFrom(serialized, reader, cancellationToken); }
public int RealizaCompra(int productId, int cantidad) { IPEndPoint remotePoint = new IPEndPoint(IPAddress.Loopback, 4040); Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); s.Connect(remotePoint); ObjectReader r = new ObjectReader(s); ObjectWriter w = new ObjectWriter(s); w.WriteInt32((int)Transacciones.RealizarCompra); Orden o = new Orden { ProductId = productId, Cantidad = cantidad }; w.WriteObject<Orden>(o); s.Shutdown(SocketShutdown.Both); s.Close(); return 1; }
protected override void ReadProperties (ObjectReader reader, XmlElement elem) { int history = (int)GladeUtils.ExtractProperty (elem, "history", -1); base.ReadProperties (reader, elem); // Fiddle with things to make the optionmenu resize itself correctly Gtk.Widget menu = optionmenu.Menu; optionmenu.Menu = new Gtk.Menu (); optionmenu.Menu = menu; if (history != -1) Active = history; else Active = 0; }
public ObjectSerializer(Type type) { if (type == null) throw new ArgumentNullException(nameof(type)); Type = type; //TODO: remove version info var typeName = type.GetShortAssemblyQualifiedName(); // ReSharper disable once PossibleNullReferenceException // ReSharper disable once AssignNullToNotNullAttribute var typeNameBytes = typeName.ToUtf8Bytes(); var fields = type.GetFieldInfosForType(); var fieldNames = fields.Select(field => field.Name.ToUtf8Bytes()).ToList(); var versionInfo = TypeEx.GetTypeManifest(fieldNames); //precalculate the entire manifest for this serializer //this helps us to minimize calls to Stream.Write/WriteByte _manifest = new[] {ManifestFull} .Concat(BitConverter.GetBytes(typeNameBytes.Length)) .Concat(typeNameBytes) .ToArray(); //serializer id 255 + assembly qualified name //TODO: this should only work this way for standard poco objects //custom object serializers should not emit their inner fields //this is the same as the above, but including all field names of the type, in alphabetical order _manifestWithVersionInfo = new[] {ManifestVersion} .Concat(BitConverter.GetBytes(typeNameBytes.Length)) .Concat(typeNameBytes) .Concat(versionInfo) .ToArray(); //serializer id 255 + assembly qualified name + versionInfo //initialize reader and writer with dummy handlers that wait until the serializer is fully initialized _writer = (stream, o, session) => { SpinWait.SpinUntil(() => _isInitialized); WriteValue(stream, o, session); }; _reader = (stream, session) => { SpinWait.SpinUntil(() => _isInitialized); return ReadValue(stream, session); }; }
public void ShouldHandleTwoWritesAndReads() { var strings = new [] { "One", "Two" }; var stream = new MemoryStream(); var writer = new ObjectWriter(stream); writer.WriteObject(strings[0]); writer.WriteObject(strings[1]); var position = stream.Position; stream.Seek(0, SeekOrigin.Begin); var reader = new ObjectReader(stream); Assert.AreEqual(strings[0], reader.ReadObject<string>()); Assert.AreEqual(strings[1], reader.ReadObject<string>()); Assert.AreEqual(position, stream.Position); }
protected override void ReadProperties (ObjectReader reader, XmlElement elem) { if (reader.Format == FileFormat.Glade) { string file = (string)GladeUtils.ExtractProperty (elem, "pixbuf", ""); string stock = (string)GladeUtils.ExtractProperty (elem, "stock", ""); string iconSize = (string)GladeUtils.ExtractProperty (elem, "icon_size", ""); base.ReadProperties (reader, elem); if (stock != null && stock.Length > 0) { Pixbuf = ImageInfo.FromTheme (stock, (Gtk.IconSize) int.Parse (iconSize)); } else if (file != null && file != "") { Pixbuf = ImageInfo.FromFile (file); } } else base.ReadProperties (reader, elem); }
protected override void ReadProperties (ObjectReader reader, XmlElement elem) { if (reader.Format == FileFormat.Glade) { string icon = (string)GladeUtils.ExtractProperty (elem, "icon", ""); stockId = (string)GladeUtils.ExtractProperty (elem, "stock_id", ""); label = (string)GladeUtils.ExtractProperty (elem, "label", ""); base.ReadProperties (reader, elem); if (stockId != null && stockId.Length > 0) { Type = ButtonType.StockItem; } else if (icon != null && icon != "") { imageInfo = ImageInfo.FromFile (icon); Type = ButtonType.TextAndIcon; } } else base.ReadProperties (reader, elem); }
protected override void ReadProperties (ObjectReader reader, XmlElement elem) { Gtk.StockItem stockItem = Gtk.StockItem.Zero; bool use_stock = (bool)GladeUtils.ExtractProperty (elem, "use_stock", false); if (use_stock) { string label = (string)GladeUtils.GetProperty (elem, "label", ""); stockItem = Gtk.Stock.Lookup (label); if (stockItem.Label != null) GladeUtils.ExtractProperty (elem, "label", ""); } base.ReadProperties (reader, elem); if (stockItem.StockId != null) Image = "stock:" + stockItem.StockId; if (stockItem.Keyval != 0) Accelerator = Gtk.Accelerator.Name (stockItem.Keyval, stockItem.Modifier); }
internal static SymbolTreeInfo ReadSymbolTreeInfo_ForTestingPurposesOnly(ObjectReader reader) { return(ReadSymbolTreeInfo(reader, (version, nodes) => Task.FromResult(new SpellChecker(version, nodes.Select(n => n.Name))))); }
public override void Read(ObjectReader reader) { ReadStamp(reader); ReadStructureStampIfNeeded(reader, reader.VersionToleranceLevel, reader.ForceStampVerification); }
/// <summary> /// Generalized function for loading/creating/persisting data. Used as the common core /// code for serialization of SymbolTreeInfos and SpellCheckers. /// </summary> private static async Task <T> LoadOrCreateAsync <T>( Solution solution, IAssemblySymbol assembly, string filePath, bool loadOnly, Func <VersionStamp, T> create, string keySuffix, Func <T, VersionStamp> getVersion, Func <ObjectReader, T> readObject, Action <ObjectWriter, T> writeObject, CancellationToken cancellationToken) where T : class { // See if we can even use serialization. If not, we'll just have to make the value // from scratch. string prefix; VersionStamp version; if (ShouldCreateFromScratch(solution, assembly, filePath, out prefix, out version, cancellationToken)) { return(loadOnly ? null : create(VersionStamp.Default)); } // Ok, we can use persistence. First try to load from the persistence service. var persistentStorageService = solution.Workspace.Services.GetService <IPersistentStorageService>(); T result; using (var storage = persistentStorageService.GetStorage(solution)) { // Get the unique key to identify our data. var key = PrefixMetadataSymbolTreeInfo + prefix + keySuffix; using (var stream = await storage.ReadStreamAsync(key, cancellationToken).ConfigureAwait(false)) { if (stream != null) { using (var reader = new ObjectReader(stream)) { // We have some previously persisted data. Attempt to read it back. // If we're able to, and the version of the persisted data matches // our version, then we can reuse this instance. result = readObject(reader); if (result != null && VersionStamp.CanReusePersistedVersion(version, getVersion(result))) { return(result); } } } } cancellationToken.ThrowIfCancellationRequested(); // Couldn't read from the persistence service. If we've been asked to only load // data and not create new instances in their absense, then there's nothing left // to do at this point. if (loadOnly) { return(null); } // Now, try to create a new instance and write it to the persistence service. result = create(version); if (result != null) { using (var stream = SerializableBytes.CreateWritableStream()) using (var writer = new ObjectWriter(stream, cancellationToken: cancellationToken)) { writeObject(writer, result); stream.Position = 0; await storage.WriteStreamAsync(key, stream, cancellationToken).ConfigureAwait(false); } } } return(result); }
/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception> /// <exception cref="System.IO.IOException"></exception> public override AbstractTreeIterator CreateSubtreeIterator(ObjectReader reader) { return((NGit.Treewalk.CanonicalTreeParser)CreateSubtreeIterator(reader, new MutableObjectId ())); }
protected SyntaxDiagnosticInfo(ObjectReader reader) : base(reader) { this.Offset = reader.ReadInt32(); this.Width = reader.ReadInt32(); }
private int index = -2; //-2 - Prepare, -1 - Missing public PPtr(ObjectReader reader) { m_FileID = reader.ReadInt32(); m_PathID = reader.m_Version < 14 ? reader.ReadInt32() : reader.ReadInt64(); assetsFile = reader.assetsFile; }
private WritableClass(ObjectReader reader) { this.X = reader.ReadInt32(); this.Y = reader.ReadString(); }
private TypeWithOneMember(ObjectReader reader) { _member = typeof(T).IsEnum ? (T)Enum.ToObject(typeof(T), reader.ReadInt64()) : (T)reader.ReadValue(); }
private Node(ObjectReader reader) { this.Name = reader.ReadString(); this.Children = (Node[])reader.ReadValue(); }
private PrimitiveArrayMemberTest(ObjectReader reader) { TestReadingPrimitiveArrays(reader); }
private TypeWithTwoMembers(ObjectReader reader) { _member1 = (T)reader.ReadValue(); _member2 = (S)reader.ReadValue(); }
protected override void ReadProperties(ObjectReader reader, XmlElement elem) { base.ReadProperties(reader, elem); menuInfo = elem ["node"]; treeChanged = false; }
internal SyntaxIdentifier(ObjectReader reader) : base(reader) { this.TextField = reader.ReadString(); this.FullWidth = this.TextField.Length; }
/// <summary> /// Generalized function for loading/creating/persisting data. Used as the common core /// code for serialization of SymbolTreeInfos and SpellCheckers. /// </summary> private static async Task <T> TryLoadOrCreateAsync <T>( Solution solution, Checksum checksum, bool loadOnly, Func <Task <T> > createAsync, string keySuffix, Func <ObjectReader, T> tryReadObject, CancellationToken cancellationToken) where T : class, IObjectWritable, IChecksummedObject { using (Logger.LogBlock(FunctionId.SymbolTreeInfo_TryLoadOrCreate, cancellationToken)) { if (checksum == null) { return(loadOnly ? null : await CreateWithLoggingAsync().ConfigureAwait(false)); } // Ok, we can use persistence. First try to load from the persistence service. var persistentStorageService = (IPersistentStorageService2)solution.Workspace.Services.GetService <IPersistentStorageService>(); T result; using (var storage = persistentStorageService.GetStorage(solution, checkBranchId: false)) { // Get the unique key to identify our data. var key = PrefixMetadataSymbolTreeInfo + keySuffix; using (var stream = await storage.ReadStreamAsync(key, cancellationToken).ConfigureAwait(false)) using (var reader = ObjectReader.TryGetReader(stream)) { if (reader != null) { // We have some previously persisted data. Attempt to read it back. // If we're able to, and the version of the persisted data matches // our version, then we can reuse this instance. result = tryReadObject(reader); if (result?.Checksum == checksum) { return(result); } } } cancellationToken.ThrowIfCancellationRequested(); // Couldn't read from the persistence service. If we've been asked to only load // data and not create new instances in their absence, then there's nothing left // to do at this point. if (loadOnly) { return(null); } // Now, try to create a new instance and write it to the persistence service. result = await CreateWithLoggingAsync().ConfigureAwait(false); Contract.ThrowIfNull(result); using (var stream = SerializableBytes.CreateWritableStream()) using (var writer = new ObjectWriter(stream, cancellationToken: cancellationToken)) { result.WriteTo(writer); stream.Position = 0; await storage.WriteStreamAsync(key, stream, cancellationToken).ConfigureAwait(false); } } return(result); } async Task <T> CreateWithLoggingAsync() { using (Logger.LogBlock(FunctionId.SymbolTreeInfo_Create, cancellationToken)) { return(await createAsync().ConfigureAwait(false)); } }; }
public AudioClip(ObjectReader reader) : base(reader) { Read(); }
public ME3Field(ObjectReader data, ExportTableEntry exp, PCCFile pcc) : base(data, exp, pcc) { }
public ME3NameProperty(ObjectReader data, ExportTableEntry exp, PCCFile pcc) : base(data, exp, pcc) { }
/// <summary>Create a new parser for a tree appearing in a subset of a repository.</summary> /// <remarks>Create a new parser for a tree appearing in a subset of a repository.</remarks> /// <param name="prefix"> /// position of this iterator in the repository tree. The value /// may be null or the empty array to indicate the prefix is the /// root of the repository. A trailing slash ('/') is /// automatically appended if the prefix does not end in '/'. /// </param> /// <param name="reader">reader to load the tree data from.</param> /// <param name="treeId"> /// identity of the tree being parsed; used only in exception /// messages if data corruption is found. /// </param> /// <exception cref="NGit.Errors.MissingObjectException">the object supplied is not available from the repository. /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException"> /// the object supplied as an argument is not actually a tree and /// cannot be parsed as though it were a tree. /// </exception> /// <exception cref="System.IO.IOException">a loose object or pack file could not be read. /// </exception> public CanonicalTreeParser(byte[] prefix, ObjectReader reader, AnyObjectId treeId ) : base(prefix) { Reset(reader, treeId); }
public void TestRoundTripPrimitivesAsValues() { var stream = new MemoryStream(); var writer = new ObjectWriter(stream); writer.WriteValue(true); writer.WriteValue(false); writer.WriteValue(Byte.MaxValue); writer.WriteValue(SByte.MaxValue); writer.WriteValue(Int16.MaxValue); writer.WriteValue(Int32.MaxValue); writer.WriteValue((Int32)Byte.MaxValue); writer.WriteValue((Int32)Int16.MaxValue); writer.WriteValue(Int64.MaxValue); writer.WriteValue(UInt16.MaxValue); writer.WriteValue(UInt32.MaxValue); writer.WriteValue(UInt64.MaxValue); writer.WriteValue(Decimal.MaxValue); writer.WriteValue(Double.MaxValue); writer.WriteValue(Single.MaxValue); writer.WriteValue('X'); writer.WriteValue("YYY"); writer.WriteValue(null); writer.WriteValue(ConsoleColor.Cyan); writer.WriteValue(EByte.Value); writer.WriteValue(ESByte.Value); writer.WriteValue(EShort.Value); writer.WriteValue(EUShort.Value); writer.WriteValue(EInt.Value); writer.WriteValue(EUInt.Value); writer.WriteValue(ELong.Value); writer.WriteValue(EULong.Value); writer.WriteValue(typeof(object)); var date = DateTime.Now; writer.WriteValue(date); writer.Dispose(); stream.Position = 0; var reader = new ObjectReader(stream, binder: writer.Binder); Assert.Equal(true, (bool)reader.ReadValue()); Assert.Equal(false, (bool)reader.ReadValue()); Assert.Equal(Byte.MaxValue, (Byte)reader.ReadValue()); Assert.Equal(SByte.MaxValue, (SByte)reader.ReadValue()); Assert.Equal(Int16.MaxValue, (Int16)reader.ReadValue()); Assert.Equal(Int32.MaxValue, (Int32)reader.ReadValue()); Assert.Equal(Byte.MaxValue, (Int32)reader.ReadValue()); Assert.Equal(Int16.MaxValue, (Int32)reader.ReadValue()); Assert.Equal(Int64.MaxValue, (Int64)reader.ReadValue()); Assert.Equal(UInt16.MaxValue, (UInt16)reader.ReadValue()); Assert.Equal(UInt32.MaxValue, (UInt32)reader.ReadValue()); Assert.Equal(UInt64.MaxValue, (UInt64)reader.ReadValue()); Assert.Equal(Decimal.MaxValue, (Decimal)reader.ReadValue()); Assert.Equal(Double.MaxValue, (Double)reader.ReadValue()); Assert.Equal(Single.MaxValue, (Single)reader.ReadValue()); Assert.Equal('X', (Char)reader.ReadValue()); Assert.Equal("YYY", (String)reader.ReadValue()); Assert.Equal(null, reader.ReadValue()); Assert.Equal(ConsoleColor.Cyan, reader.ReadValue()); Assert.Equal(EByte.Value, reader.ReadValue()); Assert.Equal(ESByte.Value, reader.ReadValue()); Assert.Equal(EShort.Value, reader.ReadValue()); Assert.Equal(EUShort.Value, reader.ReadValue()); Assert.Equal(EInt.Value, reader.ReadValue()); Assert.Equal(EUInt.Value, reader.ReadValue()); Assert.Equal(ELong.Value, reader.ReadValue()); Assert.Equal(EULong.Value, reader.ReadValue()); Assert.Equal(typeof(object), (Type)reader.ReadValue()); Assert.Equal(date, (DateTime)reader.ReadValue()); reader.Dispose(); }
public static async Task ResetAndPopulateSqlStorage() { var commitments = CreateCommitmentsFromEarnings(); using (var cnn = new SqlConnection(Configuration.SqlServerConnectionString)) { cnn.Execute(@"truncate table Commitment"); using (var bulkCopy = new SqlBulkCopy(cnn)) using (var reader = ObjectReader.Create(commitments, "Id", "ProgrammeType", "StandardCode", "FrameworkCode", "PathwayCode", "Ukprn", "LearnerReferenceNumber", "TransferSenderAccountId", "EmployerAccountId", "PaymentStatus", "NegotiatedPrice", "StartDate", "EndDate", "EffectiveFrom", "EffectiveTo", "Uln")) { bulkCopy.BatchSize = 4000; bulkCopy.DestinationTableName = "Commitment"; //var table = new DataTable(); //table.Columns.Add("Id", typeof(long)); //table.Columns.Add("ProgrammeType", typeof(int)); //table.Columns.Add("StandardCode", typeof(long)); //table.Columns.Add("FrameworkCode", typeof(int)); //table.Columns.Add("PathwayCode", typeof(int)); //table.Columns.Add("Ukprn", typeof(long)); //table.Columns.Add("LearnerReferenceNumber", typeof(string)); //table.Columns.Add("TransferSenderAccountId", typeof(long)); //table.Columns.Add("EmployerAccountId", typeof(long)); //table.Columns.Add("PaymentStatus", typeof(int)); //table.Columns.Add("NegotiatedPrice", typeof(long)); //table.Columns.Add("StartDate", typeof(DateTime)); //table.Columns.Add("EndDate", typeof(DateTime)); //table.Columns.Add("EffectiveFrom", typeof(DateTime)); //table.Columns.Add("EffectiveTo", typeof(DateTime)); //table.Columns.Add("Uln", typeof(long)); bulkCopy.ColumnMappings.Add("Id", "Id"); bulkCopy.ColumnMappings.Add("ProgrammeType", "ProgrammeType"); bulkCopy.ColumnMappings.Add("StandardCode", "StandardCode"); bulkCopy.ColumnMappings.Add("FrameworkCode", "FrameworkCode"); bulkCopy.ColumnMappings.Add("PathwayCode", "PathwayCode"); bulkCopy.ColumnMappings.Add("Ukprn", "Ukprn"); bulkCopy.ColumnMappings.Add("LearnerReferenceNumber", "LearnerReferenceNumber"); bulkCopy.ColumnMappings.Add("TransferSenderAccountId", "TransferSenderAccountId"); bulkCopy.ColumnMappings.Add("EmployerAccountId", "EmployerAccountId"); bulkCopy.ColumnMappings.Add("PaymentStatus", "PaymentStatus"); bulkCopy.ColumnMappings.Add("NegotiatedPrice", "NegotiatedPrice"); bulkCopy.ColumnMappings.Add("StartDate", "StartDate"); bulkCopy.ColumnMappings.Add("EndDate", "EndDate"); bulkCopy.ColumnMappings.Add("EffectiveFrom", "EffectiveFrom"); bulkCopy.ColumnMappings.Add("EffectiveTo", "EffectiveTo"); bulkCopy.ColumnMappings.Add("Uln", "Uln"); //foreach (var c in commitments) //{ // table.Rows.Add(c); //} cnn.Open(); await bulkCopy.WriteToServerAsync(reader); } //await cnn.ExecuteAsync(@"INSERT INTO [dbo].[Commitment] // ([Id] // ,[ProgrammeType] // ,[StandardCode] // ,[FrameworkCode] // ,[PathwayCode] // ,[Ukprn] // ,[LearnerReferenceNumber] // ,[TransferSenderAccountId] // ,[EmployerAccountId] // ,[PaymentStatus] // ,[NegotiatedPrice] // ,[StartDate] // ,[EndDate] // ,[EffectiveFrom] // ,[EffectiveTo] // ,[Uln]) // VALUES // (@Id // ,@ProgrammeType // ,@StandardCode // ,@FrameworkCode // ,@PathwayCode // ,@Ukprn // ,@LearnerReferenceNumber // ,@TransferSenderAccountId // ,@EmployerAccountId // ,@PaymentStatus // ,@NegotiatedPrice // ,@StartDate // ,@EndDate // ,@EffectiveFrom // ,@EffectiveTo // ,@Uln)", commitments); } }
private static MetadataReferenceProperties ReadMetadataReferencePropertiesFrom(ObjectReader reader, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var kind = (MetadataImageKind)reader.ReadInt32(); var aliases = reader.ReadArray <string>().ToImmutableArrayOrEmpty(); var embedInteropTypes = reader.ReadBoolean(); return(new MetadataReferenceProperties(kind, aliases, embedInteropTypes)); }
private PrimitiveMemberTest(ObjectReader reader) { TestReadingPrimitiveAPIs(reader); }
public CoverReferencePropertyValue(ObjectReader data, PCCFile pcc) : base(data, pcc) { Size = 28; }
public virtual void TestFindObjects() { DirCache tree0 = DirCache.NewInCore(); DirCacheBuilder b0 = tree0.Builder(); ObjectReader or = db.NewObjectReader(); ObjectInserter oi = db.NewObjectInserter(); DirCacheEntry aDotB = MakeEntry("a.b", EXECUTABLE_FILE); b0.Add(aDotB); DirCacheEntry aSlashB = MakeEntry("a/b", REGULAR_FILE); b0.Add(aSlashB); DirCacheEntry aSlashCSlashD = MakeEntry("a/c/d", REGULAR_FILE); b0.Add(aSlashCSlashD); DirCacheEntry aZeroB = MakeEntry("a0b", SYMLINK); b0.Add(aZeroB); b0.Finish(); NUnit.Framework.Assert.AreEqual(4, tree0.GetEntryCount()); ObjectId tree = tree0.WriteTree(oi); // Find the directories that were implicitly created above. TreeWalk tw = new TreeWalk(or); tw.AddTree(tree); ObjectId a = null; ObjectId aSlashC = null; while (tw.Next()) { if (tw.PathString.Equals("a")) { a = tw.GetObjectId(0); tw.EnterSubtree(); while (tw.Next()) { if (tw.PathString.Equals("a/c")) { aSlashC = tw.GetObjectId(0); break; } } break; } } NUnit.Framework.Assert.AreEqual(a, TreeWalk.ForPath(or, "a", tree).GetObjectId(0) ); NUnit.Framework.Assert.AreEqual(a, TreeWalk.ForPath(or, "a/", tree).GetObjectId(0 )); NUnit.Framework.Assert.AreEqual(null, TreeWalk.ForPath(or, "/a", tree)); NUnit.Framework.Assert.AreEqual(null, TreeWalk.ForPath(or, "/a/", tree)); NUnit.Framework.Assert.AreEqual(aDotB.GetObjectId(), TreeWalk.ForPath(or, "a.b", tree).GetObjectId(0)); NUnit.Framework.Assert.AreEqual(null, TreeWalk.ForPath(or, "/a.b", tree)); NUnit.Framework.Assert.AreEqual(null, TreeWalk.ForPath(or, "/a.b/", tree)); NUnit.Framework.Assert.AreEqual(aDotB.GetObjectId(), TreeWalk.ForPath(or, "a.b/", tree).GetObjectId(0)); NUnit.Framework.Assert.AreEqual(aZeroB.GetObjectId(), TreeWalk.ForPath(or, "a0b", tree).GetObjectId(0)); NUnit.Framework.Assert.AreEqual(aSlashB.GetObjectId(), TreeWalk.ForPath(or, "a/b" , tree).GetObjectId(0)); NUnit.Framework.Assert.AreEqual(aSlashB.GetObjectId(), TreeWalk.ForPath(or, "b", a).GetObjectId(0)); NUnit.Framework.Assert.AreEqual(aSlashC, TreeWalk.ForPath(or, "a/c", tree).GetObjectId (0)); NUnit.Framework.Assert.AreEqual(aSlashC, TreeWalk.ForPath(or, "c", a).GetObjectId (0)); NUnit.Framework.Assert.AreEqual(aSlashCSlashD.GetObjectId(), TreeWalk.ForPath(or, "a/c/d", tree).GetObjectId(0)); NUnit.Framework.Assert.AreEqual(aSlashCSlashD.GetObjectId(), TreeWalk.ForPath(or, "c/d", a).GetObjectId(0)); or.Release(); oi.Release(); }
private void btnSave_Click(object sender, EventArgs e) { try { // Initial Transaction var transaction = Transaction; // Add Transaction to Context _appContext.Transactions.Add(transaction); for (var row = 0; row < dataGridView1.RowCount - 1; row++) { // Transaction Item var transactionItem = TransactionItem(row); _appContext.TransactionItems.Add(transactionItem); /* Save into Productwarehouse */ var wareId = int.Parse(txtWarehouseId.Text); var proId = int.Parse(dataGridView1.Rows[row].Cells[0].Value.ToString()); var producWarehouse = _appContext.ProducWarehouses.Find(proId, wareId); // Check Product Onhand Each ProductWarehouse var onhand = int.Parse(dataGridView1.Rows[row].Cells[4].Value.ToString()); // Check Product have or not in ProductWarehouse if null Adding if not null will Modified if (producWarehouse != null) { onhand = onhand + int.Parse(dataGridView1.Rows[row].Cells[5].Value.ToString()); producWarehouse.WarehouseId = int.Parse(txtWarehouseId.Text); producWarehouse.ProductId = int.Parse(dataGridView1.Rows[row].Cells[0].Value.ToString()); producWarehouse.OnHand = onhand; producWarehouse.AlertQty = int.Parse(dataGridView1.Rows[row].Cells[6].Value.ToString()); producWarehouse.SupplierId = int.Parse(txtSupplierId.Text); producWarehouse.Note = dataGridView1.Rows[row].Cells[10].Value.ToString(); producWarehouse.SaleOrderQty = 0; _appContext.Entry(producWarehouse).State = EntityState.Modified; } else { _producWarehouse = new ProducWarehouse { WarehouseId = int.Parse(txtWarehouseId.Text), ProductId = int.Parse(dataGridView1.Rows[row].Cells[0].Value.ToString()), OnHand = int.Parse(dataGridView1.Rows[row].Cells[5].Value.ToString()), AlertQty = int.Parse(dataGridView1.Rows[row].Cells[6].Value.ToString()), SupplierId = int.Parse(txtSupplierId.Text), Note = dataGridView1.Rows[row].Cells[10].Value.ToString(), SaleOrderQty = 0 }; _appContext.ProducWarehouses.Add(_producWarehouse); } } // end foreach if (_appContext == null) { MyMessage.Warning("No Data"); } _appContext.SaveChanges(); var dialog = MessageBox.Show(@"Do you want to print report?", @"MessageBox", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialog != DialogResult.Yes) { if (dialog == DialogResult.No) { MyMessage.Success("Information saved successfully."); } } else { var t = _appContext.Transactions .Where(i => i.TransactionId.Equals(txtReceiveId.Text)) .Include(user => user.User) .Include(supplier => supplier.Supplier) .Select(tran => new { tran.TransactionId, tran.UserId, UserName = tran.User.UserNmae, tran.TotalAmount, tran.SupplierId, SupplierName = tran.Supplier.Name, SupplierPhone = tran.Supplier.Phone }) .ToList(); var ti = _appContext.TransactionItems .Where(i => i.TransactionId.Equals(txtReceiveId.Text)) .Include(pro => pro.Product) .Include(cat => cat.Product.Category) .Include(measure => measure.Product.Measure) .Select(item => new { item.ProductId, item.WarehouseId, item.Qty, item.Cost, Category = item.Product.Category.Name, Measure = item.Product.Measure.Name, ProductName = item.Product.NameEn, item.Product.NameKh }) .ToList(); var dt1 = new DataTable(); using (var reader = ObjectReader.Create(t)) { dt1.Load(reader); } dt1.TableName = "transaction"; var dt2 = new DataTable(); using (var reader = ObjectReader.Create(ti)) { dt2.Load(reader); } dt2.TableName = "TransactionItem"; var ds = new dsReceiveItem(); ds.Merge(dt1); ds.Merge(dt2); var rpt = new crptReceiveItem(); rpt.SetDataSource(ds); var frm = new frmReceiveReport(rpt); frm.Show(); } dataGridView1.Rows.Clear(); } catch (Exception exception) { MyMessage.Error(exception.ToString()); } }
internal SyntaxIdentifierExtended(ObjectReader reader) : base(reader) { this.contextualKind = (SyntaxKind)reader.ReadInt16(); this.valueText = reader.ReadString(); }
private TaskResult SaveData(string content, string type) { var response = JsonConvert.DeserializeObject <Response>(content, new JsonSerializerSettings { ContractResolver = new CustomDataContractResolver(type) }); var toAdd = response.Records.Where(r => r.StatNum == 0).ToList(); var toRemove = response.Records.Where(r => r.StatNum == 1).Select(r => r.RowNum).ToList(); DeleteList(toRemove); WriteToLog($"Inserting {toAdd.Count} rows"); using (var bcp = new SqlBulkCopy(_connectionString)) { bcp.BulkCopyTimeout = 0; using (var reader = ObjectReader.Create(toAdd)) { bcp.DestinationTableName = "ClipperStaging"; bcp.ColumnMappings.Add("DateNum", "DateNum"); bcp.ColumnMappings.Add("RowNum", "RowNum"); bcp.ColumnMappings.Add("StatNum", "StatNum"); bcp.ColumnMappings.Add("Type", "Type"); bcp.ColumnMappings.Add("LoadArea", "LoadArea"); bcp.ColumnMappings.Add("OffTakeArea", "OffTakeArea"); bcp.ColumnMappings.Add("OffTakePoint", "OffTakePoint"); bcp.ColumnMappings.Add("Api", "Api"); bcp.ColumnMappings.Add("Bbls", "Bbls"); bcp.ColumnMappings.Add("BblsNominal", "BblsNominal"); bcp.ColumnMappings.Add("Bill", "Bill"); bcp.ColumnMappings.Add("BillDate", "BillDate"); bcp.ColumnMappings.Add("BillDescription", "BillDescription"); bcp.ColumnMappings.Add("Cas", "Cas"); bcp.ColumnMappings.Add("charter_grade", "charter_grade"); bcp.ColumnMappings.Add("charter_load_area", "charter_load_area"); bcp.ColumnMappings.Add("charter_offtake_area", "charter_offtake_area"); bcp.ColumnMappings.Add("charterer", "charterer"); bcp.ColumnMappings.Add("CdReport", "CdReport"); bcp.ColumnMappings.Add("Consignee", "Consignee"); bcp.ColumnMappings.Add("declaredDest", "declaredDest"); bcp.ColumnMappings.Add("draught", "draught"); bcp.ColumnMappings.Add("fix_date", "fix_date"); bcp.ColumnMappings.Add("Grade", "Grade"); bcp.ColumnMappings.Add("GradeApi", "GradeApi"); bcp.ColumnMappings.Add("GradeCountry", "GradeCountry"); bcp.ColumnMappings.Add("GradeRegion", "GradeRegion"); bcp.ColumnMappings.Add("GradeSubtype", "GradeSubtype"); bcp.ColumnMappings.Add("GradeType", "GradeType"); bcp.ColumnMappings.Add("GradeSulfur", "GradeSulfur"); bcp.ColumnMappings.Add("Imo", "Imo"); bcp.ColumnMappings.Add("Lat", "Lat"); bcp.ColumnMappings.Add("Laycan", "Laycan"); bcp.ColumnMappings.Add("Lightering_vessel", "Lightering_vessel"); bcp.ColumnMappings.Add("LoadAreaDescr", "LoadAreaDescr"); bcp.ColumnMappings.Add("LoadCountry", "LoadCountry"); bcp.ColumnMappings.Add("LoadDate", "LoadDate"); bcp.ColumnMappings.Add("LoadOwner", "LoadOwner"); bcp.ColumnMappings.Add("LoadPoint", "LoadPoint"); bcp.ColumnMappings.Add("LoadPort", "LoadPort"); bcp.ColumnMappings.Add("LoadRegion", "LoadRegion"); bcp.ColumnMappings.Add("LoadStsVessel", "LoadStsVessel"); bcp.ColumnMappings.Add("Load_sts_imo", "Load_sts_imo"); bcp.ColumnMappings.Add("Lon", "Lon"); bcp.ColumnMappings.Add("LoadTradingWeek", "LoadTradingWeek"); bcp.ColumnMappings.Add("LoadTradingYear", "LoadTradingYear"); bcp.ColumnMappings.Add("LzTanker", "LzTanker"); bcp.ColumnMappings.Add("mt", "mt"); bcp.ColumnMappings.Add("mtNominal", "mtNominal"); bcp.ColumnMappings.Add("Notification", "Notification"); bcp.ColumnMappings.Add("OffTakeAreaDescription", "OffTakeAreaDescription"); bcp.ColumnMappings.Add("OffTakeCountry", "OffTakeCountry"); bcp.ColumnMappings.Add("OffTakeDate", "OffTakeDate"); bcp.ColumnMappings.Add("OffTakeOwner", "OffTakeOwner"); bcp.ColumnMappings.Add("OffTakePort", "OffTakePort"); bcp.ColumnMappings.Add("OffTakeRegion", "OffTakeRegion"); bcp.ColumnMappings.Add("OffTakeState", "OffTakeState"); bcp.ColumnMappings.Add("OffTakeStsVessel", "OffTakeStsVessel"); bcp.ColumnMappings.Add("OffTake_sts_imo", "OffTake_sts_imo"); bcp.ColumnMappings.Add("OfftakeTradingWeek", "OfftakeTradingWeek"); bcp.ColumnMappings.Add("OfftakeTradingYear", "OfftakeTradingYear"); bcp.ColumnMappings.Add("OpecNopec", "OpecNopec"); bcp.ColumnMappings.Add("Probability", "Probability"); bcp.ColumnMappings.Add("ProbabilityGroup", "ProbabilityGroup"); bcp.ColumnMappings.Add("Processed", "Processed"); bcp.ColumnMappings.Add("Projection", "Projection"); bcp.ColumnMappings.Add("Route", "Route"); bcp.ColumnMappings.Add("Shipper", "Shipper"); bcp.ColumnMappings.Add("ShipToShipped", "ShipToShipped"); bcp.ColumnMappings.Add("Source", "Source"); bcp.ColumnMappings.Add("Speed", "Speed"); bcp.ColumnMappings.Add("Sulfur", "Sulfur"); bcp.ColumnMappings.Add("Vessel", "Vessel"); bcp.ColumnMappings.Add("VesselClass", "VesselClass"); bcp.ColumnMappings.Add("VesselClassDescription", "VesselClassDescription"); bcp.ColumnMappings.Add("VesselFlag", "VesselFlag"); bcp.ColumnMappings.Add("VesselType", "VesselType"); bcp.ColumnMappings.Add("WeightMt", "WeightMt"); bcp.WriteToServer(reader); } return(new TaskResult(toAdd.Count, toRemove.Count, response.Records.Count > 0 ? response.Records.OrderByDescending(o => o.DateNum).First().DateNum : 0)); } }
private SyntaxAnnotation(ObjectReader reader) { _id = reader.ReadInt64(); this.Kind = reader.ReadString(); this.Data = reader.ReadString(); }
/// <summary>Reset this parser to walk through the given tree.</summary> /// <remarks>Reset this parser to walk through the given tree.</remarks> /// <param name="reader">reader to use during repository access.</param> /// <param name="id"> /// identity of the tree being parsed; used only in exception /// messages if data corruption is found. /// </param> /// <exception cref="NGit.Errors.MissingObjectException">the object supplied is not available from the repository. /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException"> /// the object supplied as an argument is not actually a tree and /// cannot be parsed as though it were a tree. /// </exception> /// <exception cref="System.IO.IOException">a loose object or pack file could not be read. /// </exception> public virtual void Reset(ObjectReader reader, AnyObjectId id) { Reset(reader.Open(id, Constants.OBJ_TREE).GetCachedBytes()); }
private PrimitiveValueTest(ObjectReader reader) { TestReadingPrimitiveValues(reader); }