本文整理汇总了C#中SerializationWriter.WriteOptimized方法的典型用法代码示例。如果您正苦于以下问题:C# SerializationWriter.WriteOptimized方法的具体用法?C# SerializationWriter.WriteOptimized怎么用?C# SerializationWriter.WriteOptimized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializationWriter
的用法示例。
在下文中一共展示了SerializationWriter.WriteOptimized方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
public static void Serialize(SerializationWriter writer, Color color)
{
BitVector32 flags = new BitVector32();
if (color.IsKnownColor)
flags[ColorIsKnown] = true;
else if (color.IsNamedColor)
flags[ColorHasName] = true;
else if (!color.IsEmpty)
{
flags[ColorHasValue] = true;
flags[ColorHasRed] = color.R != 0;
flags[ColorHasGreen] = color.G != 0;
flags[ColorHasBlue] = color.B != 0;
flags[ColorHasAlpha] = color.A != 0;
}
writer.WriteOptimized(flags);
if (color.IsKnownColor)
writer.WriteOptimized((int) color.ToKnownColor());
else if (color.IsNamedColor)
writer.WriteOptimized(color.Name);
else if (!color.IsEmpty)
{
byte component;
if ( (component = color.R) != 0) writer.Write(component);
if ( (component = color.G) != 0) writer.Write(component);
if ( (component = color.B) != 0) writer.Write(component);
if ( (component = color.A) != 0) writer.Write(component);
}
}
示例2: Serialize
// Note this is a simplistic version as it assumes defaults for comparer, hashcodeprovider, loadfactor etc.
public static void Serialize(SerializationWriter writer, Hashtable hashtable)
{
var keys = new object[hashtable.Count];
var values = new object[hashtable.Count];
hashtable.Keys.CopyTo(keys, 0);
hashtable.Values.CopyTo(values, 0);
writer.WriteOptimized(keys);
writer.WriteOptimized(values);
}
示例3: Save
public void Save(SerializationWriter writer)
{
if (ReadResource())
{
writer.WriteOptimized(0);//parameter
writer.WriteOptimized(_idx.Count);
foreach (var aKV in _idx)
{
writer.WriteObject(aKV.Key);
writer.WriteOptimized(aKV.Value.Count);
foreach (var aItem in aKV.Value)
{
writer.Write(aItem.Id);
}
}
FinishReadResource();
return;
}
throw new CollisionException();
}
示例4: SerializeSimpleDataOnly
public byte[] SerializeSimpleDataOnly(DataTable dataTable)
{
writer = new SerializationWriter();
int rowCount = dataTable.Rows.Count;
writer.WriteOptimized(rowCount);
if (rowCount != 0)
{
int[] calculatedColumnOrdinals = getCalculatedColumnOrdinals(dataTable);
foreach(DataRow row in dataTable.Rows)
{
writer.WriteOptimized(getNonCalculatedValuesFromRowVersion(row, DataRowVersion.Current, calculatedColumnOrdinals));
}
}
return getSerializedBytes();
}
示例5: SerializeDataOnly
public byte[] SerializeDataOnly(DataSet dataSet)
{
writer = new SerializationWriter();
writer.WriteOptimized(dataSet.Tables.Count);
foreach(DataTable dataTable in dataSet.Tables)
{
serializeRows(dataTable);
}
return getSerializedBytes();
}
示例6: Serialize
public byte[] Serialize(DataSet dataSet)
{
this.dataSet = dataSet;
writer = new SerializationWriter();
BitVector32 flags = GetDataSetFlags(dataSet);
writer.WriteOptimized(flags);
if (flags[DataSetHasName]) writer.WriteOptimized(dataSet.DataSetName);
writer.WriteOptimized(dataSet.Locale.LCID);
if (flags[DataSetHasNamespace]) writer.WriteOptimized(dataSet.Namespace);
if (flags[DataSetHasPrefix]) writer.WriteOptimized(dataSet.Prefix);
if (flags[DataSetHasTables]) serializeTables();
if (flags[DataSetHasForeignKeyConstraints]) serializeForeignKeyConstraints(getForeignKeyConstraints(dataSet));
if (flags[DataSetHasRelationships]) serializeRelationships();
if (flags[DataSetHasExtendedProperties]) serializeExtendedProperties(dataSet.ExtendedProperties);
return getSerializedBytes();
}
示例7: Serialize
public static void Serialize(SerializationWriter writer, MarketOrder deal)
{
writer.Write(deal.ID);
writer.Write(deal.AccountID);
writer.Write(deal.Comment);
writer.Write((Int16)(int)deal.ExitReason);
writer.Write(deal.ExpertComment);
writer.Write(deal.PriceEnter);
writer.Write(deal.ResultDepo);
writer.Write(deal.ResultPoints);
writer.Write((sbyte)deal.Side);
writer.Write((Int16)(int)deal.State);
writer.Write(deal.Symbol);
writer.Write(deal.TimeEnter);
writer.Write(deal.Trailing);
writer.Write(deal.Volume);
writer.Write(deal.VolumeInDepoCurrency);
// nullable values
var flags = new BitVector32();
if (deal.Magic.HasValue)
flags[magicIsValued] = true;
if (deal.PendingOrderID.HasValue)
flags[pendingOrderIdIsValued] = true;
if (deal.PriceBest.HasValue)
flags[priceBestIsValued] = true;
if (deal.PriceExit.HasValue)
flags[priceExitIsValued] = true;
if (deal.PriceWorst.HasValue)
flags[priceWorstIsValued] = true;
if (deal.StopLoss.HasValue)
flags[stopLossIsValued] = true;
if (deal.Swap.HasValue)
flags[swapIsValued] = true;
if (deal.TakeProfit.HasValue)
flags[takeProfitIsValued] = true;
if (deal.TimeExit.HasValue)
flags[timeExitIsValued] = true;
writer.WriteOptimized(flags);
if (deal.Magic.HasValue)
writer.Write(deal.Magic.Value);
if (deal.PendingOrderID.HasValue)
writer.Write(deal.PendingOrderID.Value);
if (deal.PriceBest.HasValue)
writer.Write(deal.PriceBest.Value);
if (deal.PriceExit.HasValue)
writer.Write(deal.PriceExit.Value);
if (deal.PriceWorst.HasValue)
writer.Write(deal.PriceWorst.Value);
if (deal.StopLoss.HasValue)
writer.Write(deal.StopLoss.Value);
if (deal.Swap.HasValue)
writer.Write(deal.Swap.Value);
if (deal.TakeProfit.HasValue)
writer.Write(deal.TakeProfit.Value);
if (deal.TimeExit.HasValue)
writer.Write(deal.TimeExit.Value);
}