当前位置: 首页>>代码示例>>C#>>正文


C# ObjectReader类代码示例

本文整理汇总了C#中ObjectReader的典型用法代码示例。如果您正苦于以下问题:C# ObjectReader类的具体用法?C# ObjectReader怎么用?C# ObjectReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ObjectReader类属于命名空间,在下文中一共展示了ObjectReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

        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();
        }
开发者ID:ZapTechnology,项目名称:ForSerial,代码行数:29,代码来源:DefaultStructureDefinition.cs

示例2: Read

 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);
 }
开发者ID:ZapTechnology,项目名称:ForSerial,代码行数:7,代码来源:ValueTypeDefinition.cs

示例3: SetUp

		public override void SetUp()
		{
			base.SetUp();
			tr = new TestRepository<Repository>(db);
			reader = db.NewObjectReader();
			inserter = db.NewObjectInserter();
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:7,代码来源:NoteMapTest.cs

示例4: ReadInternalChild

		// 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);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:9,代码来源:OptionMenu.cs

示例5: ReadStamp

        public void ReadStamp(ObjectReader reader)
        {
            TypeModule = reader.Modules.Read();
            GenericFullName = reader.PrimitiveReader.ReadString();

            Resolve();
        }
开发者ID:StepWoodProductions,项目名称:Migrant,代码行数:7,代码来源:TypeFullDescriptor.cs

示例6: ReadStructureStampIfNeeded

 public void ReadStructureStampIfNeeded(ObjectReader reader, VersionToleranceLevel versionToleranceLevel)
 {
     if(StampHelpers.IsStampNeeded(this, reader.TreatCollectionAsUserObject))
     {
         ReadStructureStamp(reader, versionToleranceLevel);
     }
 }
开发者ID:StepWoodProductions,项目名称:Migrant,代码行数:7,代码来源:TypeFullDescriptor.cs

示例7: Read

        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();
        }
开发者ID:soxtoby,项目名称:ForSerial,代码行数:26,代码来源:JsonDictionaryDefinition.cs

示例8: Read

 public override void Read(object input, ObjectReader reader, Writer writer, PartialOptions optionsOverride)
 {
     if (ReferenceStructure(input, reader, optionsOverride))
         return;
     reader.AddReference();
     writer.Write(input);
 }
开发者ID:ZapTechnology,项目名称:ForSerial,代码行数:7,代码来源:ObjectDefinition.cs

示例9: SetUp

		public override void SetUp()
		{
			base.SetUp();
			db = CreateBareRepository();
			reader = db.NewObjectReader();
			test = new TestRepository<FileRepository>(db);
		}
开发者ID:shoff,项目名称:ngit,代码行数:7,代码来源:AbbreviationTest.cs

示例10: Read

 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);
 }
开发者ID:soxtoby,项目名称:ForSerial,代码行数:7,代码来源:EnumDefinition.cs

示例11: ReadChild

		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);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:CheckButton.cs

示例12: Read

 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());
 }
开发者ID:soxtoby,项目名称:ForSerial,代码行数:8,代码来源:GuidDefinition.cs

示例13: ReadChildren

		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);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:8,代码来源:Dialog.cs

示例14: Read

        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);
        }
开发者ID:StepWoodProductions,项目名称:Migrant,代码行数:8,代码来源:TypeSimpleDescriptor.cs

示例15: Main

        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);
            }
        }
开发者ID:rokerdan,项目名称:aplicaciones-redes,代码行数:58,代码来源:Program.cs


注:本文中的ObjectReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。