コード例 #1
0
        BeginSerializeObject(
            Object serializedObject
            )
        {
            FixedDocumentSequence fds = serializedObject as FixedDocumentSequence;

            if (!NgcSerializationManager.IsPrintTicketEventHandlerEnabled)
            {
                //NgcSerializationManager.FdsPrintTicket = fds.PrintTicket as PrintTicket;
            }
            else
            {
                XpsSerializationPrintTicketRequiredEventArgs e =
                    new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentSequencePrintTicket,
                                                                     0);
                NgcSerializationManager.OnNGCSerializationPrintTicketRequired(e);
            }

            NgcSerializationManager.StartDocument(fds, false);

            NGCSerializerContext context = new NGCSerializerContext(this,
                                                                    null,
                                                                    SerializerAction.endPersistObjectData);

            NgcSerializationManager.OperationStack.Push(context);


            ReachSerializer serializer = NgcSerializationManager.GetSerializer(fds.References);

            serializer.SerializeObject(fds.References);
        }
コード例 #2
0
        AsyncOperation(
            NGCSerializerContext context
            )
        {
            if (context == null)
            {
            }

            switch (context.Action)
            {
            case SerializerAction.endPersistObjectData:
            {
                EndPersistObjectData();
                break;
            }

            case SerializerAction.serializeNextDocumentPage:
            {
                SerializeNextDocumentPage(context);
                break;
            }

            default:
            {
                base.AsyncOperation(context);
                break;
            }
            }
        }
コード例 #3
0
        BeginSerializeObject(
            Object serializedObject
            )
        {
            FixedDocument fd = serializedObject as FixedDocument;

            if (!NgcSerializationManager.IsPrintTicketEventHandlerEnabled)
            {
                //NgcSerializationManager.FdPrintTicket = fd.PrintTicket as PrintTicket;
            }

            NgcSerializationManager.StartDocument(fd, true);

            //
            // Create the context for the current object
            //

            NGCSerializerContext context = new NGCSerializerContext(this,
                                                                    null,
                                                                    SerializerAction.endPersistObjectData);

            NgcSerializationManager.OperationStack.Push(context);

            ReachSerializer serializer = NgcSerializationManager.GetSerializer(fd.Pages);

            serializer.SerializeObject(fd.Pages);
        }
コード例 #4
0
        AsyncOperation(
            NGCSerializerContext context
            )
        {
            if (context == null)
            {
            }

            switch (context.Action)
            {
            case SerializerAction.serializeNextDocumentReference:
            {
                NgcDocumentReferenceCollectionSerializerContext thisContext =
                    context as NgcDocumentReferenceCollectionSerializerContext;

                if (thisContext != null)
                {
                    SerializeNextDocumentReference(thisContext.Enumerator,
                                                   thisContext.ObjectContext);
                }

                break;
            }

            default:
            {
                base.AsyncOperation(context);
                break;
            }
            }
        }
コード例 #5
0
        AsyncOperation(
            NGCSerializerContext context
            )
        {
            if (context == null)
            {
            }

            switch (context.Action)
            {
            case SerializerAction.endPersistObjectData:
            {
                EndPersistObjectData();

                XpsSerializationProgressChangedEventArgs e =
                    new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress,
                                                                 0,
                                                                 0,
                                                                 null);
                NgcSerializationManager.OnNGCSerializationProgressChanged(e);

                break;
            }

            default:
            {
                base.AsyncOperation(context);
                break;
            }
            }
        }
コード例 #6
0
        BeginSerializeObject(
            Object serializedObject
            )
        {
            DocumentPaginator paginator = (DocumentPaginator)serializedObject;

            NgcSerializationManager.StartDocument(paginator, true);

            NGCSerializerContext context = new NGCSerializerContext(this,
                                                                    null,
                                                                    SerializerAction.endPersistObjectData);

            NgcSerializationManager.OperationStack.Push(context);



            if (paginator != null)
            {
                NGCDocumentPaginatorSerializerContext
                    paginatorContext = new NGCDocumentPaginatorSerializerContext(this,
                                                                                 paginator,
                                                                                 0,
                                                                                 SerializerAction.serializeNextDocumentPage);

                NgcSerializationManager.OperationStack.Push(paginatorContext);
            }
        }
コード例 #7
0
        SerializeProperties(
            SerializableObjectContext serializableObjectContext
            )
        {
            if (serializableObjectContext == null)
            {
                throw new ArgumentNullException("serializableObjectContext");
            }

            SerializablePropertyCollection propertyCollection = serializableObjectContext.PropertiesCollection;

            if (propertyCollection != null)
            {
                //for(propertyCollection.Reset();
                //    propertyCollection.MoveNext();)
                //{
                //    SerializablePropertyContext serializablePropertyContext =
                //    (SerializablePropertyContext)propertyCollection.Current;
                //
                //    if(serializablePropertyContext!=null)
                //    {
                //        SerializeProperty(serializablePropertyContext);
                //    }
                //}
                propertyCollection.Reset();
                NGCSerializerContext context = new NGCSerializerContext(this,
                                                                        serializableObjectContext,
                                                                        SerializerAction.serializeNextProperty);

                _serializationManager.OperationStack.Push(context);
            }
        }
コード例 #8
0
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            if (serializableObjectContext.IsComplexValue)
            {
                NGCSerializerContext context = new NGCSerializerContext(this,
                                                                        serializableObjectContext,
                                                                        SerializerAction.serializePage);

                ((NgcSerializationManagerAsync)SerializationManager).OperationStack.Push(context);
            }
            else
            {
                throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_WrongPropertyTypeForPageContent));
            }
        }
コード例 #9
0
        SerializeNextDocumentPage(
            NGCSerializerContext context
            )
        {
            NGCDocumentPaginatorSerializerContext paginatorContext = context as NGCDocumentPaginatorSerializerContext;

            if (paginatorContext != null)
            {
                DocumentPaginator paginator = paginatorContext.Paginator;
                int index = paginatorContext.Index;

                if (!paginator.IsPageCountValid ||
                    (index < paginator.PageCount))
                {
                    index++;


                    NGCDocumentPaginatorSerializerContext
                        nextContext = new NGCDocumentPaginatorSerializerContext(this,
                                                                                paginator,
                                                                                index,
                                                                                SerializerAction.serializeNextDocumentPage);


                    NgcSerializationManager.OperationStack.Push(nextContext);

                    DocumentPage page = Toolbox.GetPage(paginator, index - 1);

                    ReachSerializer serializer = SerializationManager.GetSerializer(page);

                    if (serializer != null)
                    {
                        serializer.SerializeObject(page);
                    }
                }
            }
            else
            {
            }
        }
コード例 #10
0
        BeginSerializeObject(
            SerializablePropertyContext serializedProperty
            )
        {
            if (serializedProperty == null)
            {
                throw new ArgumentNullException("serializedProperty");
            }

            if (SerializationManager == null)
            {
                throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_MustHaveSerializationManager));
            }

            //
            // At this stage discover the graph of properties of the object that
            // need to be serialized
            //
            SerializableObjectContext serializableObjectContext = DiscoverObjectData(serializedProperty.Value,
                                                                                     serializedProperty);

            if (serializableObjectContext != null)
            {
                //
                // Push the object at hand on the context stack
                //
                SerializationManager.GraphContextStack.Push(serializableObjectContext);

                NGCSerializerContext context = new NGCSerializerContext(this,
                                                                        serializableObjectContext,
                                                                        SerializerAction.endSerializeObject);

                _serializationManager.OperationStack.Push(context);
                //
                // At this stage we should start streaming the markup representing the
                // object graph to the corresponding destination
                //
                PersistObjectData(serializableObjectContext);
            }
        }
コード例 #11
0
        SerializeNextProperty(
            SerializableObjectContext serializableObjectContext
            )
        {
            SerializablePropertyCollection propertyCollection = serializableObjectContext.PropertiesCollection;

            if (propertyCollection.MoveNext())
            {
                SerializablePropertyContext serializablePropertyContext =
                    (SerializablePropertyContext)propertyCollection.Current;

                if (serializablePropertyContext != null)
                {
                    NGCSerializerContext context = new NGCSerializerContext(this,
                                                                            serializableObjectContext,
                                                                            SerializerAction.serializeNextProperty);

                    _serializationManager.OperationStack.Push(context);
                    SerializeProperty(serializablePropertyContext);
                }
            }
        }
コード例 #12
0
        AsyncOperation(
            NGCSerializerContext context
            )
        {
            if (context == null)
            {
            }

            switch (context.Action)
            {
            case SerializerAction.endSerializeObject:
            {
                EndSerializeObject(context.ObjectContext);
                break;
            }

            case SerializerAction.serializeNextProperty:
            {
                SerializeNextProperty(context.ObjectContext);
                break;
            }
            }
        }
コード例 #13
0
        AsyncOperation(
            NGCSerializerContext context
            )
        {
            if (context == null)
            {
            }

            switch (context.Action)
            {
            case SerializerAction.serializePage:
            {
                SerializePage(context.ObjectContext);
                break;
            }

            default:
            {
                base.AsyncOperation(context);
                break;
            }
            }
        }
        AsyncOperation(
            NGCSerializerContext context
            )
        {
            if (context == null)
            {
            }

            switch (context.Action)
            {
            case SerializerAction.endPersistObjectData:
            {
                EndPersistObjectData();
                break;
            }

            case SerializerAction.serializeNextPageContent:
            {
                NgcPageContentCollectionSerializerContext thisContext =
                    context as NgcPageContentCollectionSerializerContext;

                if (thisContext != null)
                {
                    SerializeNextPageContent(thisContext.Enumerator,
                                             thisContext.ObjectContext);
                }

                break;
            }

            default:
            {
                base.AsyncOperation(context);
                break;
            }
            }
        }
コード例 #15
0
        AsyncOperation(
            NGCSerializerContext context
            )
        {
            if (context == null)
            {
            }

            switch (context.Action)
            {
            case SerializerAction.endPersistObjectData:
            {
                NGCPageSerializerContext ngcPageSerializerContext = context as NGCPageSerializerContext;
                EndPersistObjectData(ngcPageSerializerContext.IsManualStartDoc);
                break;
            }

            default:
            {
                base.AsyncOperation(context);
                break;
            }
            }
        }
コード例 #16
0
        InvokeSaveAsXamlWorkItem(
            Object arg
            )
        {
            //
            // PreSharp uses message numbers that the C# compiler doesn't know about.
            // Disable the C# complaints, per the PreSharp documentation.
            #pragma warning disable 1634, 1691
            //
            // PreSharp complains about catching NullReference (and other) exceptions.
            // This is an async model and we need to catch all exception ourselves and then
            // send them to the completion delegate
            #pragma warning disable 56500
            try
            {
                if (!_serializationOperationCanceled)
                {
                    if (_operationStack.Count > 0)
                    {
                        Object objectOnStack = _operationStack.Pop();

                        if (objectOnStack.GetType() ==
                            typeof(System.Windows.Xps.Serialization.SerializationManagerOperationContextStack))
                        {
                            SerializationManagerOperationContextStack context =
                                (SerializationManagerOperationContextStack)objectOnStack;

                            context.ReachSerializer.SerializeObject(context.SerializedObject);
                        }
                        else if (typeof(System.Windows.Xps.Serialization.NGCSerializerContext).IsAssignableFrom(objectOnStack.GetType()))
                        {
                            NGCSerializerContext context = (NGCSerializerContext)objectOnStack;
                            context.Serializer.AsyncOperation(context);
                        }
                        PostSerializationTask(new DispatcherOperationCallback(InvokeSaveAsXamlWorkItem));
                    }
                    else
                    {
                        NGCSerializationCompletionMethod();
                    }
                }
            }
            catch (Exception e)
            {
                EndDocument(true);
                if (CriticalExceptions.IsCriticalException(e))
                {
                    throw;
                }

                //
                // Indicate that an error happened
                //
                bool canceled = false;

                XpsSerializationCompletedEventArgs args = new XpsSerializationCompletedEventArgs(canceled,
                                                                                                 null,
                                                                                                 e);

                _serializationOperationCanceled = true;

                PostSerializationTask(new DispatcherOperationCallback(OnNGCSerializationCompleted), args);

                return(null);
            }
            #pragma warning restore 56500
            #pragma warning restore 1634, 1691

            return(null);
        }
コード例 #17
0
        InvokeSaveAsXamlBatchWorkItem(
            Object arg
            )
        {
            //
            // PreSharp uses message numbers that the C# compiler doesn't know about.
            // Disable the C# complaints, per the PreSharp documentation.
            #pragma warning disable 1634, 1691
            //
            // PreSharp complains about catching NullReference (and other) exceptions.
            // This is an async model and we need to catch all exception ourselves and then
            // send them to the completion delegate
            #pragma warning disable 56500
            try
            {
                // This logic must be mirrored in IsAsyncWorkPending see remarks.

                if (!_serializationOperationCanceled)
                {
                    if (!_isBatchWorkItemInProgress && _batchOperationQueue.Count > 0)
                    {
                        BatchOperationWorkItem batchOperationWorkItem = (BatchOperationWorkItem)_batchOperationQueue.Dequeue();

                        if (batchOperationWorkItem.OperationType == BatchOperationType.batchWrite)
                        {
                            StartPage();

                            ReachSerializer reachSerializer = GetSerializer(batchOperationWorkItem.SerializedObject);

                            if (reachSerializer != null)
                            {
                                //
                                // Prepare the context that is going to be pushed on the stack
                                //
                                SerializationManagerOperationContextStack
                                    contextStack = new SerializationManagerOperationContextStack(reachSerializer,
                                                                                                 batchOperationWorkItem.SerializedObject);
                                //
                                // At this stage, start calling another method which would peak at the stack
                                //
                                _operationStack.Push(contextStack);

                                PostSerializationTask(new DispatcherOperationCallback(InvokeSaveAsXamlBatchWorkItem));
                            }
                            else
                            {
                                throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_NoSerializer));
                            }
                            _isBatchWorkItemInProgress = true;
                        }
                        else if (batchOperationWorkItem.OperationType == BatchOperationType.batchCommit)
                        {
                            if (_isSimulating)
                            {
                                EndDocument();
                            }
                            NGCSerializationCompletionMethod();
                        }
                    }
                    else
                    {
                        if (_operationStack.Count > 0)
                        {
                            Object objectOnStack = _operationStack.Pop();

                            if (objectOnStack.GetType() ==
                                typeof(System.Windows.Xps.Serialization.SerializationManagerOperationContextStack))
                            {
                                SerializationManagerOperationContextStack context =
                                    (SerializationManagerOperationContextStack)objectOnStack;

                                context.ReachSerializer.SerializeObject(context.SerializedObject);
                            }
                            else if (typeof(System.Windows.Xps.Serialization.NGCSerializerContext).IsAssignableFrom(objectOnStack.GetType()))
                            {
                                NGCSerializerContext context = (NGCSerializerContext)objectOnStack;
                                context.Serializer.AsyncOperation(context);
                            }
                            PostSerializationTask(new DispatcherOperationCallback(InvokeSaveAsXamlBatchWorkItem));
                        }
                        else
                        {
                            EndPage();
                            _isBatchWorkItemInProgress = false;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                //
                //  Force document count back to 1
                //  This causes EndDocument to effectivly abort dispite not properly calling an End
                //  document for each Start Document
                //
                // 07/24/06 brianad
                //
                EndDocument(true);
                if (CriticalExceptions.IsCriticalException(e))
                {
                    throw;
                }

                //
                // Indicate that an error happened
                //
                bool canceled = false;

                XpsSerializationCompletedEventArgs args = new XpsSerializationCompletedEventArgs(canceled,
                                                                                                 null,
                                                                                                 e);

                _serializationOperationCanceled = true;

                PostSerializationTask(new DispatcherOperationCallback(OnNGCSerializationCompleted), args);

                return(null);
            }
            #pragma warning restore 56500
            #pragma warning restore 1634, 1691

            return(null);
        }