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


C# Serializer.ForSurrogate方法代码示例

本文整理汇总了C#中Serializer.ForSurrogate方法的典型用法代码示例。如果您正苦于以下问题:C# Serializer.ForSurrogate方法的具体用法?C# Serializer.ForSurrogate怎么用?C# Serializer.ForSurrogate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Serializer的用法示例。


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

示例1: ShouldDoSurrogateObjectSwapTwoTimes

        public void ShouldDoSurrogateObjectSwapTwoTimes()
        {
            var b = new SurrogateMockB();
            var serializer = new Serializer(GetSettings());
            serializer.ForObject<SurrogateMockB>().SetSurrogate(x => new SurrogateMockA(1));
            serializer.ForSurrogate<SurrogateMockA>().SetObject(x => new SurrogateMockC());

            for(var i = 0; i < 2; i++)
            {
                using(var stream = new MemoryStream())
                {
                    serializer.Serialize(b, stream);
                    stream.Seek(0, SeekOrigin.Begin);
                    var pseudocopy = serializer.Deserialize<object>(stream);
                    var c = pseudocopy as SurrogateMockC;
                    Assert.IsNotNull(c);
                }
            }
        }
开发者ID:rogeralsing,项目名称:Migrant,代码行数:19,代码来源:SurrogateTests.cs

示例2: ShouldThrowWhenSettingObjectForSurrogateAfterDeserialization

 public void ShouldThrowWhenSettingObjectForSurrogateAfterDeserialization()
 {
     var serializer = new Serializer(SettingsFromFields);
     var stream = new MemoryStream();
     serializer.Serialize(new object(), stream);
     stream.Seek(0, SeekOrigin.Begin);
     serializer.Deserialize<object>(stream);
     Assert.Throws<InvalidOperationException>(() => serializer.ForSurrogate<object>().SetObject(x => new object()));
 }
开发者ID:PiotrZierhoffer,项目名称:Migrant,代码行数:9,代码来源:SurrogateTests.cs

示例3: EmulationManager

 private EmulationManager()
 {
     var settings = new Antmicro.Migrant.Customization.Settings(Antmicro.Migrant.Customization.Method.Generated, Antmicro.Migrant.Customization.Method.Generated,
         Antmicro.Migrant.Customization.VersionToleranceLevel.AllowFieldAddition 
         | Antmicro.Migrant.Customization.VersionToleranceLevel.AllowFieldRemoval 
         | Antmicro.Migrant.Customization.VersionToleranceLevel.AllowGuidChange 
         | Antmicro.Migrant.Customization.VersionToleranceLevel.AllowAssemblyVersionChange);
     serializer = new Serializer(settings);
     serializer.ForObject<PythonDictionary>().SetSurrogate(x => new PythonDictionarySurrogate(x));
     serializer.ForSurrogate<PythonDictionarySurrogate>().SetObject(x => x.Restore());
     currentEmulation = new Emulation();
     ProgressMonitor = new ProgressMonitor();
     stopwatch = new Stopwatch();
 }
开发者ID:rte-se,项目名称:emul8,代码行数:14,代码来源:EmulationManager.cs


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