private IFigure InstantFigure_Compilation_Helper_Test(InstantFigure str, FieldsAndPropertiesModel fom)
        {
            IFigure rts = str.New();

            for (int i = 1; i < str.Rubrics.Count; i++)
            {
                var r = str.Rubrics[i].RubricInfo;
                if (r.MemberType == MemberTypes.Field)
                {
                    var fi = fom.GetType().GetField(((FieldInfo)r).Name);
                    if (fi != null)
                    {
                        rts[r.Name] = fi.GetValue(fom);
                    }
                }
                if (r.MemberType == MemberTypes.Property)
                {
                    var pi = fom.GetType().GetProperty(((PropertyInfo)r).Name);
                    if (pi != null)
                    {
                        rts[r.Name] = pi.GetValue(fom);
                    }
                }
            }

            return(rts);
        }
        private IFigure InstantFigure_Compilation_Helper_Test(InstantFigure str, PropertiesOnlyModel fom)
        {
            IFigure rts = str.New();

            fom.Id = 202;
            rts[0] = 202;
            Assert.Equal(fom.Id, rts[0]);
            rts["Id"] = 404;
            Assert.NotEqual(fom.Id, rts[nameof(fom.Id)]);
            rts[nameof(fom.Name)] = fom.Name;
            Assert.Equal(fom.Name, rts[nameof(fom.Name)]);
            rts.SystemSerialCode = new Ussn(DateTime.Now.ToBinary());
            string hexTetra = rts.SystemSerialCode.ToString();
            Ussn   ssn      = new Ussn(hexTetra);

            Assert.Equal(ssn, rts.SystemSerialCode);

            for (int i = 1; i < str.Rubrics.Count; i++)
            {
                var r = str.Rubrics[i].RubricInfo;
                if (r.MemberType == MemberTypes.Field)
                {
                    var fi = fom.GetType().GetField(((FieldInfo)r).Name);
                    if (fi != null)
                    {
                        rts[r.Name] = fi.GetValue(fom);
                    }
                }
                if (r.MemberType == MemberTypes.Property)
                {
                    var pi = fom.GetType().GetProperty(((PropertyInfo)r).Name);
                    if (pi != null)
                    {
                        rts[r.Name] = pi.GetValue(fom);
                    }
                }
            }

            for (int i = 1; i < str.Rubrics.Count; i++)
            {
                var r = str.Rubrics[i].RubricInfo;
                if (r.MemberType == MemberTypes.Field)
                {
                    var fi = fom.GetType().GetField(((FieldInfo)r).Name);
                    if (fi != null)
                    {
                        Assert.Equal(rts[r.Name], fi.GetValue(fom));
                    }
                }
                if (r.MemberType == MemberTypes.Property)
                {
                    var pi = fom.GetType().GetProperty(((PropertyInfo)r).Name);
                    if (pi != null)
                    {
                        Assert.Equal(rts[r.Name], pi.GetValue(fom));
                    }
                }
            }
            return(rts);
        }
コード例 #3
0
        public void InstantFigures_MutatorAndAccessorById_Test()
        {
            str = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_FieldsAndPropertiesModel(),
                                    "InstantFigure_MemberRubric_FieldsAndPropertiesModel");
            FieldsAndPropertiesModel fom = new FieldsAndPropertiesModel();

            iRts = InstantFigure_Compilation_Helper_Test(str, fom);

            rtsq = new InstantFigures(str, "InstantSequence_Compilation_Test");

            iRtseq = rtsq.New();

            iRtseq.Add(iRtseq.NewFigure());
            iRtseq[0, 4] = iRts[4];

            isel = new InstantSelection(iRtseq);

            IFigures ifsel = isel.New();

            IFigures isel2 = new InstantSelection(ifsel).New();

            isel2.Add(isel2.NewFigure());
            isel2[0, 4] = iRts[4];

            Assert.Equal(iRts[4], isel2[0, 4]);
        }
        private void    InstantFigure_Compilation_Helper_Test(InstantFigure str, IFigure figure)
        {
            IFigure rts = str.New();

            object[] values = rts.ValueArray;
            rts.ValueArray = figure.ValueArray;
            for (int i = 0; i < values.Length; i++)
            {
                Assert.Equal(figure[i], rts.ValueArray[i]);
            }
            byte[] serie = rts.GetBytes();
        }
コード例 #5
0
        public InstantFigures(InstantFigure figure, string typeName, bool safeThread = true)
        {
            SafeThread = safeThread;
            TypeName   = typeName;
            Figure     = figure;
            InstantFiguresCompiler rsb = new InstantFiguresCompiler(this);

            compiledType = rsb.CompileFigureType(TypeName);

            FiguresType            = compiledType.New().GetType();
            Collection             = New();
            Collection.FiguresType = FiguresType;
        }
        public void InstantFigures_SetRubrics_Test()
        {
            str = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_FieldsAndPropertiesModel(),
                                    "InstantFigure_MemberRubric_FieldsAndPropertiesModel");
            FieldsAndPropertiesModel fom = new FieldsAndPropertiesModel();

            iRts = InstantFigure_Compilation_Helper_Test(str, fom);

            rtsq = new InstantFigures(str, "InstantSequence_Compilation_Test");

            var rttab = rtsq.New();

            Assert.Equal(rttab.Rubrics, rtsq.Figure.Rubrics);
        }
        [Fact] public void InstantFigure_ValueArray_GetSet_Test()
        {
            InstantFigure referenceType = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_FieldsAndPropertiesModel(),
                                                            "InstantFigure_ValueArray_FieldsAndPropertiesModel_Reference");
            FieldsAndPropertiesModel fom = new FieldsAndPropertiesModel();;

            InstantFigure_Compilation_Helper_Test(referenceType, (IFigure)InstantFigure_Compilation_Helper_Test(referenceType, fom));

            InstantFigure valueType = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_FieldsAndPropertiesModel(),
                                                        "InstantFigure_ValueArray_FieldsAndPropertiesModel_ValueType", FigureMode.ValueType);

            fom = new FieldsAndPropertiesModel();
            InstantFigure_Compilation_Helper_Test(valueType, (IFigure)InstantFigure_Compilation_Helper_Test(valueType, fom));
        }
        [Fact] public void InstantFigure_MemberRubric_PropertiesOnlyModel_Compilation_Test()
        {
            InstantFigure referenceType = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_PropertiesOnlyModel(),
                                                            "InstantFigure_MemberRubric_PropertiesOnlyModel_Reference");
            PropertiesOnlyModel fom = new PropertiesOnlyModel();

            InstantFigure_Compilation_Helper_Test(referenceType, fom);

            InstantFigure valueType = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_PropertiesOnlyModel(),
                                                        "InstantFigure_MemberRubric_PropertiesOnlyModel_ValueType", FigureMode.ValueType);

            fom = new PropertiesOnlyModel();
            InstantFigure_Compilation_Helper_Test(valueType, fom);
        }
        [Fact] public unsafe void InstantFigure_ExtractOperations_Test()
        {
            InstantFigure referenceType = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_FieldsAndPropertiesModel(),
                                                            "InstantFigure_MemberRubric_FieldsAndPropertiesModel_Reference");
            FieldsAndPropertiesModel fom = new FieldsAndPropertiesModel();
            object rts = InstantFigure_Compilation_Helper_Test(referenceType, fom);

            IntPtr pserial = rts.GetStructureIntPtr();
            object rts2    = referenceType.NewObject();

            pserial.ToStructure(rts2);

            byte[] bserial = rts2.GetBytes();
            object rts3    = referenceType.NewObject();

            bserial.ToStructure(rts3);

            object rts4 = referenceType.NewObject();

            rts4.StructureFrom(bserial);

            InstantFigure valueType = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_FieldsAndPropertiesModel(),
                                                        "InstantFigure_MemberRubric_FieldsAndPropertiesModel_ValueType",
                                                        FigureMode.ValueType);

            fom = new FieldsAndPropertiesModel();
            object    vts = InstantFigure_Compilation_Helper_Test(valueType, fom);
            ValueType v   = (ValueType)vts;

            IntPtr pserial2 = vts.GetStructureIntPtr();

            object    vts2 = valueType.NewObject();
            ValueType v2   = (ValueType)vts2;

            vts2 = pserial2.ToStructure(vts2);

            byte[] bserial2 = vts.GetBytes();
            object vts3     = valueType.NewObject();

            fixed(byte *b = bserial2)
            vts3 = Extractor.PointerToStructure(b, vts3);

            object vts4 = valueType.NewObject();

            vts4 = vts4.StructureFrom(pserial2);

            Marshal.FreeHGlobal((IntPtr)pserial2);
        }
        public void InstantFigures_NewFigure_Test()
        {
            str = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_FieldsAndPropertiesModel(),
                                    "InstantFigure_MemberRubric_FieldsAndPropertiesModel");
            FieldsAndPropertiesModel fom = new FieldsAndPropertiesModel();

            iRts = InstantFigure_Compilation_Helper_Test(str, fom);

            rtsq = new InstantFigures(str, "InstantSequence_Compilation_Test");

            iRtseq = rtsq.New();

            IFigure rcst = iRtseq.NewFigure();

            Assert.NotNull(rcst);
        }
        public void InstantFigures_MutatorAndAccessorByName_Test()
        {
            str = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_FieldsAndPropertiesModel(),
                                    "InstantFigure_MemberRubric_FieldsAndPropertiesModel");
            FieldsAndPropertiesModel fom = new FieldsAndPropertiesModel();

            iRts = InstantFigure_Compilation_Helper_Test(str, fom);

            rtsq = new InstantFigures(str, "InstantSequence_Compilation_Test");

            iRtseq = rtsq.New();

            iRtseq.Add(iRtseq.NewFigure());
            iRtseq[0, nameof(fom.Name)] = iRts[nameof(fom.Name)];

            Assert.Equal(iRts[nameof(fom.Name)], iRtseq[0, nameof(fom.Name)]);
        }
        public void InstantFigures_NewFigures_Test()
        {
            str = new InstantFigure(InstantFigureMocks.InstantFigure_MemberRubric_FieldsAndPropertiesModel(),
                                    "InstantFigure_MemberRubric_FieldsAndPropertiesModel");
            FieldsAndPropertiesModel fom = new FieldsAndPropertiesModel();

            iRts = InstantFigure_Compilation_Helper_Test(str, fom);

            rtsq = new InstantFigures(str, "InstantSequence_Compilation_Test");

            var rttab = rtsq.New();

            for (int i = 0; i < 10000; i++)
            {
                rttab.Add((long)int.MaxValue + i, rttab.NewFigure());
            }

            for (int i = 9999; i > -1; i--)
            {
                rttab[i] = rttab.Get(i + (long)int.MaxValue);
            }
        }
 public InstantFigureReferenceCompiler(InstantFigure instantFigure)
 {
     figure = instantFigure;
     length = members.Count;
 }
コード例 #14
0
 public InstantFigures(InstantFigure figure, bool safeThread = true) : this(figure, null, safeThread)
 {
 }
コード例 #15
0
 public InstantFigureValueTypeCompiler(InstantFigure instantFigure)
 {
     figure = instantFigure;
     length = members.Count;
 }