public override string GetMonikerQualifier(DomainXmlSerializerDirectory directory, ModelElement element) { if (directory == null) { throw new System.ArgumentNullException("directory"); } if (element == null) { throw new System.ArgumentNullException("element"); } DomainType domainType = element as DomainType; string s = domainType.MetaModel.Name; object[] objArr = new object[] { s }; return(System.String.Format(CultureInfo.CurrentCulture, "/{0}", objArr)); }
public static string GetDomainTypeCodeName(DomainType domainType) { if (domainType.Name.Contains("?")) { // remove ? and see if we can use that name.. otherwise add "Nullable" and an integer if needed at the end to destinguish name ReadOnlyCollection<ModelElement> elements = domainType.Store.ElementDirectory.FindElements(DomainType.DomainClassId); string typeName = domainType.Name.Replace("?", ""); string typeNameWithoutIndex = typeName; bool bNullableAdded = false; int index = 0; while (true) { bool bFound = false; foreach (ModelElement m in elements) { if (m != domainType) { DomainType t = m as DomainType; if (t.Name == typeName) { bFound = true; if (!bNullableAdded) { typeName += "Nullable"; typeNameWithoutIndex = typeName; bNullableAdded = true; } else { typeName = typeNameWithoutIndex + (index++); } // need to restart again break; } } } if (!bFound) return typeName; } } return domainType.Name; }
public override string CalculateQualifiedName(DomainXmlSerializerDirectory directory, ModelElement element) { if (directory == null) { throw new System.ArgumentNullException("directory"); } if (element == null) { throw new System.ArgumentNullException("element"); } DomainType domainType = element as DomainType; string s1 = this.GetMonikerQualifier(directory, domainType); string s2 = domainType.Namespace; string s3 = domainType.Name; object[] objArr = new object[] { s1, s2, s3 }; return(System.String.Format(CultureInfo.CurrentCulture, "{0}/{1}/{2}", objArr)); }
public override void ElementAdded(ElementAddedEventArgs e) { if (e.ModelElement != null) { if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null) { if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { return; } } } if (e.ModelElement == null) { return; } if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None) { return; } DomainType domainType = e.ModelElement as DomainType; if (domainType != null) { if (domainType.MetaModel != null) { if (domainType.Namespace == "" || domainType.Namespace == null) { domainType.Namespace = domainType.MetaModel.Namespace; } } } }
protected override IList <Microsoft.VisualStudio.Modeling.ModelElement> BuildElementList(object component) { Microsoft.VisualStudio.Modeling.DomainClassInfo domainClassInfo = DomainRoleInfo.RolePlayer; if (domainClassInfo == null || component == null) { return(new System.Collections.Generic.List <Microsoft.VisualStudio.Modeling.ModelElement>()); } Microsoft.VisualStudio.Modeling.Store store = this.GetStore(component); DomainType domainType = component as DomainType; System.Collections.Generic.List <Microsoft.VisualStudio.Modeling.ModelElement> list = new System.Collections.Generic.List <Microsoft.VisualStudio.Modeling.ModelElement>(); list.AddRange(domainType.MetaModel.PropertyGridEditors); System.Collections.Generic.IList <Microsoft.VisualStudio.Modeling.ModelElement> ilist = store.ElementDirectory.FindElements(domainClassInfo, false); foreach (Microsoft.VisualStudio.Modeling.ModelElement modelElement in ilist) { PropertyGridEditor p = modelElement as PropertyGridEditor; bool bFound = false; foreach (PropertyGridEditor e in list) { if (e.Name == p.Name) { bFound = true; break; } } if (!bFound) { list.Add(p); } } return(list); }