public async Task IWireMockAdminApi_PostMappingAsync() { // Arrange var server = WireMockServer.StartWithAdminInterface(); var api = RestClient.For <IWireMockAdminApi>(server.Urls[0]); // Act var model = new MappingModel { Request = new RequestModel { Path = "/1" }, Response = new ResponseModel { Body = "txt", StatusCode = 200 }, Priority = 500, Title = "test" }; var result = await api.PostMappingAsync(model); // Assert Check.That(result).IsNotNull(); Check.That(result.Status).IsNotNull(); Check.That(result.Guid).IsNotNull(); var mapping = server.Mappings.Single(m => m.Priority == 500); Check.That(mapping).IsNotNull(); Check.That(mapping.Title).Equals("test"); server.Stop(); }
public string EditMapping(MappingModel model) { string table_Name = model.Table_Name; string FormID = model.FormID; int Approved = model.Approved; int MappingFormID = model.MappingFormID; string Message = "OK"; using (SysContext db = new SysContext()) { try { fl_MappingForm entity_fl_MappingForm = db.fl_MappingForm.Single(d => d.MappingFormID == MappingFormID); if (entity_fl_MappingForm != null) { entity_fl_MappingForm.FormNo = FormID; entity_fl_MappingForm.Table_Name = table_Name; entity_fl_MappingForm.Approved = Approved; entity_fl_MappingForm.ModifiedUser = LoginInfo.UserID; entity_fl_MappingForm.ModifiedTime = DateTime.Now; entity_fl_MappingForm.ResetUpdated(); db.SaveChanges(); } } catch { Message = "Error"; } } return(Message); }
private MappingModel GetAuthMapping() { var mapping = new MappingModel { Guid = Guid.Parse("425db3ef-06ca-4a69-b5c9-a9384cabc34e"), Title = "Post Authentication", Request = new RequestModel { Methods = new[] { "Post" }, Path = JObject.Parse( "{\"Matchers\": [{\"Name\": \"WildcardMatcher\",\"Pattern\": \"/login/v1/oauth2/token\",\"IgnoreCase\": true}]}") }, Response = new ResponseModel { StatusCode = 200, BodyAsJson = new Token { AccessToken = "access_token", ExpiresIn = "20", TokenType = "token_type" } } }; return(mapping); }
public void Post(MappingModel model) { try { if (string.IsNullOrWhiteSpace(model.MappingId)) { _mappingManager.CreateMapping(model); } else { _mappingManager.UpdateMapping(model); } } catch (WebException exception) { LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception); throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exception.Message + " Please check your credentials")); } catch (Exception exception) { LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception); throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exception.Message)); } }
public HttpResponseMessage SaveRedirect(MappingModel model) { var map = new Mapping(); map.SourceUrl = model.SourceUrl.Trim(); if (!string.IsNullOrEmpty(model.TargetUrl)) { map.TargetUrl = model.TargetUrl; } else if (model.TargetTabId > 0) { map.TargetTabId = model.TargetTabId; map.TargetUrl = DotNetNuke.Common.Globals.NavigateURL(map.TargetTabId, PortalSettings, ""); } else { // keep giving 404 map.EnableLogging = false; } if (map != null) { map.UseRegex = false; var cfg = RedirectConfig.Instance; cfg.Mappings.Add(map); cfg.ToFile(Common.RedirectConfigFile()); RedirectConfig.Reload(PortalSettings.PortalId); } // set handledon/handledby in table RedirectController.SetHandledUrl(model.SourceUrl); return(Request.CreateResponse(HttpStatusCode.OK, new {})); }
/// <summary> /// /// </summary> /// <param name="templateMapping"></param> /// <returns></returns> private MappingModel MapAddMappingModel(TemplateMapping templateMapping) { var addCmsMappingModel = new MappingModel { GcTemplate = new GcTemplateModel { Id = templateMapping.GcTemplate.GcTemplateId, }, CmsTemplate = new CmsTemplateModel { Id = templateMapping.CmsTemplate.TemplateId, }, MappingTitle = templateMapping.MappingTitle, DefaultLocationId = templateMapping.DefaultLocationId, DefaultLocationTitle = templateMapping.DefaultLocationTitle }; if (templateMapping.FieldMappings != null) { foreach (var fieldMapping in templateMapping.FieldMappings) { addCmsMappingModel.FieldMappings.Add(new FieldMappingModel { CmsTemplateId = fieldMapping.CmsField.TemplateField.FieldId, GcFieldId = fieldMapping.GcField.Id, GcFieldName = fieldMapping.GcField.Name }); } } return(addCmsMappingModel); }
public TFSSettingViewModel(ITFSSettingView view, IUriHelpView uriHelpView) : base(view) { if (uriHelpView == null) { throw new ArgumentNullException("uriHelpView"); } this.uriHelpView = uriHelpView; this.uriHelpCommand = new DelegateCommand(OpenUriHelpCommandExcute); this.propertyMappingCollection = new PropertyMappingDictionary(); this.tfsFields = new ObservableCollection <TFSField>(); this.bugFilterFields = new ObservableCollection <TFSField>(); this.priorityValues = new ObservableCollection <CheckString>(); PropertyDescriptorCollection propertyDescriptorCollection = TypeDescriptor.GetProperties(typeof(Bug)); foreach (PropertyDescriptor propertyDescriptor in propertyDescriptorCollection) { if (propertyDescriptor.Name == "Type") { continue; } var mapping = new MappingModel(propertyDescriptor.Name); this.propertyMappingCollection.Add(mapping); AddWeakEventListener(mapping, PropertyMappingModelPropertyChanged); } ClearMappingData(); }
private ResponseMessage MappingsPost(RequestMessage requestMessage) { try { MappingModel mappingModel = requestMessage.Body != null?JsonConvert.DeserializeObject <MappingModel>(requestMessage.Body) : ((JObject)requestMessage.BodyAsJson).ToObject <MappingModel>(); DeserializeAndAddOrUpdateMapping(mappingModel); } catch (ArgumentException a) { Log.Error("HttpStatusCode set to 400", a); return(new ResponseMessage { StatusCode = 400, Body = a.Message }); } catch (Exception e) { Log.Error("HttpStatusCode set to 500", e); return(new ResponseMessage { StatusCode = 500, Body = e.ToString() }); } return(new ResponseMessage { StatusCode = 201, Body = "Mapping added" }); }
public void GeneralSettingDocumentTest() { MappingModel mappingModel = new MappingModel("ID"); Assert.AreEqual("ID", mappingModel.Key); Assert.AreEqual(string.Empty, mappingModel.Value); }
private void MatchTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { TreeView treeView = (TreeView)sender; MatchTreeNode treeItem = (MatchTreeNode)treeView.SelectedItem; ((MatchTree)DataContext).SelectedNode = treeItem; MappingModel MappingModel = ((MatchTree)treeItem.Root).MappingModel; // Redraw both trees. Use property name like "CanMatch" or String.Empty for all properties (but it does not work because selection is also updated) MappingModel.SourceTree.NotifyAllOnPropertyChanged("CanMatch"); MappingModel.TargetTree.NotifyAllOnPropertyChanged("CanMatch"); MappingModel.SourceTree.NotifyAllOnPropertyChanged("IsMatched"); MappingModel.TargetTree.NotifyAllOnPropertyChanged("IsMatched"); this.UpdateLayout(); this.UpdateLayout(); treeView.UpdateLayout(); treeView.UpdateLayout(); // treeView.Items.Refresh(); // Error: stack overflow //GetBindingExpression(TreeView.ItemsSourceProperty).UpdateTarget(); //ForceUIToUpdate(); //this.OnPropertyChanged("IsSelected"); }
public string AddMapping(MappingModel model) { string table_Name = model.Table_Name; string FormID = model.FormID; int Approved = model.Approved; string Message = "OK"; using (SysContext db = new SysContext()) { System.Data.Entity.DbContextTransaction tran = db.Database.BeginTransaction(); try { fl_MappingForm entity_fl_MappingForm = new fl_MappingForm(); entity_fl_MappingForm.FormNo = FormID; entity_fl_MappingForm.Table_Name = table_Name; entity_fl_MappingForm.Approved = Approved; entity_fl_MappingForm.ApprovedDate = DateTime.Now; entity_fl_MappingForm.TemplateUrl = ""; entity_fl_MappingForm.CreatedUser = LoginInfo.UserID; entity_fl_MappingForm.ModifiedUser = LoginInfo.UserID; entity_fl_MappingForm.ResetCreated(); db.fl_MappingForm.Add(entity_fl_MappingForm); db.SaveChanges(); tran.Commit(); } catch { tran.Rollback(); Message = "Error"; } } return(Message); }
public IHttpActionResult Post(MappingModel model) { try { if (string.IsNullOrWhiteSpace(model.MappingId)) { _mappingManager.CreateMapping(model); } else { _mappingManager.UpdateMapping(model); } return(Ok()); } catch (WebException exception) { LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception); return(BadRequest(exception.Message + " Please check your credentials")); } catch (Exception exception) { LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception); return(BadRequest(exception.Message)); } }
/// <summary> /// /// </summary> /// <param name="model"></param> public void UpdateMapping(MappingModel model) { var template = FactoryService.Services.TemplateService.GetSingleTemplate(model.GcTemplate.Id); var project = FactoryService.Services.ProjectsService.GetSingleProject(template.Data.ProjectId.ToString()); var templateMapping = new TemplateMapping { MappingId = model.MappingId, MappingTitle = model.MappingTitle, DefaultLocationId = model.DefaultLocationId, LastUpdatedDate = template.Data.Updated.ToString(), GcProjectId = project.Data.Id.ToString(), GcProjectName = project.Data.Name, CmsTemplate = new CmsTemplate { TemplateId = model.CmsTemplate.Id }, GcTemplate = new GcTemplate { GcTemplateId = template.Data.Id.ToString(), GcTemplateName = template.Data.Name }, }; var fieldMappings = ConvertToFieldMappings(model.FieldMappings); templateMapping.FieldMappings = fieldMappings; FactoryRepository.Repositories.MappingRepository.UpdateMapping(templateMapping); }
/// <summary> /// Creates a new Repository with the table name and maps passed directly into the contructor. /// </summary> /// <param name="dbAdapter">DbAdapter class for the database being used</param> /// <param name="tableName">Name of the table</param> /// <param name="maps">List of maps for this tabe</param> public DbRepository(IDbAdapter dbAdapter, string tableName, IEnumerable <IMap> maps) { DbAdapter = dbAdapter; ConnectionString = dbAdapter.ConnectionString; TableName = tableName; Mappings = new MappingModel <T>(maps); }
/// <summary> /// Creates a new Repository using an EntityMap to define the database mapping. /// </summary> /// <param name="dbAdapter">DbAdapter class for the database being used</param> /// <param name="entityMap">Entity map class used to define the mapping for this repository</param> public DbRepository(IDbAdapter dbAdapter, EntityMap <T> entityMap) { DbAdapter = dbAdapter; ConnectionString = dbAdapter.ConnectionString; TableName = entityMap.TableName; Mappings = new MappingModel <T>(entityMap); }
public List <MappingModel> GetMappingModel() { var mappings = MappingRepository.GetMappings(); var model = new List <MappingModel>(); foreach (var templateMapping in mappings) { var mappingModel = new MappingModel { GcProject = new GcProjectModel { Name = templateMapping.GcProjectName }, GcTemplate = new GcTemplateModel { Id = templateMapping.GcTemplate.GcTemplateId, Name = templateMapping.GcTemplate.GcTemplateName, }, CmsTemplate = new CmsTemplateModel { Name = templateMapping.CmsTemplate.TemplateName, }, MappingId = templateMapping.MappingId, MappingTitle = templateMapping.MappingTitle, LastMappedDateTime = templateMapping.LastMappedDateTime, LastUpdatedDate = templateMapping.LastUpdatedDate, }; model.Add(mappingModel); } foreach (var mapping in model) { try { var template = GetGcTemplateEntity(mapping.GcTemplate.Id); if (template == null) { mapping.LastUpdatedDate = "Removed from GatherContent"; } else { var gcUpdateDate = ConvertMsecToDate((double)template.Data.Updated); var dateFormat = AccountSettings.DateFormat; if (string.IsNullOrEmpty(dateFormat)) { dateFormat = Constants.DateFormat; } mapping.LastUpdatedDate = gcUpdateDate.ToString(dateFormat); } } catch (Exception) { mapping.LastUpdatedDate = "Removed from GatherContent"; } } return(model); }
private async Task AddMapping(MappingModel model) { var api = RestClient.For <IWireMockAdminApi>(new Uri(_settings.OdsApiWireMockBaseUrl)); var result = await api.PostMappingAsync(model); result.Status.Should().Be("Mapping added"); _context[ScenarioContextKeys.MappingAdded] = true; }
private Guid?ConvertMappingAndRegisterAsRespondProvider(MappingModel mappingModel, Guid?guid = null, string path = null) { Check.NotNull(mappingModel, nameof(mappingModel)); Check.NotNull(mappingModel.Request, nameof(mappingModel.Request)); Check.NotNull(mappingModel.Response, nameof(mappingModel.Response)); var requestBuilder = InitRequestBuilder(mappingModel.Request, true); if (requestBuilder == null) { return(null); } var responseBuilder = InitResponseBuilder(mappingModel.Response); var respondProvider = Given(requestBuilder, mappingModel.SaveToFile == true); if (guid != null) { respondProvider = respondProvider.WithGuid(guid.Value); } else if (mappingModel.Guid != null && mappingModel.Guid != Guid.Empty) { respondProvider = respondProvider.WithGuid(mappingModel.Guid.Value); } if (path != null) { respondProvider = respondProvider.WithPath(path); } if (!string.IsNullOrEmpty(mappingModel.Title)) { respondProvider = respondProvider.WithTitle(mappingModel.Title); } if (mappingModel.Priority != null) { respondProvider = respondProvider.AtPriority(mappingModel.Priority.Value); } if (mappingModel.Scenario != null) { respondProvider = respondProvider.InScenario(mappingModel.Scenario); respondProvider = respondProvider.WhenStateIs(mappingModel.WhenStateIs); respondProvider = respondProvider.WillSetStateTo(mappingModel.SetStateTo); } if (mappingModel.Webhook?.Request != null) { respondProvider = respondProvider.WithWebhook(WebhookMapper.Map(mappingModel.Webhook)); } respondProvider.RespondWith(responseBuilder); return(respondProvider.Guid); }
private static async Task AddMapping(MappingModel model) { model.Guid = Guid.NewGuid(); model.Priority = 10; var api = RestClient.For <IWireMockAdminApi>(new Uri(WireMockBaseUrl)); var result = await api.PostMappingAsync(model).ConfigureAwait(false); result.Status.Should().Be("Mapping added"); }
public HttpResponseMessage SaveMapping(MappingModel model) // string id, bool useRegex, string sourceUrl, string targetUrl, int targetTabId) { var map = RedirectConfig.Instance.Mappings.FirstOrDefault(m => m.Id == model.Id); if (!string.IsNullOrEmpty(model.Id) && map == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } if (map == null && string.IsNullOrEmpty(model.Id)) { map = new Mapping(); map.Id = Guid.NewGuid().ToString(); RedirectConfig.Instance.Mappings.Add(map); } map.StatusCode = model.StatusCode; map.SourceUrl = model.SourceUrl.Trim(); map.UseRegex = model.UseRegex; map.EnableLogging = model.EnableLogging; if (!string.IsNullOrEmpty(model.TargetUrl)) { map.TargetTabId = Null.NullInteger; map.TargetUrl = model.TargetUrl; } else if (model.TargetTabId > 0) { map.TargetTabId = model.TargetTabId; map.TargetUrl = DotNetNuke.Common.Globals.NavigateURL(map.TargetTabId, PortalSettings, ""); } else if (model.TargetTabId == -1) // matches with number in js file { map.TargetTabId = model.TargetTabId; map.TargetUrl = ""; } else if (model.TargetTabId == -2) // matches with number in js file, meaning it needs to be deleted { // remove mapping RedirectConfig.Instance.Mappings.Remove(map); map = null; } RedirectConfig.Instance.ToFile(Common.RedirectConfigFile()); RedirectConfig.Reload(PortalSettings.PortalId); // set handledon/handledby in table if (!model.UseRegex) { RedirectController.SetHandledUrl(model.SourceUrl); } return(Request.CreateResponse(HttpStatusCode.OK, map == null ? null : new MappingModel(map))); }
private ResponseMessage MappingPut(RequestMessage requestMessage) { Guid guid = Guid.Parse(requestMessage.Path.TrimStart(AdminMappings.ToCharArray())); MappingModel mappingModel = requestMessage.Body != null?JsonConvert.DeserializeObject <MappingModel>(requestMessage.Body) : ((JObject)requestMessage.BodyAsJson).ToObject <MappingModel>(); DeserializeAndAddOrUpdateMapping(mappingModel, guid); return(new ResponseMessage { Body = "Mapping added or updated" }); }
private Guid?DeserializeAndAddOrUpdateMapping(MappingModel mappingModel, Guid?guid = null, string path = null) { Check.NotNull(mappingModel, nameof(mappingModel)); Check.NotNull(mappingModel.Request, nameof(mappingModel.Request)); Check.NotNull(mappingModel.Response, nameof(mappingModel.Response)); var requestBuilder = InitRequestBuilder(mappingModel.Request, true); if (requestBuilder == null) { return(null); } var responseBuilder = InitResponseBuilder(mappingModel.Response); var respondProvider = Given(requestBuilder); if (guid != null) { respondProvider = respondProvider.WithGuid(guid.Value); } else if (mappingModel.Guid != null && mappingModel.Guid != Guid.Empty) { respondProvider = respondProvider.WithGuid(mappingModel.Guid.Value); } if (path != null) { respondProvider = respondProvider.WithPath(path); } if (!string.IsNullOrEmpty(mappingModel.Title)) { respondProvider = respondProvider.WithTitle(mappingModel.Title); } if (mappingModel.Priority != null) { respondProvider = respondProvider.AtPriority(mappingModel.Priority.Value); } if (mappingModel.Scenario != null) { respondProvider = respondProvider.InScenario(mappingModel.Scenario); respondProvider = respondProvider.WhenStateIs(mappingModel.WhenStateIs); respondProvider = respondProvider.WillSetStateTo(mappingModel.SetStateTo); } respondProvider.RespondWith(responseBuilder); return(respondProvider.Guid); }
private void ShowMappingWindow(MappingModel mappingModel) { XmlElement newMapping = mConfiguration.ConfigXml.CreateElement(MappingName); IElementConfiguration elementConfiguration = new ElementConfiguration(mConfiguration, mappingModel.Node, newMapping); ElementWindow elementWindow = new ElementWindow(elementConfiguration, DefinitionFactory.Create(MappingDescriptor.Mapping, elementConfiguration), WindowSizeLocationFactory.Create(MappingDescriptor.Mapping), new AddSaveStrategy <MappingModel>(mappingModel, model => Mappings.Add(model), newMapping)); mMessageBoxService.ShowWindow(elementWindow); }
public IActionResult Index(HomeModel model) { MappingModel mapModel = new MappingModel(); var circumferencePoints = GetList(model.latitude, model.longitude, model.distance); Coordinates coordinates = new Coordinates(); coordinates.lat = model.latitude; coordinates.lng = model.longitude; var populatedCoordinates = PopulatedCoordinates(circumferencePoints, false, coordinates); mapModel.CordinateList = Newtonsoft.Json.JsonConvert.SerializeObject(populatedCoordinates); return(View(mapModel)); }
public void PropertiesWithNotification() { MappingModel mappingModel = new MappingModel("ID"); AssertHelper.PropertyChangedEvent(mappingModel, x => x.Value, () => mappingModel.Value = "ID"); Assert.AreEqual("ID", mappingModel.Value); mappingModel.Value = null; Assert.AreEqual("ID", mappingModel.Value); AssertHelper.PropertyChangedEvent(mappingModel, x => x.Value, () => mappingModel.Value = string.Empty); Assert.AreEqual(string.Empty, mappingModel.Value); }
public static Mapping ToNewDbObject(this MappingModel mapping) { return(new Mapping { ApplicationId = mapping.ApplicationId, EnvironmentId = mapping.EnvironmentId, ParameterId = mapping.ParameterId, RegionId = mapping.RegionId, ServerId = mapping.ServerId, SuiteId = mapping.SuiteId, MappingId = mapping.MappingId }); }
public void XNamespace_returns_element_namespace_if_element_not_null() { var element = new XElement("{urn:tempuri}element"); var modelManager = new Mock<ModelManager>(null, null).Object; var modelProvider = new Mock<XmlModelProvider>().Object; var entityDesignArtifactMock = new Mock<EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider); entityDesignArtifactMock.Setup(a => a.SchemaVersion).Returns(EntityFrameworkVersion.Version3); using (var mappingModel = new MappingModel(entityDesignArtifactMock.Object, element)) { Assert.Same(element.Name.Namespace, mappingModel.XNamespace); } }
/// <summary> /// Creates a new Repository using attributes to define the database mapping. /// All non-virtual properties with public getters and setters will be mapped /// unless overridden with an attribute. /// </summary> /// <param name="dbAdapter">DbAdapter class for the database being used</param> /// <param name="overrideTableName">Overrides the table name generated from the object name or the table attribute.</param> /// <param name="ignoreObjectMaps">Sets if properties that end with _Object or _Objects will be ignored by the automatic mapping</param> public DbRepository(IDbAdapter dbAdapter, string overrideTableName = null, bool ignoreObjectMaps = true) { DbAdapter = dbAdapter; ConnectionString = dbAdapter.ConnectionString; if (string.IsNullOrWhiteSpace(overrideTableName)) { TableName = GetTableName(); } else { TableName = overrideTableName; } Mappings = new MappingModel <T>(ignoreObjectMaps); }
public void ReadStaticMappingAndAddOrUpdate([NotNull] string path) { Check.NotNull(path, nameof(path)); string filenameWithoutExtension = Path.GetFileNameWithoutExtension(path); MappingModel mappingModel = JsonConvert.DeserializeObject <MappingModel>(FileHelper.ReadAllText(path)); if (Guid.TryParse(filenameWithoutExtension, out Guid guidFromFilename)) { DeserializeAndAddOrUpdateMapping(mappingModel, guidFromFilename, path); } else { DeserializeAndAddOrUpdateMapping(mappingModel, null, path); } }
private static async Task SendModel(MappingModel model, ScenarioContext context, string mappingKey) { await AddMapping(model).ConfigureAwait(false); if (!context.ContainsKey(mappingKey)) { context[mappingKey] = new List <Guid>(); } if (context[mappingKey] is List <Guid> guidList) { if (model.Guid != null) { guidList.Add(model.Guid.Value); } } }
public void WireMockServer_WithMappingAsModel_Should_Add_Mapping() { // Arrange var guid = Guid.NewGuid(); var pattern = "hello wiremock"; var path = "/foo"; var response = "OK"; var mapping = new MappingModel { Guid = guid, Request = new RequestModel { Path = path, Body = new BodyModel { Matcher = new MatcherModel { Name = "ExactMatcher", Pattern = pattern } } }, Response = new ResponseModel { Body = response, StatusCode = 201 } }; var server = WireMockServer.Start(); // Act server.WithMapping(mapping); // Assert server.MappingModels.Should().HaveCount(1).And.Contain(m => m.Guid == guid && //((PathModel)m.Request.Path).Matchers.OfType<WildcardMatcher>().First().GetPatterns().First() == "/foo*" // m.Request.Body.Matchers.OfType<ExactMatcher>().First().GetPatterns().First() == pattern && m.Response.Body == response && (int)m.Response.StatusCode == 201 ); server.Stop(); }
public void XNamespace_returns_root_namespace_if_element_null() { var tmpElement = new XElement("{http://schemas.microsoft.com/ado/2009/11/mapping/cs}Schema"); var modelManager = new Mock<ModelManager>(null, null).Object; var modelProvider = new Mock<XmlModelProvider>().Object; var enityDesignArtifiact = new Mock<EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider) { CallBase = true }.Object; enityDesignArtifiact.SetXObject( XDocument.Parse("<Edmx xmlns=\"http://schemas.microsoft.com/ado/2009/11/edmx\" />")); using (var mappingModel = new MappingModel(enityDesignArtifiact, tmpElement)) { mappingModel.SetXObject(null); Assert.Equal("http://schemas.microsoft.com/ado/2009/11/mapping/cs", mappingModel.XNamespace); // resetting the element is required for clean up mappingModel.SetXObject(tmpElement); } }
public virtual void ProcessCollection(MappingModel.Collections.CollectionMapping mapping) { }
public virtual void Visit(MappingModel.Collections.CollectionMapping collectionMapping) { }
protected override void OnChildDeleted(EFContainer efContainer) { if (efContainer == _designerInfoRoot) { _designerInfoRoot = null; } else if (efContainer == _mappingModel) { _mappingModel = null; } else if (efContainer == _conceptualEntityModel) { _conceptualEntityModel = null; } else if (efContainer == _storageEntityModel) { _storageEntityModel = null; } base.OnChildDeleted(efContainer); }
internal EFRuntimeModelRoot CreateRuntimeModelRoot(XElement runtimeModelRoot) { if (runtimeModelRoot.Name.LocalName == BaseEntityModel.ElementName && CheckForCorrectNamespace(runtimeModelRoot, SchemaManager.GetCSDLNamespaceNames(), false)) { if (_conceptualEntityModel != null) { _conceptualEntityModel.Dispose(); } _conceptualEntityModel = new ConceptualEntityModel(this, runtimeModelRoot); return _conceptualEntityModel; } else if (runtimeModelRoot.Name.LocalName == BaseEntityModel.ElementName && CheckForCorrectNamespace(runtimeModelRoot, SchemaManager.GetSSDLNamespaceNames(), false)) { if (_storageEntityModel != null) { _storageEntityModel.Dispose(); } _storageEntityModel = new StorageEntityModel(this, runtimeModelRoot); return _storageEntityModel; } else if (runtimeModelRoot.Name.LocalName == MappingModel.ElementName && CheckForCorrectNamespace(runtimeModelRoot, SchemaManager.GetMSLNamespaceNames(), false)) { if (_mappingModel != null) { _mappingModel.Dispose(); } _mappingModel = new MappingModel(this, runtimeModelRoot); return _mappingModel; } else { //Debug.Fail("Unexpected runtime model root"); return null; } }
internal override void Parse(ICollection<XName> unprocessedElements) { State = EFElementState.ParseAttempted; var path = Uri.LocalPath; var lastdot = path.LastIndexOf('.'); var extension = Uri.LocalPath.Substring(lastdot, path.Length - lastdot); if (extension.EndsWith(ExtensionMsl, StringComparison.OrdinalIgnoreCase)) { _mappingModel = new MappingModel(this, XDocument.Root); } else if (extension.EndsWith(ExtensionCsdl, StringComparison.OrdinalIgnoreCase)) { _conceptualEntityModel = new ConceptualEntityModel(this, XDocument.Root); } else if (extension.EndsWith(ExtensionSsdl, StringComparison.OrdinalIgnoreCase)) { _storageEntityModel = new StorageEntityModel(this, XDocument.Root); } else if (GetFileExtensions().Contains(extension)) { if (_designerInfoRoot != null) { _designerInfoRoot.Dispose(); _designerInfoRoot = null; } if (_storageEntityModel != null) { _storageEntityModel.Dispose(); _storageEntityModel = null; } if (_mappingModel != null) { _mappingModel.Dispose(); _mappingModel = null; } if (_conceptualEntityModel != null) { _conceptualEntityModel.Dispose(); _conceptualEntityModel = null; } // convert the xlinq tree to our model foreach (var elem in XObject.Document.Elements()) { ParseSingleElement(unprocessedElements, elem); } } if (_designerInfoRoot != null) { _designerInfoRoot.Parse(unprocessedElements); } if (_conceptualEntityModel != null) { _conceptualEntityModel.Parse(unprocessedElements); } if (_storageEntityModel != null) { _storageEntityModel.Parse(unprocessedElements); } if (_mappingModel != null) { _mappingModel.Parse(unprocessedElements); } State = EFElementState.Parsed; }
protected override void Dispose(bool disposing) { try { if (disposing) { if (_designerInfoRoot != null) { _designerInfoRoot.Dispose(); _designerInfoRoot = null; } if (_mappingModel != null) { _mappingModel.Dispose(); _mappingModel = null; } if (_conceptualEntityModel != null) { _conceptualEntityModel.Dispose(); _conceptualEntityModel = null; } if (_storageEntityModel != null) { _storageEntityModel.Dispose(); _storageEntityModel = null; } if (DiagramArtifact != null) { ModelManager.ClearArtifact(DiagramArtifact.Uri); DiagramArtifact = null; } } } finally { base.Dispose(disposing); } }