public static int test_0_pass_bool_in_struct() { for (int i = 0; i < 8; i++) { BoolStruct s = new BoolStruct(); s.i = i; s.b1 = (i & 4) != 0; s.b2 = (i & 2) != 0; s.b3 = (i & 1) != 0; BoolStruct orig = s; if (marshal_test_bool_struct(ref s) != 0) { return(4 * i + 33); } if (s.b1 != !orig.b1) { return(4 * i + 34); } if (s.b2 != !orig.b2) { return(4 * i + 35); } if (s.b3 != !orig.b3) { return(4 * i + 36); } } return(0); }
public static bool StructWithBool(bool value) { // This method test that storage of boolean between local and struct is working // (as they could have different layout) var b = new BoolStruct(); b.b1 = !value; return(b.b1); }
public static byte AndAllMembers([DNNE.C99Type("struct bool_struct*")] BoolStructNative *pArray, int length) { bool result = true; for (int i = 0; i < length; i++) { BoolStruct managed = pArray[i].ToManaged(); result &= managed.b1 && managed.b2 && managed.b3; } return((byte)(result ? 1 : 0)); }
public void NonBlittableStructIn(bool b1, bool b2, bool b3) { var container = new BoolStruct { b1 = b1, b2 = b2, b3 = b3 }; Assert.Equal(b1 && b2 && b3, NativeExportsNE.AndBoolsRef(container)); }
public static byte AndBoolStructsIn([DNNE.C99Type("struct bool_struct**")] BoolStructMarshaller.BoolStructNative **pArray, int length) { bool result = true; for (int i = 0; i < length; i++) { BoolStruct managed = BoolStructMarshaller.ConvertToManaged((*pArray)[i]); result &= managed.b1 && managed.b2 && managed.b3; } return((byte)(result ? 1 : 0)); }
public static void Main() { unsafe { BoolStruct b = new BoolStruct(); bool * addr = (bool *)&b; Console.WriteLine("Size of BoolStruct: {0}", sizeof(BoolStruct)); Console.WriteLine("Field offsets:"); Console.WriteLine(" flag1: {0}", (bool *)&b.flag1 - addr); Console.WriteLine(" flag1: {0}", (bool *)&b.flag2 - addr); Console.WriteLine(" flag1: {0}", (bool *)&b.flag3 - addr); Console.WriteLine(" flag1: {0}", (bool *)&b.flag4 - addr); Console.WriteLine(" flag1: {0}", (bool *)&b.flag5 - addr); } }
public void NonBlittableStructWithoutAllocation() { var boolStruct = new BoolStruct { b1 = true, b2 = false, b3 = true }; NativeExportsNE.NegateBools(boolStruct, out BoolStruct boolStructNegated); Assert.Equal(!boolStruct.b1, boolStructNegated.b1); Assert.Equal(!boolStruct.b2, boolStructNegated.b2); Assert.Equal(!boolStruct.b3, boolStructNegated.b3); }
public IEnumerator <TResult> GetEnumerator() { var source = _source.GetEnumerator(); // We cannot use a simple bool here because it's modified within SameKey and iterator functions cannot take ref arguments BoolStruct sourceIncomplete = new BoolStruct { Value = source.MoveNext() }; while (sourceIncomplete.Value) { var key = _keySelector(source.Current); var group = new ListBackedEnumerable <TElement>(SameKey(key, source, sourceIncomplete).GetEnumerator()); yield return(_resultSelector(key, group)); // Make sure we move on to the next key group.Enumerate(); } }
public override async Task <BoolStruct> checkIsExistFormPublicByCondition(ExbContractConditionRequest request, ServerCallContext context) { BoolStruct boolStruct = new BoolStruct(); try { var search = Mapper.Map <ExbContractConditionRequest, ExbContractConditionModel>(request); var boolModel = await _service.checkIsExistFormPublicByCondition(search); boolStruct = Mapper.Map <BoolModel, BoolStruct>(boolModel); return(boolStruct); } catch (Exception ex) { LogHelper.Error(this, ex); throw ex; } }
public static int Main() { for (int i = 0; i < 8; i++) { bool b1 = (i & 4) != 0; bool b2 = (i & 2) != 0; bool b3 = (i & 1) != 0; bool orig_b1 = b1, orig_b2 = b2, orig_b3 = b3; if (marshal_test_ref_bool(i, ref b1, ref b2, ref b3) != 0) return 4 * i + 1; if (b1 != !orig_b1) return 4 * i + 2; if (b2 != !orig_b2) return 4 * i + 3; if (b3 != !orig_b3) return 4 * i + 4; } for (int i = 0; i < 8; i++) { BoolStruct s = new BoolStruct(); s.i = i; s.b1 = (i & 4) != 0; s.b2 = (i & 2) != 0; s.b3 = (i & 1) != 0; BoolStruct orig = s; if (marshal_test_bool_struct(ref s) != 0) return 4 * i + 33; if (s.b1 != !orig.b1) return 4 * i + 34; if (s.b2 != !orig.b2) return 4 * i + 35; if (s.b3 != !orig.b3) return 4 * i + 36; } Console.WriteLine("Success"); return 0; }
public static partial void NegateBools( [MarshalUsing(typeof(BoolStructMarshallerStateful))] BoolStruct boolStruct, [MarshalUsing(typeof(BoolStructMarshallerStateful))] out BoolStruct pBoolStructOut);
public static partial void NegateBools( BoolStruct boolStruct, out BoolStruct pBoolStructOut);
extern static int marshal_test_bool_struct(ref BoolStruct s);
private IEnumerable <TElement> SameKey(TKey key, IEnumerator <TSource> source, BoolStruct sourceIncomplete) { do { yield return(_elementSelector(source.Current)); sourceIncomplete.Value = source.MoveNext(); } while (sourceIncomplete.Value && _comparer.Equals(key, _keySelector(source.Current))); }
static extern int marshal_test_bool_struct(ref BoolStruct s);
public static int test_0_pass_bool_in_struct() { for (int i = 0; i < 8; i++) { BoolStruct s = new BoolStruct(); s.i = i; s.b1 = (i & 4) != 0; s.b2 = (i & 2) != 0; s.b3 = (i & 1) != 0; BoolStruct orig = s; if (marshal_test_bool_struct(ref s) != 0) return 4 * i + 33; if (s.b1 != !orig.b1) return 4 * i + 34; if (s.b2 != !orig.b2) return 4 * i + 35; if (s.b3 != !orig.b3) return 4 * i + 36; } return 0; }