Exemplo n.º 1
0
    public void RenderDiagram(SequenceData data)
    {
      using (SequenceContextScope renderingScope = ContextHelper.CreateSequenceScope())
      {
        // add all the objects to the scope's context.
        foreach (var item in data.GetObjectList())
        {
          renderingScope.CurrentContext.AddSequenceObject(item.Key, item.TypeName);
        }

        // add all the messages to the scope's context.
        foreach (var item in data.GetMethodList())
        {
          MethodCallInfo itemCopy = item;

          string sourceKey = data.GetObjectList().Find(objectInfo => objectInfo.TypeName.Equals(itemCopy.TypeName, StringComparison.Ordinal)).Key;
          string targetKey = data.GetObjectList().Find(objectInfo => objectInfo.TypeName.Equals(itemCopy.MethodCallType, StringComparison.Ordinal)).Key;

          renderingScope.CurrentContext.AddMessage(sourceKey, targetKey, item.MethodCallName, item);
        }

        // render the diagram.
        renderingScope.CurrentContext.Render();
      }
    }
Exemplo n.º 2
0
        public string Export(SequenceData data)
        {
            string currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            String filePath = Path.Combine(currentDirectory, "tempseq.pic");

            using (var sw = new StreamWriter(filePath, false))
            {
                Write(sw, ".PS");
                Write(sw, "copy \"sequence.pic\";");
                Write(sw, "maxpswid = 20;");
                Write(sw, "maxpsht = 20;");

                Write(sw, "boxwid = 1.9;");
                Write(sw, "movewid = 0.1;");
                Write(sw, "spacing = 0.3;");

                Write(sw, "step();");
                objectList = data.GetObjectList();

                foreach (ObjectInstanceInfo oInfo in objectList)
                {
                    WriteObject(sw, oInfo.TypeName, oInfo.Key);
                    //Write(sw, "active(" + oInfo.Key + ");");
                }

                Write(sw, "step();");
                Write(sw, "step();");

                foreach (MethodCallInfo mInfo in data.GetMethodList())
                {
                    WriteMessage(sw, mInfo);
                }

                Write(sw, "step();");
                Write(sw, "step();");

                // reverse iterate the object collection to put complete
                objectList.Reverse();

                foreach (ObjectInstanceInfo oInfo in objectList)
                {
                    WriteComplete(sw, oInfo.Key);
                }

                Write(sw, ".PE");
            }

            return this.ExecutePlot(currentDirectory, filePath, data.ToString());
        }
Exemplo n.º 3
0
    public string Export(SequenceData data)
    {
      DiagramViewer viewer = new DiagramViewer();
      Size size = new Size(2000D, 2000D);
      viewer.Measure(size);
      viewer.Arrange(new Rect(size));

      string outputFileName = data.ToString();
      outputFileName = Helper.RemoveInvalidCharsFromFileName(outputFileName);
      string extension = "xps";
      if (!this.UseUniqueFileName)
      {
        outputFileName = "seq";
      }

      outputFileName = Path.Combine(this.DestinationPath, string.Concat(outputFileName, ".", extension));
      using (SaveContextScope saveScope = ContextHelper.CreateSaveScope(viewer, outputFileName))
      {
        using (SequenceContextScope renderScope = ContextHelper.CreateSequenceScope())
        {
          foreach (ObjectInstanceInfo item in data.GetObjectList())
          {
            renderScope.CurrentContext.AddSequenceObject(item.Key, item.TypeName);
          }

          foreach (MethodCallInfo item in data.GetMethodList())
          {
            string sourceKey = data.GetObjectList().Find(objectInfo => objectInfo.TypeName.Equals(item.TypeName, StringComparison.Ordinal)).Key;
            string targetKey = data.GetObjectList().Find(objectInfo => objectInfo.TypeName.Equals(item.MethodCallType, StringComparison.Ordinal)).Key;

            renderScope.CurrentContext.AddMessage(sourceKey, targetKey, item.MethodCallName, item);
          }

          renderScope.CurrentContext.Render();
        }
      }

      return outputFileName;
    }
Exemplo n.º 4
0
        public SequenceData GetSequenceData(string methodName, string typeName, string nameSpace, string assemblyName)
        {
            // here match the methodName in the methodcalllist structure
            // and populate the SequenceData field.
            var data = new SequenceData(typeName + methodName);
            data.AddObject(typeName);

            SelectMethod(methodName, typeName, nameSpace, assemblyName, data);

            return data;
        }
Exemplo n.º 5
0
        private void SelectMethod(string methodName, string typeName, string nameSpace, string assemblyName,
                                  SequenceData data)
        {
            foreach (MethodCallInfo mInfo in AssemblyData.MethodCallList)
            {
                if (!mInfo.StartMethod.Equals(nameSpace + "." + typeName + "." + methodName)) 
                    continue;
                
                data.AddObject(mInfo.MethodCallType);
                data.AddMessage(mInfo);
                Logger.Current.Debug(">> Found method:" + mInfo);

                // if targetAssembly is different from assemblyName then recursively call this method
                var targetAssembly = Helper.RemoveExtension(Helper.RemoveExtension(mInfo.TargetMethodAssembly, ".dll"), ".exe");
                if (!targetAssembly.Equals(assemblyName))
                {
                    SelectMethod(mInfo.MethodCallName, mInfo.MethodCallType, mInfo.MethodCallNamespace,
                                 mInfo.TargetMethodAssembly, data);
                }
               
            }
        }
Exemplo n.º 6
0
 public string Export(SequenceData data)
 {
   RenderDiagram(data);
   return string.Empty;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Selects the method.
 /// </summary>
 /// <param name="methodName">Name of the method.</param>
 /// <param name="typeName">Name of the type.</param>
 /// <param name="namespaceName">Name of the namespace.</param>
 /// <param name="data">The sequence data.</param>
 private void SelectMethod(string methodName, string typeName, string namespaceName, SequenceData data)
 {
   foreach (MethodCallInfo methodInfo in this.Data.MethodCallList)
   {
     if (methodInfo.StartMethod.Equals(namespaceName + "." + typeName + "." + methodName))
     {
       data.AddObject(methodInfo.MethodCallType);
       data.AddMessage(methodInfo);
       Logger.Current.Info(">> Found method:" + methodInfo.ToString());
     }
   }
 }
Exemplo n.º 8
0
    /// <summary>
    /// Gets the sequence data.
    /// </summary>
    /// <param name="methodName">Name of the method.</param>
    /// <param name="typeName">Name of the type.</param>
    /// <param name="namespaceName">Name of the namespace.</param>
    /// <returns>
    /// A new instance of SequenceData, with the related sequence data.
    /// </returns>
    private SequenceData GetSequenceData(string methodName, string typeName, string namespaceName)
    {
      // here match the methodName in the methodcalllist structure
      // and populate the SequenceData field.
      SequenceData data = new SequenceData(typeName + methodName);
      data.AddObject(typeName);

      this.SelectMethod(methodName, typeName, namespaceName, data);

      return data;
    }