// ======================================================================== // Methods #region === Methods /// <summary> /// Determines if a class will be reflected. /// </summary> /// <param name="nrClass">The class to test.</param> /// <returns><c>True</c> if the class should be reflected.</returns> public bool Reflect(NRClass nrClass) { FilterModifiers filterModifiers = GetFilterModifier(nrClass.AccessModifier); filterModifiers |= nrClass.ClassModifier == ClassModifier.Static ? FilterModifiers.Static : FilterModifiers.Instance; return(RuleMatch(FilterElements.Class, filterModifiers)); }
/// <summary> /// Visit a <see cref="NRClass"/>. /// </summary> /// <param name="nrClass">The <see cref="NRClass"/> to visit.</param> public void Visit(NRClass nrClass) { OutputLine("NRClass"); indent++; PrintMembers(nrClass); OutputLine("ClassModifier: " + nrClass.ClassModifier); indent--; }
// ======================================================================== // Methods #region === Methods /// <summary> /// Determines if a class will be reflected. /// </summary> /// <param name="nrClass">The class to test.</param> /// <returns><c>True</c> if the class should be reflected.</returns> public bool Reflect(NRClass nrClass) { if (Filter.Reflect(nrClass)) { ReflectedClasses++; return(true); } IgnoredClasses++; return(false); }
// ======================================================================== // Methods #region === Methods /// <summary> /// Gets the <see cref="NRClass" /> as a C# string. Only the head of the class /// is returned. /// </summary> /// <param name="nrClass">The class to get the code for.</param> /// <returns>A string representing the class header.</returns> public static string Declaration(this NRClass nrClass) { string accessModifier = AddSpace(nrClass.AccessModifier.Declaration( )); string modifier = AddSpace(nrClass.ClassModifier.Declaration( )); string genericDecl = GetGenericDefinition(nrClass); string baseDecl = ""; if (nrClass.ClassModifier != ClassModifier.Static) { baseDecl = GetBaseTypeAndInterfaces(nrClass); } string genericConstraint = GetGenericConstraint(nrClass); return(string.Format("{0}{1}class {2}{3}{4}{5}", accessModifier, modifier, nrClass.Name, genericDecl, baseDecl, genericConstraint)); }
/// <summary> /// Visit a <see cref="NRClass"/>. /// </summary> /// <param name="nrClass">The <see cref="NRClass"/> to visit.</param> public void Visit(NRClass nrClass) { if (!string.IsNullOrWhiteSpace(nrClass.DeclaringTypeFullName) && (currentType != null && nrClass.DeclaringTypeFullName != currentType.FullName || currentType == null)) { // Do not output the class since it is nested and we are not inside the parent type. return; } NRTypeBase oldCurrentType = currentType; currentType = nrClass; VisitAttributes(nrClass); OutputLine(nrClass.Declaration()); OutputLine("{"); indent++; foreach (NRField nrField in nrClass.Fields) { nrField.Accept(this); } foreach (NRConstructor nrConstructor in nrClass.Constructors) { nrConstructor.Accept(this); } foreach (NRProperty nrProperty in nrClass.Properties) { nrProperty.Accept(this); } foreach (NREvent nrEvent in nrClass.Events) { nrEvent.Accept(this); } foreach (NRMethod nrMethod in nrClass.Methods) { nrMethod.Accept(this); } foreach (NROperator nrOperator in nrClass.Operators) { nrOperator.Accept(this); } VisitNestedTypes(nrClass); indent--; OutputLine("}"); OutputEmptyLineAfterType(); currentType = oldCurrentType; }
/// <summary> /// Visit a <see cref="NRClass"/>. /// </summary> /// <param name="nrClass">The <see cref="NRClass"/> to visit.</param> public void Visit(NRClass nrClass) { VisitAttributes(nrClass); Output(ToString(nrClass.AccessModifier) + ToString(nrClass.ClassModifier) + "class " + nrClass.Name + GetGenericDefinition(nrClass)); PrintBaseTypeAndInterfaces(nrClass); VisitTypeParameters(nrClass); OutputLine(""); OutputLine("{"); indent++; foreach (NRField nrField in nrClass.Fields) { nrField.Accept(this); } foreach (NRProperty nrProperty in nrClass.Properties) { nrProperty.Accept(this); } foreach (NRConstructor nrConstructor in nrClass.Constructors) { nrConstructor.Accept(this); } foreach (NRMethod nrMethod in nrClass.Methods) { nrMethod.Accept(this); } foreach (NROperator nrOperator in nrClass.Operators) { nrOperator.Accept(this); } foreach (NREvent nrEvent in nrClass.Events) { nrEvent.Accept(this); } indent--; OutputLine("}"); }
// ======================================================================== // Operators and Type Conversions #region === Operators and Type Conversions #endregion // ======================================================================== // Methods #region === Methods /// <summary> /// Determines if a class will be reflected. /// </summary> /// <param name="nrClass">The class to test.</param> /// <returns> /// <c>True</c> if the class should be reflected. /// </returns> public bool Reflect(NRClass nrClass) { return(filter.Reflect(nrClass)); }
// ======================================================================== // Operators and Type Conversions #region === Operators and Type Conversions #endregion // ======================================================================== // Methods #region === Methods /// <summary> /// Determines if a class will be reflected. /// </summary> /// <param name="nrClass">The class to test.</param> /// <returns> /// <c>True</c> if the class should be reflected. /// </returns> public bool Reflect(NRClass nrClass) { return filter.Reflect(nrClass); }
// ======================================================================== // Methods #region === Methods /// <summary> /// Determines if a class will be reflected. /// </summary> /// <param name="nrClass">The class to test.</param> /// <returns><c>True</c> if the class should be reflected.</returns> public bool Reflect(NRClass nrClass) { return(true); }