public void InsertSingle_JsonDocument_IsStoredAndAssignedId() { var document2Insert = @"{Name : ""Daniel"", Age : 29}"; using (var cn = TestHelper.CreateConnection()) { var insertCommand = new InsertDocumentsCommand(cn) { FullCollectionName = Constants.Collections.PersonsFullCollectionName, Documents = new[] { document2Insert } }; insertCommand.Execute(); } var inferedTemplate = new { _id = SimoId.Empty }; var refetched = TestHelper.GetDocument(document2Insert, inferedTemplate, Constants.Collections.PersonsCollectionName); Assert.AreNotEqual(SimoId.Empty, refetched._id); }
public void InsertSingle_AnonymousDocumentWithArray_ArrayItemsStored() { var document2Insert = new { Name = "Daniel", Age = 29, WorkDays = new[] { 1, 1, 1, 0, 1, 0, 0 } }; using (var cn = TestHelper.CreateConnection()) { var insertCommand = new InsertDocumentsCommand(cn) { FullCollectionName = Constants.Collections.PersonsFullCollectionName, Documents = new[] { document2Insert } }; insertCommand.Execute(); } var inferedTemplate = new { _id = SimoId.Empty, WorkDays = new int[] { } }; var refetched = TestHelper.GetDocument(document2Insert, inferedTemplate, Constants.Collections.PersonsCollectionName); CollectionAssert.AreEqual(document2Insert.WorkDays, refetched.WorkDays); }
protected ExpressionException( S.SerializationInfo info, S.StreamingContext context) : base(info, context) { }
public void InsertSingle_TypedDocumentWithNoIdContainer_IsStoredAndAssignedId() { var person2Insert = new Person { Name = "Daniel", Age = 29 }; using (var cn = TestHelper.CreateConnection()) { var insertCommand = new InsertDocumentsCommand(cn) { FullCollectionName = Constants.Collections.PersonsFullCollectionName, Documents = new[] { person2Insert } }; insertCommand.Execute(); } var inferedTemplate = new { _id = SimoId.Empty }; var refetched = TestHelper.GetDocument(person2Insert, inferedTemplate, Constants.Collections.PersonsCollectionName); Assert.AreNotEqual(SimoId.Empty, refetched._id); }
protected YanesdkException(SRS.SerializationInfo info, SRS.StreamingContext context) { }
public static byte[] GetTypeManifest(IReadOnlyCollection<byte[]> fieldNames) { IEnumerable<byte> result = new[] { (byte)fieldNames.Count }; foreach (var name in fieldNames) { var encodedLength = BitConverter.GetBytes(name.Length); result = result.Concat(encodedLength); result = result.Concat(name); } var versionTolerantHeader = result.ToArray(); return versionTolerantHeader; }
private static void ImplementGetObjectData(TypeBuilder b, Type baseType, Type[] baseInterfaces, FieldInfo interceptorField) { const MethodAttributes attributes = MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.Public; var parameterTypes = new[] { typeof(SerializationInfo), typeof(StreamingContext) }; var w = b.DefineMethod("GetObjectData", attributes, typeof(void), parameterTypes).GetILGenerator(); w.Emit(OpCodes.Ldarg_1); w.Emit(OpCodes.Ldtoken, typeof(ProxyObjectReference)); w.Emit(OpCodes.Call, s_getTypeFromHandleMethod); w.Emit(OpCodes.Callvirt, s_setTypeMethod); w.Emit(OpCodes.Ldarg_1); w.Emit(OpCodes.Ldstr, "__interceptor"); w.Emit(OpCodes.Ldarg_0); w.Emit(OpCodes.Ldfld, interceptorField); w.Emit(OpCodes.Callvirt, s_addValueMethod); w.Emit(OpCodes.Ldarg_1); w.Emit(OpCodes.Ldstr, "__baseType"); w.Emit(OpCodes.Ldstr, baseType.AssemblyQualifiedName); w.Emit(OpCodes.Callvirt, s_addValueMethod); int length = baseInterfaces.Length; w.Emit(OpCodes.Ldarg_1); w.Emit(OpCodes.Ldstr, "__baseInterfaceCount"); w.Emit(OpCodes.Ldc_I4, length); w.Emit(OpCodes.Box, typeof(int)); w.Emit(OpCodes.Callvirt, s_addValueMethod); int index = 0; foreach (var baseInterface in baseInterfaces) { w.Emit(OpCodes.Ldarg_1); w.Emit(OpCodes.Ldstr, string.Format("__baseInterface{0}", index++)); w.Emit(OpCodes.Ldstr, baseInterface.AssemblyQualifiedName); w.Emit(OpCodes.Callvirt, s_addValueMethod); } w.Emit(OpCodes.Ret); }
private static void DefineSerializationConstructor(TypeBuilder b, Type[] baseInterfaces, FieldInfo interceptorField, ConstructorBuilder constructorBuilder) { const MethodAttributes attributes = MethodAttributes.RTSpecialName | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Public; var parameterTypes = new[] { typeof(SerializationInfo), typeof(StreamingContext) }; var methodBuilder = b.DefineConstructor(attributes, CallingConventions.Standard, parameterTypes); var w = methodBuilder.GetILGenerator(); var local = w.DeclareLocal(typeof(Type)); methodBuilder.SetImplementationFlags(MethodImplAttributes.IL); w.Emit(OpCodes.Ldtoken, typeof(IMethodInterceptor)); w.Emit(OpCodes.Call, s_getTypeFromHandleMethod); w.Emit(OpCodes.Stloc, local); w.Emit(OpCodes.Ldarg_0); w.Emit(OpCodes.Call, constructorBuilder); w.Emit(OpCodes.Ldarg_0); w.Emit(OpCodes.Ldarg_1); w.Emit(OpCodes.Ldstr, "__interceptor"); w.Emit(OpCodes.Ldloc, local); w.Emit(OpCodes.Callvirt, s_getValueMethod); w.Emit(OpCodes.Castclass, typeof(IMethodInterceptor)); w.Emit(OpCodes.Stfld, interceptorField); w.Emit(OpCodes.Ret); }
private string FormatFullName() { //TODO:Format the name based on a preference; possibly something defined globally. var names = new[] { Profile.FirstName, Profile.MiddleName, Profile.LastName }; var separator = " "; return PatientFullNameFormatter ( names, separator ); }