/*        public override Object Perform(Object obj)
 *      {
 *          return null;
 *      }
 */
        public override Object Perform(Object obj)
        {
            Document source = ResolveSourceDocument();

            Image image = (Image)GetArgumentObject(SemanticOperationNamedArguments.Metadata);

            if (image == null)
            {
                ParsedUri imagePURL = (ParsedUri)GetArgumentObject(SemanticOperationNamedArguments.ImagePurl);

/*			    if (imagePURL != null)
 *                          {
 *                                  image								= sessionScope.GetOrConstructImage(imagePURL);
 *
 *                                  //TODO -- if it already exists: (1) do we need to download??
 *                                  //															(2) should we merge metadata
 *                          }
 */
            }
            else
            {
                //TODO add to global collections?! if already there merge!
            }
            if (image != null && image.Location != null)
            {
                image.SemanticsSessionScope = sessionScope as SemanticsSessionScope;

                Document mixin = (Document)GetArgumentObject(SemanticOperationNamedArguments.Mixin);
                if (mixin != null)
                {
                    image.AddMixin(mixin);
                }

                Object captionObject = GetArgumentObject(SemanticOperationNamedArguments.Caption);
                String caption       = (captionObject != null) ? captionObject.ToString() : null;

                int width  = GetArgumentInteger(SemanticOperationNamedArguments.Width, 0);
                int height = GetArgumentInteger(SemanticOperationNamedArguments.Height, 0);

                ParsedUri hrefPURL = (ParsedUri)GetArgumentObject(SemanticOperationNamedArguments.Href);
                Document  outlink  = (Document)GetArgumentObject(SemanticOperationNamedArguments.HrefMetadata);
                //if (hrefPURL != null & outlink == null)
                //	    outlink				= sessionScope.GetOrConstructDocument(hrefPURL);

                ImageClipping imageClipping = image.ConstructClipping(source, outlink, caption, null);
                source.AddClipping(imageClipping);

                DocumentClosure imageClosure;

                if (this.sessionScope is SemanticsSessionScope)
                {
                    imageClosure = image.GetOrConstructClosure();

                    if (documentParser != null)
                    {
                    }
                    else
                    {
                        //imageClosure.RequestMetadata();
                    }
                }
                else
                {
                    image.GetOrConstructClosure();
                }

                return(image);
            }
            else
            {
                MetaMetadata mm       = GetMetaMetadata();
                String       mmString = mm != null ? mm.Name : "Couldn't getMetaMetadata()";
                Debug.WriteLine("Can't createAndVisualizeImgSurrogate because null PURL: " + mmString
                                + " - " + source.Location);
            }

            return(null);
        }
Esempio n. 2
0
 void OnEnable()
 {
     _clipping = target as ImageClipping;
 }