/// <summary> /// Builds the workspace asynchronously. /// </summary> /// <param name="workspace">The workspace to populate.</param> /// <param name="continuation">The continuation to invoke at the end of the build operation.</param> public void BuildWorkspaceAsync(AstoriaWorkspace workspace, IAsyncContinuation continuation) { ExceptionUtilities.CheckAllRequiredDependencies(this); this.CurrentWorkspace = workspace; this.Logger.WriteLine(LogLevel.Verbose, "Initializing model..."); this.InitializeModel(workspace); #if WIN8 this.clientLayerAssembly = typeof(DefaultNamespace.DefaultContainer).GetAssembly(); this.dataServiceContextType = this.clientLayerAssembly.GetType(this.DataServiceContextTypeName); ExceptionUtilities.CheckObjectNotNull(dataServiceContextType, "The DataServiceContext type was not found."); #endif this.Logger.WriteLine(LogLevel.Verbose, "Building workspace asynchronously."); AsyncHelpers.RunActionSequence( continuation, this.BuildDataService, this.UpdateEntityModel, this.InitializeResourceStringVerifiers, this.GenerateClientLayerCode, this.CompileClientLayerCode, this.BuildEntitySetResolver, this.RegisterServiceUri, this.BuildEdmModel, this.DownloadData, this.FindDataServiceContext); }
/// <summary> /// Initializes a new instance of the <see cref="JsonLightDataContextFormatApplier"/> class. /// </summary> /// <param name="workspace">The workspace.</param> /// <param name="clientCodeLayerGenerator">The ClientCodeLayerGenerator</param> public JsonLightDataContextFormatApplier(AstoriaWorkspace workspace, IClientCodeLayerGenerator clientCodeLayerGenerator) { ExceptionUtilities.CheckArgumentNotNull(workspace, "workspace"); ExceptionUtilities.CheckArgumentNotNull(clientCodeLayerGenerator, "clientCodeLayerGenerator"); this.workspace = workspace; }
/// <summary> /// Initializes a new instance of the DataServiceExecuteVerifier class. /// </summary> /// <param name="workspace">The workspace.</param> public DataServiceExecuteVerifier(AstoriaWorkspace workspace) { this.workspace = workspace; this.Logger = Logger.Null; this.IsUri = false; this.UseSendingRequestEventVerifier = true; }
/// <summary> /// Builds the workspace. /// </summary> /// <returns> /// Returns instance of a class which derives from <see cref="Workspace"/>. The instance is not fully /// initialized until the current method (Init() or variation) completes asynchronously. /// </returns> public AstoriaWorkspace BuildWorkspace() { ExceptionUtilities.CheckAllRequiredDependencies(this); var workspace = new AstoriaWorkspace(this); AsyncExecutionContext.EnqueueAsynchronousAction(cb => this.BuildWorkspaceAsync(workspace, cb)); return(workspace); }
private void InitializeModel(AstoriaWorkspace workspace) { workspace.ConceptualModel = this.initialModel ?? this.ModelGenerator.GenerateModel(); this.Logger.WriteLine(LogLevel.Verbose, "Customizing model before fixups..."); this.RaiseWorkspaceEvent(this.CustomizeModelBeforeDefaultFixups, workspace); var configurationFixup = new SetDefaultDataServiceConfigurationBehaviors(); configurationFixup.MaxProtocolVersion = this.MaxProtocolVersion; configurationFixup.Fixup(workspace.ConceptualModel); // remove higher version features based on max protocol version. new RemoveHigherVersionFeaturesFixup(this.ModelFeatureVersion).Fixup(workspace.ConceptualModel); // we keep these fixups here. They remove things that are always invalid, regardless of the provider type. new ReplaceBinaryKeysFixup().Fixup(workspace.ConceptualModel); new RemoveConcurrencyTokensFromComplexTypesFixup().Fixup(workspace.ConceptualModel); // Note this must be done after the binary fixup, as we replace binary keys with integer ones, but before the provider-specific fixup // It must also be done before getting the provider-specific fixups as they rely on CLR typing in some cases this.PrimitiveTypeResolver.ResolveProviderTypes(workspace.ConceptualModel, this.EdmDataTypeResolver); var providerFixup = this.DataProviderSettings.GetProviderSpecificModelFixup(); if (providerFixup != null) { providerFixup.Fixup(workspace.ConceptualModel); } // resolve method body IServiceMethodResolver serviceMethodResolver = this.DataProviderSettings.GetProviderSpecificServiceModelResolver(); foreach (Function f in workspace.ConceptualModel.Functions) { serviceMethodResolver.ResolveServiceMethodBody(f); } // Customizes actions to specify entitySets they are in new SetActionDefaultEntitySetFixup().Fixup(workspace.ConceptualModel); if (this.AstoriaGlobalizationFixup != null) { this.AstoriaGlobalizationFixup.Fixup(workspace.ConceptualModel); } // generate method code with potentially localized names foreach (Function f in workspace.ConceptualModel.Functions) { serviceMethodResolver.GenerateServiceMethodCode(f); } this.Logger.WriteLine(LogLevel.Verbose, "Customizing model after fixups..."); this.RaiseWorkspaceEvent(this.CustomizeModelAfterDefaultFixups, workspace); }
/// <summary> /// Builds the workspace asynchronously. /// </summary> /// <param name="workspace">The workspace to populate.</param> /// <param name="continuation">The continuation to invoke at the end of the build operation.</param> public void BuildWorkspaceAsync(AstoriaWorkspace workspace, IAsyncContinuation continuation) { ExceptionUtilities.CheckAllRequiredDependencies(this); this.CurrentWorkspace = workspace; this.Logger.WriteLine(LogLevel.Verbose, "Initializing model..."); this.InitializeModel(workspace); this.Logger.WriteLine(LogLevel.Verbose, "Building workspace asynchronously."); AsyncHelpers.RunActionSequence( continuation, this.BuildDataService, this.UpdateEntityModel, this.InitializeResourceStringVerifiers, this.GenerateClientLayerCode, this.CompileClientLayerCode, this.BuildEntitySetResolver, this.RegisterServiceUri, this.BuildEdmModel, this.DownloadData, this.FindDataServiceContext); }
/// <summary> /// Initializes a new instance of the DataServiceQueryVerifier class. /// </summary> /// <param name="workspace">The workspace.</param> public DataServiceQueryVerifier(AstoriaWorkspace workspace) { this.workspace = workspace; this.Logger = Logger.Null; this.IsAsync = true; }