public ResponseSerializer Put(int id, [FromBody] FactorySerializer factorySerializer)
 {
     return(new ResponseSerializer(
                200,
                "success",
                this._factoryBus.UpdateFactory(id, factorySerializer)));
 }
Exemplo n.º 2
0
        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)));
 }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 protected void LoadFactoryData(FactorySerializer fs)
 {
     SetRecipe(Recipe.GetRecipeByNumber(fs.recipeID));
     inputResourcesBuffer  = fs.inputResourcesBuffer;
     outputResourcesBuffer = fs.outputResourcesBuffer;
     LoadWorkBuildingData(fs.workBuildingSerializer);
 }
Exemplo n.º 6
0
    override public void Load(StructureSerializer ss, SurfaceBlock sblock)
    {
        LoadStructureData(ss, sblock);
        FactorySerializer fs = new FactorySerializer();

        GameMaster.DeserializeByteArray(ss.specificData, ref fs);
        LoadFactoryData(fs);
    }
Exemplo n.º 7
0
    protected FactorySerializer GetFactorySerializer()
    {
        FactorySerializer fs = new FactorySerializer();

        fs.workBuildingSerializer = GetWorkBuildingSerializer();
        fs.recipeID              = recipe.ID;
        fs.inputResourcesBuffer  = inputResourcesBuffer;
        fs.outputResourcesBuffer = outputResourcesBuffer;
        return(fs);
    }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
    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);
    }
Exemplo n.º 11
0
 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);
        }
Exemplo n.º 13
0
        public object Release(byte[] item, Type type)
        {
            IServiceSerializer serviceSerializer = FactorySerializer.CreateServiceSerializer(type);

            return(serviceSerializer.Deserialize(item, type));
        }
Exemplo n.º 14
0
        public T Release <T>(byte[] item)
        {
            IServiceSerializer serviceSerializer = FactorySerializer.CreateServiceSerializer(typeof(T));

            return(serviceSerializer.Deserialize <T>(item));
        }