public DataService(IModelSerializer serializer, FSO.Content.Content content) { this.Serializer = serializer; this.DataDefinition = content.DataDefinition; //Build Struct => Field[] maps for quicker serialization foreach (var derived in DataDefinition.DerivedStructs) { var type = MaskedStructUtils.FromID(derived.ID); List <StructField> fields = new List <StructField>(); var parent = DataDefinition.Structs.First(x => x.ID == derived.Parent); foreach (var field in parent.Fields) { var mask = derived.FieldMasks.FirstOrDefault(x => x.ID == field.ID); if (mask == null) { continue; } /* * var action = DerivedStructFieldMaskType.KEEP; * if (mask != null){ * action = mask.Type; * } * if (action == DerivedStructFieldMaskType.REMOVE){ * //These seems wrong, ServerMyAvatar and MyAvatar both exclude bookmarks by this logic * //continue; * } */ fields.Add(field); } MaskedStructToActualFields.Add(type, fields.ToArray()); } foreach (var _struct in DataDefinition.Structs) { StructToActualFields.Add(_struct.ID, _struct.Fields.ToArray()); } var assembly = Assembly.GetAssembly(typeof(DataService)); foreach (Type type in assembly.GetTypes()) { System.Attribute[] attributes = System.Attribute.GetCustomAttributes(type); foreach (Attribute attribute in attributes) { if (attribute is DataServiceModel) { var _struct = DataDefinition.GetStruct(type.Name); if (_struct != null) { ModelTypeById.Add(_struct.ID, type); ModelIdByType.Add(type, _struct.ID); } } } } }
public DataServiceModelTypeSerializer(TSODataDefinition model) { this.Model = model; foreach (var obj in model.Structs) { StructsByName.Add(obj.Name, obj); StructById.Add(obj.ID, obj); } var assemblies = AssemblyUtils.GetFreeSOLibs(); foreach (var asm in assemblies) { try { ScanAssembly(asm); } catch (Exception) { Console.WriteLine("huh??"); } } }
private void Reload() { Data = Content.Content.Get().DataDefinition; //populate the tree views TreeToObject.Clear(); ReloadTree(TreeView1S, Data.List1); ReloadTree(TreeView2S, Data.List2); ReloadTree(TreeViewDS, Data.List3); }
private void InitBasic() { var contentFiles = new List <string>(); _ScanFiles("Content/", contentFiles, "Content/"); ContentFiles = contentFiles.ToArray(); CustomUI.Init(); if (!TS1) { var allFiles = new List <string>(); _ScanFiles(BasePath, allFiles, BasePath); AllFiles = allFiles.ToArray(); UIGraphics?.Init(); DataDefinition = new TSODataDefinition(); using (var stream = File.OpenRead(GetPath("TSOData_datadefinition.dat"))) { DataDefinition.Read(stream); } } }
private void InitBasic() { var contentFiles = new List <string>(); _ScanFiles("Content/", contentFiles, "Content/"); ContentFiles = contentFiles.ToArray(); CustomUI.Init(); if (!TS1) { var allFiles = new List <string>(); _ScanFiles(BasePath, allFiles, BasePath); AllFiles = allFiles.ToArray(); UIGraphics?.Init(); DataDefinition = new TSODataDefinition(); try { using (var stream = File.Open("Content/FSODataDefinition.dat", FileMode.Open, FileAccess.Read, FileShare.Read)) { DataDefinition.Read(stream); } } catch { using (var stream = File.OpenRead(GetPath("TSOData_datadefinition.dat"))) { DataDefinition.Read(stream); } } try { VersionString = File.ReadAllText(GetPath("version")); } catch { } } else { VersionString = "TS1"; } }
private void loadToolStripMenuItem_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog(); dialog.Title = "Select a Data Service Definition file. (dat)"; SaveFile(dialog); try { Stream str; if ((str = dialog.OpenFile()) != null) { var tsoData = new TSODataDefinition(); tsoData.Read(str); Content.Content.Get().DataDefinition = tsoData; } } catch (Exception ex) { MessageBox.Show("Couldn't load the file! Exception: " + ex.Message); } Reload(); }
public cTSOSerializer(TSODataDefinition data) { INSTANCE = this; this.Format = data; //Scan for classes with decorations var assembly = Assembly.GetAssembly(typeof(cTSOSerializer)); foreach (Type type in assembly.GetTypes()) { System.Attribute[] attributes = System.Attribute.GetCustomAttributes(type); foreach (Attribute attribute in attributes) { if (attribute is clsid) { ClassesById.Add(((clsid)attribute).Value, type); IdByClass.Add(type, ((clsid)attribute).Value); } else if (attribute is cTSONetMessageParameter) { var param = (cTSONetMessageParameter)attribute; object paramValue = param.Value; /*if(paramValue is DBRequestType){ * paramValue = ((DBRequestType)paramValue).GetRequestID(); * }else if(paramValue is DBResponseType) * { * paramValue = ((DBResponseType)paramValue).GetResponseID(); * }*/ cNetMessageParametersById.Add((uint)paramValue, type); } } } }
/// <summary> /// Setup the content manager so it knows where to find various files. /// </summary> private void Init() { /** Scan system for files **/ var allFiles = new List <string>(); _ScanFiles(BasePath, allFiles); AllFiles = allFiles.ToArray(); var ts1AllFiles = new List <string>(); var oldBase = BasePath; if (TS1) { BasePath = TS1BasePath; _ScanFiles(TS1BasePath, ts1AllFiles); BasePath = oldBase; TS1AllFiles = ts1AllFiles.ToArray(); } TS1Global?.Init(); BCFGlobal?.Init(); if (!TS1) { PIFFRegistry.Init(Path.Combine(FSOEnvironment.ContentDir, "Patch/")); } Archives = new Dictionary <string, FAR3Archive>(); if (Mode == ContentMode.CLIENT) { UIGraphics.Init(); AvatarHandgroups.Init(); } AvatarBindings.Init(); AvatarOutfits.Init(); if (TS1) { ((TS1AvatarTextureProvider)AvatarTextures)?.Init(); ((TS1BMFProvider)AvatarMeshes)?.Init(); Jobs = new TS1JobProvider(TS1Global); Neighborhood = new TS1NeighborhoodProvider(this); } else { ((AvatarTextureProvider)AvatarTextures)?.Init(); ((AvatarAnimationProvider)AvatarAnimations).Init(); ((AvatarSkeletonProvider)AvatarSkeletons).Init(); ((AvatarAppearanceProvider)AvatarAppearances).Init(); ((AvatarMeshProvider)AvatarMeshes)?.Init(); } Audio.Init(); AvatarPurchasables.Init(); AvatarCollections.Init(); Ini.Init(); CityMaps.Init(); RackOutfits.Init(); DataDefinition = new TSODataDefinition(); using (var stream = File.OpenRead(GetPath("TSOData_datadefinition.dat"))) { DataDefinition.Read(stream); } AvatarThumbnails.Init(); InitWorld(); }
public DataServiceModelVectorTypeSerializer(TSODataDefinition model) : base(model) { }