Inheritance: FanObj, Facet
コード例 #1
0
ファイル: Serializable.cs プロジェクト: nomit007/f4
 public static Serializable make(Func func)
 {
     Serializable self = new Serializable();
       if (func != null)
       {
     func.enterCtor(self);
     func.call(self);
     func.exitCtor();
       }
       return self;
 }
コード例 #2
0
ファイル: Serializable.cs プロジェクト: syatanic/fantom
        public static Serializable make(Func func)
        {
            Serializable self = new Serializable();

            if (func != null)
            {
                func.enterCtor(self);
                func.call(self);
                func.exitCtor();
            }
            return(self);
        }
コード例 #3
0
ファイル: ObjEncoder.cs プロジェクト: nomit007/f4
        //////////////////////////////////////////////////////////////////////////
        // Complex
        //////////////////////////////////////////////////////////////////////////
        private void writeComplex(Type type, object obj, Serializable ser)
        {
            wType(type);

              bool first = true;
              object defObj = null;
              if (skipDefaults) defObj = FanObj.@typeof(obj).make();

              List fields = type.fields();
              for (int i=0; i<fields.sz(); ++i)
              {
            Field f = (Field)fields.get(i);

            // skip static, transient, and synthetic (once) fields
            if (f.isStatic() || f.isSynthetic() || f.hasFacet(Sys.TransientType))
              continue;

            // get the value
            object val = f.get(obj);

            // if skipping defaults
            if (defObj != null)
            {
              object defVal = f.get(defObj);
              if (OpUtil.compareEQ(val, defVal)) continue;
            }

            // if first then open braces
            if (first) { w('\n').wIndent().w('{').w('\n'); level++; first = false; }

            // field name =
            wIndent().w(f.name()).w('=');

            // field value
            curFieldType = f.type().toNonNullable();
            writeObj(val);
            curFieldType = null;

            w('\n');
              }

              // if collection
              if (ser.m_collection)
            first = writeCollectionItems(type, obj, first);

              // if we output fields, then close braces
              if (!first) { level--; wIndent().w('}'); }
        }