예제 #1
0
        static public IsFingerEquivolentOperation CreateIsFingerEquivolentOperation(this Type item)
        {
            MethodInfoEX equals_ex_method = typeof(TypeExtensions_Finger_Create).GetStaticMethod <object, object>("EqualsEX");

            return(item.CreateDynamicMethodDelegate <IsFingerEquivolentOperation>("IsFingerEquivolent_" + item.Name, delegate(MethodBase method) {
                ILBlock body = new ILBlock();

                ILLocal obj1 = body.CreateNamedLocal(item, "obj1", method.GetTechnicalILParameter(0));
                ILLocal obj2 = body.CreateNamedLocal(item, "obj2", method.GetTechnicalILParameter(1));

                body.AddStatement(new ILIf(
                                      obj1.GetILIsNotNull()& obj2.GetILIsNotNull(),

                                      new ILBlock(delegate(ILBlock block) {
                    foreach (FieldInfo field in item.GetAllInstanceFields())
                    {
                        block.AddStatement(new ILIf(
                                               equals_ex_method.GetStaticILMethodInvokation(
                                                   obj1.GetILField(field),
                                                   obj2.GetILField(field)
                                                   ).GetILIsFalse(),
                                               new ILReturn(false)
                                               ));
                    }

                    block.AddStatement(new ILReturn(true));
                })
                                      ));

                body.AddStatement(new ILReturn(false));
                return body;
            }));
        }
예제 #2
0
        static public FingerPrintOperation CreateFingerPrintOperation(this Type item)
        {
            MethodInfoEX get_hash_code_ex_method = typeof(TypeExtensions_Finger_Create).GetStaticMethod <object>("GetHashCodeEX");

            return(item.CreateDynamicMethodDelegate <FingerPrintOperation>("FingerPrint_" + item.Name, delegate(MethodBase method){
                ILBlock body = new ILBlock();

                ILLocal obj = body.CreateNamedLocal(item, "this", method.GetTechnicalILParameter(0));
                ILLocal hash = body.CreateNamedLocal(typeof(int), "hash", 17);

                foreach (FieldInfo field in item.GetAllInstanceFields())
                {
                    body.AddStatement(
                        new ILAssign(
                            hash,
                            hash * 23 + get_hash_code_ex_method.GetStaticILMethodInvokation(obj.GetILField(field))
                            )
                        );
                }

                body.AddStatement(new ILReturn(hash));
                return body;
            }));
        }
예제 #3
0
            public bool WriteWithLiaison(object target, Interval field_update_interval, object liaison, Buffer buffer)
            {
                if (object_liaison_writer == null)
                {
                    object_liaison_writer = GetTargetType().CreateDynamicMethodDelegateWithForcedParameterTypes <ObjectLiaisonWriter>(delegate(ILValue il_target, ILValue il_field_update_interval, ILValue il_liaison, ILValue il_buffer) {
                        ILBlock block = new ILBlock();

                        ILLocal il_to_return = block.CreateNamedLocal(typeof(bool), "to_return");

                        block.AddStatements(
                            target_serializer_prop_groups
                            .Convert(g => g.GenerateWrite(il_target, il_field_update_interval, type_update_interval, il_liaison, il_to_return, il_buffer))
                            );

                        block.AddStatement(new ILReturn(il_to_return));
                        return(block);
                    }, GetTargetType(), typeof(Interval), GetLiaisonType(), typeof(Buffer));
                }

                return(object_liaison_writer(target, field_update_interval, liaison, buffer));
            }