···13361336 #region Interaction
1337133713381338 /// <summary>
13391339- /// Allows you to prevent the Prexonite VM from performing type conversions on the PValue object.
13401340- /// </summary>
13411341- /// <value>A boolean value that indicates whether the type lock is in action or not.</value>
13421342- public bool IsTypeLocked { get; set; }
13431343-13441344- /// <summary>
13451339 /// Indicates whether the PValue object contains a null reference or not.
13461340 /// </summary>
13471341 /// <value>True if <see cref = "Value" /> is null; false otherwise.</value>
+24-91
Prexonite/Types/ObjectPType.cs
···570570 for (var i = 0; i < cargs.Length; i++)
571571 {
572572 var arg = sargs[i];
573573- if (!(arg.IsTypeLocked || arg.IsNull)) //Neither Type-locked nor null
573573+ if (!(arg.IsNull)) //Neither Type-locked nor null
574574 {
575575 var P = parameters[i].ParameterType;
576576 var A = arg.ClrType;
···600600 }
601601 catch (TargetInvocationException exc)
602602 {
603603- if (exc.InnerException is PrexoniteRuntimeException {InnerException: {} inner} innerRt)
603603+ if (exc.InnerException is PrexoniteRuntimeException {InnerException: {} inner})
604604 throw inner;
605605 throw;
606606 }
···614614 else
615615 {
616616 var arg = cond.Args[0];
617617- if (!(arg.IsTypeLocked || arg.IsNull)) //Neither Type-locked nor null
617617+ if (!(arg.IsNull)) //Neither Type-locked nor null
618618 {
619619 var paramTy = field.FieldType;
620620 var argTy = arg.ClrType;
···786786 private static bool _member_filter(MemberInfo candidate, object arg)
787787 {
788788 var cond = (call_conditions) arg;
789789- //Criteria No.1: The members name (may be supressed)
789789+ //Criteria No.1: The members name (may be suppressed)
790790 if (
791791 !(cond.IgnoreId ||
792792 candidate.Name.Equals(cond.Id, StringComparison.OrdinalIgnoreCase)))
···796796 //Set = min 1 Argument
797797 if (cond.Call == PCall.Set && cond.Args.Length == 0)
798798 return false;
799799- if (candidate is FieldInfo)
799799+ return candidate switch
800800 {
801801 //Get+Field = 0 Parameters, Set+Field = 1 Parameter
802802- if (cond.Call == PCall.Get)
803803- {
804804- if (cond.Args.Length == 0)
805805- return true;
806806- else
807807- return false;
808808- }
809809- else
810810- {
811811- if (cond.Args.Length == 1)
812812- {
813813- //Ensure that type-locked values are acceptable
814814- if (cond.Args[0].IsTypeLocked)
815815- {
816816- var P = (candidate as FieldInfo).FieldType;
817817- var A = cond.Args[0].ClrType;
818818- if (!(P.Equals(A) || P.IsAssignableFrom(A)))
819819- //Neiter Equal nor assignable
820820- return false;
821821- }
822822-823823- return true;
824824- }
825825- else
826826- return false;
827827- }
828828- }
829829- else if (candidate is PropertyInfo)
830830- {
831831- var property = candidate as PropertyInfo;
832832- if (cond.Call == PCall.Get)
833833- {
834834- if (!property.CanRead)
835835- return false;
836836- else
837837- return _method_filter(property.GetGetMethod(), cond);
838838- }
839839- else //cond.Call == PCall.Set
840840- {
841841- if (!property.CanWrite)
842842- return false;
843843- else
844844- return _method_filter(property.GetSetMethod(), cond);
845845- }
846846- }
847847- else if (candidate is MethodInfo)
848848- {
849849- return _method_filter(candidate as MethodInfo, cond);
850850- }
851851- else if (candidate is EventInfo)
852852- {
853853- var info = candidate as EventInfo;
854854- if (cond.Directive == "" ||
855855- Engine.DefaultStringComparer.Compare(cond.Directive, "Raise") == 0)
856856- {
857857- return _method_filter(info.GetRaiseMethod(), cond);
858858- }
859859- else if (Engine.DefaultStringComparer.Compare(cond.Directive, "Add") == 0)
860860- {
861861- return _method_filter(info.GetAddMethod(), cond);
862862- }
863863- else if (Engine.DefaultStringComparer.Compare(cond.Directive, "Remove") == 0)
864864- {
865865- return _method_filter(info.GetRemoveMethod(), cond);
866866- }
867867- else
868868- return false;
869869- }
870870- else //Do not support other members than fields, properties, methods and events
871871- return false;
802802+ FieldInfo when cond.Call == PCall.Get => cond.Args.Length == 0,
803803+ FieldInfo => cond.Args.Length == 1,
804804+ PropertyInfo property when cond.Call == PCall.Get =>
805805+ property.CanRead && _method_filter(property.GetGetMethod(), cond),
806806+ //cond.Call == PCall.Set
807807+ PropertyInfo property => property.CanWrite && _method_filter(property.GetSetMethod(), cond),
808808+ MethodInfo method => _method_filter(method, cond),
809809+ EventInfo @event when cond.Directive == "" ||
810810+ Engine.DefaultStringComparer.Compare(cond.Directive, "Raise") == 0 =>
811811+ _method_filter(@event.GetRaiseMethod(), cond),
812812+ EventInfo @event when Engine.DefaultStringComparer.Compare(cond.Directive, "Add") == 0 =>
813813+ _method_filter( @event.GetAddMethod(), cond),
814814+ EventInfo @event when Engine.DefaultStringComparer.Compare(cond.Directive, "Remove") == 0 =>
815815+ _method_filter(@event.GetRemoveMethod(), cond),
816816+ _ => false
817817+ };
872818 }
873819874820 /// <summary>
···906852 if (cond.Args.Length != parameters.Length)
907853 return false;
908854909909- //Criteria No.2: All Type-Locked arguments must match without a conversion
910910- for (var i = 0; i < parameters.Length; i++)
911911- {
912912- if (cond.Args[i].IsTypeLocked)
913913- {
914914- var P = parameters[i].ParameterType;
915915- var A = cond.Args[i].ClrType;
916916- if (!(P == A || P.IsAssignableFrom(A))) //Neither Equal nor assignable
917917- return false;
918918- }
919919- }
920920-921855 //optional Criteria No.3: Return types must match
922922- if (cond.returnType != null && method is MethodInfo)
856856+ if (cond.returnType != null && method is MethodInfo methodInfo)
923857 {
924924- var methodEx = (MethodInfo) method;
925925- if (!(methodEx.ReturnType == cond.returnType ||
926926- cond.returnType.IsAssignableFrom(methodEx.ReturnType)))
858858+ if (!(methodInfo.ReturnType == cond.returnType ||
859859+ cond.returnType.IsAssignableFrom(methodInfo.ReturnType)))
927860 {
928861 return false;
929862 }