コード例 #1
0
 public DocumentFill(DocumentDeserializationContext context, PropertyDictionary framedObjectDictionary)
 {
     if (framedObjectDictionary.HasDictionaryFor("color"))
     {
         _color = PropertyBuilders.ToColor(framedObjectDictionary.DictionaryFor("color"));
     }
 }
コード例 #2
0
        public DocumentFrame(DocumentDeserializationContext context, PropertyDictionary frameProperties)
        {
            if (!frameProperties.HasDictionaryFor("offsetInDocument"))
            {
                throw new DocumentReadingException("A frame is missing the required \"offsetInDocument\" field.");
            }

            _offsetInDocument = PropertyBuilders.ToPoint(frameProperties.DictionaryFor("offsetInDocument"));
        }
コード例 #3
0
        public LabelDocumentFrame(DocumentDeserializationContext context, PropertyDictionary frameProperties)
            : base(context, frameProperties)
        {
            if (!frameProperties.HasDictionaryFor("callOutOffsetInDocument"))
            {
                throw new DocumentReadingException("A label frame is missing the required \"callOutOffsetInDocument\" field.");
            }

            _callOutOffsetInDocument = PropertyBuilders.ToSize(frameProperties.DictionaryFor("callOutOffsetInDocument"));
            _label = frameProperties.StringFor("label", "");
            _caption = frameProperties.StringFor("caption", "");
        }
コード例 #4
0
        internal ImageLinkManager(DocumentDeserializationContext context, PropertyDictionary managerDictionary)
        {
            PropertyDictionary imageLinks = managerDictionary.DictionaryFor("imageLinks");

            if (imageLinks == null) throw new InvalidOperationException("The image manager dictionary is missing the \"imageLinks\" key.");

            foreach (object key in imageLinks.Keys)
            {
                if (!(key is int)) throw new InvalidOperationException("The image links dictionary contains a non-integer key, which is not permitted.");

                int linkIndex = (int)key;

                PropertyDictionary imageDictionary = imageLinks.DictionaryFor(key);

                ImageLink link = new ImageLink(context, imageDictionary);

                _referenceCountByLink[link] = 0;
                context.ImageLinksByKey[linkIndex] = link;
            }
        }
コード例 #5
0
ファイル: ImageLink.cs プロジェクト: gregorypilar/interlace
 public ImageLink(DocumentDeserializationContext context, PropertyDictionary dictionary)
 {
     _fileName = Path.Combine(context.AbsolutePath, dictionary.StringFor("fileName"));
     _physicalDimension = PropertyBuilders.ToSize(dictionary.DictionaryFor("physicalDimension"));
 }
コード例 #6
0
ファイル: Document.cs プロジェクト: gregorypilar/interlace
        public static Document Deserialize(PropertyDictionary container, string absolutePath)
        {
            PropertyDictionary documentProperties = container.DictionaryFor("pasteUp");

            if (documentProperties == null) return null;

            if (!documentProperties.HasIntegerFor("majorVersion", "majorVersion"))
            {
                throw new DocumentReadingException("The document lacks the required major and minor version numbers.");
            }

            if (documentProperties.IntegerFor("majorVersion") > MajorVersion)
            {
                throw new DocumentReadingException("The document version is not supported by this reader.");
            }

            Document document = new Document();

            if (documentProperties.IntegerFor("majorVersion") == MajorVersion &&
                documentProperties.IntegerFor("minorVersion") > MinorVersion)
            {
                document._wasDownConverted = true;
            }

            DocumentDeserializationContext context = new DocumentDeserializationContext(
                documentProperties.IntegerFor("majorVersion").Value,
                documentProperties.IntegerFor("minorVersion").Value,
                absolutePath);

            PropertyDictionary imageLinkManagerProperties = documentProperties.DictionaryFor("imageLinkManager");

            if (imageLinkManagerProperties == null) throw new DocumentReadingException(
                "The image link manager dictionary is missing from the document.");

            document._imageLinkManager = new ImageLinkManager(context, imageLinkManagerProperties);

            PropertyArray framesArray = documentProperties.ArrayFor("frames");

            if (framesArray == null) throw new DocumentReadingException("The frames array is missing from the document.");

            for (int i = 0; i < framesArray.Count; i++)
            {
                PropertyDictionary frameProperties = framesArray.DictionaryAt(i);

                if (frameProperties == null) throw new DocumentReadingException(
                    "The document frame array contains an invalid non-dictionary object.");

                document._frames.Add(DeserializeFrame(context, frameProperties));
            }

            return document;
        }
コード例 #7
0
ファイル: Language.cs プロジェクト: gregorypilar/interlace
        public virtual void CreateDomImplementationHelpers(Document document, PropertyDictionary documentOptions)
        {
            foreach (Protocol protocol in document.Protocols)
            {
                PropertyDictionary protocolOptions =
                    documentOptions.DictionaryFor(protocol.Name.ToString()) ?? PropertyDictionary.EmptyDictionary();

                PropertyDictionary declarationDictionary =
                    protocolOptions.DictionaryFor("declarations") ?? PropertyDictionary.EmptyDictionary();

                protocol.Implementation = CreateProtocolImplementationHelper(protocol, protocolOptions);

                foreach (Declaration declaration in protocol.Declarations)
                {
                    PropertyDictionary declarationOptions =
                        declarationDictionary.DictionaryFor(declaration.QualifiedName.UnqualifiedName) ?? PropertyDictionary.EmptyDictionary();

                    if (declaration is Enumeration)
                    {
                        Enumeration enumeration = (Enumeration)declaration;

                        enumeration.Implementation = CreateEnumerationImplementationHelper(enumeration, declarationOptions);

                        foreach (EnumerationMember member in enumeration.MemberBases)
                        {
                            member.Implementation = CreateEnumerationMemberImplementationHelper(member);
                        }
                    }
                    else if (declaration is Structure)
                    {
                        // The implementations of structures are created first, before any members:
                        Structure structure = (Structure)declaration;

                        structure.Implementation = CreateStructureImplementationHelper(structure, declarationOptions);
                    }
                }

                // Now the members of each structure are created:
                foreach (Declaration declaration in protocol.Declarations)
                {
                    if (declaration is Structure)
                    {
                        Structure structure = (Structure)declaration;

                        foreach (StructureMember member in structure.Members)
                        {
                            member.Implementation = CreateStructureMemberImplementationHelper(member);
                        }
                    }
                }
            }
        }
コード例 #8
0
        public RectangularDocumentFrame(DocumentDeserializationContext context, PropertyDictionary frameDictionary)
            : base(context, frameDictionary)
        {
            if (!frameDictionary.HasDictionaryFor("clipBounds"))
            {
                throw new DocumentReadingException("A label frame is missing the required \"clipBounds\" field.");
            }

            if (!frameDictionary.HasDictionaryFor("framedObject"))
            {
                throw new DocumentReadingException("A label frame is missing the required \"framedObject\" field.");
            }

            _clipBounds = PropertyBuilders.ToRectangle(frameDictionary.DictionaryFor("clipBounds"));

            PropertyDictionary framedObjectDictionary = frameDictionary.DictionaryFor("framedObject");

            string framedObjectType = framedObjectDictionary.StringFor("type", "missing");

            switch (framedObjectType)
            {
                case "image":
                    _framedObject = new DocumentImage(context, framedObjectDictionary);
                    break;

                case "fill":
                    _framedObject = new DocumentFill(context, framedObjectDictionary);
                    break;

                default:
                    throw new DocumentReadingException(string.Format("The document object type \"{0}\" is not supported in this version.",
                        framedObjectType));
            }
        }