Esempio n. 1
0
 /// <summary>
 /// This method will return the string representation of the mirror data if it is available
 /// </summary>
 public string GetStringData()
 {
     Validity.Assert(this.runtimeCore != null);
     Validity.Assert(TargetExecutive != null);
     return(deprecateThisMirror.GetStringValue(mirrorData.GetStackValue(), TargetExecutive.rmem.Heap, blockDeclaration));
 }
        private void DisplayPreviewValueOnUi(NodeValueReadyEventArgs e)
        {
            VisualNode visualNode = controller.GetVisualNode(e.NodeId);

            if (null == visualNode || (false != visualNode.Error))
            {
                return; // Node not found, or it is in error state.
            }
            MirrorData mirrorData = e.RuntimeMirror.GetData();

            if (null == mirrorData)
            {
                return;
            }

            //set the returnType and assemblyusing mirror data
            Dictionary <string, List <string> > assemblyAndReturnTypes = e.RuntimeMirror.GetDynamicAssemblyType();

            string assembly = string.Empty;

            foreach (string assem in assemblyAndReturnTypes.Keys)
            {
                assembly += assem;
                assembly += ",";
            }
            if (string.IsNullOrEmpty(assembly) == false)
            {
                assembly = assembly.TrimEnd(',');
            }
            string returnTypes = string.Empty;

            foreach (List <string> returnType in assemblyAndReturnTypes.Values)
            {
                foreach (string type in returnType)
                {
                    returnTypes += type;
                    returnTypes += ",";
                }
            }
            if (string.IsNullOrEmpty(returnTypes) == false)
            {
                returnTypes = returnTypes.TrimEnd(',');
            }

            bool geometryPreviewFlag = false;
            bool textualPreviewFlag  = false;

            if (visualNode.NodeStates.HasFlag(States.TextualPreview))
            {
                textualPreviewFlag = true;
            }
            else
            {
                geometryPreviewFlag = true;
            }

            // If user wants geometric preview and we are not running in headless mode.
            if (geometryPreviewFlag == true && (null != CoreComponent.CurrentDispatcher))
            {
                // If the geometric preview is enabled.
                if (!CoreComponent.Instance.GeometricPreviewEnabled)
                {
                    // Geometric preview is not enabled, show no preview placeholder.
                    visualNode.SetPreviewValue(CoreComponent.Instance.PreviewPlaceholder);
                }
                else
                {
                    List <IGraphicItem> graphicItems = mirrorData.GetGraphicsItems();
                    if (graphicItems == null || graphicItems.Count < 0)
                    {
                        textualPreviewFlag = true; // No graphics item, display text.
                    }
                    else
                    {
                        CoreComponent.CurrentDispatcher.BeginInvoke(new Action(() =>
                        {
                            // Start to request for a visual (e.g. geometry preview).
                            CoreComponent coreComponent = CoreComponent.Instance;
                            if (!coreComponent.RequestVisualization(controller.Identifier, e.NodeId, graphicItems))
                            {
                                DisplayPreviewFailureMessage(e.NodeId);
                            }
                        }));
                    }
                }
            }

            if (textualPreviewFlag == true)
            {
                //show textual preview
                // Fix: IDE-1263 Preview window shouldn't appear when there's nothing to preview.
                string preview = null;
                if (mirrorData.GetStackValue().optype != AddressType.Null)
                {
                    preview = e.RuntimeMirror.GetStringData();
                }

                visualNode.SetPreviewValue(preview);
            }

            visualNode.SetReturnTypeAndAssembly(returnTypes, assembly);
        }