本文整理汇总了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();
}
示例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);
}
示例3: SetUp
public override void SetUp()
{
base.SetUp();
tr = new TestRepository<Repository>(db);
reader = db.NewObjectReader();
inserter = db.NewObjectInserter();
}
示例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);
}
示例5: ReadStamp
public void ReadStamp(ObjectReader reader)
{
TypeModule = reader.Modules.Read();
GenericFullName = reader.PrimitiveReader.ReadString();
Resolve();
}
示例6: ReadStructureStampIfNeeded
public void ReadStructureStampIfNeeded(ObjectReader reader, VersionToleranceLevel versionToleranceLevel)
{
if(StampHelpers.IsStampNeeded(this, reader.TreatCollectionAsUserObject))
{
ReadStructureStamp(reader, versionToleranceLevel);
}
}
示例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();
}
示例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);
}
示例9: SetUp
public override void SetUp()
{
base.SetUp();
db = CreateBareRepository();
reader = db.NewObjectReader();
test = new TestRepository<FileRepository>(db);
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
}