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


C# SerializationWriter.WriteOptimized方法代码示例

本文整理汇总了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);	
			}
		}
开发者ID:elementar,项目名称:Suprifattus.Util,代码行数:31,代码来源:DrawingFastSerializationHelper.cs

示例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);
        }
开发者ID:bbqchickenrobot,项目名称:FastSerializer,代码行数:12,代码来源:WebFastSerializationHelper.cs

示例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();
        }
开发者ID:knocte,项目名称:fallen-8,代码行数:23,代码来源:RangeIndex.cs

示例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();
            }
开发者ID:randomyed,项目名称:SobekCM-Web-Application,代码行数:18,代码来源:AdoNetHelper.cs

示例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();
            }
开发者ID:randomyed,项目名称:SobekCM-Web-Application,代码行数:12,代码来源:AdoNetHelper.cs

示例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();
            }
开发者ID:randomyed,项目名称:SobekCM-Web-Application,代码行数:19,代码来源:AdoNetHelper.cs

示例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);
        }
开发者ID:johnmensen,项目名称:TradeSharp,代码行数:61,代码来源:MarketOrderSerializer.cs


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