public static IStaticData GetStaticData(ISerializator serializator, string staticData) { var data = serializator.Deserialize <Internal_StaticData>(staticData); data.PostSerialize(); return(data); }
private static bool TryGetSerializator(TypeInfo type, out ISerializator serializator) { if (type.IsGenericType) { type = type.GetGenericTypeDefinition().GetTypeInfo(); } if (type.Equals(typeof(object).GetTypeInfo())) { type = typeof(IObject).GetTypeInfo(); } if (SerializatorsMap.TryGetValue(type, out var foundSerializator)) { serializator = foundSerializator; return(true); } serializator = Serializators.SingleOrDefault(s => Equals(s.SupportedType, type)) ?? Serializators.FirstOrDefault(s => s.SupportedType.IsAssignableFrom(type)); if (serializator != null) { SerializatorsMap[type] = serializator; return(true); } return(false); }
public bool LoadShapeList(string filePath, ref string errorMessage) { try { string formatName = Path.GetExtension(filePath); if (formatName.Length > 1) { formatName = formatName.Substring(1); } SerializationFormat serializationFormat = SerializationFormat.Binary; if (Functionality.GetSerializationFormatByName(formatName, ref serializationFormat)) { ISerializator serializator = SerializationManager.getInstance().GetSerializatorForFormat(serializationFormat); if (null != serializator) { using (FileStream fileStream = new FileStream(filePath, FileMode.Open)) { //plugins work routine var bytes = Utils.ReadStream(fileStream); for (int i = Settings.OrderedAppliedPluginsList.Count - 1; i >= 0; i--) { bytes = Settings.OrderedAppliedPluginsList[i].ProcessDataOnLoad(filePath, serializationFormat, bytes); } //shapes deserealization using (MemoryStream memoryStream = new MemoryStream(bytes)) { ListOfShapes loadedShapeList = serializator.Deserialize <ListOfShapes>(memoryStream); if (null != loadedShapeList) { foreach (Shape shape in loadedShapeList.Shapes) { ListOfShapes.AddShape(shape); } return(true); } } } } } return(false); } catch (Exception e) { errorMessage = e.Message; return(false); } }
public void SerializeEntities(ISerializator <List <IEntity> > serializator, List <IEntity> entities, IDisposable writer) { if (entities.Count > 0) { using (writer) { serializator.Serialize(writer, entities); } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"No entity to serialize found!"); Console.ForegroundColor = ConsoleColor.White; } }
public MainWindow() { InitializeComponent(); // For tests only. //_serializator = new SerializatorStub(); //_scrapper = new OddsScrapperStub(); // Uncomment for production. _serializator = new Serializator(); _scrapper = new OddsScrapper(); _scrapper.ProgressReportedEvent += ProgressReportedEvent; //Oddslist = _scrapper.OddValues; OddsValuesList = new ObservableCollection <OddSerializationModel>(); }
public bool SaveShapeList(SerializationFormat serializationFormat, string dirPath, ref string filePath) { string extension = serializationFormat.ToString(); var shapeFilesOfSelectedFormat = new HashSet <string>(Directory.GetFiles(dirPath, "*." + extension)); int i = 0; do { filePath = dirPath + "\\" + "shape_" + i + "." + serializationFormat.ToString(); i++; } while (shapeFilesOfSelectedFormat.Contains(filePath)); ISerializator serializator = SerializationManager.getInstance().GetSerializatorForFormat(serializationFormat); if (null != serializator) { using (MemoryStream memoryStream = new MemoryStream()) { serializator.Serialize(memoryStream, ListOfShapes); //plugins work routine var dataToSave = Utils.ReadStream(memoryStream); foreach (Plugin plugin in Settings.OrderedAppliedPluginsList) { dataToSave = plugin.ProcessDataOnSave(filePath, serializationFormat, dataToSave); } //save data to file using (FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate)) { fileStream.Write(dataToSave, 0, dataToSave.Length); } } return(true); } return(false); }
public void Init(Vector3 startPosition, IEnumerable <IPoolable> Pooalables, float size) { activated = false; this.startCenterPosition = startPosition; this.size = size; enterTriger = gameObject.AddComponent <BoxCollider>(); enterTriger.transform.position = this.startCenterPosition; enterTriger.size = new Vector3(TrackAbstract.GetInstance().LineWidth *10f, 40f, 1f); enterTriger.isTrigger = true; var trigerScript = gameObject.AddComponent <EnterTrackChunkStartTrigger>(); trigerScript.chunk = this; bounds = new Bounds(startPosition + new Vector3(0f, 5f, size / 2f), new Vector3(100f, 20f, size)); foreach (IPoolable poolable in Pooalables) { if (bounds.Contains(poolable.GetGameObject.transform.position)) { try { ISerializator serializator = (ISerializator)gameObject.AddComponent(SerializatorTypes.SerializatorFor(poolable.GetType().Name)); if (serializator == null) { Debug.LogWarning(poolable.GetType().Name + "Serializator not found"); } else { serializator.Serialize(poolable); } } catch (Exception e) { Debug.LogException(e); Debug.LogError(poolable); } } } }
public static string CreateDefaultStatic(ISerializator serializator) { return(null); //return serializator.Serialize(new Internal_StaticData()); }
public Form1(ISerializator serializator) { this.serializator = serializator; folderBrowserDialog = new FolderBrowserDialog(); InitializeComponent(); }
public SerializingController(ISerializator serializator) { this.serializator = serializator; }
public void Serialize(ISerializator <PhoneBook> serializer, IWriter writer) { serializer.Serialize(writer as FileWriter, this); }
public static string CreateDefaultState(ISerializator serializator) { return(serializator.Serialize(new Internal_StateData())); }
public static IServerLogicContext Create(ISerializator serializator, IMigrationsExternalAPI api) { return(null); //return new InternalContext(serializator, api); }
public static IClientLogicContext Create(ISerializator serializator, ICommandStorage commandStorage, ITestExternalAPI api) { return(null); //return new InternalContext(serializator, commandStorage, api); }
public SerializationEventArgs( ISerializator key, RegistrySerialization storage ) { m_key = key; m_storage = storage; }
private void RegisterSerializator(ISerializator serializator) { serialozators[serializator.OutputFormat()] = serializator; }
public SerializationEventArgs(ISerializator key, RegistrySerialization storage) { m_key = key; m_storage = storage; }
public TestCommandStorage(ISerializator serializator) { _serializator = serializator; }
public void SerializeBook(ISerializator <PhoneBook <IEntity> > serializer, IWriter writer, PhoneBook <IEntity> book) { serializer.Serialize(writer as FileWriter, book); }