コード例 #1
0
        public IFormatter Create(Type type)
        {
            Type formatterType           = typeof(EditableFormatter <>).MakeGenericType(type);
            IEditableFormatter formatter = Activator.CreateInstance(formatterType) as IEditableFormatter;

            formatter.SerializationDelegate   = CreateWriteMethod(type);
            formatter.DeserializationDelegate = CreateReadMethod(type);
            formatter.ShouldSkipFieldDelegate = CreateShouldSkipMethod(type);

            return(formatter as IFormatter);
        }
コード例 #2
0
ファイル: BuilderContext.cs プロジェクト: HellBrick/AowSdk
        public IFormatter BuildFormatter()
        {
            Initialize();
            CreateSerializeMethod();
            CreateDeserializeMethod();
            CreateShouldSkipMethod();

            IEditableFormatter editableFormatter = Activator.CreateInstance(typeof(EditableFormatter <>).MakeGenericType(TargetType)) as IEditableFormatter;

            editableFormatter.DeserializationDelegate = DeserializeExpression.Compile();
            editableFormatter.SerializationDelegate   = SerializeExpression.Compile();
            editableFormatter.ShouldSkipFieldDelegate = ShouldSkipExpression.Compile();

            return(editableFormatter as IFormatter);
        }