public GameScores() { PlayerScoreMultiplier = 80.0; ProductionMultiplier = 100.0; StudentNumberMultiplier = 16.0; FutureCampus = 30.0; SpecialSiteMultiplier = 10.0; NormalSite = 200.0; InternetLinkMultiplier = 10.0; HasAllDegrees = 100.0; TakenOtherPlayerCampus = 100.0; LeadMostScore = 100.0; DegreeModifier = new XmlSerializableDictionary<DegreeType, double>(); DegreeModifier[DegreeType.Ore] = 1.4; DegreeModifier[DegreeType.Brick] = 1.2; DegreeModifier[DegreeType.Wood] = 1.2; DegreeModifier[DegreeType.Sheep] = 1; DegreeModifier[DegreeType.Grain] = 1.1; DegreeModifier[DegreeType.None] = 0; SetupDegreeModifier = new XmlSerializableDictionary<DegreeType, double>(); SetupDegreeModifier[DegreeType.Ore] = 1.3; SetupDegreeModifier[DegreeType.Brick] = 1.3; SetupDegreeModifier[DegreeType.Wood] = 1.3; SetupDegreeModifier[DegreeType.Sheep] = 1; SetupDegreeModifier[DegreeType.Grain] = 1.1; SetupDegreeModifier[DegreeType.None] = 0; }
private ChatLogModel() { this.messagesLog = new XmlSerializableDictionary <string, List <ChatLogNode> >(); this.messagesLog.Add("For testing", new List <ChatLogNode> { new ChatLogNode() }); // Что бы было что видеть }
private static SlideBulk ComposeSlideBulk(PresentationInfo presentationInfo, IEnumerable<TechnicalServices.Persistence.SystemPersistence.Presentation.Slide> slideArr) { XmlSerializableDictionary<int, SlideLinkList> linkDic = new XmlSerializableDictionary<int, SlideLinkList>(); XmlSerializableDictionary<int, Point> positionDic = new XmlSerializableDictionary<int, Point>(); SlideBulk slideBulk = new SlideBulk(); foreach (TechnicalServices.Persistence.SystemPersistence.Presentation.Slide slide in slideArr) { slideBulk.SlideList.Add(slide); positionDic[slide.Id] = presentationInfo.SlidePositionList[slide.Id]; IList<LinkInfo> linkInfoList; if (!presentationInfo.SlideLinkInfoList.TryGetValue(slide.Id, out linkInfoList)) continue; foreach (LinkInfo linkInfo in linkInfoList) { if (!slideArr.Any(sl => sl.Id == linkInfo.NextSlideId)) continue; SlideLinkList slideLinkList; if (!linkDic.TryGetValue(slide.Id, out slideLinkList)) { linkDic[slide.Id] = slideLinkList = new SlideLinkList(); } slideLinkList.LinkList.Add(linkInfo.CreateLinkStub()); } } slideBulk.LinkDictionary = linkDic; slideBulk.SlidePositionList = positionDic; return slideBulk; }
static void Main(string[] args) { Dictionary <string, string> Dictionary = new XmlSerializableDictionary <string, string>(); Dictionary.Add("Hello", "World"); MemoryStream Stream = new MemoryStream(); XmlSerializer Serializer = new XmlSerializer(typeof(XmlSerializableDictionary <string, string>)); Serializer.Serialize(Stream, Dictionary); Stream.Position = 0; Dictionary = (XmlSerializableDictionary <string, string>)Serializer.Deserialize(Stream); Console.WriteLine(Dictionary["Hello"]); Stream.Dispose(); }
static void Main(string[] args) { XmlSerializableDictionary<my_name_test_class, int> test_dictionary = new XmlSerializableDictionary<my_name_test_class, int>(); test_dictionary.Add(new my_name_test_class("Nicholas", "Ryan"), 18); test_dictionary.Add(new my_name_test_class("Nicholas", "Ryan"), 43); test_dictionary.Add(new my_name_test_class("Nicholas", "Ryan"), 23); test_dictionary.Add(new my_name_test_class("Nicholas", "Ryan"), 89); XmlSerializer current_serializer = new XmlSerializer(typeof(XmlSerializableDictionary<my_name_test_class, int>)); FileStream test_file_stream = new FileStream(@"dictionary_another_test.xml",FileMode.OpenOrCreate,FileAccess.Write); current_serializer.Serialize(test_file_stream, test_dictionary); test_file_stream.Close(); FileStream test_file_stream_2 = new FileStream(@"dictionary_another_test.xml", FileMode.Open, FileAccess.Read); XmlSerializableDictionary<my_name_test_class, int> another_dictionary = (XmlSerializableDictionary<my_name_test_class, int>)current_serializer. Deserialize(test_file_stream_2); test_file_stream_2.Close(); Console.ReadKey(); }
public ChatBotModel() { answers = new XmlSerializableDictionary <string, List <string> >(); loadSimpleData(); imagePathBot = @"C:\Users\User\Source\Repos\WPF_ChatBOT_MVVM\WPF_ChatBOT\WPF_ChatBOT\Images\photo.ico"; }
} // end of BeforeSaveLocalizedString() /// <summary> /// On load we want to see if there any localizations for the strings. /// If there are then we look for one that matches the current language. /// If not we just set all the strings to match each other. /// /// We return the main str so this can be used like Str = OnLoadLocalizedString(Str, ... /// even if Str is an accessor which doesn't work with ref. /// </summary> /// <param name="str"></param> /// <param name="originalStr"></param> /// <param name="localizedStr"></param> /// <param name="dict"></param> /// <returns>The new version of the in use string, str.</returns> public static string OnLoadLocalizedString(string str, ref string originalStr, ref string localizedStr, ref XmlSerializableDictionary <string, string> dict) { string curLang = Boku.Common.Localization.Localizer.LocalLanguage; originalStr = str; if (dict == null) { // If localized dictionary is null, must be an old level so do nothing. } else { // If localized dictionary is not null, see if we have a string from current language to use. string locStr; if (dict.TryGetValue(curLang, out locStr)) { str = TextHelper.CleanUpString(locStr); } } localizedStr = str; return(str); } // end of OnLoadLocalizedString()
} // end of GetImageFilenameWithoutExtension() // // Helper functions for working with localizable strings in the world data. // /// <summary> /// Before we save we need to check if the user has changed the string. /// If the user has changed the string then all the translations are invalid and should be removed. /// If the user didn't change the string then we need to restore the original string so it gets properly saved. /// /// We return the main str so this can be used like Str = OnLoadLocalizedString(Str, ... /// even if Str is an accessor which doesn't work with ref. /// </summary> /// <param name="str"></param> /// <param name="originalStr"></param> /// <param name="localizedStr"></param> /// <param name="dict"></param> /// <returns>The new version of the in use string, str.</returns> public static string BeforeSaveLocalizedString(string str, ref string originalStr, ref string localizedStr, ref XmlSerializableDictionary <string, string> dict) { // If the user has changed the strings, then keep the new strings and remove the localized versions. if (str != localizedStr) { // Reset everything to reflect the fact that we have a new string. dict = null; originalStr = str; localizedStr = str; } else { // No change so restore original so it's the one that gets saved out. str = originalStr; } return(str); } // end of BeforeSaveLocalizedString()