當前位置: 首頁>>代碼示例>>C#>>正文


C# YAXLib.YAXSerializer類代碼示例

本文整理匯總了C#中YAXLib.YAXSerializer的典型用法代碼示例。如果您正苦於以下問題:C# YAXSerializer類的具體用法?C# YAXSerializer怎麽用?C# YAXSerializer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


YAXSerializer類屬於YAXLib命名空間,在下文中一共展示了YAXSerializer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetAdaptor

        public object GetAdaptor(string adaptorName, Type adaptorType, Stream sutFile = null)
        {
            if (adaptors.ContainsKey(adaptorName))
            {
                return adaptors[adaptorName];
            }
            var serializer = new YAXSerializer(adaptorType, YAXExceptionHandlingPolicies.ThrowErrorsOnly, YAXExceptionTypes.Error, YAXSerializationOptions.DontSerializeNullObjects);
            AdaptorImpl adaptor = null;
            try
            {
                string sutXml = null;
                if (sutFile != null)
                {
                    var stramReader = new StreamReader(sutFile);
                    sutXml = stramReader.ReadToEnd();
                }
                else
                {
                    sutXml = File.ReadAllText(SutManager.CurrentSut());
                }

                adaptor = (AdaptorImpl)serializer.Deserialize(sutXml);
            }
            catch (YAXBadlyFormedXML e)
            {
                report.Report("Failed to read sut file", e);
                return null;
            }
            adaptors.Add(adaptorName, adaptor);

            adaptor.Init();

            return adaptor;
        }
開發者ID:Top-Q,項目名稱:TFS-automation-testing-framework,代碼行數:34,代碼來源:AdaptorsManager.cs

示例2: CanUseTheDefaultNamespace

        public void CanUseTheDefaultNamespace()
        {
            var ser = new YAXSerializer(typeof(YAXLibMetadataOverriding));

            ser.YaxLibNamespacePrefix = "";
            ser.YaxLibNamespaceUri = "http://namespace.org/sample";
            ser.DimentionsAttributeName = "dm";
            ser.RealTypeAttributeName = "type";

            var sampleInstance = YAXLibMetadataOverriding.GetSampleInstance();
            string result = ser.Serialize(sampleInstance);

            string expected =
            @"<YAXLibMetadataOverriding xmlns=""http://namespace.org/sample"">
              <IntArray dm=""2,3"">
            <Int32>1</Int32>
            <Int32>2</Int32>
            <Int32>3</Int32>
            <Int32>2</Int32>
            <Int32>3</Int32>
            <Int32>4</Int32>
              </IntArray>
              <Obj type=""System.String"">Hello, World!</Obj>
            </YAXLibMetadataOverriding>";
            Assert.That(result, Is.EqualTo(expected));

            var desObj = (YAXLibMetadataOverriding)ser.Deserialize(expected);

            Assert.That(desObj.Obj.ToString(), Is.EqualTo(sampleInstance.Obj.ToString()));
            Assert.That(desObj.IntArray.Length, Is.EqualTo(sampleInstance.IntArray.Length));
        }
開發者ID:silwol,項目名稱:YAXLib,代碼行數:31,代碼來源:OverridingYAXLibMetadataTests.cs

示例3: LoadPlanDesign

        public static PlanDesign LoadPlanDesign(string filePath, out string xmlCurr)
        {
            xmlCurr = null;

            YAXSerializer serializer = new YAXSerializer(typeof(PlanDesign));
            if (string.IsNullOrEmpty(filePath))
                return null;

            try { xmlCurr = File.ReadAllText(filePath); }
            catch (IOException e)
            {
                MyLog.WARNING.WriteLine("Unable to read file " + filePath + " during curriculum loading. " + e.Message);
                return null;
            }

            try
            {
                PlanDesign plan = (PlanDesign)serializer.Deserialize(xmlCurr);
                return plan;
            }
            catch (YAXException e)
            {
                MyLog.WARNING.WriteLine("Unable to deserialize data from " + filePath + " during curriculum loading. " + e.Message);
                return null;
            }
        }
開發者ID:GoodAI,項目名稱:BrainSimulator,代碼行數:26,代碼來源:CurriculumManager.cs

示例4: AnotherArraySampleTest

 public void AnotherArraySampleTest()
 {
     const string result =
     @"<!-- This example shows usage of jagged multi-dimensional arrays -->
     <AnotherArraySample xmlns:yaxlib=""http://www.sinairv.com/yaxlib/"">
       <Array1>
     <Array2OfInt32 yaxlib:dims=""2,3"">
       <Int32>1</Int32>
       <Int32>1</Int32>
       <Int32>1</Int32>
       <Int32>1</Int32>
       <Int32>2</Int32>
       <Int32>3</Int32>
     </Array2OfInt32>
     <Array2OfInt32 yaxlib:dims=""3,2"">
       <Int32>3</Int32>
       <Int32>3</Int32>
       <Int32>3</Int32>
       <Int32>4</Int32>
       <Int32>3</Int32>
       <Int32>5</Int32>
     </Array2OfInt32>
       </Array1>
     </AnotherArraySample>";
     var serializer = new YAXSerializer(typeof(AnotherArraySample), YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Warning, YAXSerializationOptions.SerializeNullObjects);
     string got = serializer.Serialize(AnotherArraySample.GetSampleInstance());
     Assert.That(got, Is.EqualTo(result));
 }
開發者ID:sschocke,項目名稱:BrainSimulator,代碼行數:28,代碼來源:SerializationTest.cs

示例5: Read

 protected Xwt.Widget Read(string Text)
 {
     YAXLib.YAXSerializer Y = new YAXSerializer(typeof(FrameRootNode), YAXExceptionHandlingPolicies.DoNotThrow);
     FrameRootNode Target = (FrameRootNode)Y.Deserialize(Text);
     this.Root = Target.Content.Makeup(this);
     return Root;
 }
開發者ID:ksigne,項目名稱:xwt-extensions,代碼行數:7,代碼來源:FrameExt.cs

示例6: CollectionNamespaceGoesThruRecursiveNoContainingElementDeserializationTest

 public void CollectionNamespaceGoesThruRecursiveNoContainingElementDeserializationTest()
 {
     var serializer = new YAXSerializer(typeof(CellPhone_CollectionNamespaceGoesThruRecursiveNoContainingElement), YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Warning, YAXSerializationOptions.SerializeNullObjects);
     string got = serializer.Serialize(CellPhone_CollectionNamespaceGoesThruRecursiveNoContainingElement.GetSampleInstance());
     var deserialized = serializer.Deserialize(got) as CellPhone_CollectionNamespaceGoesThruRecursiveNoContainingElement;
     Assert.That(deserialized, Is.Not.Null);
     Assert.That(serializer.ParsingErrors, Has.Count.EqualTo(0));
 }
開發者ID:silwol,項目名稱:YAXLib,代碼行數:8,代碼來源:NamespaceTest.cs

示例7: MediaInfoProcess

 public MediaInfoProcess(string pathToVideoFile)
 {
     _pathToVideoFile = pathToVideoFile;
     _isDisposed = false;
     _alreadyExecuted = false;
     _process = new Process();
     _serializer = new YAXSerializer(typeof(MediaInfo), YAXExceptionHandlingPolicies.DoNotThrow);
 }
開發者ID:helios2k6,項目名稱:MobileImageProcessor,代碼行數:8,代碼來源:MediaInfoProcess.cs

示例8: Serialize

 public static void Serialize(List<ObjectEffect> effects)
 {
     foreach (var effect in effects)
     {
          YAXSerializer serializer = new YAXSerializer(effect.GetType());
          string contents = serializer.Serialize(effect);
     }
 }
開發者ID:thomasvinot,項目名稱:Symbioz,代碼行數:8,代碼來源:EffectSerializer.cs

示例9: DeserializeDataFromStream

        /// <summary>
        /// Deserializes graph data from a stream
        /// </summary>
        /// <param name="stream">The stream</param>
        /// <returns>The graph data</returns>
		public static List<GraphSerializationData> DeserializeDataFromStream(Stream stream)
        {
            var deserializer = new YAXSerializer(typeof(List<GraphSerializationData>));
            using (var textReader = new StreamReader(stream))
            {
                return (List<GraphSerializationData>)deserializer.Deserialize(textReader);
            }
        }
開發者ID:aliaspilote,項目名稱:TX52,代碼行數:13,代碼來源:FileServiceProviderWPF.cs

示例10: AttributeWithDefaultNamespaceDeserializationTest

 public void AttributeWithDefaultNamespaceDeserializationTest()
 {
     var serializer = new YAXSerializer(typeof(AttributeWithNamespace), YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Warning, YAXSerializationOptions.SerializeNullObjects);
     string got = serializer.Serialize(AttributeWithNamespace.GetSampleInstance());
     var deserialized = serializer.Deserialize(got) as AttributeWithNamespace;
     Assert.That(deserialized, Is.Not.Null);
     Assert.That(serializer.ParsingErrors, Has.Count.EqualTo(0));
 }
開發者ID:miloszkukla,項目名稱:YAXLib,代碼行數:8,代碼來源:NamespaceTest.cs

示例11: SavePlanDesign

        public static void SavePlanDesign(PlanDesign design, string filePath, out string xmlResult)
        {
            YAXSerializer serializer = new YAXSerializer(typeof(PlanDesign));

            xmlResult = serializer.Serialize(design);
            File.WriteAllText(filePath, xmlResult);
            MyLog.Writer.WriteLine(MyLogLevel.INFO, "School project saved to: " + filePath);
        }
開發者ID:GoodAI,項目名稱:BrainSimulator,代碼行數:8,代碼來源:CurriculumManager.cs

示例12: Parse

        public static ProjectBuildDefinition Parse(string xml)
        {
            var yaxSer = new YAXSerializer(typeof(ProjectBuildDefinition),
                YAXExceptionHandlingPolicies.DoNotThrow,
                YAXExceptionTypes.Ignore,
                YAXSerializationOptions.DontSerializeNullObjects);

            return yaxSer.Deserialize(xml) as ProjectBuildDefinition;
        }
開發者ID:sschocke,項目名稱:BrainSimulator,代碼行數:9,代碼來源:CsprojParser.cs

示例13: SerializeDataToStream

        /// <summary>
        /// Serializes graph data list to a stream
        /// </summary>
        /// <param name="stream">The destination stream</param>
        /// <param name="modelsList">The graph data</param>
		public static void SerializeDataToStream(Stream stream, List<GraphSerializationData> modelsList)
        {
            var serializer = new YAXSerializer(typeof(List<GraphSerializationData>));
            using (var textWriter = new StreamWriter(stream))
            {
                serializer.Serialize(modelsList, textWriter);
                textWriter.Flush();
            }
        }
開發者ID:aliaspilote,項目名稱:TX52,代碼行數:14,代碼來源:FileServiceProviderWPF.cs

示例14: AttributeNamespaceSerializationTest

        public void AttributeNamespaceSerializationTest()
        {
            const string result = "<AttributeNamespaceSample xmlns:ns=\"http://namespaces.org/ns\" xmlns=\"http://namespaces.org/default\">" + @"
              <Attribs " + "attrib=\"value\" ns:attrib2=\"value2\"" + @" />
            </AttributeNamespaceSample>";

            var serializer = new YAXSerializer(typeof(AttributeNamespaceSample), YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Warning, YAXSerializationOptions.SerializeNullObjects);
            string got = serializer.Serialize(AttributeNamespaceSample.GetSampleInstance());
            Assert.That(got, Is.EqualTo(result));
        }
開發者ID:silwol,項目名稱:YAXLib,代碼行數:10,代碼來源:NamespaceTest.cs

示例15: ParseAndRegenerateXml

        public static string ParseAndRegenerateXml(string xml)
        {
            var project = Parse(xml);

            var yaxSer = new YAXSerializer(typeof(ProjectBuildDefinition),
                YAXExceptionHandlingPolicies.DoNotThrow,
                YAXExceptionTypes.Ignore,
                YAXSerializationOptions.DontSerializeNullObjects);

            return yaxSer.Serialize(project);
        }
開發者ID:sschocke,項目名稱:BrainSimulator,代碼行數:11,代碼來源:CsprojParser.cs


注:本文中的YAXLib.YAXSerializer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。