Example #1
0
        /// <summary>
        /// Determines if two code roots are the same.
        /// </summary>
        /// <param name="comparisonCodeRoot">The CodeRoot to compare against.</param>
        /// <param name="depth">The depth to which we should compare. Signature will always
        /// return true, as CodeRoots have no signature. Outer will return true if the UsingStatements
        /// are the same, and complete will compare all children.</param>
        /// <returns>true if the given CodeRoot matches this one to the specified depth.</returns>
        private bool IsTheSame(CodeRoot comparisonCodeRoot, ComparisonDepth depth)
        {
            if (comparisonCodeRoot == null)
            {
                return(false);
            }

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

            if (UsingStatementsTextBlock != comparisonCodeRoot.UsingStatementsTextBlock)
            {
                BaseConstruct.ComparisonDifference += GetType().Name + ".UsingStatements";
                return(false);
            }

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

            if (!Utility.BaseContructCollectionsAreTheSame(Classes.ToArray(), comparisonCodeRoot.Classes.ToArray()))
            {
                BaseConstruct.ComparisonDifference += GetType().Name + ".Classes";
                return(false);
            }
            if (
                !Utility.BaseContructCollectionsAreTheSame(Namespaces.ToArray(), comparisonCodeRoot.Namespaces.ToArray()))
            {
                BaseConstruct.ComparisonDifference += GetType().Name + ".Namespaces";
                return(false);
            }
            if (!Utility.BaseContructCollectionsAreTheSame(Structs.ToArray(), comparisonCodeRoot.Structs.ToArray()))
            {
                BaseConstruct.ComparisonDifference += GetType().Name + ".Structs";
                return(false);
            }
            if (
                !Utility.BaseContructCollectionsAreTheSame(Interfaces.ToArray(), comparisonCodeRoot.Interfaces.ToArray()))
            {
                BaseConstruct.ComparisonDifference += GetType().Name + ".Interfaces";
                return(false);
            }
            if (!Utility.BaseContructCollectionsAreTheSame(Enums.ToArray(), comparisonCodeRoot.Enums.ToArray()))
            {
                BaseConstruct.ComparisonDifference += GetType().Name + ".Enums";
                return(false);
            }
            if (!Utility.BaseContructCollectionsAreTheSame(UsingStatements.ToArray(), comparisonCodeRoot.UsingStatements.ToArray()))
            {
                BaseConstruct.ComparisonDifference += GetType().Name + ".UsingStatements";
                return(false);
            }
            return(true);
        }
 public CSharpController()
 {
     Root = new CodeRoot(this);
     dict = new Dictionary <Type, Func <IPrintable, IPrinter> >()
     {
         { typeof(Attribute), bc => new AttributePrinter(bc as Attribute) },
         { typeof(AttributeSection), bc => new AttributeSectionPrinter(bc as AttributeSection) },
         { typeof(BaseConstruct), bc => new BaseConstructPrinter(bc as BaseConstruct) },
         { typeof(Class), bc => new ClassPrinter(bc as Class) },
         { typeof(CodeRoot), bc => new CodeRootPrinter(bc as CodeRoot) },
         { typeof(Constant), bc => new ConstantPrinter(bc as Constant) },
         { typeof(Constructor), bc => new ConstructorPrinter(bc as Constructor) },
         { typeof(DataType), bc => new DataTypePrinter(bc as DataType) },
         { typeof(Delegate), bc => new DelegatePrinter(bc as Delegate) },
         { typeof(Destructor), bc => new DestructorPrinter(bc as Destructor) },
         { typeof(EmptyPlaceholder), bc => new EmptyPlaceholderPrinter(bc as EmptyPlaceholder) },
         { typeof(Enumeration), bc => new EnumerationPrinter(bc as Enumeration) },
         { typeof(Event), bc => new EventPrinter(bc as Event) },
         { typeof(Field), bc => new FieldPrinter(bc as Field) },
         { typeof(Function), bc => new FunctionPrinter(bc as Function) },
         { typeof(Indexer), bc => new IndexerPrinter(bc as Indexer) },
         { typeof(Interface), bc => new InterfacePrinter(bc as Interface) },
         { typeof(InterfaceAccessor), bc => new InterfaceAccessorPrinter(bc as InterfaceAccessor) },
         { typeof(InterfaceEvent), bc => new InterfaceEventPrinter(bc as InterfaceEvent) },
         { typeof(InterfaceIndexer), bc => new InterfaceIndexerPrinter(bc as InterfaceIndexer) },
         { typeof(InterfaceMethod), bc => new InterfaceMethodPrinter(bc as InterfaceMethod) },
         { typeof(InterfaceProperty), bc => new InterfacePropertyPrinter(bc as InterfaceProperty) },
         { typeof(Namespace), bc => new NamespacePrinter(bc as Namespace) },
         { typeof(Operator), bc => new OperatorPrinter(bc as Operator) },
         { typeof(Parameter), bc => new ParameterPrinter(bc as Parameter) },
         { typeof(Property), bc => new PropertyPrinter(bc as Property) },
         { typeof(PropertyAccessor), bc => new PropertyAccessorPrinter(bc as PropertyAccessor) },
         { typeof(Region), bc => new RegionPrinter(bc as Region) },
         { typeof(RegionStart), bc => new RegionStartPrinter(bc as RegionStart) },
         { typeof(RegionEnd), bc => new RegionEndPrinter(bc as RegionEnd) },
         { typeof(Struct), bc => new StructPrinter(bc as Struct) },
         { typeof(UsingStatement), bc => new UsingStatementPrinter(bc as UsingStatement) },
         { typeof(Enumeration.EnumMember), bc => new EnumerationPrinter.EnumMemberPrinter(bc as Enumeration.EnumMember) }
     };
 }
 public override void Reset()
 {
     Root = new CodeRoot(this);
 }
 public CodeRootPrinter(CodeRoot obj)
 {
     this.obj = obj;
 }