private static T CastOrCreate <T>(IEnumeration enumeration) { var genericType = typeof(T); if (genericType == enumeration.GetType()) { return((T)enumeration); } var argTypes = new[] { typeof(int), typeof(string), typeof(string) }; var constructor = genericType.GetConstructor( BindingFlags.NonPublic | BindingFlags.Instance, null, argTypes, null); var argValues = new object[] { enumeration.Id, enumeration.Name, enumeration.DisplayValue }; return((T)constructor?.Invoke(argValues)); }
public static string Comment(IEnumeration t, string indent = "") { var sb = new StringBuilder(); sb.Append(indent); sb.Append(commentBegSummary); sb.AppendLine(); sb.Append(indent); sb.Append(comment); sb.Append("UI name: "); sb.Append(t.NameUi); sb.AppendLine(); if (!string.IsNullOrWhiteSpace(t.Description)) { sb.Append(indent); sb.Append(comment); //sb.Append("Description: "); sb.Append(t.Description); sb.AppendLine(); } sb.Append(indent); sb.Append(commentEndSummary); return(sb.ToString()); }
public virtual StringBuilder GetResquestInfo() { StringBuilder sb = new StringBuilder(512); sb.Append("\n").Append("> ").Append(GetMethod()).Append(" ").Append(GetRequestURL ()); if (GetQueryString() != null) { sb.Append("?").Append(GetQueryString()); } sb.Append("\n"); IEnumeration names = GetHeaderNames(); while (names.MoveNext()) { string name = (string)names.Current; IEnumeration values = GetHeaders(name); while (values.MoveNext()) { string value = (string)values.Current; sb.Append("> ").Append(name).Append(": ").Append(value).Append("\n"); } } sb.Append(">"); return(sb); }
/// <summary> /// 解压文件 /// </summary> /// <param name="inputZip"></param> /// <param name="destinationDirectory"></param> public static void UnzipFile(string inputZip, string destinationDirectory) { int buffer = 2048; List <string> zipFiles = new List <string>(); File sourceZipFile = new File(inputZip); File unzipDirectory = new File(destinationDirectory); CreateDir(unzipDirectory.AbsolutePath); ZipFile zipFile; zipFile = new ZipFile(sourceZipFile, ZipFile.OpenRead); IEnumeration zipFileEntries = zipFile.Entries(); while (zipFileEntries.HasMoreElements) { ZipEntry entry = (ZipEntry)zipFileEntries.NextElement(); string currentEntry = entry.Name; File destFile = new File(unzipDirectory, currentEntry); if (currentEntry.EndsWith(Constant.SUFFIX_ZIP)) { zipFiles.Add(destFile.AbsolutePath); } File destinationParent = destFile.ParentFile; CreateDir(destinationParent.AbsolutePath); if (!entry.IsDirectory) { if (destFile != null && destFile.Exists()) { continue; } BufferedInputStream inputStream = new BufferedInputStream(zipFile.GetInputStream(entry)); int currentByte; // buffer for writing file byte[] data = new byte[buffer]; var fos = new System.IO.FileStream(destFile.AbsolutePath, System.IO.FileMode.OpenOrCreate); BufferedOutputStream dest = new BufferedOutputStream(fos, buffer); while ((currentByte = inputStream.Read(data, 0, buffer)) != -1) { dest.Write(data, 0, currentByte); } dest.Flush(); dest.Close(); inputStream.Close(); } } zipFile.Close(); foreach (var zipName in zipFiles) { UnzipFile(zipName, destinationDirectory + File.SeparatorChar + zipName.Substring(0, zipName.LastIndexOf(Constant.SUFFIX_ZIP))); } }
protected override void BeginVisit(IEnumeration en) { if (en is INodeGenSettings) { _act(en as INodeGenSettings); } }
public HybridCorefAnnotator(Properties props) { // for backward compatibility try { // Load the default properties Properties corefProps = new Properties(); try { using (BufferedReader reader = IOUtils.ReaderFromString("edu/stanford/nlp/hcoref/properties/coref-default-dep.properties")) { corefProps.Load(reader); } } catch (IOException) { } // Add passed properties IEnumeration <object> keys = props.Keys; while (keys.MoveNext()) { string key = keys.Current.ToString(); corefProps.SetProperty(key, props.GetProperty(key)); } // Create coref system corefSystem = new HybridCorefSystem(corefProps); OldFormat = bool.ParseBoolean(props.GetProperty("oldCorefFormat", "false")); } catch (Exception e) { log.Error("cannot create HybridCorefAnnotator!"); Sharpen.Runtime.PrintStackTrace(e); throw new Exception(e); } }
public IEnumerable<Account> FindAccountsForService(string serviceId) { if (_keyStore == null) { InitializeStore(); } var accounts = new List<Account>(); string postfix = "-" + serviceId; IEnumeration aliases = _keyStore.Aliases(); while(aliases.HasMoreElements) { string alias = aliases.NextElement().ToString(); if(alias.EndsWith(postfix)) { var entry = _keyStore.GetEntry(alias, _prot) as KeyStore.SecretKeyEntry; if(entry != null) { byte[] bytes = entry.SecretKey.GetEncoded(); string serialized = Encoding.UTF8.GetString(bytes); Account account = Account.Deserialize(serialized); accounts.Add(account); } } } return accounts; }
private static void CheckNotCorrupt(EnumParameter p, Guid value, IEnumeration enumeration) { Assert.That(p.Corrupted, Is.False); Assert.That(p.DisplayValue((a, b) => ""), Is.EqualTo(enumeration.GetName(value))); Assert.That(p.Value, Is.EqualTo(value)); Assert.That(Guid.TryParse(p.ValueAsString(), out Guid guid), Is.True); Assert.That(guid, Is.EqualTo(p.Value)); }
private static bool StaticValueValid(IEnumeration enumeration, Guid value) { if (enumeration == null) { throw new ArgumentNullException(nameof(enumeration)); } return(enumeration.Options.Contains(value)); }
private void ProcessEnumeration(IEnumeration enumeration) { cw.WriteLine("[DataContract]"); cw.WriteLine("public enum {0}", enumeration.Name); cw.BeginScope(); for (int i = 0; i < enumeration.Items.Count; i++) { IEnumerationItem item = enumeration.Items[i]; cw.WriteLine("[EnumMember] {0} = {1}{2}", item.Name, item.Value, i + 1 == enumeration.Items.Count ? "" : ","); } cw.EndScope(); if (this.genie.Lamp.Config.Patterns.Localization != null) { cw.WriteLine("public static class {0}L10n", enumeration.Name); cw.BeginScope(); cw.BeginFunction("public static string GetName({0} value)", enumeration.Name); cw.WriteLine("switch(value)"); cw.BeginScope(); for (int i = 0; i < enumeration.Items.Count; i++) { IEnumerationItem item = enumeration.Items[i]; string caption = item.HasDoc ? item.Doc.GetLabel(new System.Globalization.CultureInfo("en")) : item.Name; cw.WriteLine("case {0}.{1}: return {2}.L.Catalog.GetString(\"{3}\");", enumeration.Name, item.Name, ServicesLayerConfig.ServicesInterfacesNamespace, String.IsNullOrWhiteSpace(caption) ? item.Name : caption); } cw.EndScope(); cw.WriteLine("throw new Exception(String.Format(\"Unsupported value: {{0}}. Enum: {0}\", value));", enumeration.Name); cw.EndFunction(); cw.WriteLine(); string enumItemClassName = String.Format("{0}Item", enumeration.Name); cw.BeginClass(AccessLevel.Public, false, enumItemClassName, null); cw.WriteLine("public {0} Id {{ get; set; }}", enumeration.Name); cw.WriteLine("public string Name { get; set; }"); cw.EndClass(); cw.WriteLine(); cw.BeginFunction("public static IList<{0}> GetList()", enumItemClassName); cw.WriteLine("List<{0}> list = new List<{0}>();", enumItemClassName); cw.WriteLine("{0}[] items = ({0}[])Enum.GetValues(typeof({0}));", enumeration.Name); cw.WriteLine("for(int i = 0; i < items.Length; i++ )"); cw.BeginScope(); cw.WriteLine("{0} item = new {0}() {{ Id = items[i], Name = GetName(items[i]) }};", enumItemClassName); cw.WriteLine("list.Add(item);"); cw.EndScope(); cw.WriteLine("return list;"); cw.EndFunction(); cw.EndScope(); cw.WriteLine(); } }
/// <summary> /// Gets called when the parent model element of the current model element is about to change /// </summary> /// <param name="oldParent">The old parent model element</param> /// <param name="newParent">The new parent model element</param> protected override void OnParentChanging(NMF.Models.IModelElement newParent, NMF.Models.IModelElement oldParent) { IEnumeration oldEnumeration = ModelHelper.CastAs <IEnumeration>(oldParent); IEnumeration newEnumeration = ModelHelper.CastAs <IEnumeration>(newParent); ValueChangedEventArgs e = new ValueChangedEventArgs(oldEnumeration, newEnumeration); this.OnEnumerationChanging(e); this.OnPropertyChanging("Enumeration", e, _enumerationReference); }
public void LoadNMeta() { EPackage package; package = EcoreInterop.LoadPackageFromFile("NMeta.ecore"); Assert.IsNotNull(package); metaNamespace = EcoreInterop.Transform2Meta(package); var boolean = metaNamespace.Resolve(new Uri("Boolean", UriKind.Relative)); var isInterface = metaNamespace.Resolve(new Uri("Class/IsInterface", UriKind.Relative)) as IAttribute; //var serializer = new ModelSerializer(); //serializer.RootPrefix = "nmeta"; //using (var sw = new FileStream(@"C:\Projekte\NMF\NMeta.nmf", FileMode.OpenOrCreate)) //{ // serializer.Serialize(metaNamespace.Model, sw); //} Assert.IsNotNull(metaNamespace); Assert.AreEqual(20, metaNamespace.Types.OfType<IClass>().Count()); type = GetClass("Type"); @class = GetClass("Class"); structuredType = GetClass("StructuredType"); typedElement = GetClass("ITypedElement"); metaElement = GetClass("MetaElement"); attribute = GetClass("Attribute"); reference = GetClass("Reference"); referenceType = GetClass("ReferenceType"); dataType = GetClass("DataType"); primitiveType = GetClass("PrimitiveType"); @namespace = GetClass("Namespace"); extension = GetClass("Extension"); @event = GetClass("Event"); operation = GetClass("Operation"); parameter = GetClass("Parameter"); enumeration = GetClass("Enumeration"); literal = GetClass("Literal"); modelElement = GetClass("ModelElement"); direction = metaNamespace.Types.OfType<IEnumeration>().FirstOrDefault(en => en.Name == "Direction"); Assert.IsNotNull(direction); direction.Literals.Select(l => l.Name).AssertSequence("In", "Out", "InOut"); AssertBaseTypes(); AssertProperties(); var model = metaNamespace.Model; Assert.IsNotNull(model); Assert.AreSame(type, model.Resolve("#//Type")); Assert.AreSame(@class, model.Resolve("#//Class")); Assert.AreSame(structuredType, model.Resolve("#//StructuredType")); }
/// <summary>Returns the full path to the Jar containing the class.</summary> /// <remarks> /// Returns the full path to the Jar containing the class. It always return a /// JAR. /// </remarks> /// <param name="klass">class.</param> /// <returns>path to the Jar containing the class.</returns> public static string GetJar(Type klass) { Preconditions.CheckNotNull(klass, "klass"); ClassLoader loader = klass.GetClassLoader(); if (loader != null) { string class_file = klass.FullName.ReplaceAll("\\.", "/") + ".class"; try { for (IEnumeration itr = loader.GetResources(class_file); itr.MoveNext();) { Uri url = (Uri)itr.Current; string path = url.AbsolutePath; if (path.StartsWith("file:")) { path = Runtime.Substring(path, "file:".Length); } path = URLDecoder.Decode(path, "UTF-8"); if ("jar".Equals(url.Scheme)) { path = URLDecoder.Decode(path, "UTF-8"); return(path.ReplaceAll("!.*$", string.Empty)); } else { if ("file".Equals(url.Scheme)) { string klassName = klass.FullName; klassName = klassName.Replace(".", "/") + ".class"; path = Runtime.Substring(path, 0, path.Length - klassName.Length); FilePath baseDir = new FilePath(path); FilePath testDir = new FilePath(Runtime.GetProperty("test.build.dir", "target/test-dir" )); testDir = testDir.GetAbsoluteFile(); if (!testDir.Exists()) { testDir.Mkdirs(); } FilePath tempJar = FilePath.CreateTempFile("hadoop-", string.Empty, testDir); tempJar = new FilePath(tempJar.GetAbsolutePath() + ".jar"); CreateJar(baseDir, tempJar); return(tempJar.GetAbsolutePath()); } } } } catch (IOException e) { throw new RuntimeException(e); } } return(null); }
/// <summary> /// Gets the <see cref="IEnumeration"/> value that has the specified value /// </summary> /// <param name="typeEnum">An <see cref="IEnumeration"/> value</param> /// <param name="value">The value of a particular enumerated constant in terms</param> /// <returns>The <see cref="IEnumeration"/> containing the value of the enumerated constant</returns> /// <exception cref="ArgumentException"><paramref name="typeEnum"/> is not a <see cref="IEnumeration"/> subclass</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="typeEnum"/> not contains a instance with the <paramref name="value"/> value</exception> public static IEnumeration GetValue(Type typeEnum, int value) { IEnumeration enumValue = GetValues(typeEnum).FirstOrDefault(enumeration => enumeration.Value == value); if (enumValue == null) { throw new ArgumentOutOfRangeException(nameof(value)); } return(enumValue); }
private static Tuple <Guid, bool> StaticDeserialize(IEnumeration enumeration, string value) { if (!Guid.TryParse(value, out Guid guid)) { return(Tuple.Create(default(Guid), true)); } else { return(Tuple.Create(guid, !StaticValueValid(enumeration, guid))); } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(NMF.Models.IModelElement item) { if ((this._parent.Enumeration == null)) { IEnumeration enumerationCasted = item.As <IEnumeration>(); if ((enumerationCasted != null)) { this._parent.Enumeration = enumerationCasted; return; } } }
protected override void EndVisit(IEnumeration en) { var p = (Enumeration)en; foreach (var t in p.ListEnumerationPairs) { t.IsMarkedForDeletion = false; t.IsNew = false; } p.IsMarkedForDeletion = false; p.IsNew = false; }
private static void CheckConstruction(IEnumeration enumeration, string name, Id <Parameter> id, SetParameter p) { Assert.That(p.Id, Is.EqualTo(id)); Assert.That(p.Name, Is.EqualTo(name)); Assert.That(p.TypeId, Is.EqualTo(ParameterType.ValueSetType.Of(enumeration.TypeId))); Assert.That(p.Options, Is.EquivalentTo(enumeration.Options)); foreach (var option in enumeration.Options) { Assert.That(p.GetName(option), Is.EqualTo(enumeration.GetName(option))); } }
/// <summary>Returns the response.</summary> /// <param name="responseCode">The response code.</param> /// <param name="fileSize">Size of the file.</param> private GetFileFromDfsResponse ReturnResponse(IEnumeration responseCode, long fileSize) { Logger.Information("File upload response code: " + responseCode); // Build Response var response = new GetFileFromDfsResponse { ResponseCode = ByteString.CopyFrom((byte)responseCode.Id), FileSize = (ulong)fileSize }; return(response); }
private static void CheckSetParameter(Tuple <Guid, string>[] options, IEnumeration enumeration, Id <Parameter> id, string def, bool corrupt) { string name = "testSetParameter"; var setParameter = enumeration.ParameterSet(name, id, def); Assert.That(setParameter.Corrupted, Is.EqualTo(corrupt)); Assert.That(setParameter.ValueAsString(), Is.EqualTo(def ?? enumeration.DefaultValue.Transformed(s => s, g => enumeration.GetName(g)))); Assert.That(setParameter.Id, Is.EqualTo(id)); Assert.That(setParameter.Name, Is.EqualTo(name)); Assert.That(setParameter.TypeId, Is.EqualTo(ParameterType.ValueSetType.Of(enumeration.TypeId))); Assert.That(setParameter, Is.InstanceOf <ISetParameter>()); Assert.That((setParameter as ISetParameter).Options, Is.EquivalentTo(options.Select(o => o.Item1))); }
public void LoadNMeta() { EPackage package; package = EcoreInterop.LoadPackageFromFile("NMeta.ecore"); Assert.IsNotNull(package); metaNamespace = EcoreInterop.Transform2Meta(package); var boolean = metaNamespace.Resolve(new Uri("Boolean", UriKind.Relative)); var isInterface = metaNamespace.Resolve(new Uri("Class/IsInterface", UriKind.Relative)) as IAttribute; Assert.IsNotNull(metaNamespace); Assert.AreEqual(20, metaNamespace.Types.OfType <IClass>().Count()); type = GetClass("Type"); @class = GetClass("Class"); structuredType = GetClass("StructuredType"); typedElement = GetClass("ITypedElement"); metaElement = GetClass("MetaElement"); attribute = GetClass("Attribute"); reference = GetClass("Reference"); referenceType = GetClass("ReferenceType"); dataType = GetClass("DataType"); primitiveType = GetClass("PrimitiveType"); @namespace = GetClass("Namespace"); extension = GetClass("Extension"); @event = GetClass("Event"); operation = GetClass("Operation"); parameter = GetClass("Parameter"); enumeration = GetClass("Enumeration"); literal = GetClass("Literal"); modelElement = GetClass("ModelElement"); direction = metaNamespace.Types.OfType <IEnumeration>().FirstOrDefault(en => en.Name == "Direction"); Assert.IsNotNull(direction); direction.Literals.Select(l => l.Name).AssertSequence("In", "Out", "InOut"); AssertBaseTypes(); AssertProperties(); var model = metaNamespace.Model; Assert.IsNotNull(model); Assert.AreSame(type, model.Resolve("#//Type")); Assert.AreSame(@class, model.Resolve("#//Class")); Assert.AreSame(structuredType, model.Resolve("#//StructuredType")); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 21DEC2008 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * get all records based on given rectangle. * @param rectGeo the boundary.. * @return a hashtable of all matched record.the key is the mapInfo ID. */ public Hashtable SearchMapObjectsInRect(GeoLatLngBounds rectGeo) { Point pt1, pt2; pt1 = new Point(new[] { (int)(rectGeo.X * DOUBLE_PRECISION + 0.5), (int)(rectGeo.Y * DOUBLE_PRECISION + 0.5) }); pt2 = new Point(new int[] { (int)((rectGeo.X + rectGeo.Width) * DOUBLE_PRECISION + 0.5), (int)((rectGeo.Y + rectGeo.Height) * DOUBLE_PRECISION + 0.5) }); HyperCube h1 = new HyperCube(pt1, pt2); Hashtable retArrayList = new Hashtable(); Point p11, p12; for (IEnumeration e1 = _tree.Intersection(h1); e1.HasMoreElements();) { AbstractNode node = (AbstractNode)(e1.NextElement()); if (node.IsLeaf()) { int index = 0; HyperCube[] data = node.GetHyperCubes(); HyperCube cube; for (int cubeIndex = 0; cubeIndex < data.Length; cubeIndex++) { cube = data[cubeIndex]; if (cube.Intersection(h1)) { p11 = cube.GetP1(); p12 = cube.GetP2(); int mapinfoId = ((Leaf)node).GetDataPointer(index); int mapInfoId = mapinfoId; GeoLatLngBounds mbr = new GeoLatLngBounds(); mbr.X = p11.GetFloatCoordinate(0) / DOUBLE_PRECISION; mbr.Y = p11.GetFloatCoordinate(1) / DOUBLE_PRECISION; mbr.Width = ((p12.GetFloatCoordinate(0) - p11.GetFloatCoordinate(0))) / DOUBLE_PRECISION; mbr.Height = ((p12.GetFloatCoordinate(1) - p11.GetFloatCoordinate(1))) / DOUBLE_PRECISION; if (!retArrayList.Contains(mapInfoId)) { retArrayList.Add(mapInfoId, mbr); } } index++; } } } return(retArrayList); }
protected override void Visit(IEnumeration parent, List <IEnumerationPair> diff_lst) { Contract.Requires(diff_lst != null); Contract.Requires(parent != null); List <EnumerationPair> lst = new List <EnumerationPair>(); foreach (var t in diff_lst) { lst.Add((EnumerationPair)t); } var grp = (Enumeration)parent; grp.ListEnumerationPairs.Clear(); grp.ListEnumerationPairs.AddRange(lst); }
public static string FormatEnumeration(IEnumerationItem item) { IEnumeration _enumeration = item.Enumeration; StringBuilder stringBuilder = new StringBuilder(); if (TemplateClass.SystemClasses.Any(_systemClass => _systemClass.Name == _enumeration.Name)) { stringBuilder.Append(_enumeration.Namespace.Name).Append("."); } stringBuilder.Append(_enumeration.Name).Append(".").Append(item.Name); return(stringBuilder.ToString()); }
public IReadOnlyList <IEnumerationPair> GetListEnumerationPairs(IEnumeration node, string guidAppPrjGen) { var lst = new List <IEnumerationPair>(); var cfg = this.Parent as Config; var g = cfg.DicActiveAppProjectGenerators[guidAppPrjGen]; foreach (var tt in node.ListEnumerationPairs) { if (tt.IsIncluded(guidAppPrjGen)) { lst.Add(tt); } } return(lst); }
protected override void EndVisit(IEnumeration en) { var p = (Enumeration)en; if (p.IsHasMarkedForDeletion && p.IsHasNew) { var lst = p.ListEnumerationPairs.ToList(); foreach (var t in lst) { if (t.IsMarkedForDeletion && t.IsNew) { p.ListEnumerationPairs.Remove(t); } } } }
/* * Dictionaries (notably, Properties) -- convert them to Maps and dispatch */ private static void Log <K, V>(Redwood.RedwoodChannels channels, string description, Dictionary <K, V> dict) { //(a real data structure) IDictionary <K, V> map = Generics.NewHashMap(); //(copy to map) IEnumeration <K> keys = dict.Keys; while (keys.MoveNext()) { K key = keys.Current; V value = dict[key]; map[key] = value; } //(log like normal) Log(channels, description, map); }
/// <summary> /// 写配置文件 /// </summary> /// <param name="context"></param> /// <param name="propertyKey"></param> /// <param name="propertyValue"></param> public static void changeValueByPropertyName(Context context, string propertyKey, string propertyValue) { // 实例化Properties对象 Properties prop = new Properties(); try { // 读取文件流 Stream ins = context.Assets.Open("Config.properties", Access.Random); // 装载Properties对象 prop.Load(ins); // 打开流 Stream fos = context.OpenFileOutput("Config.properties", FileCreationMode.Private); IEnumeration ie = prop.PropertyNames(); // 循环每一个节点 while (ie.HasMoreElements) { // 取出值 string s = ie.NextElement().ToString(); // 发是否是指定修改值得名称 if (!s.Equals(propertyKey)) { // 设置值 prop.SetProperty(s, prop.GetProperty(s)); } } // 设置值 prop.SetProperty(propertyKey, propertyValue); // 保存配置文件 prop.Store(fos, ""); ins.Close(); // 关闭Properties对象 fos.Close(); } catch (FileNotFoundException e) { Log.Error(LOG_FLAG, e.ToString()); LogUtil.SaveLogInfoToFile(e.ToString()); } catch (IOException e) { Log.Error(LOG_FLAG, e.ToString()); LogUtil.SaveLogInfoToFile(e.ToString()); } }
private static IEnumerable <ZipEntry> GetBitmapEntries(ZipFile file) { using (IEnumeration entries = file.Entries()) { while (entries.HasMoreElements) { var entry = (ZipEntry)entries.NextElement(); if (!entry.IsDirectory && (entry.Name.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) || entry.Name.EndsWith(".jpeg", StringComparison.OrdinalIgnoreCase) || entry.Name.EndsWith(".gif", StringComparison.OrdinalIgnoreCase) || entry.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase))) { yield return(entry); } } } }
/// <summary> /// Gets called when the parent model element of the current model element changes /// </summary> /// <param name="oldParent">The old parent model element</param> /// <param name="newParent">The new parent model element</param> protected override void OnParentChanged(IModelElement newParent, IModelElement oldParent) { IEnumeration oldEnumeration = ModelHelper.CastAs <IEnumeration>(oldParent); IEnumeration newEnumeration = ModelHelper.CastAs <IEnumeration>(newParent); if ((oldEnumeration != null)) { oldEnumeration.OwnedLiteral.Remove(this); } if ((newEnumeration != null)) { newEnumeration.OwnedLiteral.Add(this); } ValueChangedEventArgs e = new ValueChangedEventArgs(oldEnumeration, newEnumeration); this.OnEnumerationChanged(e); this.OnPropertyChanged("Enumeration", e); }
/// <summary> /// Gets called when the parent model element of the current model element changes /// </summary> /// <param name="oldParent">The old parent model element</param> /// <param name="newParent">The new parent model element</param> protected override void OnParentChanged(NMF.Models.IModelElement newParent, NMF.Models.IModelElement oldParent) { IEnumeration oldEnumeration = ModelHelper.CastAs <IEnumeration>(oldParent); IEnumeration newEnumeration = ModelHelper.CastAs <IEnumeration>(newParent); if ((oldEnumeration != null)) { oldEnumeration.Literals.Remove(this); } if ((newEnumeration != null)) { newEnumeration.Literals.Add(this); } ValueChangedEventArgs e = new ValueChangedEventArgs(oldEnumeration, newEnumeration); this.OnEnumerationChanged(e); this.OnPropertyChanged("Enumeration", e, _enumerationReference); base.OnParentChanged(newParent, oldParent); }