static public void SerializeTest(object obj, string filename) { string dir = @"Temp\Serialization"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } FileStream fs = new FileStream(Path.Combine(dir, filename), FileMode.Create, FileAccess.Write); #if DATACONTRACT DataContractSerializer serializer = new DataContractSerializer(obj.GetType()); #else DataContractSerializer serializer = new DataContractSerializer( obj.GetType(), KnownTypeHelper.GetKnownTypes(), 0x7fff, // Maximum number of items in the object graph false, // Don't ignore ExtensionDataObjects true, // Preserve object references null); // The DataContract surrogate #endif serializer.WriteObject(fs, obj); object deserializedObject = null; fs.Close(); fs = new FileStream(Path.Combine(dir, filename), FileMode.Open, FileAccess.Read); deserializedObject = serializer.ReadObject(fs); AssertEquality(obj, deserializedObject); }
private void ConfigureAgatha() { var agathaContainer = new Container(Container); IoC.Container = agathaContainer; Container.RegisterInstance <IContainer> (agathaContainer); var clientConfiguration = new ClientConfiguration(agathaContainer) { AsyncRequestDispatcherImplementation = typeof(AsyncRequestDispatcher) }; KnownTypeProvider.Register(typeof(LookupValueDto)); KnownTypeHelper.RegisterNonGenericRequestsAndResponses(typeof(InfrastructureModule).Assembly); clientConfiguration.AddRequestAndResponseAssembly(typeof(GetLookupValuesRequest).Assembly); var genericsToApply = KnownTypeHelper.GetGenerics(typeof(Const).Assembly); KnownTypeHelper.RegisterGenerics(genericsToApply, typeof(InfrastructureModule).Assembly); KnownTypeHelper.RegisterKnownTypesFromIKnownTypeProviders(typeof(IMetadataItemDto).Assembly); // metadata clientConfiguration.RequestProcessorImplementation = typeof(CustomAsyncRequestProcessorProxy); clientConfiguration.Initialize(); }
private void RegisterServices() { var genericsToApply = KnownTypeHelper.GetGenerics(typeof(Const).Assembly); KnownTypeHelper.RegisterNonGenericRequestsAndResponses(typeof(ReportsModule).Assembly); KnownTypeHelper.RegisterGenerics(genericsToApply, typeof(ReportsModule).Assembly); _accessControlManager.RegisterPermissionDescriptor( new ClientPermissionDescriptor()); }
private void RegisterServices() { _accessControlManager.RegisterPermissionDescriptor( new ClientPermissionDescriptor()); _metadataService.LoadMetadataForModule(this); var genericsToApply = KnownTypeHelper.GetGenerics(typeof(Const).Assembly); KnownTypeHelper.RegisterNonGenericRequestsAndResponses(typeof(AgencyModule).Assembly); KnownTypeHelper.RegisterGenerics(genericsToApply, typeof(AgencyModule).Assembly); }
private void RegisterServices() { var genericsToApply = KnownTypeHelper.GetGenerics(typeof(Const).Assembly); KnownTypeHelper.RegisterNonGenericRequestsAndResponses(typeof(PatientModule).Assembly); KnownTypeHelper.RegisterGenerics(genericsToApply, typeof(PatientModule).Assembly); KnownTypeHelper.RegisterKnownTypesFromIKnownTypeProviders(typeof(PatientModule).Assembly); KnownTypeProvider.RegisterDerivedTypesOf <AbstractDataTransferObject>(typeof(PatientModule).Assembly.GetTypes().Where(t => !t.IsGenericType)); _container.RegisterType <ITerminologyProxy, TerminologyProxy> (); _container.RegisterType <ICdsAlertService, CdsAlertService> (); _container.RegisterType <IPatientAccessService, PatientAccessService> (); _accessControlManager.RegisterPermissionDescriptor( new ClientPermissionDescriptor()); _metadataService.LoadMetadataForModule(this); }
/// <summary> /// Configures agatha. /// </summary> /// <param name="appContainer">The app container.</param> protected virtual void ConfigureAgatha(IContainer appContainer) { var structureMapContainer = new Agatha.StructureMap.Container(appContainer); Agatha.Common.InversionOfControl.IoC.Container = structureMapContainer; var assemblyLocator = appContainer.GetInstance <IAssemblyLocator> (); var infrastructureAssemblies = assemblyLocator.LocateInfrastructureAssemblies(); var genericsToApply = new Dictionary <Type, Type> (); foreach (var infrastructureAssembly in infrastructureAssemblies) { var genericsToApplyInAssebmly = KnownTypeHelper.GetGenerics(infrastructureAssembly); foreach (var keyValuePair in genericsToApplyInAssebmly) { genericsToApply.Add(keyValuePair.Key, keyValuePair.Value); } } var serviceAssemblies = assemblyLocator.LocateWebServiceAssemblies(); foreach (var assembly in serviceAssemblies) { KnownTypeHelper.RegisterNonGenericRequestsAndResponses(assembly); KnownTypeProvider.RegisterDerivedTypesOf <AbstractDataTransferObject> (assembly.GetTypes().Where(t => !t.IsGenericType)); KnownTypeHelper.RegisterGenerics(genericsToApply, assembly); } var clientConfiguration = new ClientConfiguration(structureMapContainer) { AsyncRequestDispatcherImplementation = typeof(AsyncRequestDispatcher) }; clientConfiguration.AddRequestAndResponseAssembly(typeof(GetLookupValuesRequest).Assembly); clientConfiguration.RequestProcessorImplementation = typeof(CustomSyncRequestProcessorProxy); clientConfiguration.Initialize(); }