public virtual IUimlElement Resolve(Template t, IUimlElement placeholder) { // add all children of the template's top element to placeholder's children Console.Write("Trying to unite element '{0}' with template '{1}'... ", ((UimlAttributes) placeholder).Identifier, t.Identifier); try { // check if types are compatible if (t.Top.GetType().Equals(placeholder.GetType())) { // TODO: check for children with the same identifier, and resolve name conflicts! // add elements from template's top element placeholder.Children.AddRange(t.Top.Children); Console.WriteLine("OK!"); } else Console.WriteLine("Failed! -> incompatible types, no action taken"); } catch (Exception e) { Console.WriteLine("Failed!"); } return placeholder; // always return placeholder, whether it's modified or not }
public virtual IUimlElement Resolve(Template t, IUimlElement placeholder) { // add all unique children of the template's top element to placeholder's children Console.Write("Trying to unite element '{0}' with template '{1}'... ", ((UimlAttributes) placeholder).Identifier, t.Identifier); try { // check if types are compatible if (t.Top.GetType().Equals(placeholder.GetType())) { // TODO: only add unique children !!! placeholder.Children.AddRange(t.Top.Children); Console.WriteLine("OK!"); } else Console.WriteLine("Failed! -> incompatible types, no action taken"); } catch (Exception e) { Console.WriteLine("Failed!"); } return placeholder; // always return placeholder, regardless of modifications }