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


C# Serializer.Save方法代码示例

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


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

示例1: Save_GivenStream_WritesSomething

        public void Save_GivenStream_WritesSomething()
        {
            ISerializer<TestModel> fileStore = new Serializer<TestModel>();
            using (var stream = new MemoryStream())
            {
                fileStore.Save(stream, new TestModel(), KnownTypes);

                Assert.True(stream.Position> 0L, "The file written to should not be empty.");
            }
        }
开发者ID:martin2kcs34,项目名称:relax-gtd,代码行数:10,代码来源:SerializerTestFixture.cs

示例2: OnInspectorGUI

	public override void OnInspectorGUI()
	{
		if (!onSelected) // this must be Pauls name.
		{
			onSelected = true;
			OnSelected();  //?this is called just to get OnSelected called when the first gui call happens ?
		}
		DrawDefaultInspector();

		GUILayout.BeginHorizontal();
		if ( GUILayout.Button ("Load Case Order" ) )
		{
			Serializer<List<string>> serializer = new Serializer<List<string>>();
			myObject.CaseOrder = serializer.Load ("XML/CaseOrder");
		}
		if ( GUILayout.Button ("Save Case Order" ) )
		{
			Serializer<List<string>> serializer = new Serializer<List<string>>();
			serializer.Save (Application.dataPath + "/Resources/XML/CaseOrder.xml",myObject.CaseOrder);
		}
		GUILayout.EndHorizontal();

		GUILayout.BeginHorizontal();
		if ( myObject.UseLocalData == false )
		{
			if ( GUILayout.Button ("Save WEB Cases to CaseInfo.xml") )
			{
				if ( CaseConfiguratorMgr.GetInstance().CaseList == null || CaseConfiguratorMgr.GetInstance().CaseList.Count == 0 )
					UnityEngine.Debug.LogError ("NO CASES, go to case selection screen first!");
				else
					CaseConfiguratorMgr.GetInstance().SaveXML (Application.dataPath + "/Resources/XML/CaseInfo.xml");
			}
		}
		else
		{
			if ( GUILayout.Button ("Save Selected Case to WEB") )
			{
				if ( CaseConfiguratorMgr.GetInstance().CaseList == null || CaseConfiguratorMgr.GetInstance().CaseList.Count == 0 )
					UnityEngine.Debug.LogError ("NO CASES, go to case selection screen first!");
				else
					// takes the current case and saves it to the database
					CaseConfiguratorMgr.GetInstance().SaveCaseConfiguration(null);
			}
		}
		GUILayout.EndHorizontal();
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:46,代码来源:CaseConfiguratorSettingsInspector.cs

示例3: Load_GivenSerializedSolutionModel_MatchesSaved

        public void Load_GivenSerializedSolutionModel_MatchesSaved()
        {
            var savedModel = new TestModel {TestInt = 5, TestString = "hello"};
            TestModel loadedModel;

            ISerializer<TestModel> test = new Serializer<TestModel>();

            using (var stream = new MemoryStream())
            {
                test.Save(stream, savedModel, KnownTypes);
                stream.Seek(0L, SeekOrigin.Begin);
                loadedModel = test.Load(stream, KnownTypes);
            }

            Assert.NotSame(savedModel, loadedModel);
            Assert.Equal(5, loadedModel.TestInt);
            Assert.Equal("hello", loadedModel.TestString);
        }
开发者ID:martin2kcs34,项目名称:relax-gtd,代码行数:18,代码来源:SerializerTestFixture.cs

示例4: Xml_Serialization

        public void Xml_Serialization()
        {
            SerClass obj = new SerClass();
            obj.x = int.MaxValue;
            obj.y = int.MinValue;
            obj.value = "Some_String";
            Serializer<SerClass> serializer = new Serializer<SerClass>();

            // Save
            string filename = "test.xml";
            serializer.Save(filename, obj, SerializationMethod.Xml);
            Assert.IsTrue(File.Exists(filename));

            // Open
            SerClass obj2 = serializer.Open(filename, SerializationMethod.Xml);
            Assert.AreEqual(obj.x, obj2.x);
            Assert.AreEqual(obj.y, obj2.y);
            Assert.AreEqual(obj.z, obj2.z);
            Assert.AreEqual(obj.value, obj2.value);
        }
开发者ID:KonH,项目名称:Serializer,代码行数:20,代码来源:UnitTest1.cs

示例5: GPCallback

    public void GPCallback(NluMgr.match_record record)
    {
        // make to upper case
        record.sim_command = record.sim_command.ToUpper();

        string text = "NLU : sim_command=<" + record.sim_command + ">";
        // subject 
        if (record.command_subject != null && record.command_subject != "")
            text += " : s=<" + record.command_subject + ">";
        // params
        foreach (NluMgr.sim_command_param param in record.parameters)
            text += " : p=<" + param.name + "," + param.value + ">";
        // missing params
        foreach (NluMgr.missing_sim_command_param param in record.missing_parameters)
            text += " : m=<" + param.name + ">";
        // readback
        if (record.readback != null && record.readback != "")
            text += " : r=<" + record.readback + ">";
        // feedback
        if (record.feedback != null && record.feedback != "")
            text += " : f=<" + record.feedback + ">";
		
		// save this one
#if ADD_NLU_RECORDS
		currCV.NLURecords.Add(record);
#endif
		if ( record.input != currCV.CV.Variations[currVariationIdx] )
			currCV.NLUResults.Add(text + " : input=<" + record.input + "> doesn't match Variation");
		else
			currCV.NLUResults.Add(text + " : input=<" + record.input + ">");
		
		// get next result
		currCV = NextResult();
		
		// kick off next one
		if ( currCV != null )
		{
        	NluMgr.GetInstance().Utterance(currCV.CV.Variations[currVariationIdx], "nurse");
		}
		else
		{
			// we're done, save the file
			Serializer<List<CommandVariationResult>> serializer = new Serializer<List<CommandVariationResult>>();
			serializer.Save("CommandVariationResult.xml",CVResults);
		}
    }	
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:46,代码来源:FilterInteractions.cs

示例6: SaveXML

    public void SaveXML(string filename)
    {	// saves the current set of interactions and lists to file
		InteractionInfo sInfo = new InteractionInfo();
		sInfo.Interactions = Interactions;
		sInfo.InteractionLists = InteractionLists;
		Serializer<InteractionInfo> iSerializer = new Serializer<InteractionInfo>();
		iSerializer.Save(filename, sInfo);
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:8,代码来源:InteractionMgr.cs

示例7: AnalyzeGoldenPath

	public void AnalyzeGoldenPath( List<NluMgr.match_record> list )
	{
		GoldenPathResults = new List<ResultRecord>();
		
		foreach( NluMgr.match_record record in list )
		{
			ResultRecord rr = new ResultRecord();
#if RESULT_INCLUDE_RECORD
			rr.Record = record;
#endif
			rr.Input = record.input;
			rr.Command = record.sim_command;
			
			// get sim command and subject
            // no subject, find someone to do the command
            List<ObjectInteraction> objects = ObjectInteractionMgr.GetInstance().GetEligibleObjects(record.sim_command);
			if ( objects.Count > 0 )
			{
				bool found = false;
				foreach( ObjectInteraction obj in objects )
				{
					if ( obj.Name == record.command_subject )
					{
						rr.Result = "command interaction found for subject '" + record.command_subject + "'";
						rr.Feedback = record.feedback;
						rr.Avatar = record.command_subject;
						rr.Ok = true;
						found = true;
					}
				}
				if ( found == false )
				{
					if ( record.command_subject == "" || record.command_subject == null )
						rr.Result = "command interaction found but no command_subject";
					else
						rr.Result = "command interaction found for subject '" + record.command_subject + "' not found";
					rr.Feedback = record.feedback;
					rr.Avatar = record.command_subject;
					rr.Ok = false;
				}
			}
			else
			{
				if ( record.sim_command.Contains("PLAYER") == true )
				{
					rr.Result = "command is for player";
					rr.Feedback = record.feedback;
					rr.Avatar = record.command_subject;
					rr.Ok = true;
				}
				else
				{
					rr.Result = "no avatar to play this command";
					rr.Feedback = record.feedback;
					rr.Avatar = record.command_subject;
					rr.Ok = false;
				}
			}
			
#if RESULT_ONLY_IF_BAD
			if ( rr.Ok == false && rr.Command != "BAD:COMMAND")
				GoldenPathResults.Add(rr);
#endif
		}
		// we're done, save the file
		Serializer<List<ResultRecord>> serializer = new Serializer<List<ResultRecord>>();
		serializer.Save("GoldenPathResults.xml",GoldenPathResults);
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:68,代码来源:NluMgr.cs

示例8: EditorSaveXML

	public void EditorSaveXML( string name )
	{
		// build the screen
		//GUIScreen screen = myObject.BuildScreenXML();
		GUIScreen screen = myObject.guiScreen;
		
		// create new screen info
		ScreenInfo si = new ScreenInfo();
		si.AddScreen(screen as GUIScreen);
		
		// convert to save
		si.ConvertToGUIScreen();
		
		// create new XML
		Serializer<ScreenInfo> serializer = new Serializer<ScreenInfo>();
		serializer.Save(name + ".xml",si);				
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:17,代码来源:GUIEditObjectInspector.cs

示例9: GUISaveGUIStyleInfo

	public void GUISaveGUIStyleInfo( GUISkin skin )
	{
		List<GUIStyleInfo> Info = new List<GUIStyleInfo>();
		
		foreach( GUIStyle style in skin.customStyles )
		{
			GUIStyleInfo info = new GUIStyleInfo();
			info.Copy (style);
			if ( info.HasInfo == true )
				Info.Add (info);
		}
		
		// save it
		string path = EditorUtility.SaveFilePanel("Enter GUIStyleInfo Save Name...","./Assets/Resources/GUIScripts/",skin.name+"-StyleInfo","xml");
		if ( path == null || path == "" )
			return;
		
		// create new XML
		Serializer<List<GUIStyleInfo>> serializer = new Serializer<List<GUIStyleInfo>>();
		serializer.Save(path,Info);			
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:21,代码来源:GUIEditScreenInfoInspector.cs

示例10: LoadTriggers

	void LoadTriggers()
	{
		Serializer<List<VideoTriggerInfo>> serializer = new Serializer<List<VideoTriggerInfo>>();
#if SAVE_TEMPLATE
		List<VideoTriggerInfo> tmpList = new List<VideoTriggerInfo>();
		VideoTriggerInfo tmpInfo = new VideoTriggerInfo();
		tmpInfo.Conditions = new List<string>();
		tmpInfo.Conditions.Add ("condition1");
		tmpInfo.Interactions = new List<string>();
		tmpInfo.Interactions.Add ("interactions");
		tmpInfo.Movies = new List<string>();
		tmpInfo.Movies.Add ("movies");
		tmpList.Add (tmpInfo);
		serializer.Save ("VideoTriggers",tmpList);
#else
		Triggers = serializer.Load ("XML/VideoTriggers");
		foreach( VideoTriggerInfo item in Triggers )
			item.Init();
#endif
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:20,代码来源:VideoTriggers.cs

示例11: SaveSceneObjectToXML

	void SaveSceneObjectToXML(){
		FilterInteractions obj = FindObjectOfType(typeof (FilterInteractions)) as FilterInteractions;
		if (obj != null){
			Serializer<List<FilterInteractions.CommandVariation>> serializer2 = new Serializer<List<FilterInteractions.CommandVariation>>();
			serializer2.Save("Assets/Resources/XML/CommandVariationsNew.xml",obj.variations);
		}		
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:7,代码来源:InteractionScriptInspector.cs

示例12: ExportCommandVariations

	void ExportCommandVariations()
	{
		// merge both from xml and to xml, to all the instances in the scene
		Serializer<List<FilterInteractions.CommandVariation>> serializer2 = new Serializer<List<FilterInteractions.CommandVariation>>();

		InteractionScript[] scripts = GameObject.FindObjectsOfType(typeof(InteractionScript)) as InteractionScript[];

		List<FilterInteractions.CommandVariation> variations = new List<FilterInteractions.CommandVariation>();

		// add each command variation to the list
		foreach (InteractionScript s in scripts){
			if ( s.commandVariation != null && s.commandVariation.Cmd != "" )
			{
				// check for duplicates
				bool found = false;
				foreach( FilterInteractions.CommandVariation item in variations )
				{
					if ( item.Cmd == s.commandVariation.Cmd )
						found = true;
				}
				if ( found == false )
					variations.Add(s.commandVariation);
			}
		}
		// then write the results out to the xml
		serializer2.Save("Assets/Resources/XML/CommandVariations.xml",variations);
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:27,代码来源:InteractionScriptInspector.cs

示例13: MergeCommandVariations

	void MergeCommandVariations(){
		// merge both from xml and to xml, to all the instances in the scene
		Serializer<List<FilterInteractions.CommandVariation>> serializer2 = new Serializer<List<FilterInteractions.CommandVariation>>();
		List<FilterInteractions.CommandVariation> variations = serializer2.Load("XML/CommandVariations");
		
		InteractionScript[] scripts = GameObject.FindObjectsOfType(typeof(InteractionScript)) as InteractionScript[];
		
		foreach (InteractionScript s in scripts){
			if ( s.commandVariation == null || s.commandVariation.Variations == null )
				continue;
			
			bool vFound = false;
			foreach (FilterInteractions.CommandVariation v in variations){
				if (v.CmdString == null && v.Variations != null && v.Variations.Count > 0 ) v.CmdString = v.Variations[0];
				if (s.name == v.Cmd){
					vFound=true;
					// match, now merge
					//s.commandVariation = v;
					foreach (string st in v.Variations){
						bool found = false;
						foreach (string st2 in s.commandVariation.Variations){
							if (st == st2){
								found = true;
								break;
							}
						}
						if (!found)
							s.commandVariation.Variations.Add(st);
					}
					foreach (string st in s.commandVariation.Variations){
						bool found = false;
						foreach (string st2 in v.Variations){
							if (st == st2){
								found = true;
								break;
							}
						}
						if (!found)
							v.Variations.Add(st);
					}
					break;
				}
			}
			if (!vFound && s.commandVariation.Cmd!=""){
				
				variations.Add(s.commandVariation);
			}
		}
		// perform the loop a second time, to merge any late additions into early commands
		foreach (InteractionScript s in scripts){
			if ( s.commandVariation == null || s.commandVariation.Variations == null )
				continue;
			foreach (FilterInteractions.CommandVariation v in variations){
				if (v.CmdString == null && v.Variations != null && v.Variations.Count > 0 ) v.CmdString = v.Variations[0];
				if (s.name == v.Cmd){
					// match, now merge
					//s.commandVariation = v;
					foreach (string st in v.Variations){
						bool found = false;
						foreach (string st2 in s.commandVariation.Variations){
							if (st == st2){
								found = true;
								break;
							}
						}
						if (!found)
							s.commandVariation.Variations.Add(st);
					}
					foreach (string st in s.commandVariation.Variations){
						bool found = false;
						foreach (string st2 in v.Variations){
							if (st == st2){
								found = true;
								break;
							}
						}
						if (!found)
							v.Variations.Add(st);
					}
					break;
				}
			}
		}
		// then write the results out to the xml
		serializer2.Save("Assets/Resources/XML/CommandVariationsNew.xml",variations);
	}	
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:86,代码来源:InteractionScriptInspector.cs

示例14: ConnectExecuted

        private void ConnectExecuted()
        {
            var login = activity as LoginViewModel;
            if (login != null)
            {
                var serializer = new Serializer<List<ServerCredentialsModel>>();

                // save the credential info
                var credentials = File.Exists(ServerFile)
                    ? serializer.Load(ServerFile)
                    : new List<ServerCredentialsModel>();
                var model = login.ServerCredentials;
                credentials.Add(model);
                serializer.Save(credentials, ServerFile);

                ShowServerOverview(model);
            }
        }
开发者ID:Mizipzor,项目名称:TeamCityDesktop,代码行数:18,代码来源:MainWindowViewModel.cs

示例15: DrawConfigurator

	void DrawConfigurator(int id){
		GUI.depth=0;
		GUI.DrawTexture(new Rect(0,20,guiRect.width,guiRect.height-20),backgroundTex);
		GUI.DragWindow (new Rect(0,0,guiRect.width,20));
		GUILayout.BeginVertical();
		GUILayout.Space(5);
		GUILayout.BeginHorizontal();
		GUILayout.Label("Name",GUILayout.Width(35));
		data.name = GUILayout.TextField(data.name,GUILayout.Width(300));
		GUILayout.Label("Age",GUILayout.Width(25));
		data.age = GUILayout.TextField(data.age,GUILayout.Width(40));
		GUILayout.EndHorizontal();
		caseScrollPosition = GUILayout.BeginScrollView(caseScrollPosition,GUILayout.Height(60));
		data.caseDescription = GUILayout.TextArea(data.caseDescription,GUILayout.Height(120));
		GUILayout.EndScrollView();
		GUILayout.EndVertical();
		scroller = GUILayout.BeginScrollView(scroller);
		if (data != null && data.options != null && data.options.Length > 0){
			GUILayout.BeginArea (new Rect(0,0,guiRect.width*.7f,guiRect.height));
			GUILayout.Label("CASE OPTIONS");
			foreach (CaseConfigOption opt in data.options){
				GUILayout.BeginHorizontal();
				opt.Enabled = GUILayout.Toggle(opt.Enabled,opt.shortDescription);
				GUILayout.EndHorizontal();
				if (opt.param.Length > 0){
					foreach (string str in opt.param){
						GUILayout.BeginHorizontal();
						//GUILayout.FlexibleSpace();
						GUILayout.Label("\t\t"+str);
						GUILayout.EndHorizontal();
					}
				}
			}
			GUILayout.EndArea();
			
#if SHOW_TEAM_SELECT			
			GUILayout.BeginArea (new Rect(guiRect.width*.6f,0,guiRect.width*.3f,guiRect.height*0.28f));
			GUILayout.Label("TEAM MEMBERS (planned feature)");
			teamScrollPosition = GUILayout.BeginScrollView(teamScrollPosition,false,true);
			foreach (CaseConfigOption opt in data.team){
				GUILayout.BeginHorizontal();
				GUILayout.Toggle(opt.Enabled,opt.shortDescription);
				GUILayout.EndHorizontal();
			}
			GUILayout.EndScrollView();
			GUILayout.EndArea();
#endif
#if SHOW_VITALS_SELECT
			GUILayout.BeginArea (new Rect(guiRect.width*.6f,guiRect.height*0.30f,guiRect.width*.3f,guiRect.height*0.28f));
			GUILayout.Label("VITALS (START/END)");
			GUILayout.BeginHorizontal();
			GUILayout.Label("HR");
			float w=30;
			data.start.HR = GUILayout.TextArea(data.start.HR,GUILayout.Width(w));
			GUILayout.Label("SYS");
			data.start.BPSYS = GUILayout.TextArea(data.start.BPSYS,GUILayout.Width(w));
			GUILayout.Label("DIA");
			data.start.BPDIA = GUILayout.TextArea(data.start.BPDIA,GUILayout.Width(w));
			GUILayout.Label("SP");
			data.start.SP = GUILayout.TextArea(data.start.SP,GUILayout.Width(w));
			GUILayout.Label("TEMP");
			data.start.TEMP = GUILayout.TextArea(data.start.TEMP,GUILayout.Width(w));
			GUILayout.Label("RESP");
			data.start.RESP = GUILayout.TextArea(data.start.RESP,GUILayout.Width(w));
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal();
			GUILayout.Label("HR");
			data.end.HR = GUILayout.TextArea(data.end.HR,GUILayout.Width(w));
			GUILayout.Label("SYS");
			data.end.BPSYS = GUILayout.TextArea(data.end.BPSYS,GUILayout.Width(w));
			GUILayout.Label("DIA");
			data.end.BPDIA = GUILayout.TextArea(data.end.BPDIA,GUILayout.Width(w));
			GUILayout.Label("SP");
			data.end.SP = GUILayout.TextArea(data.end.SP,GUILayout.Width(w));
			GUILayout.Label("TEMP");
			data.end.TEMP = GUILayout.TextArea(data.end.TEMP,GUILayout.Width(w));
			GUILayout.Label("RESP");
			data.end.RESP = GUILayout.TextArea(data.end.RESP,GUILayout.Width(w));
			GUILayout.EndHorizontal();
			GUILayout.EndArea();			
#endif
#if SHOW_DB_CASES
			GUILayout.BeginArea (new Rect(guiRect.width*.6f,guiRect.height*0.50f,guiRect.width*.3f,guiRect.height*0.20f));
			GUILayout.BeginHorizontal();
			GUILayout.Label("DB Saved Options");
			if ( GUILayout.Button("Refresh List") )
				LoadCaseConfigurations("rob");
			GUILayout.EndHorizontal();
			dbScrollPosition = GUILayout.BeginScrollView(dbScrollPosition,false,true);
			foreach( CaseInfo ci in CaseList )
			{
				if ( GUILayout.Button(ci.name) )
					LoadCaseConfiguration(ci);
			}
			GUILayout.EndScrollView();
			GUILayout.EndArea();			
#endif
		}
		GUILayout.EndScrollView();
		GUILayout.BeginHorizontal();
//.........这里部分代码省略.........
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:101,代码来源:CaseConfigurator.cs


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