Ejemplo n.º 1
0
        /// <summary>
        ///     Gets the <see cref="NRField" /> as a C# string.
        /// </summary>
        /// <param name="field">The field to get the code for.</param>
        /// <returns>A string representing the field.</returns>
        public static string Declaration(this NRField field)
        {
            string accessModifier = AddSpace(field.AccessModifier.Declaration( ));
            string modifier       = AddSpace(field.FieldModifier.Declaration( ));
            string value          = "";

            if (!string.IsNullOrWhiteSpace(field.InitialValue) || field.IsConstant)
            {
                if (field.InitialValue == null)
                {
                    value = " = null";
                }
                else if (field.Type.Name == "String")
                {
                    value = " = \"" + EscapeString(field.InitialValue) + "\"";
                }
                else if (field.Type.Name == "Char")
                {
                    value = " = '" + EscapeString(field.InitialValue) + "'";
                }
                else
                {
                    value = " = " + field.InitialValue;
                }
            }

            return(string.Format("{0}{1}{2} {3}{4}", accessModifier, modifier, field.Type.Declaration( ), field.Name, value));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Visit a <see cref="NRField"/>.
        /// </summary>
        /// <param name="nrField">The <see cref="NRField"/> to visit.</param>
        public void Visit(NRField nrField)
        {
            VisitAttributes(nrField);

            OutputLine(nrField.Declaration() + ";");
            OutputEmptyLineAfterMember();
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Determines if a field will be reflected.
        /// </summary>
        /// <param name="nrField">The field to test.</param>
        /// <returns><c>True</c> if the field should be reflected.</returns>
        public bool Reflect(NRField nrField)
        {
            FilterModifiers filterModifiers = GetFilterModifier(nrField.AccessModifier);

            filterModifiers |= nrField.FieldModifier == FieldModifier.Static ? FilterModifiers.Static : FilterModifiers.Instance;
            FilterElements filterElement = nrField.IsConstant ? FilterElements.Constant : FilterElements.Field;

            return(RuleMatch(filterElement, filterModifiers));
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Determines if a field will be reflected.
 /// </summary>
 /// <param name="nrField">The field to test.</param>
 /// <returns><c>True</c> if the field should be reflected.</returns>
 public bool Reflect(NRField nrField)
 {
     if (Filter.Reflect(nrField))
     {
         ReflectedFields++;
         return(true);
     }
     IgnoredFields++;
     return(false);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Visit a <see cref="NRField"/>.
        /// </summary>
        /// <param name="nrField">The <see cref="NRField"/> to visit.</param>
        public void Visit(NRField nrField)
        {
            VisitAttributes(nrField);
            string value = "";

            if (nrField.IsConstant)
            {
                value = ": " + (nrField.InitialValue ?? "null");
            }
            OutputLine(ToString(nrField.AccessModifier) + ToString(nrField.FieldModifier) + ToString(nrField.Type) + " " + nrField.Name + value);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Visit a <see cref="NRField"/>.
 /// </summary>
 /// <param name="nrField">The <see cref="NRField"/> to visit.</param>
 public void Visit(NRField nrField)
 {
     OutputLine("NRField");
     indent++;
     PrintMembers(nrField);
     OutputLine("FieldModifier: " + nrField.FieldModifier);
     OutputLine("InitialValue: " + nrField.InitialValue);
     OutputLine("IsConstant: " + nrField.IsConstant);
     OutputLine("IsHider: " + nrField.IsHider);
     OutputLine("IsReadonly: " + nrField.IsReadonly);
     OutputLine("IsStatic: " + nrField.IsStatic);
     OutputLine("IsVolatile: " + nrField.IsVolatile);
     indent--;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Determines if a field will be reflected.
 /// </summary>
 /// <param name="nrField">The field to test.</param>
 /// <returns>
 /// <c>True</c> if the field should be reflected.
 /// </returns>
 public bool Reflect(NRField nrField)
 {
     return(IsUnsafePointer(nrField.Type.Name) ? false : filter.Reflect(nrField));
 }
Ejemplo n.º 8
0
 public NRFieldDeclaration(NRField field)
 {
     this.field = field;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Determines if a field will be reflected.
 /// </summary>
 /// <param name="nrField">The field to test.</param>
 /// <returns>
 /// <c>True</c> if the field should be reflected.
 /// </returns>
 public bool Reflect(NRField nrField)
 {
   return IsUnsafePointer(nrField.Type) ? false : filter.Reflect(nrField);
 }
Ejemplo n.º 10
0
 /// <summary>
 ///     Determines if a field will be reflected.
 /// </summary>
 /// <param name="nrField">The field to test.</param>
 /// <returns><c>False</c> if the field should not be reflected.</returns>
 public bool Reflect(NRField nrField)
 {
     return(true);
 }
Ejemplo n.º 11
0
 /// <summary>
 ///     Determines if a field will be reflected.
 /// </summary>
 /// <param name="nrField">The field to test.</param>
 /// <returns><c>True</c> if the field should be reflected.</returns>
 public bool Reflect(NRField nrField)
 {
     return(!Filter.Reflect(nrField));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Determines if a field will be reflected.
 /// </summary>
 /// <param name="nrField">The field to test.</param>
 /// <returns>
 /// <c>True</c> if the field should be reflected.
 /// </returns>
 public bool Reflect(NRField nrField)
 {
     return(filter.Reflect(nrField) && CanImportTypeUsage(nrField.Type));
 }