Exemplo n.º 1
0
        public override Present Realize(string refCredit)
        {
            Present present = documentFuture.Realize(refCredit);

            if (!(present is SourceDocument))
            {
                return(PresentFailureCode.FailedCast(present, "FetchDocumentFuture"));
            }

            SourceDocument sourceDocument         = (SourceDocument)present;
            string         filesystemAbsolutePath = sourceDocument.localDocument.GetFilesystemAbsolutePath();

            Present[] paramList = new Present[]
            {
                new StringParameter(filesystemAbsolutePath),
                new IntParameter(sourceDocument.localDocument.GetPageNumber())
            };
            string text = Path.GetExtension(filesystemAbsolutePath).ToLower();

            if (text[0] == '.')
            {
                text = text.Substring(1);
            }

            Verb   verb = null;
            string a    = null;

            if (knownExtensions.ContainsKey(text))
            {
                a = knownExtensions[text];
            }

            if (a == "FoxIt")
            {
                verb = new FoxitOpenVerb();
            }
            else
            {
                if (a == "WPF")
                {
                    verb = new WPFOpenVerb();
                }
                else
                {
                    if (a == "GDI")
                    {
                        verb = new GDIOpenVerb();
                    }
                }
            }

            if (verb == null)
            {
                return(new PresentFailureCode(new UnknownImageTypeException("Unknown file type " + text)));
            }

            return(verb.Evaluate(paramList));
        }
Exemplo n.º 2
0
		public override Present Realize(string refCredit)
		{
			Present present = this.documentFuture.Realize(refCredit);
			if (!(present is SourceDocument))
			{
				return PresentFailureCode.FailedCast(present, "FetchDocumentFuture");
			}
			SourceDocument sourceDocument = (SourceDocument)present;
			string filesystemAbsolutePath = sourceDocument.localDocument.GetFilesystemAbsolutePath();
			Present[] paramList = new Present[]
			{
				new StringParameter(filesystemAbsolutePath),
				new IntParameter(sourceDocument.localDocument.GetPageNumber())
			};
			string text = Path.GetExtension(filesystemAbsolutePath).ToLower();
			if (text[0] == '.')
			{
				text = text.Substring(1);
			}
			Verb verb = null;
			string a = null;
			if (FetchDocumentFuture.knownExtensions.ContainsKey(text))
			{
				a = FetchDocumentFuture.knownExtensions[text];
			}
			if (a == "FoxIt")
			{
				verb = new FoxitOpenVerb();
			}
			else
			{
				if (a == "WPF")
				{
					verb = new WPFOpenVerb();
				}
				else
				{
					if (a == "GDI")
					{
						verb = new GDIOpenVerb();
					}
				}
			}
			if (verb == null)
			{
				return new PresentFailureCode(new UnknownImageTypeException("Unknown file type " + text));
			}
			return verb.Evaluate(paramList);
		}