Esempio n. 1
0
        protected override bool CustomMergeStepInternal(BaseConstruct user, BaseConstruct newgen, BaseConstruct prevgen)
        {
            Event userBC = (Event)user, newgenBC = (Event)newgen, prevgenBC = (Event)prevgen;

            // DataType;
            if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.MergeDataType(ref DataType, userBC.DataType, newgenBC.DataType, prevgenBC.DataType))
            {
                return(false);
            }
            // Modifiers
            if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.MergeModifiers(this, userBC, newgenBC, prevgenBC))
            {
                return(false);
            }
            // AddAccessorText
            if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.MergeSingleItem(ref AddAccessorText, userBC.AddAccessorText, newgenBC.AddAccessorText, prevgenBC.AddAccessorText))
            {
                return(false);
            }
            // RemoveAccessorText
            if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.MergeSingleItem(ref RemoveAccessorText, userBC.RemoveAccessorText, newgenBC.RemoveAccessorText, prevgenBC.RemoveAccessorText))
            {
                return(false);
            }
            // InitialValue
            if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.MergeSingleItem(ref InitialValue, userBC.InitialValue, newgenBC.InitialValue, prevgenBC.InitialValue))
            {
                return(false);
            }
            return(true);
        }
 public InterfaceAccessor(Controller controller, BaseConstruct parentObject, AccessorTypes accessorType, CodeLanguage language)
     : base(controller)
 {
     ParentObject = parentObject;
     AccessorType = accessorType;
     Language     = language;
 }
Esempio n. 3
0
        public virtual bool IsTheSame(BaseConstruct comparisonObject, ComparisonDepth depth)
        {
            if (Name != comparisonObject.Name)
            {
                ComparisonDifference += comparisonObject.GetType().Name + ".Name";
                return(false);
            }

            if (depth == ComparisonDepth.Signature)
            {
                return(true);
            }

            Comparers.BaseConstructComparer comparer = new Comparers.BaseConstructComparer();

            if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.BaseContructCollectionsAreTheSame(_Attributes.ToArray(), comparisonObject._Attributes.ToArray(), comparer))
            {
                ComparisonDifference += comparisonObject.GetType().Name + ".Attributes";
                return(false);
            }
            if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.StringCollectionsAreTheSame(XmlComments, comparisonObject.XmlComments))
            {
                ComparisonDifference += comparisonObject.GetType().Name + ".XmlComments";
                return(false);
            }
            if (Comments.IsTheSame(comparisonObject.Comments) == false)
            {
                ComparisonDifference += comparisonObject.GetType().Name + ".Comments";
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a new child to this IBaseConstruct.
        /// </summary>
        /// <param name="childBC">The child object to add</param>
        public void AddChild(IBaseConstruct childBC)
        {
            if (childBC == this)
            {
                throw new ArgumentException("Cannot add an object as a child of itself");
            }

            // Cannot add non C# BaseConstructs.
            if (!(childBC is BaseConstruct))
            {
                throw new ArgumentException("Cannot add an non C# BaseConstruct as a child of a C# BaseConstruct");
            }

            BaseConstruct bc = (BaseConstruct)childBC;

            bc.ParentObject = this;
            bc.Controller   = Controller;

            // No longer treating attributes as children.
            //if(childBC is Attribute)
            //{
            //    Attributes.Add(childBC as Attribute);
            //}
            if (childBC is EmptyPlaceholder)
            {
                emptyPlaceholders.Add(childBC as EmptyPlaceholder);
            }
            else
            {
                AddChildInternal(bc);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Adds a new child to this IBaseConstruct.
        /// </summary>
        /// <param name="child">The child object to add.</param>
        protected override void AddChildInternal(BaseConstruct child)
        {
            if (child == null)
            {
                throw new InvalidOperationException("Cannot add null child");
            }

            if (child is InterfaceIndexer)
            {
                Indexers.Add(child as InterfaceIndexer);
            }
            else if (child is InterfaceMethod)
            {
                Methods.Add(child as InterfaceMethod);
            }
            else if (child is InterfaceProperty)
            {
                Properties.Add(child as InterfaceProperty);
            }
            else if (child is InterfaceEvent)
            {
                Events.Add(child as InterfaceEvent);
            }

            else
            {
                throw new InvalidOperationException("Cannot add child of type " + child.GetType());
            }
        }
Esempio n. 6
0
        private bool MergeComments(BaseConstruct userBC, BaseConstruct newgenBC, BaseConstruct prevgenBC)
        {
            bool userChange = false, templateChange = false;

            // Comments
            if (userBC.Comments.IsTheSame(prevgenBC.Comments) == false)
            {
                userChange = true;
            }
            if (newgenBC.Comments.IsTheSame(prevgenBC.Comments) == false)
            {
                templateChange = true;
            }

            if (userBC.Equals(newgenBC))
            {
                userChange     = true;
                templateChange = false;
            }

            if (templateChange && userChange)
            {
                return(false);
            }
            if (userChange)
            {
                Comments = userBC.Comments.Clone();
            }
            else if (templateChange)
            {
                Comments = newgenBC.Comments.Clone();
            }
            return(true);
        }
Esempio n. 7
0
 public Field(Controller controller, BaseConstruct parentObject, CodeLanguage language, int nodeIndex)
     : base(controller)
 {
     ParentObject = parentObject;
     Language     = language;
     Index        = nodeIndex;
 }
Esempio n. 8
0
 public Function(Controller controller, BaseConstruct parentObject, int nodeIndex)
     : base(controller)
 {
     ParentObject = parentObject;
     Language     = CodeLanguage.CSharp;
     Index        = nodeIndex;
 }
Esempio n. 9
0
        protected override void RemoveChildObjectInternal(BaseConstruct childBC)
        {
            if (childBC == null)
            {
                throw new InvalidOperationException("Cannot remove null child");
            }

            if (childBC is PropertyAccessor)
            {
                PropertyAccessor accessor = (PropertyAccessor)childBC;
                if (accessor == GetAccessor)
                {
                    GetAccessor = null;
                }
                else if (accessor == SetAccessor)
                {
                    SetAccessor = null;
                }
                else
                {
                    throw new InvalidOperationException("The accessor does not belong to this Property");
                }
            }
            else
            {
                throw new InvalidOperationException("Cannot remove child of type " + childBC.GetType());
            }
        }
Esempio n. 10
0
 public Parameter(Controller controller, BaseConstruct parentObject, string name, string dataType, CodeLanguage language)
     : this(controller)
 {
     ParentObject = parentObject;
     Name         = name;
     DataType     = dataType;
     Language     = language;
 }
 public PropertyAccessor(Controller controller, BaseConstruct parentObject, AccessorTypes accessorType, string text, CodeLanguage language)
     : base(controller)
 {
     ParentObject = parentObject;
     AccessorType = accessorType;
     Text         = text;
     Language     = language;
 }
Esempio n. 12
0
 public Class(Controller controller, string name, List <string> modifiers, List <string> baseNames, BaseConstruct.CodeLanguage language, BaseConstruct parentObject)
     : base(controller)
 {
     Name         = name;
     BaseNames    = baseNames;
     Language     = language;
     Modifiers    = modifiers;
     ParentObject = parentObject;
 }
Esempio n. 13
0
 public Struct(Controller controller, BaseConstruct parentObject, string name, List <string> modifiers, CodeLanguage language, int nodeIndex)
     : base(controller)
 {
     ParentObject = parentObject;
     Name         = name;
     Language     = language;
     Modifiers    = modifiers;
     Index        = nodeIndex;
 }
Esempio n. 14
0
 public Namespace(Controller controller, BaseConstruct parentObject, string name, CodeRoot parentCodeRoot, CodeLanguage language, int nodeIndex)
     : this(controller)
 {
     ParentObject   = parentObject;
     Name           = name;
     ParentCodeRoot = parentCodeRoot;
     Language       = language;
     Index          = nodeIndex;
 }
Esempio n. 15
0
 public InterfaceEvent(Controller controller, BaseConstruct parentObject, string name, DotNet.DataType dataType, bool hasNewKeyword, CodeLanguage language, int nodeIndex)
     : base(controller)
 {
     ParentObject  = parentObject;
     Name          = name;
     DataType      = dataType;
     HasNewKeyword = hasNewKeyword;
     Language      = language;
     Index         = nodeIndex;
 }
Esempio n. 16
0
 public Enumeration(Controller controller, string name, List <string> modifiers, string enumBase, BaseConstruct parentObject, CodeLanguage language, int nodeIndex)
     : base(controller)
 {
     Name         = name;
     EnumBase     = enumBase;
     Modifiers    = modifiers;
     ParentObject = parentObject;
     Language     = language;
     Index        = nodeIndex;
 }
Esempio n. 17
0
 public Interface(Controller controller, string name, List <string> modifiers, string interfaceBase, CodeLanguage language, BaseConstruct parentObject, int nodeIndex)
     : base(controller)
 {
     Name          = name;
     InterfaceBase = interfaceBase;
     Language      = language;
     Modifiers     = modifiers;
     ParentObject  = parentObject;
     Index         = nodeIndex;
 }
        protected override bool CustomMergeStepInternal(BaseConstruct user, BaseConstruct newgen, BaseConstruct prevgen)
        {
            InterfaceAccessor userBC = (InterfaceAccessor)user, newgenBC = (InterfaceAccessor)newgen, prevgenBC = (InterfaceAccessor)prevgen;

            // Modifiers
            if (!Utility.MergeModifiers(this, userBC, newgenBC, prevgenBC))
            {
                return(false);
            }
            return(true);
        }
 public InterfaceProperty(Controller controller, BaseConstruct parentObject, string name, DotNet.DataType dataType, InterfaceAccessor getAccessor, InterfaceAccessor setAccessor, bool hasNewKeyword, CodeLanguage language, int nodeIndex)
     : base(controller)
 {
     ParentObject  = parentObject;
     Name          = name;
     DataType      = dataType;
     GetAccessor   = getAccessor;
     SetAccessor   = setAccessor;
     HasNewKeyword = hasNewKeyword;
     Language      = language;
     Index         = nodeIndex;
 }
Esempio n. 20
0
 protected Property(Controller controller, BaseConstruct parentObject, string name, DotNet.DataType dataType, List <string> modifiers, PropertyAccessor getAccessor, PropertyAccessor setAccessor, CodeLanguage language, int nodeIndex)
     : base(controller)
 {
     ParentObject = parentObject;
     Name         = name;
     DataType     = dataType;
     Modifiers    = modifiers;
     GetAccessor  = getAccessor;
     SetAccessor  = setAccessor;
     Language     = language;
     Index        = nodeIndex;
 }
Esempio n. 21
0
        private bool MergeAttributes(BaseConstruct userBC, BaseConstruct newgenBC, BaseConstruct prevgenBC)
        {
            bool userChange = false, templateChange = false;

            if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.BaseContructCollectionsAreTheSame(userBC._Attributes.ToArray(), prevgenBC._Attributes.ToArray()))
            {
                userChange = true;
            }
            if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.BaseContructCollectionsAreTheSame(newgenBC._Attributes.ToArray(), prevgenBC._Attributes.ToArray()))
            {
                templateChange = true;
            }

            if (ArchAngel.Providers.CodeProvider.CSharp.Utility.BaseContructCollectionsAreTheSame(newgenBC._Attributes.ToArray(), userBC._Attributes.ToArray()))
            {
                userChange     = true;
                templateChange = false;
            }

            if (templateChange && userChange)
            {
                return(false);
            }

            _Attributes.Clear();
            _AttributeSections.Clear();
            if (userChange)
            {
                foreach (Attribute attr in userBC._Attributes)
                {
                    Attribute clone = (Attribute)attr.Clone();

                    AttributeSection parentSec = new AttributeSection(controller);
                    parentSec.Target = ((AttributeSection)attr.ParentObject).Target;
                    parentSec.AddAttribute(clone);
                    AddAttributeSection(parentSec);
                }
            }
            else if (templateChange)
            {
                foreach (Attribute attr in newgenBC._Attributes)
                {
                    Attribute clone = (Attribute)attr.Clone();

                    AttributeSection parentSec = new AttributeSection(controller);
                    parentSec.Target = ((AttributeSection)attr.ParentObject).Target;
                    parentSec.AddAttribute(clone);
                    AddAttributeSection(parentSec);
                }
            }
            return(true);
        }
Esempio n. 22
0
        protected override bool CustomMergeStepInternal(BaseConstruct user, BaseConstruct newgen, BaseConstruct prevgen)
        {
            Destructor userCon = (Destructor)user, newgenCon = (Destructor)newgen, prevgenCon = (Destructor)prevgen;

            // IsExtern
            if (Utility.MergeSingleItem(ref isExtern, userCon.IsExtern, newgenCon.IsExtern, prevgenCon.IsExtern) == false)
            {
                return(false);
            }
            IsExtern = isExtern;             // Triggers the replacement of BodyText if needed.

            return(true);
        }
Esempio n. 23
0
        private string CalculateFullyQualifiedName(string separator)
        {
            StringBuilder sb = new StringBuilder(50);

            sb.Append(Name);
            BaseConstruct parentObject = ParentObject;

            while (parentObject != null && parentObject is CSharpParser.CodeRootBaseConstructAdapter == false)
            {
                sb.Insert(0, parentObject.DisplayName + separator);
                parentObject = parentObject.ParentObject;
            }
            return(sb.ToString());
        }
Esempio n. 24
0
 public InterfaceMethod(Controller controller, BaseConstruct parentObject, string name, DotNet.DataType returnType, bool hasNewKeyword, IEnumerable <Parameter> parameters, CodeLanguage language, int nodeIndex)
     : base(controller)
 {
     ParentObject       = parentObject;
     Name               = name;
     this.returnType    = returnType;
     this.hasNewKeyword = hasNewKeyword;
     Parameters.Clear();
     if (parameters != null)
     {
         Parameters.AddRange(parameters);
     }
     Language = language;
     Index    = nodeIndex;
 }
Esempio n. 25
0
 public InterfaceIndexer(Controller controller, BaseConstruct parentObject, DotNet.DataType dataType, bool hasNewKeyword, IEnumerable <Parameter> parameters, InterfaceAccessor getAccessor, InterfaceAccessor setAccessor, CodeLanguage language, int nodeIndex)
     : this(controller)
 {
     ParentObject       = parentObject;
     this.dataType      = dataType;
     this.hasNewKeyword = hasNewKeyword;
     if (parameters != null)
     {
         Parameters.AddRange(parameters);
     }
     GetAccessor = getAccessor;
     SetAccessor = setAccessor;
     Language    = language;
     Index       = nodeIndex;
 }
Esempio n. 26
0
 public Delegate(Controller controller, string name, List <string> modifiers, string genericType, IEnumerable <Parameter> parameters, DataType returnType, BaseConstruct.CodeLanguage language, BaseConstruct parentObject, int nodeIndex)
     : base(controller)
 {
     Name        = name;
     ReturnType  = returnType;
     GenericType = genericType ?? "";
     if (parameters != null)
     {
         Parameters.AddRange(parameters);
     }
     Language     = language;
     Modifiers    = modifiers;
     ParentObject = parentObject;
     Index        = nodeIndex;
 }
Esempio n. 27
0
        /// <summary>
        /// Adds a new child to this IBaseConstruct.
        /// </summary>
        /// <param name="child">The child object to add.</param>
        protected override void AddChildInternal(BaseConstruct child)
        {
            if (child == null)
            {
                throw new InvalidOperationException("Cannot add null child");
            }

            if (child is Event)
            {
                Events.Add(child as Event);
            }
            else if (child is Class)
            {
                Classes.Add(child as Class);
            }
            else if (child is Struct)
            {
                Structs.Add(child as Struct);
            }
            else if (child is Enumeration)
            {
                Enums.Add(child as Enumeration);
            }
            else if (child is Interface)
            {
                Interfaces.Add(child as Interface);
            }
            else if (child is Delegate)
            {
                Delegates.Add(child as Delegate);
            }
            else if (child is Region)
            {
                Regions.Add(child as Region);
            }
            else if (child is Namespace)
            {
                InnerNamespaces.Add(child as Namespace);
            }
            else if (child is UsingStatement)
            {
                UsingStatements.Add(child as UsingStatement);
            }
            else
            {
                throw new InvalidOperationException("Cannot add child of type " + child.GetType());
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Adds a new child to this IBaseConstruct.
        /// </summary>
        /// <param name="childBC"></param>
        protected override void AddChildInternal(BaseConstruct childBC)
        {
            if (childBC == null)
            {
                throw new InvalidOperationException("Cannot add null child");
            }

            if (childBC is EnumMember)
            {
                Members.Add(childBC as EnumMember);
            }
            else
            {
                throw new InvalidOperationException("Cannot add child of type " + childBC.GetType());
            }
        }
Esempio n. 29
0
        protected override bool CustomMergeStepParameterInternal(BaseConstruct user, BaseConstruct newgen, BaseConstruct prevgen)
        {
            Operator userBC = (Operator)user, newgenBC = (Operator)newgen, prevgenBC = (Operator)prevgen;

            // DataType
            if (!Utility.MergeDataType(ref DataType, userBC.DataType, newgenBC.DataType, prevgenBC.DataType))
            {
                return(false);
            }
            // Modifiers
            if (!Utility.MergeModifiers(this, userBC, newgenBC, prevgenBC))
            {
                return(false);
            }
            return(true);
        }
Esempio n. 30
0
 public Indexer(Controller controller, BaseConstruct parentObject, DataType dataType, IEnumerable <Parameter> parameters, PropertyAccessor getAccessor, PropertyAccessor setAccessor, CodeLanguage language, int nodeIndex)
     : base(controller)
 {
     ParentObject = parentObject;
     DataType     = dataType;
     Parameters.Clear();
     if (parameters != null)
     {
         Parameters.AddRange(parameters);
     }
     GetAccessor = getAccessor;
     SetAccessor = setAccessor;
     Language    = language;
     Index       = nodeIndex;
     Name        = "this";
 }