Beispiel #1
0
        protected void DoRemove()
        {
            Wrappers.Wrapper[] appliedto = d_wrapped.TemplateAppliesTo;

            if (appliedto.Length != 0)
            {
                if (appliedto.Length > 5)
                {
                    throw new Exception(String.Format("The template is still in use by {0} objects", appliedto.Length));
                }
                else
                {
                    string names = String.Join(", ", Array.ConvertAll <Wrappers.Wrapper, string>(appliedto, a => a.FullId));
                    throw new Exception(String.Format("The template is still in use by `{0}'", names));
                }
            }

            Wrappers.Edge link = d_wrapped as Wrappers.Edge;

            if (link != null && link.Output != null)
            {
                // Do this so that link offsets are recalculated correctly. This is a bit of a hack
                // really, and might be solved differently in the distant future, the year 2000
                link.Output.Unlink(link);
            }

            d_templates = new List <Wrappers.Wrapper>(d_wrapped.AppliedTemplates);

            d_parent.Remove(d_wrapped);
            d_wrapped.Removed();

            for (int i = d_templates.Count - 1; i >= 0; --i)
            {
                d_wrapped.UnapplyTemplate(d_templates[i]);
            }
        }
Beispiel #2
0
 protected void Unapply()
 {
     d_obj.UnapplyTemplate(d_template);
 }