public DomainClassFirstBuilder(DomainClass domainClass) { _domainClass = domainClass; _classBuilder = new ClassBuilderUtil(); _nameSpaceBuilderUtil = new NameSpaceBuilderUtil(); _nameBuilderUtil = new NameBuilderUtil(); }
private CodeMemberMethod MakeUpdateLoadMethod(DomainClass domainClass, DomainMethod domainMethod) { var updateMethod = new CodeMemberMethod { Name = $"{domainMethod.Name}", ReturnType = new CodeTypeReference("async Task<IActionResult>") }; updateMethod.Parameters.Add(new CodeParameterDeclarationExpression { Type = new CodeTypeReference("Guid"), Name = "id" }); updateMethod.Parameters.Add(new CodeParameterDeclarationExpression { Type = new CodeTypeReference($"[FromBody] {_nameBuilderUtil.UpdateApiCommandName(domainClass, domainMethod)}"), Name = "command" }); updateMethod.Statements.Add( new CodeSnippetExpression($"return await Handler.{domainMethod.Name}{domainClass.Name}(id, command)")); updateMethod.Attributes = MemberAttributes.Final | MemberAttributes.Public; return(updateMethod); }
public void Page_Load(object sender, EventArgs e) { if (!SessionManager.IsAdministrator) { throw new ManagedAccount.AccessDeniedException(); } if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("System Preferences", Request, "SystemPreferencesManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Settings", Request, "SystemConfigurationsManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Outgoing E-Mail", Request.Url)); StackSiteMap(sitemapdata); DomainClass cs = SessionManager.GetDomainClass("Configuration"); int len = cs["OptionName"].MaxLengthInChars; inputServer.MaxLength = len; inputUsername.MaxLength = len; inputPassword.MaxLength = len; inputPort.MaxLength = len; inputPickupDirectoryLocation.MaxLength = len; inputDelivery.DataSource = smtpdeliverymethods; inputDelivery.DataBind(); ListItemManager.TrySelect(inputDelivery, SessionManager.GetCachedConfiguration("SnCore.Mail.Delivery", SmtpDeliveryMethod.Network.ToString())); inputServer.Text = SessionManager.GetCachedConfiguration("SnCore.Mail.Server", "localhost"); inputUsername.Text = SessionManager.GetCachedConfiguration("SnCore.Mail.Username", string.Empty); inputPort.Text = SessionManager.GetCachedConfiguration("SnCore.Mail.Port", "25"); inputPickupDirectoryLocation.Text = SessionManager.GetCachedConfiguration("SnCore.Mail.PickupDirectoryLocation", string.Empty); } SetDefaultButton(save); }
public DomainForm(Form parent, DBRegistrationClass dbReg, TreeNode tn, ContextMenuStrip cm) { InitializeComponent(); this.MdiParent = parent; _dbReg = dbReg; DomainClass tc = (DomainClass)tn.Tag; if (tc == null) { DomainObject = new DomainClass(); DomainObject.Name = "NEW_DOMAIN"; DomainObject.NotNull = false; DomainObject.FieldType = "INTEGER"; DomainObject.CharSet = "NONE"; DomainObject.Collate = "NONE"; DomainObject.DefaultValue = string.Empty; DomainObject.Check = string.Empty; } else { DomainObject = tc; } if (!string.IsNullOrEmpty(DomainObject.DefaultValue)) { Console.WriteLine(); } OrgDomainObject = (DomainClass)DomainObject.Clone(); Cm = cm; Tn = tn; _localNotify.Notify.OnRaiseErrorHandler += Notify_OnRaiseErrorHandler; _localNotify.Notify.OnRaiseInfoHandler += Notify_OnRaiseInfoHandler; }
public DomainRelationship CreateRelationship(DomainClass Source, Multiplicity SourceMultiplicity, DomainClass Target, Multiplicity TargetMultiplicity, Boolean IsEmbedding) { DomainRelationship dr = new DomainRelationship( OwnerDocument, Source.Xml.GetAttribute("Name") + (IsEmbedding ? "Has" : "References") + Target.Xml.GetAttribute("Name"), Source.Xml.GetAttribute("DisplayName") + (IsEmbedding ? " Has " : " References ") + Target.Xml.GetAttribute("DisplayName"), IsEmbedding ); dr.Source = new DomainRole(OwnerDocument, Source.Xml.GetAttribute("Name"), Source.Xml.GetAttribute("DisplayName"), Target.Xml.GetAttribute("Name"), Target.Xml.GetAttribute("DisplayName"), SourceMultiplicity ); dr.Target = new DomainRole(OwnerDocument, Target.Xml.GetAttribute("Name"), Target.Xml.GetAttribute("DisplayName"), Source.Xml.GetAttribute("Name"), Source.Xml.GetAttribute("DisplayName"), TargetMultiplicity ); Relationships.Add(dr); return dr; }
private Dictionary <object, List <DomainRelationship> > GetSortedByBaseClasses(ICollection rels) { Dictionary <object, List <DomainRelationship> > ret = new Dictionary <object, List <DomainRelationship> >(); ret.Add("NULL", new List <DomainRelationship>()); foreach (DomainRelationship r in rels) { if (r.Target.RolePlayer.BaseElement != null) { DomainClass d = r.Target.RolePlayer.BaseElement as DomainClass; if (!ret.ContainsKey(d)) { ret.Add(d, new List <DomainRelationship>()); } ret[d].Add(r); } else { ret["NULL"].Add(r); } } return(ret); }
public static void SetMaxMessageLength() { // figure out the max size of the Description field in the AccountAuditEntry class DomainClass dc = Session.Model["AccountAuditEntry"]; s_mMaxMessageLength = dc["Description"].MaxLengthInChars; }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("System Preferences", Request, "SystemPreferencesManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Countries", Request, "SystemCountriesManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("Country"); inputName.MaxLength = cs["Name"].MaxLengthInChars; int id = RequestId; if (id > 0) { TransitCountry tw = SessionManager.LocationService.GetCountryById( SessionManager.Ticket, id); inputName.Text = Renderer.Render(tw.Name); sitemapdata.Add(new SiteMapDataAttributeNode(tw.Name, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New Country", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("System Preferences", Request, "SystemPreferencesManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Settings", Request, "SystemConfigurationsManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("Configuration"); inputName.MaxLength = cs["OptionName"].MaxLengthInChars; int id = RequestId; if (id > 0) { TransitConfiguration tw = SessionManager.SystemService.GetConfigurationById( SessionManager.Ticket, id); inputName.Text = Renderer.Render(tw.Name); inputValue.Text = Renderer.Render(tw.Value); inputPassword.Checked = tw.Password; sitemapdata.Add(new SiteMapDataAttributeNode(tw.Name, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New Setting", Request.Url)); inputName.Text = Request["name"]; } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("System Preferences", Request, "SystemPreferencesManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Account Place Types", Request, "SystemAccountPlaceTypesManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("AccountPlaceType"); inputName.MaxLength = cs["Name"].MaxLengthInChars; if (RequestId > 0) { TransitAccountPlaceType t = SessionManager.PlaceService.GetAccountPlaceTypeById( SessionManager.Ticket, RequestId); inputName.Text = t.Name; inputDescription.Text = t.Description; inputDefaultType.Checked = t.DefaultType; inputCanWrite.Checked = t.CanWrite; sitemapdata.Add(new SiteMapDataAttributeNode(t.Name, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New Type", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("System Preferences", Request, "SystemPreferencesManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Marketing Campaigns", Request, "MarketingCampaignsManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("Campaign"); inputName.MaxLength = cs["Name"].MaxLengthInChars; inputSenderName.MaxLength = cs["SenderName"].MaxLengthInChars; inputSenderEmail.MaxLength = cs["SenderEmailAddress"].MaxLengthInChars; inputUrl.MaxLength = cs["Url"].MaxLengthInChars; if (RequestId > 0) { TransitCampaign t = SessionManager.MarketingService.GetCampaignById(SessionManager.Ticket, RequestId); inputActive.Checked = t.Active; inputDescription.Text = t.Description; inputName.Text = t.Name; inputSenderEmail.Text = t.SenderEmailAddress; inputSenderName.Text = t.SenderName; inputUrl.Text = t.Url; sitemapdata.Add(new SiteMapDataAttributeNode(t.Name, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New Marketing Campaign", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(save); }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Redirects", Request, "AccountRedirectsManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("AccountRedirect"); inputSourceUri.MaxLength = cs["SourceUri"].MaxLengthInChars; inputTargetUri.MaxLength = cs["TargetUri"].MaxLengthInChars; int id = RequestId; if (id > 0) { TransitAccountRedirect tr = SessionManager.AccountService.GetAccountRedirectById(SessionManager.Ticket, id); inputSourceUri.Text = tr.SourceUri; inputTargetUri.Text = tr.TargetUri; sitemapdata.Add(new SiteMapDataAttributeNode(tr.SourceUri, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New Redirect", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DomainClass cs = SessionManager.GetDomainClass("AccountRedirect"); inputSource.MaxLength = cs["SourceUri"].MaxLengthInChars; TransitAccountRedirect redirect = SessionManager.AccountService.GetAccountRedirectByTargetUri( SessionManager.Ticket, SessionManager.AccountId, TargetUri); if (redirect != null) { RedirectId = redirect.Id; inputSource.Text = redirect.SourceUri; linkSource.NavigateUrl = redirect.SourceUri; } if (!SessionManager.HasVerified()) { inputSource.Enabled = false; btnSave.Enabled = false; } } PageManager.SetDefaultButton(btnSave, Controls); }
public CodeTypeMember BuildCreateMethod(CreateMethod createMethod, DomainClass domainClass) { var method = new CodeMemberMethod(); method.Attributes = MemberAttributes.Public | MemberAttributes.Final; var name = _nameBuilderUtil.CreateCommandName(domainClass, createMethod); method.Parameters.Add(new CodeParameterDeclarationExpression { Type = new CodeTypeReference(name), Name = "command" }); method.Name = $"{createMethod.Name}{domainClass.Name}"; method.ReturnType = new CodeTypeReference("async Task<IActionResult>"); method.Statements.Add(new CodeSnippetExpression($"CreationResult<{domainClass.Name}> createResult = {domainClass.Name}.{createMethod.Name}(command)")); var conditionalStatement = new CodeConditionStatement( new CodeSnippetExpression("createResult.Ok"), new CodeStatement[] { new CodeExpressionStatement(new CodeSnippetExpression("var hookResult = await EventStore.AppendAll(createResult.DomainEvents)")), new CodeConditionStatement( new CodeSnippetExpression("hookResult.Ok"), new CodeStatement[] { new CodeExpressionStatement(new CodeSnippetExpression($"await {domainClass.Name}Repository.{createMethod.Name}{domainClass.Name}(createResult.CreatedEntity)")), new CodeExpressionStatement(new CodeSnippetExpression(@"return new CreatedResult(""uri"", createResult.CreatedEntity)")) }), new CodeExpressionStatement(new CodeSnippetExpression(@"return new BadRequestObjectResult(hookResult.Errors)")) }); method.Statements.Add(conditionalStatement); method.Statements.Add(new CodeMethodReturnStatement(new CodeSnippetExpression($@"new BadRequestObjectResult(createResult.DomainErrors)"))); return(method); }
public DomainForm(Form parent, DBRegistrationClass dbReg, List <TableClass> tables, TreeNode tn, ContextMenuStrip cm) { InitializeComponent(); this.MdiParent = parent; _dbReg = dbReg; _tables = tables; DomainClass tc = (DomainClass)tn.Tag; if (tc == null) { DomainObject = new DomainClass(); DomainObject.Name = "NEW_DOMAIN"; DomainObject.NotNull = false; DomainObject.FieldType = "INTEGER"; DomainObject.CharSet = "NONE"; DomainObject.Collate = "NONE"; DomainObject.DefaultValue = string.Empty; DomainObject.Check = string.Empty; } else { DomainObject = tc; } Cm = cm; Tn = tn; _localNotify.Register4Error(Notify_OnRaiseErrorHandler); _localNotify.Register4Info(Notify_OnRaiseInfoHandler); _localTableNotify.Register4Info(TableInfoRaised); }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("Bugs", Request, "BugProjectsManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("BugProject"); inputName.MaxLength = cs["Name"].MaxLengthInChars; if (RequestId > 0) { TransitBugProject t = SessionManager.BugService.GetBugProjectById( SessionManager.Ticket, RequestId); inputName.Text = t.Name; inputDescription.Text = t.Description; sitemapdata.Add(new SiteMapDataAttributeNode(t.Name, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New Project", Request.Url)); } StackSiteMap(sitemapdata); SetDefaultButton(manageAdd); } }
/// <summary> /// Gets optimizations. /// </summary> /// <returns></returns> public override List <BaseOptimization> GetOptimizations() { List <BaseOptimization> opt = new List <BaseOptimization>(); DomainClass domainModel = null; foreach (DomainClass d in this.ModelContext.Classes) { if (d.IsDomainModel) { domainModel = d; break; } } if (domainModel != null) { try { opt.AddRange(GetOptimizationsRefRelationshipsSameLevel(domainModel, new List <DomainClass>())); } catch { } } opt.AddRange(GetOptimizations(this.ModelContext.Classes, new List <DomainClass>(), false)); return(opt); }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("System Preferences", Request, "SystemPreferencesManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Attributes", Request, "SystemAttributesManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("Attribute"); inputName.MaxLength = cs["Name"].MaxLengthInChars; inputDefaultUrl.MaxLength = cs["DefaultUrl"].MaxLengthInChars; if (RequestId > 0) { TransitAttribute t = SessionManager.ObjectService.GetAttributeById( SessionManager.Ticket, RequestId); inputName.Text = t.Name; inputDescription.Text = t.Description; inputDefaultUrl.Text = t.DefaultUrl; inputDefaultValue.Text = t.DefaultValue; imageBitmap.ImageUrl = string.Format("SystemAttribute.aspx?id={0}&CacheDuration=0", t.Id); imageBitmap.Visible = t.HasBitmap; sitemapdata.Add(new SiteMapDataAttributeNode(t.Name, Request.Url)); } else { imageBitmap.Visible = false; sitemapdata.Add(new SiteMapDataAttributeNode("New Attribute", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); }
public void Page_Load(object sender, EventArgs e) { gridProperties.OnGetDataSource += new EventHandler(gridProperties_OnGetDataSource); if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("System Preferences", Request, "SystemPreferencesManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Place Property Groups", Request, "SystemPlacePropertyGroupsManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("PlacePropertyGroup"); inputName.MaxLength = cs["Name"].MaxLengthInChars; if (RequestId > 0) { TransitPlacePropertyGroup t = SessionManager.PlaceService.GetPlacePropertyGroupById( SessionManager.Ticket, RequestId); inputName.Text = t.Name; inputDescription.Text = t.Description; gridProperties_OnGetDataSource(this, null); gridProperties.DataBind(); linkNewProperty.NavigateUrl = string.Format("SystemPlacePropertyEdit.aspx?pid={0}", RequestId); sitemapdata.Add(new SiteMapDataAttributeNode(t.Name, Request.Url)); } else { panelProperties.Visible = false; sitemapdata.Add(new SiteMapDataAttributeNode("New Property Group", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); }
public DomainTreeNode(DomainClass element) : base(element.Name) { Element = element; /* iterate on element's children and add them to the node's * Childs collection ...*/ }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Syndication", Request, "AccountFeedsManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("MadLib"); inputName.MaxLength = cs["Name"].MaxLengthInChars; if (RequestId > 0) { TransitMadLib t = SessionManager.MadLibService.GetMadLibById( SessionManager.Ticket, RequestId); inputTemplate.Text = t.Template; inputName.Text = t.Name; sitemapdata.Add(new SiteMapDataAttributeNode(t.Name, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New MadLib", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(save); }
public CodeTypeDeclaration Build(DomainClass hookClass) { var iface = new CodeTypeDeclaration($"{hookClass.Name}") { IsInterface = true }; foreach (var function in hookClass.Methods) { var method = new CodeMemberMethod { Name = function.Name, ReturnType = new CodeTypeReference(function.ReturnType) }; foreach (var parameter in function.Parameters) { method.Parameters.Add(new CodeParameterDeclarationExpression { Type = new CodeTypeReference(parameter.Type), Name = parameter.Name }); } iface.Members.Add(method); } return(iface); }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = RequestId; SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Messages", Request, "AccountMessageFoldersManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("AccountMessageFolder"); inputName.MaxLength = cs["Name"].MaxLengthInChars; if (id > 0) { TransitAccountMessageFolder tw = SessionManager.AccountService.GetAccountMessageFolderById(SessionManager.Ticket, id); inputName.Text = Renderer.Render(tw.Name); sitemapdata.Add(new SiteMapDataAttributeNode(tw.Name, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New Folder", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); }
public IList <Property> Build(DomainClass domainClass) { var properties = new List <Property> { new Property { Name = "EventStore", Type = new EventStoreInterface().Name }, new Property { Name = $"{domainClass.Name}Repository", Type = $"I{domainClass.Name}Repository" } }; foreach (var loadMethod in domainClass.LoadMethods) { foreach (var loadParam in loadMethod.LoadParameters) { var repoWithSameName = properties.FirstOrDefault(prop => prop.Name == $"{loadParam.Type}Repository"); if (repoWithSameName == null) { properties.Add(new Property { Name = $"{loadParam.Type}Repository", Type = $"I{loadParam.Type}Repository" }); } } } return(properties); }
private void GetInfo() { if (domainInfo == null) { domainInfo = cmsconnector.GetDomainInfo(((ClientClass)chooseClientCombobox.SelectedItem)); } }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("System Preferences", Request, "SystemPreferencesManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Surveys", Request, "SystemSurveysManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode(Survey.Name, Request, string.Format("SystemSurveyEdit.aspx?id={0}", SurveyId))); DomainClass cs = SessionManager.GetDomainClass("SurveyQuestion"); inputQuestion.MaxLength = cs["Question"].MaxLengthInChars; linkBack.NavigateUrl = "SystemSurveyEdit.aspx?id=" + SurveyId.ToString(); if (RequestId > 0) { TransitSurveyQuestion tw = SessionManager.ObjectService.GetSurveyQuestionById( SessionManager.Ticket, RequestId); inputQuestion.Text = Renderer.Render(tw.Question); sitemapdata.Add(new SiteMapDataAttributeNode(tw.Question, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New Question", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); }
public EventsForm(Form parent, DBRegistrationClass dbReg, DomainClass domainObject) { InitializeComponent(); this.MdiParent = parent; _dbReg = dbReg; _localNotify.Notify.OnRaiseErrorHandler += Notify_OnRaiseErrorHandler; _localNotify.Notify.OnRaiseInfoHandler += Notify_OnRaiseInfoHandler; }
public XmlClassData GetClassData(DomainClass Class) { String Name = Class.Xml.GetAttribute("Name"); foreach (XmlClassData xcd in ClassData) { if (xcd.DomainClassMoniker == Name) return xcd; } return null; }
public DefaultClassBuilder(string nameSpaceName, DomainClass generatedClass) { _nameSpaceName = nameSpaceName; _generatedClass = generatedClass; _nameSpaceBuilderUtil = new NameSpaceBuilderUtil(); _constructorBuilderUtil = new ConstructorBuilderUtil(); _classBuilderUtil = new ClassBuilderUtil(); _propertyBuilderUtil = new PropertyBuilderUtil(); }
private static RolePlayerConnectDirective GetRolePlayerConnectDirective(DomainClass Class, DslElementList Directives) { String ClassName = Class.Xml.GetAttribute("Name"); foreach (RolePlayerConnectDirective rpcd in Directives) { if (rpcd.AcceptingClass == ClassName) return rpcd; } return null; }
private void ChooseClientCombobox_SelectedIndexChanged(object sender, EventArgs e) { if (chooseClientCombobox.SelectedItem != null) { showInformationButton.Enabled = true; addComputerButton.Enabled = true; domainInfo = null; } }
public DomainEventBuilder(DomainClass classModell, DomainEvent domainEvent) { _classModell = classModell; _domainEvent = domainEvent; _propertyBuilderUtil = new PropertyBuilderUtil(); _classBuilder = new ClassBuilderUtil(); _constructorBuilderUtil = new ConstructorBuilderUtil(); _nameSpaceBuilderUtil = new NameSpaceBuilderUtil(); }
public static eLogicalType ToLogicalType(DomainClass domain) { if (domain.FieldType == "LONG") { return(eLogicalType.NUMBER); } else if (domain.FieldType == "INT64") { return(eLogicalType.NUMBER); } else if (domain.FieldType == "SHORT") { return(eLogicalType.NUMBER); } else if (domain.FieldType == "FLOAT") { return(eLogicalType.POINTNUMBER); } else if (domain.FieldType == "VARYING") { return(eLogicalType.TEXT); } else if (domain.FieldType == "CSTRING") { return(eLogicalType.TEXT); } else if (domain.FieldType == "TEXT") { return(eLogicalType.TEXT); } else if (domain.FieldType.StartsWith("TIME")) { return(eLogicalType.TIMESTAMP); } else if (domain.FieldType.StartsWith("DATE")) { return(eLogicalType.DATE); } else if (domain.FieldType.StartsWith("DOUBLE")) { return(eLogicalType.POINTNUMBER); } else if (domain.FieldType.StartsWith("BOOLEAN")) { return(eLogicalType.BOOL); } else if (domain.FieldType.StartsWith("BLOB")) { return(eLogicalType.BINARY); } else { Console.WriteLine(); } return(eLogicalType.NONE); }
public void Update(DomainClass Class) { String Name = Class.Xml.GetAttribute("Name"); String subName = Dsl.SubName(Name); Xml.SetAttribute("TypeName", Name); Xml.SetAttribute("MonikerAttributeName", Xml.GetAttribute("MonikerAttributeName")); Xml.SetAttribute("MonikerElementName", subName + "Moniker"); Xml.SetAttribute("ElementName", subName); Xml.SetAttribute("MonikerTypeName", Name + "Moniker"); DomainClassMoniker = Name; }
protected override void OnSetUp() { base.OnSetUp(); using (ISession session = this.OpenSession()) { DomainClass entity = new DomainClass(); entity.Id = 1; session.Save(entity); session.Flush(); session.Evict(entity); } }
/// <summary> /// Creates the temp model. /// </summary> /// <returns></returns> public MetaModel CreateTempModel(bool bIsTarget) { // disable undo/redo this.MetaModel.Store.UndoManager.UndoState = Microsoft.VisualStudio.Modeling.UndoState.DisabledNoFlush; MetaModel m = null; LibraryModelContext context = null; using (Transaction t = this.MetaModel.Store.TransactionManager.BeginTransaction()) { m = new MetaModel(this.MetaModel.Store); context = new LibraryModelContext(this.MetaModel.Store); m.ModelContexts.Add(context); // post process SerializationPostProcessor.PostProcessModelLoad(m); t.Commit(); } // create copies of domain classes using (Transaction t = this.MetaModel.Store.TransactionManager.BeginTransaction()) { foreach (DomainClass d in this.InvolvedClasses) { DomainClass domainClass = new DomainClass(this.MetaModel.Store); domainClass.Name = d.Name; context.Classes.Add(domainClass); if( !bIsTarget ) this.InvolvedClassesMapping.Add(d.Id, domainClass.Id); else this.InvolvedClassesTargetMapping.Add(d.Id, domainClass.Id); } t.Commit(); } // create inheritance relationships using (Transaction t = this.MetaModel.Store.TransactionManager.BeginTransaction()) { foreach (DomainClassReferencesBaseClass con in this.InvolvedInheritancesRelationships) { DomainClass source; DomainClass target; if (!bIsTarget) { source = m.Store.ElementDirectory.GetElement(this.InvolvedClassesMapping[con.DerivedClass.Id]) as DomainClass; target = m.Store.ElementDirectory.GetElement(this.InvolvedClassesMapping[con.BaseClass.Id]) as DomainClass; } else { source = m.Store.ElementDirectory.GetElement(this.InvolvedClassesTargetMapping[con.DerivedClass.Id]) as DomainClass; target = m.Store.ElementDirectory.GetElement(this.InvolvedClassesTargetMapping[con.BaseClass.Id]) as DomainClass; } DomainClassReferencesBaseClass conCreated = new DomainClassReferencesBaseClass(source, target); if( !bIsTarget ) this.InvolvedInheritancesRelationshipsMapping.Add(con.Id, conCreated.Id); else this.InvolvedInheritancesRelationshipsTargetMapping.Add(con.Id, conCreated.Id); } t.Commit(); } // create relationships using (Transaction t = this.MetaModel.Store.TransactionManager.BeginTransaction()) { foreach (DomainRelationship rel in this.InvolvedRelationships) { DomainClass source; DomainClass target; if (!bIsTarget) { source = m.Store.ElementDirectory.GetElement(this.InvolvedClassesMapping[rel.Source.RolePlayer.Id]) as DomainClass; target = m.Store.ElementDirectory.GetElement(this.InvolvedClassesMapping[rel.Target.RolePlayer.Id]) as DomainClass; } else { source = m.Store.ElementDirectory.GetElement(this.InvolvedClassesTargetMapping[rel.Source.RolePlayer.Id]) as DomainClass; target = m.Store.ElementDirectory.GetElement(this.InvolvedClassesTargetMapping[rel.Target.RolePlayer.Id]) as DomainClass; } DomainRelationship relCreated; if( rel is ReferenceRelationship) relCreated = Tum.PDE.LanguageDSL.ModelTreeHelper.AddNewReferenceRelationship(source, target); else relCreated = Tum.PDE.LanguageDSL.ModelTreeHelper.AddNewEmbeddingRS(source, target, false); if (!bIsTarget) this.InvolvedRelationshipsMapping.Add(rel.Id, relCreated.Id); else this.InvolvedRelationshipsTargetMapping.Add(rel.Id, relCreated.Id); } t.Commit(); } this.CreateTempModel(m, bIsTarget); // enable undo/redo this.MetaModel.Store.UndoManager.UndoState = Microsoft.VisualStudio.Modeling.UndoState.Enabled; return m; }
private DomainProperty GetProperty(DomainClass domainClass, DomainProperty referenceProperty) { foreach (DomainProperty p in domainClass.Properties) if (p.Name == referenceProperty.Name && p.Type == referenceProperty.Type) return p; return null; }
/// <summary> /// Removes the reference. /// </summary> /// <param name="node">Node.</param> public void RemoveReference(DomainClass node) { for (int i = this.referenceVMs.Count - 1; i >= 0; i--) if (this.referenceVMs[i].Element.Id == node.Id) { this.referenceVMs[i].Dispose(); this.referenceVMs.RemoveAt(i); } OnPropertyChanged("ReferenceVMs"); }
private static string GetSpecificViewModelString(DomainClass domainClass, bool bBase) { string specificVMProperties = ""; if (domainClass.GenerateSpecificViewModel == false) specificVMProperties = "// Specific ViewModels are generated if 'GenerateSpecificVM' is set to true. This is not the case for the DomainClass '" + domainClass.Name + "': " + "\r\n"; else { specificVMProperties = ""; if (!bBase) { specificVMProperties += "// The following general properties are available for binding in the Specific ViewModel '" + domainClass.Name + "SpecificViewModel': \r\n"; specificVMProperties += " DomainElementName (string)" + "\r\n"; specificVMProperties += " DomainElementFullName (string)" + "\r\n"; specificVMProperties += " DomainElementHasName (bool)" + "\r\n"; specificVMProperties += " DomainElementType (string)" + "\r\n"; specificVMProperties += " DomainElementTypeDisplayName (string)" + "\r\n"; specificVMProperties += " DomainElementParentHasName (bool)" + "\r\n"; specificVMProperties += " DomainElementParentName (string)" + "\r\n"; specificVMProperties += " DomainElementParentFullName (string)" + "\r\n"; specificVMProperties += " DomainElementParentHasFirstExistingName (bool)" + "\r\n"; specificVMProperties += " DomainElementParentFirstExistingName (string)" + "\r\n"; specificVMProperties += " DomainElementHasParentFullPath (bool)" + "\r\n"; specificVMProperties += " DomainElementParentFullPath (string)" + "\r\n\r\n"; } specificVMProperties += "// The following properties/roles are available for binding in the Specific ViewModel '" + domainClass.Name + "SpecificViewModel':"; specificVMProperties += "\r\n"; foreach (DomainProperty p in domainClass.Properties) { if (p.IsElementName) continue; if (p.Type == null) continue; specificVMProperties += " "+p.Name + "\r\n"; } foreach (DomainRole role in domainClass.RolesPlayed) { if (role.Relationship.InheritanceModifier == InheritanceModifier.Abstract) continue; if (role.Relationship.Source != role) { if (!domainClass.GenerateSpecificViewModelOppositeReferences) continue; if (!(role.Relationship is ReferenceRelationship)) continue; } //if( !role.IsPropertyGenerator ) // continue; if (role.Relationship is EmbeddingRelationship && !domainClass.GenerateSpecificViewModelEmbeddings) continue; if (role.Relationship is ReferenceRelationship && !domainClass.GenerateSpecificViewModelReferences) if (role.Relationship.Source == role) continue; /* if (role.Relationship.InheritanceModifier == InheritanceModifier.Abstract || role.Relationship.Source != role) continue; if (!role.IsPropertyGenerator) continue; if (role.Relationship is EmbeddingRelationship && !domainClass.GenerateSpecificViewModelEmbeddings) continue; if (role.Relationship is ReferenceRelationship && !domainClass.GenerateSpecificViewModelReferences) continue; */ if (role.Multiplicity == Tum.PDE.LanguageDSL.Multiplicity.ZeroMany || role.Multiplicity == Tum.PDE.LanguageDSL.Multiplicity.OneMany) { specificVMProperties += " " + role.PropertyName + "VMs // for DomainClasses of type '" + role.Opposite.RolePlayer.Name + "' and Relationship type '"+role.Relationship.Name+"'" + "\r\n"; } else { specificVMProperties += " " + role.PropertyName + "VM // for DomainClass of type '" + role.Opposite.RolePlayer.Name + "' and Relationship type '" + role.Relationship.Name + "'" + "\r\n"; } } if (domainClass.BaseClass != null) if (domainClass.BaseClass.GenerateSpecificViewModel) { specificVMProperties += "\r\n"; specificVMProperties += "// ***Base Class '"+domainClass.BaseClass.Name+"' of " + domainClass.Name + "***:" + "\r\n"; specificVMProperties += GetSpecificViewModelString(domainClass.BaseClass, true); } } return specificVMProperties; }
public void Update(DomainClass Class) { AcceptingClass = Class.Xml.GetAttribute("Name"); }
/// <summary> /// Sets the reference. /// </summary> /// <param name="node">Node.</param> public void SetReference(DomainClass node) { this.ReferenceVM = new BaseModelElementViewModel(this.ViewModelStore, node); }
private bool IsImplementationClass(DomainClass dc) { if (dc == null) { return false; } DslAttribute entityAttribute = dc.DslAttributes.FindIfExist("Name", "EntityAttribute") as DslAttribute; if (entityAttribute != null) { bool implementationOnlyEntity; if (Boolean.TryParse(entityAttribute["IsImplementationOnlyEntity"], out implementationOnlyEntity) && implementationOnlyEntity) { return true; } } return false; }
/// <summary> /// Adds a new inheritance relationship instance for each source. /// </summary> /// <param name="sources">DomainClass to be the derived classes.</param> /// <param name="target">DomainClass to act as the base class.</param> public static void AddNewInheritanceRelationship(List<DomainClass> sources, DomainClass target) { ModelTreeHelper.AddNewInheritanceRelationship(sources, target); }
/// <summary> /// Sets the reference. /// </summary> /// <param name="node">Node.</param> public void AddReference(DomainClass node) { // verify that element has not been added yet foreach (BaseModelElementViewModel viewModel in this.referenceVMs) if (viewModel.Element.Id == node.Id) return; BaseModelElementViewModel vm = new BaseModelElementViewModel(this.ViewModelStore, node, true); this.referenceVMs.Add(vm); OnPropertyChanged("ReferenceVMs"); }
public override void ApplyOptimization(bool bApplyForTempModel) { MetaModel metaModel; LibraryModelContext modelContext; if (bApplyForTempModel) { metaModel = this.TargetModel; modelContext = this.TargetModel.ModelContexts[0] as LibraryModelContext; } else { metaModel = this.MetaModel; modelContext = this.ModelContext; } //using (Transaction t = this.MetaModel.Store.TransactionManager.BeginTransaction("Apply optimization")) //{ DomainClass bClass = null; #region Base classes if (this.CreateIntermediate || this.BaseClass == null) { // create class using (Transaction tD = this.MetaModel.Store.TransactionManager.BeginTransaction("Create intermediate Base class")) { DomainClass intermediateBaseClass = new DomainClass(metaModel.Store); modelContext.Classes.Add(intermediateBaseClass); intermediateBaseClass.InheritanceModifier = InheritanceModifier.Abstract; intermediateBaseClass.Name = GetUniqueNameForBaseClass(); bClass = intermediateBaseClass; if (this.BaseClass != null) { // create inheritance to the current base class DomainClass domainClass; if (bApplyForTempModel) domainClass = bClass.Store.ElementDirectory.FindElement(this.InvolvedClassesTargetMapping[this.BaseClass.Id]) as DomainClass; else domainClass = this.BaseClass; if (domainClass == null) throw new ArgumentNullException("DomainClass not found: Target Mappping error.. "); intermediateBaseClass.BaseClass = domainClass; } tD.Commit(); } } else { if (this.BaseClass != null) { if (bApplyForTempModel) bClass = metaModel.Store.ElementDirectory.FindElement(this.InvolvedClassesTargetMapping[this.BaseClass.Id]) as DomainClass; else bClass = this.BaseClass; } } if (bClass == null) throw new ArgumentNullException("Couldn't retrieve base class"); // create inheritance rs to domain classes foreach (DomainRelationship r in this.InvolvedRelationships) { DomainClass s = r.Target.RolePlayer as DomainClass; if (s == this.BaseClass) continue; DomainClass domainClass; if (bApplyForTempModel) domainClass = bClass.Store.ElementDirectory.FindElement(this.InvolvedClassesTargetMapping[s.Id]) as DomainClass; else domainClass = s; if (domainClass == null) throw new ArgumentNullException("DomainClass not found: Target Mappping error.. "); if( domainClass.BaseClass != null ) using (Transaction t2 = this.MetaModel.Store.TransactionManager.BeginTransaction("Base class")) { domainClass.BaseClass = null; t2.Commit(); } using (Transaction t3 = this.MetaModel.Store.TransactionManager.BeginTransaction("Add inh class")) { new DomainClassReferencesBaseClass(domainClass, bClass); t3.Commit(); } } #endregion #region Delete Rels using (Transaction tD = this.MetaModel.Store.TransactionManager.BeginTransaction("Delete Rels")) { foreach (DomainRelationship rel in this.InvolvedRelationships) { DomainRelationship relToDelete; if (bApplyForTempModel) relToDelete = bClass.Store.ElementDirectory.FindElement(this.InvolvedRelationshipsTargetMapping[rel.Id]) as DomainRelationship; else relToDelete = rel; relToDelete.Delete(); } tD.Commit(); } #endregion #region Create Rel using (Transaction tD = this.MetaModel.Store.TransactionManager.BeginTransaction("Create Rels")) { DomainClass parent; if (bApplyForTempModel) parent = bClass.Store.ElementDirectory.FindElement(this.InvolvedClassesTargetMapping[this.ParentClass.Id]) as DomainClass; else parent = this.ParentClass; DomainRelationship relCreated; if (this.IsEmbedding) relCreated = Tum.PDE.LanguageDSL.ModelTreeHelper.AddNewEmbeddingRS(parent, bClass, false); else relCreated = Tum.PDE.LanguageDSL.ModelTreeHelper.AddNewReferenceRelationship(parent, bClass); tD.Commit(); } #endregion //t.Commit(); //} }
public RolePlayerConnectDirective GetSourceConnectDirective(DomainClass Class) { return GetRolePlayerConnectDirective(Class, SourceDirectives); }
private List<RelationshipsOptimization> CreateOptimizations(DomainClass domainClass, ICollection references) { List<RelationshipsOptimization> opt = new List<RelationshipsOptimization>(); Dictionary<object, List<DomainRelationship>> dict = GetSortedByBaseClasses(references); foreach (object key in dict.Keys) { List<DomainRelationship> rels = dict[key]; if (rels.Count <= 1) continue; Dictionary<string, List<DomainRelationship>> dict2 = GetSortedByMutliplicity(rels); foreach (string key2 in dict2.Keys) { rels = dict2[key2]; if (rels.Count <= 1) continue; bool bUseIntermediate = false; if (key is DomainClass) { if ((key as DomainClass) == domainClass) continue; bUseIntermediate = UseIntermediate(rels); if (!bUseIntermediate) if ((key as DomainClass).DerivedClasses.Count != rels.Count) bUseIntermediate = true; } RelationshipsOptimization rOpt = new RelationshipsOptimization(this.MetaModel, this.ModelContext); rOpt.Title = "Relationship Optimization"; rOpt.InvolvedClasses.Add(domainClass); rOpt.ParentClass = domainClass; rOpt.CreateIntermediate = bUseIntermediate; if (rOpt.CreateIntermediate) rOpt.Description = "Existing references are replaces with one reference to a new base class"; else rOpt.Description = "Existing references are replaces with one reference to a base class"; if (key is DomainClass) { rOpt.BaseClass = (key as DomainClass); if (!rOpt.InvolvedClasses.Contains(rOpt.BaseClass)) rOpt.InvolvedClasses.Add(rOpt.BaseClass); } foreach (DomainRelationship r in rels) { if( !rOpt.InvolvedClasses.Contains(r.Target.RolePlayer as DomainClass) ) rOpt.InvolvedClasses.Add(r.Target.RolePlayer as DomainClass); if( !rOpt.InvolvedRelationships.Contains(r) ) rOpt.InvolvedRelationships.Add(r); } if (rels[0] is ReferenceRelationship) rOpt.IsEmbedding = false; else rOpt.IsEmbedding = true; opt.Add(rOpt); } } return opt; }
private void AddClassesRelationshipToCollection(EntitiesRelationshipsCollection erCollection, DomainClass dc, DomainClass relatedClass, DomainRelationship dr) { if (dc != null) { if (!erCollection.ContainsKey(dc)) { erCollection.Add(dc, new Dictionary<DomainClass, DomainRelationship>()); } if (!erCollection[dc].ContainsKey(relatedClass)) { erCollection[dc].Add(relatedClass, dr); } } }
private void MarkClassAsImplementationOnly(DomainClass dc) { DslAttribute dslAttribute = dc.DslAttributes.FindIfExist("Name", "EntityAttribute") as DslAttribute; if (dslAttribute != null) { dslAttribute["IsImplementationOnlyEntity"] = Boolean.TrueString; } else { dslAttribute = new DslAttribute(Doc, "EntityAttribute"); dslAttribute["IsImplementationOnlyEntity"] = Boolean.TrueString; dc.DslAttributes.Add(dslAttribute); } }
private void CreateImplementationOnlyClassesList(EntitiesRelationshipsCollection dependentClassesDictionary, ref List<DomainClass> implementationClassesResult, ref List<DomainRelationship> implementationRelationshipsResult, DomainClass domainClass) { if (implementationClassesResult.Contains(domainClass)) { return; } implementationClassesResult.Add(domainClass); foreach (Dictionary<DomainClass, DomainRelationship> relatedClasses in dependentClassesDictionary.Values) { if (relatedClasses.ContainsKey(domainClass)) { implementationRelationshipsResult.Add(relatedClasses[domainClass]); } } if (dependentClassesDictionary.ContainsKey(domainClass)) { foreach (DomainClass dc in dependentClassesDictionary[domainClass].Keys) { if (!implementationClassesResult.Contains(dc)) { CreateImplementationOnlyClassesList(dependentClassesDictionary, ref implementationClassesResult, ref implementationRelationshipsResult, dc); } } } }
private List<RelationshipsOptimization> GetOptimizationsRefRelationshipsSameLevel(DomainClass start, List<DomainClass> alreadyProcessedBaseClasses) { List<RelationshipsOptimization> opt = new List<RelationshipsOptimization>(); Dictionary<object, List<DomainClass>> embeddedClasses = new Dictionary<object, List<DomainClass>>(); Dictionary<object, Dictionary<object, List<DomainRelationship>>> refClasses = new Dictionary<object, Dictionary<object, List<DomainRelationship>>>(); // gather references for found embeddings foreach (DomainRole role in start.RolesPlayed) if (role.Relationship.Source == role && role.Relationship is Tum.PDE.LanguageDSL.EmbeddingRelationship) { DomainClass target = role.Relationship.Target.RolePlayer as DomainClass; if (target == null) continue; object bClass = "NULL"; if (target.BaseClass != null) bClass = target.BaseClass; if (!embeddedClasses.ContainsKey(bClass)) embeddedClasses.Add(bClass, new List<DomainClass>()); embeddedClasses[bClass].Add(target); foreach(DomainClass dClass in target.DerivedClasses) { object bClass2 = "NULL"; if (dClass.BaseClass != null) bClass2 = dClass.BaseClass; if (!embeddedClasses.ContainsKey(bClass2)) embeddedClasses.Add(bClass2, new List<DomainClass>()); embeddedClasses[bClass2].Add(dClass); } } // gather references for found embeddings foreach(object key in embeddedClasses.Keys) if( embeddedClasses[key].Count > 1 ) { refClasses.Add(key, new Dictionary<object, List<DomainRelationship>>()); foreach (DomainClass c in embeddedClasses[key]) foreach (DomainRole role in c.RolesPlayed) if (role.Relationship.Source == role && role.Relationship is Tum.PDE.LanguageDSL.ReferenceRelationship) { DomainClass target = role.Relationship.Target.RolePlayer as DomainClass; if (target == null) continue; if (!embeddedClasses[key].Contains(target)) continue; object bClass = "NULL"; if (target.BaseClass != null) bClass = target.BaseClass; if (!refClasses[key].ContainsKey(bClass)) refClasses[key].Add(bClass, new List<DomainRelationship>()); refClasses[key][bClass].Add(role.Relationship); } } // continue with children foreach (DomainRole role in start.RolesPlayed) if (role.Relationship.Source == role && role.Relationship is Tum.PDE.LanguageDSL.EmbeddingRelationship) { if (!(role.Relationship.Source.RolePlayer is DomainClass)) continue; if (!(role.Relationship.Target.RolePlayer is DomainClass)) continue; DomainClass target = role.Relationship.Target.RolePlayer as DomainClass; if (target == null) continue; if (!alreadyProcessedBaseClasses.Contains(target)) { alreadyProcessedBaseClasses.Add(target); opt.AddRange(GetOptimizationsRefRelationshipsSameLevel(target, alreadyProcessedBaseClasses)); } } // Create opt if(refClasses.Keys.Count >0 ) foreach(object key in refClasses.Keys) if (refClasses[key].Count > 0) { foreach(object key2 in refClasses[key].Keys) if (refClasses[key][key2].Count > 1) { // create optimization RelationshipsReferencesBetweenBaseClassesOptimization rOpt = new RelationshipsReferencesBetweenBaseClassesOptimization(this.MetaModel, this.ModelContext); rOpt.Title = "Reference Relationship Optimization"; rOpt.Description = "Existing references are replaces with one reference. WARNING: This might extend/restrict existing constraints."; if (key != key2) continue; if (key is DomainClass) rOpt.BaseClass = key as DomainClass; if (key2 is DomainClass) rOpt.BaseClassTarget = key2 as DomainClass; // add classes and relationships foreach (DomainRelationship r in refClasses[key][key2]) { if (!rOpt.InvolvedClasses.Contains(r.Source.RolePlayer as DomainClass)) rOpt.InvolvedClasses.Add(r.Source.RolePlayer as DomainClass); if (!rOpt.InvolvedClasses.Contains(r.Target.RolePlayer as DomainClass)) rOpt.InvolvedClasses.Add(r.Target.RolePlayer as DomainClass); if (!rOpt.InvolvedRelationships.Contains(r)) rOpt.InvolvedRelationships.Add(r); } if (rOpt.BaseClass is DomainClass) if (!rOpt.InvolvedClasses.Contains(rOpt.BaseClass)) rOpt.InvolvedClasses.Add(rOpt.BaseClass); if (rOpt.BaseClassTarget is DomainClass) if (!rOpt.InvolvedClasses.Contains(rOpt.BaseClassTarget)) rOpt.InvolvedClasses.Add(rOpt.BaseClassTarget); opt.Add(rOpt); } } return opt; }
public XmlClassData(DomainClass Class) : base(Class.OwnerDocument.CreateElement("XmlClassData")) { Update(Class); }
public RolePlayerConnectDirective GetTargetConnectDirective(DomainClass Class) { return GetRolePlayerConnectDirective(Class, TargetDirectives); }
/// <summary> /// Compares two domain classes by comparing their names. /// </summary> /// <param name="x">DomainClass to be compared.</param> /// <param name="y">DomainClass to be compared.</param> /// <returns>Int from Compare.To</returns> private static int CompareDomainClassesByName(DomainClass x, DomainClass y) { return x.Name.CompareTo(y.Name); }
/// <summary> /// Applies the optimization. /// </summary> /// <param name="metaModel"></param> /// <param name="modelContext"></param> public override void ApplyOptimization(bool bApplyForTempModel) { MetaModel metaModel; LibraryModelContext modelContext; if (bApplyForTempModel) { metaModel = this.TargetModel; modelContext = this.TargetModel.ModelContexts[0] as LibraryModelContext; } else { metaModel = this.MetaModel; modelContext = this.ModelContext; } using (Transaction t = this.MetaModel.Store.TransactionManager.BeginTransaction("Apply optimization")) { DomainClass bClass = null; if (!IsInheritance) { // create new base class to host the properties bClass = new DomainClass(metaModel.Store); modelContext.Classes.Add(bClass); bClass.InheritanceModifier = InheritanceModifier.Abstract; bClass.Name = GetUniqueNameForBaseClass(); // create inheritance rs to domain classes foreach (DomainClass s in this.InvolvedClasses) { DomainClass domainClass; if (bApplyForTempModel) domainClass = bClass.Store.ElementDirectory.FindElement(this.InvolvedClassesTargetMapping[s.Id]) as DomainClass; else domainClass = s; if (domainClass == null) throw new ArgumentNullException("DomainClass not found: Target Mappping error.. "); new DomainClassReferencesBaseClass(domainClass, bClass); } } else { if (CreateIntermediate) { // create class using (Transaction tD = this.MetaModel.Store.TransactionManager.BeginTransaction("Create intermediate Base class")) { DomainClass intermediateBaseClass = new DomainClass(metaModel.Store); modelContext.Classes.Add(intermediateBaseClass); intermediateBaseClass.InheritanceModifier = InheritanceModifier.Abstract; intermediateBaseClass.Name = GetUniqueNameForBaseClass(); bClass = intermediateBaseClass; tD.Commit(); } // create inheritance rs to domain classes foreach (DomainClass s in this.InvolvedClasses) { if (s == this.BaseClass) continue; DomainClass domainClass; if (bApplyForTempModel) domainClass = bClass.Store.ElementDirectory.FindElement(this.InvolvedClassesTargetMapping[s.Id]) as DomainClass; else domainClass = s; if (domainClass == null) throw new ArgumentNullException("DomainClass not found: Target Mappping error.. "); using (Transaction t2 = this.MetaModel.Store.TransactionManager.BeginTransaction("Base class")) { domainClass.BaseClass = null; t2.Commit(); } using (Transaction t3 = this.MetaModel.Store.TransactionManager.BeginTransaction("Add inh class")) { new DomainClassReferencesBaseClass(domainClass, bClass); t3.Commit(); } } // create inheritance from intermediate base class to base class DomainClass curBaseClass; if (bApplyForTempModel) curBaseClass = metaModel.Store.ElementDirectory.FindElement(this.InvolvedClassesTargetMapping[this.BaseClass.Id]) as DomainClass; else curBaseClass = this.BaseClass; new DomainClassReferencesBaseClass(bClass, curBaseClass); } else { // get base class if (bApplyForTempModel) bClass = metaModel.Store.ElementDirectory.FindElement(this.InvolvedClassesTargetMapping[this.BaseClass.Id]) as DomainClass; else bClass = this.BaseClass; } } if (bClass == null) throw new ArgumentNullException("Couldn't retrieve base class"); // remove properties from domain classes List<DomainProperty> toDelete = new List<DomainProperty>(); foreach (DomainClass d in this.InvolvedClasses) { if (d == this.BaseClass) continue; DomainClass domainClass; if (bApplyForTempModel) domainClass = bClass.Store.ElementDirectory.FindElement(this.InvolvedClassesTargetMapping[d.Id]) as DomainClass; else domainClass = d; if (domainClass == null) throw new ArgumentNullException("DomainClass not found: Target Mappping error.. "); for (int i = domainClass.Properties.Count - 1; i >= 0; i--) if (ContainsPropertyInInvolved(domainClass.Properties[i])) toDelete.Add(domainClass.Properties[i]); } foreach (DomainProperty p in toDelete) if( !p.IsDeleted && !p.IsDeleting ) p.Delete(); // add properties on bClass foreach (DomainProperty p in this.InvolvedProperties) { DomainProperty domainProperty = new DomainProperty(bClass.Store); domainProperty.Name = p.Name; domainProperty.Type = p.Type; domainProperty.IsElementName = p.IsElementName; bClass.Properties.Add(domainProperty); } t.Commit(); } }
/// <summary> /// Removes the reference. /// </summary> /// <param name="node">Node.</param> public void RemoveReference(DomainClass node) { this.ReferenceVM = null; }
/// <summary>Создание недостающих классов\отношений</summary> private void CreateElements() { Trace.WriteLine("Creating DSL elements"); Trace.Indent(); // Создание недостающих классов foreach (VisioClass vc in Page.Classes) { if (vc.IsDslRelationClass) { DomainRelationship dr = Doc.Dsl.Relationships.FindByGuid(vc.GUID) as DomainRelationship; // We can only create such VisioClass during synch with Dsl - it should not be possible to add such class from Visio. Debug.Assert(dr.IsValid); SynchronizeProperties(dr, vc); } else { DomainClass dc = Doc.Dsl.Classes.FindByGuid(vc.GUID) as DomainClass; if (!dc.IsValid) { Trace.WriteLine(vc.Name); dc = new DomainClass(Doc); dc.GUID = vc.GUID; Doc.Dsl.Classes.Add(dc); } // Синхронизация свойств SynchronizeProperties(dc, vc); } } // Создание недостающих ассоциаций\композиций foreach (VisioConnector vc in Page.Relationships) { DomainRelationship dr = Doc.Dsl.Relationships.FindByGuid(vc.GUID) as DomainRelationship; if (!dr.IsValid) { Trace.WriteLine(vc.Name); dr = new DomainRelationship(Doc); dr.GUID = vc.GUID; dr.Source = new DomainRole(Doc); dr.Target = new DomainRole(Doc); dr.IsEmbedding = vc.IsComposition; Doc.Dsl.Relationships.Add(dr); } } Trace.Unindent(); }
public RolePlayerConnectDirective(DomainClass Class) : base(Class.OwnerDocument.CreateElement("RolePlayerConnectDirective")) { Update(Class); }
/// <summary>Синхронизация свойств классов</summary> /// <param name="dc">Класс, который синхронизируем</param> /// <param name="vc">Класс, с которым синхронизируем</param> private void SynchronizeProperties(DomainClass dc, VisioClass vc) { // Приводим в порядок атрибуты String attrstr = "\n"; String[] attrs = vc.Attributes.Split('\n'); for (int i = 0; i < attrs.Length; i++) { attrs[i] = attrs[i].Trim(); attrstr += attrs[i] + "\n"; } // Добавляем новые свойства foreach (String attr in attrs) { if (attr.Length == 0) continue; if (dc.Properties[attr].Xml == null) { dc.CreateProperty("/System/String", attr, attr); } } // Удаляем ненужные свойства for (int i = 0; i < dc.Properties.Count; i++) { DomainProperty prop = dc.Properties[i] as DomainProperty; if (!attrstr.Contains("\n" + prop.Xml.GetAttribute("Name") + "\n")) { dc.Properties.RemoveLinked(prop); i--; } } }
/// <summary> /// Adds a new view model for the given element. /// </summary> /// <param name="node">Element.</param> public void AddShapeElement(DomainClass element) { if (this.elementViewModel != null) this.elementViewModel.Dispose(); if( element != null ) this.elementViewModel = new BaseModelElementViewModel(this.ViewModelStore, element); OnPropertyChanged("DiagramElementViewModel"); }