Esempio n. 1
0
 protected override void WriteElement(Int16 e, BinaryWriter writer, AContainer <BinaryStream> container)
 {
     writer.Write(e);
 }
Esempio n. 2
0
 protected override void ReadElement(ref UInt32 e, BinaryReader reader, AContainer <BinaryStream> container)
 {
     e = reader.ReadUInt32();
 }
Esempio n. 3
0
 protected override void ReadElement(ref Int16 e, BinaryReader reader, AContainer <BinaryStream> container)
 {
     e = reader.ReadInt16();
 }
Esempio n. 4
0
        private void fi_solve()
        {
            List <Tuple <Constant, Constant, Constant> >[] possiblePairs = new List <Tuple <Constant, Constant, Constant> > [3];
            for (int i = 0; i < possiblePairs.Length; i++)
            {
                possiblePairs[i] = new List <Tuple <Constant, Constant, Constant> >();
            }
            ContainerList[] hor = new ContainerList[3];
            for (int i = 0; i < 3; i++)
            {
                hor[i] = AContainer.Read($"{(char)(65 + 0 + 3 * i)}{mi_hOperators[i, 0]}{(char)(65 + 1 + 3 * i)}{mi_hOperators[i, 1]}{(char)(65 + 2 + 3 * i)}");
            }


            double   value;
            Constant c1, c2, c3;

            for (int first = 0; first < 10; first++)
            {
                for (int second = 0; second < 10; second++)
                {
                    for (int third = 0; third < 10; third++)
                    {
                        for (int cl = 0; cl < hor.Length; cl++)
                        {
                            c1 = new Constant(((char)(65 + 0 + 3 * cl)).ToString(), first);
                            c2 = new Constant(((char)(65 + 1 + 3 * cl)).ToString(), second);
                            c3 = new Constant(((char)(65 + 2 + 3 * cl)).ToString(), third);

                            hor[cl].SetConstants(c1);
                            hor[cl].SetConstants(c2);
                            hor[cl].SetConstants(c3);

                            value = ((ContainerList)hor[cl].Clone()).Calculate();
                            if ((int)value == mi_hResults[cl])
                            {
                                possiblePairs[cl].Add(new Tuple <Constant, Constant, Constant>(c1, c2, c3));
                            }
                        }
                    }
                }
            }


            ContainerList[] ver    = new ContainerList[3];
            int[]           values = new int[3];
            for (int i = 0; i < 3; i++)
            {
                string text = $"{(char)(65 + i + 3 * 0)}{mi_vOperators[i, 0]}{(char)(65 + i + 3 * 1)}{mi_vOperators[i, 1]}{(char)(65 + i + 3 * 2)}";
                ver[i] = AContainer.Read(text);
            }
            for (int first = 0; first < possiblePairs[0].Count; first++)
            {
                for (int i = 0; i < 3; i++)
                {
                    ver[i].SetConstants(possiblePairs[0][first].Item1, possiblePairs[0][first].Item2, possiblePairs[0][first].Item3);
                }

                for (int second = 0; second < possiblePairs[1].Count; second++)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        ver[i].SetConstants(possiblePairs[1][second].Item1, possiblePairs[1][second].Item2, possiblePairs[1][second].Item3);
                    }

                    for (int third = 0; third < possiblePairs[2].Count; third++)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            ver[i].SetConstants(possiblePairs[2][third].Item1, possiblePairs[2][third].Item2, possiblePairs[2][third].Item3);
                            values[i] = (int)((ContainerList)ver[i].Clone()).Calculate();
                        }

                        if (values[0] == mi_vResults[0] &&
                            (values[1] == mi_vResults[1]) &&
                            (values[2] == mi_vResults[2]))
                        {
                            mi_operants[0, 0] = (int)possiblePairs[0][first].Item1.mu_value;
                            mi_operants[0, 1] = (int)possiblePairs[0][first].Item2.mu_value;
                            mi_operants[0, 2] = (int)possiblePairs[0][first].Item3.mu_value;

                            mi_operants[1, 0] = (int)possiblePairs[1][second].Item1.mu_value;
                            mi_operants[1, 1] = (int)possiblePairs[1][second].Item2.mu_value;
                            mi_operants[1, 2] = (int)possiblePairs[1][second].Item3.mu_value;

                            mi_operants[2, 0] = (int)possiblePairs[2][third].Item1.mu_value;
                            mi_operants[2, 1] = (int)possiblePairs[2][third].Item2.mu_value;
                            mi_operants[2, 2] = (int)possiblePairs[2][third].Item3.mu_value;

                            fi_updateOperants();

                            return;
                        }
                    }
                }
            }

            MessageBox.Show("there is no valid solution", "caution");
        }
Esempio n. 5
0
 protected override void ReadElement(ref SByte e, BinaryReader reader, AContainer <BinaryStream> container)
 {
     e = reader.ReadSByte();
 }
 public override void WriteObject(object obj, BinaryStream stream, AContainer <BinaryStream> container)
 {
     // nothing to write
 }
Esempio n. 7
0
File: Sprite.cs Progetto: gmich/Gem
 public Sprite(Texture2D texture, Rectangle?sourceRectangle = null)
 {
     this.spriteContainer = new AContainer <SpriteItem>();
     this.Add(target, texture, sourceRectangle);
 }
Esempio n. 8
0
 public abstract void WriteObject(T obj, TStream stream, AContainer <TStream> container);
Esempio n. 9
0
 public abstract void ReadDataToObject(ref T obj, TStream stream, AContainer <TStream> container);
        public override void ReadDataToObject(ref BinaryContainer c, BinaryStream stream, AContainer <BinaryStream> container)
        {
            var  reader   = stream.GetReader();
            int  len      = reader.ReadUIntPacked().ToInt32();
            bool writable = reader.ReadBoolean();

            var memStream = c?.GetUnderlyingStream() as MemoryStream;

            if (memStream == null || !memStream.CanWrite)
            {
                memStream = new MemoryStream(len);
            }
            var copiedLen = stream.GetUnderlyingStream().CopyPartiallyTo(memStream, len);

            if (copiedLen != len)
            {
                throw new Exception($"Failed to read {c.PrettyTypeName()}: {copiedLen} bytes read instead of {len} expected");
            }
            var binStream = new BinaryStream(memStream, writable);
            var storage   = (c ?? container).SerializerStorage;

            // here we re-create container to avoid messing up with internal
            // state (dirty, size, etc.)
            c = new BinaryContainer(binStream, storage);
        }