コード例 #1
0
ファイル: SimpleType.cs プロジェクト: Creepsky/Nexus
        public override void Template(TemplateContext context, IGenerationElement concreteElement)
        {
            if (concreteElement == null)
            {
                var tmp1 = context.LookupTemplateType(this);
                Name         = tmp1.Name;
                TemplateList = tmp1.TemplateList;
                return;
            }

            // get the resulting type of the concrete element
            var concreteSimpleType = concreteElement.GetResultType(context.CallerContext);

            if (concreteSimpleType == null)
            {
                throw new TemplateGenerationException(this, $"Could not get the result type of {concreteElement}");
            }

            // check the template list of both types
            if (TemplateList == null)
            {
                if (concreteSimpleType.TemplateList != null)
                {
                    throw new TemplateGenerationException(this, $"Expected an empty template list ({this}), but got {concreteSimpleType}");
                }
            }
            // if the concrete type has a template list, we have to check if it fits to the template type template list
            else if (!TemplateList.Equals(concreteSimpleType.TemplateList))
            {
                throw new TemplateGenerationException(this, $"Expected the template list to be {TemplateList} but got {concreteSimpleType.TemplateList}");
            }

            TemplateList?.Template(context, concreteSimpleType.TemplateList);

            var tmp2 = context.RegisterTemplateType(this, concreteSimpleType);

            Name         = tmp2.Name;
            TemplateList = tmp2.TemplateList;
        }
コード例 #2
0
ファイル: SimpleType.cs プロジェクト: Creepsky/Nexus
        public bool Equals(SimpleType other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            // exceptions
            if (IsTemplate || this is CppType || other is CppType)
            {
                return(true);
            }

            if (Name != other.Name)
            {
                return(false);
            }

            if (TemplateList == null)
            {
                if (other.TemplateList != null)
                {
                    return(false);
                }
            }
            else if (!TemplateList.Equals(other.TemplateList))
            {
                return(false);
            }

            return(true);
        }