Ejemplo n.º 1
0
        public GenObject(GenObject parent, ISubClassBase parentSubClass, int classId)
        {
            Parent         = parent;
            RefParent      = null;
            ParentSubClass = parentSubClass;
            ClassId        = classId;
            Attributes     = new TextList();

            if (Parent == null)
            {
                return;
            }
            GenDataBase = Parent.GenDataBase;
            if (Definition != null && Definition.IsInherited)
            {
                Contract.Assert(Definition.Parent.Inheritors.Contains(Definition),
                                "The new object is inherited, but not from its parent");
                Contract.Assert(!Definition.Parent.IsInherited && parentSubClass.ClassId == Definition.Parent.ClassId ||
                                Definition.Parent.IsInherited && parentSubClass.ClassId == Definition.Parent.Parent.ClassId,
                                "The new object is being added to the incorrect subclass");
            }
            else
            {
                Contract.Assert(parentSubClass.Definition == null || parentSubClass.Definition.SubClass.ClassId == ClassId,
                                "The new object is being assigned to the wrong subclass");
            }
        }
Ejemplo n.º 2
0
        public SubClassFieldViewModel(ISubClassBase parent, GenDataDefSubClass genDataDefSubClass, ISubClassBase subClass,
                                      SubClassField subClassField, bool isReadOnly)
        {
            IgnorePropertyValidation = true;
            Parent             = parent;
            GenDataDefSubClass = genDataDefSubClass;
            SubClassField      = subClassField;
            SubClass           = subClass;
            switch (subClassField)
            {
            case SubClassField.Name:
                Name = "Name";
                Hint = genDataDefSubClass == null || genDataDefSubClass.Reference == ""
                               ? "The name of the subclass"
                               : "The name of the top level class in the referenced file";
                DataType   = "Identifier";
                IsReadOnly = true;
                break;

            case SubClassField.Reference:
                Name = "Reference";
                Hint = genDataDefSubClass == null || genDataDefSubClass.Reference == ""
                               ? "Must be blank"
                               : "The name of the referenced file";
                DataType   = "String";
                IsReadOnly = isReadOnly || genDataDefSubClass == null || genDataDefSubClass.Reference == "";
                break;

            default:
                throw new ArgumentOutOfRangeException("subClassField");
            }
        }
Ejemplo n.º 3
0
 protected void RemoveSubClass(ISubClassBase value)
 {
     if (this.m_SubClassList == null)
     {
         this.m_SubClassList = new SubClassBaseCollection();
     }
     this.m_SubClassList.Remove(value);
     value.AmbientOwner = null;
 }
Ejemplo n.º 4
0
 protected void AddSubClass(ISubClassBase value)
 {
     if (this.m_SubClassList == null)
     {
         this.m_SubClassList = new SubClassBaseCollection();
     }
     this.m_SubClassList.Add(value);
     value.AmbientOwner = this;
 }
Ejemplo n.º 5
0
 protected void AddSubClass(ISubClassBase value)
 {
     if (this.m_SubClassList == null)
     {
         this.m_SubClassList = new SubClassBaseCollection();
     }
     this.m_SubClassList.Add(value);
     value.ComponentBase = this;
 }
Ejemplo n.º 6
0
        private static void CompareContext(ISubClassBase expectedList, ISubClassBase actualList)
        {
            var expectedId = expectedList.ClassId;
            var actualId   = actualList.ClassId;

            Assert.AreEqual(expectedId, actualId);
            Assert.AreEqual(expectedList.Count, actualList.Count, "Class " + expectedId + " objects");
            Assert.AreEqual(expectedList.ClassId, actualList.ClassId);
            Assert.AreEqual(expectedList.Definition.SubClass.RefClassId, actualList.Definition.SubClass.RefClassId);
            Assert.AreEqual(expectedList.Reference, expectedList.Reference);
            Assert.AreEqual(expectedList.Definition.SubClass.ToString(), actualList.Definition.SubClass.ToString());
            for (var i = 0; i < expectedList.Count; i++)
            {
                var expectedObject = expectedList[i];
                var actualObject   = actualList[i];
                Assert.AreEqual(expectedObject.ClassId, actualObject.ClassId);
                var expectedAttributes = new GenAttributes(expectedObject.GenDataBase.GenDataDef, expectedObject.ClassId);
                var actualAttributes   = new GenAttributes(actualObject.GenDataBase.GenDataDef, actualObject.ClassId);
                expectedAttributes.GenObject = expectedObject;
                actualAttributes.GenObject   = actualObject;
                Assert.GreaterOrEqual(expectedObject.Attributes.Count, actualObject.Attributes.Count);
                foreach (var property in actualObject.Definition.Properties)
                {
                    Assert.AreEqual(expectedAttributes.AsString(property),
                                    actualAttributes.AsString(property),
                                    property + " " + expectedAttributes.AsString("Name") + " vs " +
                                    actualAttributes.AsString("Name"));
                }

                Assert.AreEqual(expectedObject.SubClass.Count, actualObject.SubClass.Count);
                for (var j = 0; j < actualObject.SubClass.Count; j++)
                {
                    var expectedSubClassName = expectedObject.SubClass[j].Definition.SubClass.Name;
                    var actualSubClassName   = actualObject.SubClass[j].Definition.SubClass.Name;
                    Assert.AreEqual(expectedSubClassName, actualSubClassName);
                    var expectedSubClassDef = expectedObject.GetSubClass(expectedSubClassName).Definition.SubClass;
                    var actualSubClassDef   = actualObject.GetSubClass(actualSubClassName).Definition.SubClass;
                    Assert.AreEqual(expectedSubClassDef.ToString(), actualSubClassDef.ToString());
                    Assert.AreEqual(expectedSubClassDef.ClassId, actualSubClassDef.ClassId);
                    Assert.AreEqual(expectedSubClassDef.IsInherited, actualSubClassDef.IsInherited);
                    Assert.AreEqual(expectedSubClassDef.IsAbstract, actualSubClassDef.IsAbstract);
                    Assert.AreEqual(expectedObject.SubClass[j].ClassId, actualObject.SubClass[j].ClassId);
                    Assert.AreEqual(expectedObject.SubClass[j].Reference, actualObject.SubClass[j].Reference);
                    CompareContext(expectedObject.SubClass[j], actualObject.SubClass[j]);
                }

                Assert.AreEqual(expectedObject.Definition.Inheritors.Count, actualObject.Definition.Inheritors.Count);
                for (var j = 0; j < expectedObject.Definition.Inheritors.Count; j++)
                {
                    var expectedDefInheritor = expectedObject.Definition.Inheritors[j];
                    var actualDefInheritor   = actualObject.Definition.Inheritors[j];
                    Assert.AreEqual(expectedDefInheritor.ClassId, actualDefInheritor.ClassId);
                    Assert.Less(expectedId, expectedDefInheritor.ClassId);
                }
            }
        }
Ejemplo n.º 7
0
        public SubClassViewModel(ISubClassBase parent, ISubClassBase subClassBase,
                                 GenNamedApplicationBase def, GenDataDefSubClass subClassDef, bool isReadOnly)
        {
            Parent      = parent;
            Definition  = def;
            SubClassDef = subClassDef;
            IsReadOnly  = isReadOnly;
//            SavedContext = savedContext;
            SubClassBase   = subClassBase;
            SavedReference = Parent != null ? Parent.Reference : "";
            GenObject      = subClassBase.Parent;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// The saved context.
        /// </summary>
//        public new GenSavedContext SavedContext { get { return base.SavedContext; } private set { base.SavedContext = value; } }

        /// <summary>
        /// Create a new <see cref="SubClassTreeNode"/> for the selected subclass.
        /// </summary>
        /// <param name="parentNode">The tree node of the parent class of this subclass.</param>
        /// <param name="genDataBase">The data being navigated.</param>
        /// <param name="definition">The definition data for the data being navigated.</param>
        /// <param name="classId">The ClassId of this subclass.</param>
        public SubClassTreeNode(ClassTreeNode parentNode, GenDataBase genDataBase, Definition definition, int classId)
        {
            ClassId     = classId;
            ParentNode  = parentNode;
            GenDataBase = genDataBase;
            Definition  = definition;
            var    genDataDef = GenDataBase.GenDataDef;
            int    parentClassId;
            string parentClassName;
            Class  parentClass;

            Def = null;
            if (ParentNode == null)
            {
                SubClassBase = genDataBase.Root.SubClass[0];
            }
            else
            {
                parentClassId   = ParentNode.ClassId;
                parentClassName = genDataDef.GetClassName(parentClassId);
                SubClassBase    = ParentNode.GenObject.GetSubClass(genDataDef.GetClassName(classId));
                parentClass     = definition.ClassList.Find(parentClassName);
                var i = genDataDef.Classes[parentClassId].IndexOfSubClass(genDataDef.GetClassName(ClassId));
                SubClassDef = genDataDef.GetClassSubClasses(parentClassId)[i];
                if (parentClass != null)
                {
                    Def = parentClass.SubClassList[i];
                }
            }

            Text = genDataDef.GetClassName(ClassId) +
                   (SubClassDef != null && !string.IsNullOrEmpty(SubClassDef.Reference)
                       ? ":" + SubClassBase.Reference
                       : "");
            ImageIndex  = 2;
            ToolTipText = Text;
            Tag         = new SubClassViewModel(ParentNode == null ? null : ParentNode.GenObject.ParentSubClass, SubClassBase, Def,
                                                SubClassDef, SubClassDef != null && !string.IsNullOrEmpty(SubClassDef.Reference));

            for (var j = 0; j < SubClassBase.Count; j++)
            {
                Nodes.Add(new ClassTreeNode(this, GenDataBase, Definition, ClassId, SubClassBase[j]));
            }
        }
Ejemplo n.º 9
0
 protected void ResetClone(ISubClassBase clone)
 {
     if (this.m_DefaultArray != null)
     {
         foreach (PropertyData item in this.m_DefaultArray)
         {
             PropertyInfo property = clone.GetType().GetProperty(item.Name);
             if (property != (PropertyInfo)null)
             {
                 property.SetValue(clone, item.Value, null);
             }
         }
     }
     if (this.m_SubClassList != null)
     {
         for (int i = 0; i < this.m_SubClassList.Count; i++)
         {
             ISubClassBase subClassBase = this.m_SubClassList[i];
             ISubClassBase clone2       = clone.SubClassList[i];
             subClassBase.ResetClone(clone2);
         }
     }
 }
Ejemplo n.º 10
0
        private static GenObject GetDescendentContext(GenObject genObject, string className, ISubClassBase exclude = null)
        {
            var subClass = genObject.GetSubClass(className);

            if (subClass != null)
            {
                if (subClass.Definition.SubClass.IsInheritor(className))
                {
                    return(subClass.Count == 0 ? null : subClass[0]);
                }
                return(null);
            }

            foreach (var s in genObject.SubClass)
            {
                var sc = genObject.GetSubClass(s.ClassId);
                if (sc == exclude)
                {
                    continue;
                }
                if (sc.Definition.SubClass.IsInheritor(className))
                {
                    return(sc.Count == 0 ? null : sc[0]);
                }
                var descendentContext = sc.Count == 0 ? null : GetDescendentContext(sc[0], className);
                if (descendentContext != null &&
                    descendentContext.ClassName.Equals(className, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(descendentContext);
                }
            }
            return(genObject);
        }
Ejemplo n.º 11
0
 public bool Contains(ISubClassBase value)
 {
     return(base.List.Contains(value));
 }
Ejemplo n.º 12
0
 public int IndexOf(ISubClassBase value)
 {
     return(base.List.IndexOf(value));
 }
Ejemplo n.º 13
0
 public void Remove(ISubClassBase value)
 {
     base.List.Remove(value);
 }
Ejemplo n.º 14
0
 public void Insert(int index, ISubClassBase value)
 {
     base.List.Insert(index, value);
 }
Ejemplo n.º 15
0
 public int Add(ISubClassBase value)
 {
     return(base.List.Add(value));
 }
Ejemplo n.º 16
0
 void ISubClassBase.ResetClone(ISubClassBase clone)
 {
     this.ResetClone(clone);
 }