public static FieldDomain ToDomain(Transaction t, ObjectId id) { FieldDomain result; try { FieldDomain fieldDomain = new FieldDomain(t, id); fieldDomain.Read(id, t); result = fieldDomain; } catch { result = null; } return(result); }
private bool IsUniqueName(Database db, Transaction t) { DBDictionary dBDictionary = this.ParentDataset.Open(db, t, FieldDomain.DictionaryName, 0); if (!dBDictionary.Contains(this.Name)) { return(true); } FieldDomain fieldDomain = new FieldDomain(t, dBDictionary.GetAt(this.Name)); fieldDomain.ParentDataset = this.ParentDataset; if (FieldDomain.AreEqual(this, fieldDomain)) { this.Id = fieldDomain.Id; return(true); } return(false); }
public static FieldDomain ToDomain(Transaction t, MSCDataset parent, ObjectId id) { FieldDomain result; try { FieldDomain fieldDomain = new FieldDomain(t, id); if (parent != null) { fieldDomain.ParentDataset = parent; } fieldDomain.Read(id, t); result = fieldDomain; } catch { result = null; } return(result); }
private static bool AreEquivalent(FieldDomain a, Domain b) { if (string.Compare(a.DisplayName, b.DomainName, true) != 0) { return(false); } CadField.CadFieldType cadFieldType = FieldDomain.GetCadFieldType(b.FieldType); if (cadFieldType != a.FieldType) { return(false); } if (b is CodedValueDomain) { if (a.DomainType != "CodedValueDomain") { return(false); } } else if (b is RangeDomain && a.DomainType != "RangeDomain") { return(false); } return(true); }
private static bool AreEqual(FieldDomain a, FieldDomain b) { return(string.Compare(a.Name, b.Name, true) == 0 && string.Compare(a.DisplayName, b.DisplayName, true) == 0 && string.Compare(a.DomainType, b.DomainType, true) == 0 && a.FieldType == b.FieldType && a.MinValue.Equals(b.MinValue) && a.MaxValue.Equals(b.MaxValue) && a.CodedValues.Count == b.CodedValues.Count && Utility.DictionaryEqual <string, MSCCodedValue>(a.CodedValues, b.CodedValues)); }
public static FieldDomain GetDomain(Domain fs_domain) { FieldDomain result; try { ObservableDictionary <string, FieldDomain> domains = AfaDocData.ActiveDocData.DocDataset.Domains; string key = DocUtil.FixSymbolName(fs_domain.DomainName); FieldDomain fieldDomain = null; if (domains.TryGetValue(key, out fieldDomain) && FieldDomain.AreEquivalent(fieldDomain, fs_domain)) { result = fieldDomain; } else { string domainType = ""; if (fs_domain is CodedValueDomain) { domainType = "CodedValueDomain"; } else if (fs_domain is RangeDomain) { domainType = "RangeDomain"; } CadField.CadFieldType cadFieldType = FieldDomain.GetCadFieldType(fs_domain.FieldType); fieldDomain = new FieldDomain(fs_domain.DomainName, cadFieldType, domainType); if (fs_domain is CodedValueDomain) { CodedValueDomain codedValueDomain = (CodedValueDomain)fs_domain; if (codedValueDomain.CodedValues.Length <= 0) { goto IL_129; } CodedValue[] array = codedValueDomain.CodedValues.ToArray <CodedValue>(); try { CodedValue[] array2 = array; for (int i = 0; i < array2.Length; i++) { CodedValue codedValue = array2[i]; fieldDomain.CodedValues.Add(DocUtil.FixSymbolName(codedValue.Name), new MSCCodedValue(codedValue.Name, cadFieldType, codedValue.Code)); } goto IL_129; } catch (SystemException ex) { string arg_FC_0 = ex.Message; goto IL_129; } } if (fs_domain is RangeDomain) { RangeDomain rangeDomain = (RangeDomain)fs_domain; fieldDomain.MinValue = rangeDomain.MinValue; fieldDomain.MaxValue = rangeDomain.MaxValue; } IL_129: AfaDocData.ActiveDocData.DocDataset.Domains.Add(fieldDomain.Name, fieldDomain); result = fieldDomain; } } catch { result = null; } return(result); }