public ResponseSerializer Put(int id, [FromBody] FactorySerializer factorySerializer) { return(new ResponseSerializer( 200, "success", this._factoryBus.UpdateFactory(id, factorySerializer))); }
public FactorySerializer GetFactoryById(int id) { FactoryModel factory = this._factoryDao.GetById(id); FactorySerializer result = new FactorySerializer(factory); return(result); }
public ResponseSerializer Post([FromBody] FactorySerializer factorySerializer) { return(new ResponseSerializer( 200, "success", this._factoryBus.CreateNewFactory(factorySerializer))); }
public Tuple <Type, byte[]> Grab <T>(T item) { Type @type = item.GetType(); byte[] byteStream = { }; Type serializedType = @type; if (@type.IsNestedPrivate && @type.Name.Contains("Iterator") && @type.FullName.Contains("System.Linq.Enumerable") && item is IEnumerable) { MethodInfo toList = typeof(Enumerable).GetMethod("ToList"); Type baseType = item.GetType().BaseType; if (baseType == null) { return(new Tuple <Type, byte[]>(serializedType, byteStream)); } MethodInfo constructedToList = toList.MakeGenericMethod(baseType.GetGenericArguments()[0]); object castList = constructedToList.Invoke(null, new object[] { item }); serializedType = castList.GetType(); IServiceSerializer serviceSerializer = FactorySerializer.CreateServiceSerializer(serializedType); byteStream = serviceSerializer.Serialize(castList); } else { IServiceSerializer serviceSerializer = FactorySerializer.CreateServiceSerializer(serializedType); byteStream = serviceSerializer.Serialize(item); } return(new Tuple <Type, byte[]>(serializedType, byteStream)); }
protected void LoadFactoryData(FactorySerializer fs) { SetRecipe(Recipe.GetRecipeByNumber(fs.recipeID)); inputResourcesBuffer = fs.inputResourcesBuffer; outputResourcesBuffer = fs.outputResourcesBuffer; LoadWorkBuildingData(fs.workBuildingSerializer); }
override public void Load(StructureSerializer ss, SurfaceBlock sblock) { LoadStructureData(ss, sblock); FactorySerializer fs = new FactorySerializer(); GameMaster.DeserializeByteArray(ss.specificData, ref fs); LoadFactoryData(fs); }
protected FactorySerializer GetFactorySerializer() { FactorySerializer fs = new FactorySerializer(); fs.workBuildingSerializer = GetWorkBuildingSerializer(); fs.recipeID = recipe.ID; fs.inputResourcesBuffer = inputResourcesBuffer; fs.outputResourcesBuffer = outputResourcesBuffer; return(fs); }
public String CreateNewFactory(FactorySerializer factorySerializer) { FactoryModel factoryModel = new FactoryModel(); factoryModel.FactoryName = factorySerializer.factoryName; factoryModel.FactoryPhoneNumber = factorySerializer.factoryPhoneNumber; factoryModel.FactoryAddress = factorySerializer.factoryAddress; factoryModel.Remark = factorySerializer.remark; factoryModel.City = factorySerializer.city; return(this._factoryDao.Create(factoryModel)); }
public String UpdateFactory(int id, FactorySerializer factorySerializer) { FactoryModel factoryModel = new FactoryModel(); factoryModel.Id = factorySerializer.id; factoryModel.FactoryName = factorySerializer.factoryName; factoryModel.FactoryPhoneNumber = factorySerializer.factoryPhoneNumber; factoryModel.FactoryAddress = factorySerializer.factoryAddress; factoryModel.Remark = factorySerializer.remark; factoryModel.City = factorySerializer.city; return(this._factoryDao.Update(id, factoryModel)); }
public override ISerializer Serialize() { float xPos = this.transform.position.x; float yPos = this.transform.position.y; float zPos = this.transform.position.z; float[] position = { xPos, yPos, zPos }; FactorySerializer rs = new FactorySerializer(this.health, position, this.faction); return(rs); }
static HttpService() { FactorySerializer = new FactorySerializer(); }
public void Test1() { // Arrange var audi = new Audi { LicensePlate = Guid.NewGuid().ToString(), IsDiesel = true }; var merchant = new Person { FirstName = "Bill", LastName = "Bracket" }; var volvo = new Volvo { LicensePlate = Guid.NewGuid().ToString(), HasAutomaticBreak = true }; var ford = new Ford { LicensePlate = Guid.NewGuid().ToString(), HasSpareTire = true }; var factory = new Factory { Cars = { ford, audi, volvo }, Merchant = merchant }; // Act var serializer = new SerializerBuilder() .WithNamingConvention(new CamelCaseNamingConvention()) .EmitDefaults() .Build(); var rawFactoryYaml = serializer.Serialize(factory); var input = new StringReader(rawFactoryYaml); var yamlStream = new YamlStream(); yamlStream.Load(input); var deserializedFactory = FactorySerializer.Deserialize(yamlStream); // Assert Assert.NotNull(deserializedFactory); Assert.NotNull(deserializedFactory.Cars); Assert.Equal(deserializedFactory.Cars.Count, factory.Cars.Count); var deserializedAudi = (Audi)deserializedFactory.Cars.SingleOrDefault(car => car.Make == Make.Audi); Assert.NotNull(deserializedAudi); Assert.Equal(deserializedAudi.LicensePlate, audi.LicensePlate); Assert.Equal(deserializedAudi.IsDiesel, audi.IsDiesel); var deserializedFord = (Ford)deserializedFactory.Cars.SingleOrDefault(car => car.Make == Make.Ford); Assert.NotNull(deserializedFord); Assert.Equal(deserializedFord.LicensePlate, ford.LicensePlate); Assert.Equal(deserializedFord.HasSpareTire, ford.HasSpareTire); var deserializedVolvo = (Volvo)deserializedFactory.Cars.SingleOrDefault(car => car.Make == Make.Volvo); Assert.NotNull(deserializedVolvo); Assert.Equal(deserializedVolvo.LicensePlate, volvo.LicensePlate); Assert.Equal(deserializedVolvo.HasAutomaticBreak, volvo.HasAutomaticBreak); }
public object Release(byte[] item, Type type) { IServiceSerializer serviceSerializer = FactorySerializer.CreateServiceSerializer(type); return(serviceSerializer.Deserialize(item, type)); }
public T Release <T>(byte[] item) { IServiceSerializer serviceSerializer = FactorySerializer.CreateServiceSerializer(typeof(T)); return(serviceSerializer.Deserialize <T>(item)); }