当前位置: 首页>>代码示例>>C#>>正文


C# Repository.GetContextObject方法代码示例

本文整理汇总了C#中Repository.GetContextObject方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.GetContextObject方法的具体用法?C# Repository.GetContextObject怎么用?C# Repository.GetContextObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Repository的用法示例。


在下文中一共展示了Repository.GetContextObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: macroDiagram_ID

        /// <summary>
        /// Replace macro #Diagram_ID# by Diagram_Id of the current diagram or selected Diagram.
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="sql"></param>
        /// <returns>sql string with replaced macro</returns>
        static string macroDiagram_ID(Repository rep, string sql)
        {
            // get template
            string template = GetTemplateText(SqlTemplateId.DiagramId);

            // template is used
            if (sql.Contains(template))
            {
                // get the diagram
                Diagram dia;
                if (rep.GetContextItemType() == ObjectType.otDiagram)
                {
                    dia = rep.GetContextObject();
                }
                else
                {
                    dia = rep.GetCurrentDiagram();
                }
                // Diagram selected?
                if (dia == null)
                {
                    MessageBox.Show(sql, $"No Diagram  for '{template}' selected!");
                    sql = "";
                }
                else
                {
                    // replace by list of IDs
                    sql = sql.Replace(template, $"{dia.DiagramID}");
                }

            }
            return sql;
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:39,代码来源:SqlTemplates.cs

示例2: NavigateComposite

        public static void NavigateComposite(Repository repository)
        {
            ObjectType oType = repository.GetContextItemType();
            // find composite element of diagram
            if (oType.Equals(ObjectType.otDiagram))
            {
                var d = (Diagram) repository.GetContextObject();
                string guid = Util.GetElementFromCompositeDiagram(repository, d.DiagramGUID);
                if (guid != "")
                {
                    repository.ShowInProjectView(repository.GetElementByGuid(guid));
                }
            }
            // find composite diagram of element of element
            if (oType.Equals(ObjectType.otElement))
            {
                var e = (Element) repository.GetContextObject();
                // locate text or frame
                if (LocateTextOrFrame(repository, e)) return;

                repository.ShowInProjectView(e.CompositeDiagram);
            }
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:23,代码来源:EaServices.cs

示例3: ShowSpecification

 public static void ShowSpecification(Repository rep)
 {
     ObjectType oType = rep.GetContextItemType();
     if (oType.Equals(ObjectType.otElement))
     {
         var el = (Element) rep.GetContextObject();
         //over all file
         foreach (File f in el.Files)
         {
             if (f.Name.Length > 2)
             {
                 Process.Start(f.Name);
             }
         }
     }
 }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:16,代码来源:EaServices.cs

示例4: GetGuidfromSelectedItem

 private static string GetGuidfromSelectedItem(Repository rep)
 {
     ObjectType objectType = rep.GetContextItemType();
     string guid = "";
     switch (objectType)
     {
         case ObjectType.otAttribute:
             var a = (EA.Attribute) rep.GetContextObject();
             guid = a.AttributeGUID;
             break;
         case ObjectType.otMethod:
             var m = (Method) rep.GetContextObject();
             guid = m.MethodGUID;
             break;
         case ObjectType.otElement:
             var el = (Element) rep.GetContextObject();
             guid = el.ElementGUID;
             break;
         case ObjectType.otDiagram:
             var dia = (Diagram) rep.GetContextObject();
             guid = dia.DiagramGUID;
             break;
         case ObjectType.otPackage:
             var pkg = (Package) rep.GetContextObject();
             guid = pkg.PackageGUID;
             break;
         default:
             MessageBox.Show(@"Nothing useful selected");
             break;
     }
     return guid;
 }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:32,代码来源:EaServices.cs

示例5: ShowFolder

        public static void ShowFolder(Repository rep, bool isTotalCommander = false)
        {
            string path;
            ObjectType oType = rep.GetContextItemType();
            switch (oType)
            {
                case ObjectType.otPackage:
                    var pkg = (Package) rep.GetContextObject();
                    path = Util.GetVccFilePath(rep, pkg);
                    // remove filename
                    path = Regex.Replace(path, @"[a-zA-Z0-9\s_:.]*\.xml", "");

                    if (isTotalCommander)
                        Util.StartApp(@"totalcmd.exe", "/o " + path);
                    else
                        Util.StartApp(@"Explorer.exe", "/e, " + path);
                    break;

                case ObjectType.otElement:
                    var el = (Element) rep.GetContextObject();
                    path = Util.GetGenFilePath(rep, el);
                    // remove filename
                    path = Regex.Replace(path, @"[a-zA-Z0-9\s_:.]*\.[a-zA-Z0-9]{0,4}$", "");

                    if (isTotalCommander)
                        Util.StartApp(@"totalcmd.exe", "/o " + path);
                    else
                        Util.StartApp(@"Explorer.exe", "/e, " + path);

                    break;
            }
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:32,代码来源:EaServices.cs

示例6: MakeNested

        // ReSharper disable once UnusedMember.Local
        private static void MakeNested(Repository rep)
        {
            Diagram dia = rep.GetCurrentDiagram();
            if (dia == null) return;
            int count = dia.SelectedObjects.Count;
            if (count < 2) return;

            rep.SaveDiagram(dia.DiagramID);

            // target object/element

            ObjectType objType = rep.GetContextItemType();
            if (!(objType.Equals(ObjectType.otElement))) return;

            var trgEl = (Element) rep.GetContextObject();
            if (!(trgEl.Type.Equals("Activity")))
            {
                MessageBox.Show($"Target '{trgEl.Name}:{trgEl.Type}' isn't an Activity",
                    @" Only move below Activity is allowed");
                return;
            }
            for (int i = 0; i < count; i = i + 1)
            {
                var srcObj = (DiagramObject) dia.SelectedObjects.GetAt((short) i);
                var srcEl = rep.GetElementByID(srcObj.ElementID);
                if (srcEl.ElementID == trgEl.ElementID) continue;
                srcEl.ParentID = trgEl.ElementID;
                srcEl.Update();
            }
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:31,代码来源:EaServices.cs

示例7: GetContextPackage

        //--------------------------------------------------------------------------------
        /// <summary>
        /// Get context Package from Package, Element, Diagram
        /// </summary>
        /// <param name="rep"></param>
        /// <returns></returns>
        static Package GetContextPackage(Repository rep)
        {
            switch (rep.GetContextItemType())
            {
                case ObjectType.otPackage:
                    return (Package) rep.GetContextObject();

                case ObjectType.otElement:
                    Element el = (Element) rep.GetContextObject();
                    return rep.GetPackageByID(el.PackageID);

                case ObjectType.otDiagram:
                    Diagram dia = (Diagram) rep.GetContextObject();
                    return rep.GetPackageByID(dia.PackageID);

                default:
                    return null;
            }
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:25,代码来源:EaServices.cs

示例8: LocateType

        /// <summary>
        /// Locate the type for Connector, Method, Attribute, Diagram, Element, Package
        /// </summary>
        /// <param name="rep"></param>
        public static void LocateType(Repository rep)
        {
            ObjectType oType = rep.GetContextItemType();
            Element el;
            int id;
            string triggerGuid;
            // connector
            // links to trigger
            switch (oType)
            {
                case ObjectType.otConnector:
                    var con = (Connector) rep.GetContextObject();
                    triggerGuid = Util.GetTrigger(rep, con.ConnectorGUID);
                    if (triggerGuid.StartsWith("{", StringComparison.Ordinal) &&
                        triggerGuid.EndsWith("}", StringComparison.Ordinal))
                    {
                        Element trigger = rep.GetElementByGuid(triggerGuid);

                        if (trigger != null) rep.ShowInProjectView(trigger);
                    }
                    else
                    {
                        SelectBehaviorFromConnector(rep, con, DisplayMode.Method);
                    }
                    break;


                case ObjectType.otMethod:
                    var m = (Method) rep.GetContextObject();
                    if (m.ClassifierID != "")
                    {
                        id = Convert.ToInt32(m.ClassifierID);
                        // get type
                        if (id > 0)
                        {
                            el = rep.GetElementByID(id);
                            rep.ShowInProjectView(el);
                        }
                    }
                    break;

                case ObjectType.otAttribute:
                    var attr = (EA.Attribute) rep.GetContextObject();
                    id = attr.ClassifierID;
                    // get type
                    if (id > 0)
                    {
                        el = rep.GetElementByID(attr.ClassifierID);
                        if (el.Type.Equals("Package"))
                        {
                            Package pkg = rep.GetPackageByID(Convert.ToInt32(el.MiscData[0]));
                            rep.ShowInProjectView(pkg);
                        }
                        else
                        {
                            rep.ShowInProjectView(el);
                        }
                    }
                    break;

                // Locate Diagram (e.g. from Search Window)
                case ObjectType.otDiagram:
                    var d = (Diagram) rep.GetContextObject();
                    rep.ShowInProjectView(d);
                    break;


                case ObjectType.otElement:
                    el = (Element) rep.GetContextObject();
                    if (el.ClassfierID > 0)
                    {
                        el = rep.GetElementByID(el.ClassfierID);
                        rep.ShowInProjectView(el);
                    }
                    else
                    {
//MiscData(0) PDATA1,PDATA2,
                        // pdata1 Id for parts, UmlElement
                        // object_id   for text with Hyper link to diagram

                        // locate text or frame
                        if (LocateTextOrFrame(rep, el)) return;

                        string guid = el.MiscData[0];
                        if (guid.EndsWith("}", StringComparison.Ordinal))
                        {
                            el = rep.GetElementByGuid(guid);
                            rep.ShowInProjectView(el);
                        }
                        else
                        {
                            if (el.Type.Equals("Action"))
                            {
                                foreach (CustomProperty custproperty in el.CustomProperties)
                                {
                                    if (custproperty.Name.Equals("kind") && custproperty.Value.Contains("AcceptEvent"))
//.........这里部分代码省略.........
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:101,代码来源:EaServices.cs

示例9: CreateNoteFromText

 // ReSharper disable once UnusedMember.Local
 static void CreateNoteFromText(Repository rep, string text)
 {
     if (rep.GetContextItemType().Equals(ObjectType.otElement))
     {
         var el = (Element) rep.GetContextObject();
         string s0 = CallOperationAction.RemoveUnwantedStringsFromText(text.Trim(), false);
         s0 = Regex.Replace(s0, @"\/\*", "//"); // /* ==> //
         s0 = Regex.Replace(s0, @"\*\/", ""); // delete */
         el.Notes = s0;
         el.Update();
     }
 }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:13,代码来源:EaServices.cs

示例10: MacroConnector

        /// <summary>
        /// Connector macros: ConnectorID and ConveyedItemIDS
        /// Note: If Element connector 
        /// <para/>
        /// Replace macro #ConnectorID# by the ID of the selected connector.
        /// <para/>
        /// Replace macro #ConveyedItemIDS# by the IDs of conveyed Elements of the selected connector.
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="sql">The sql string to replace the macro by the found ID</param>
        /// <returns>sql string with replaced macro</returns>
        static string MacroConnector(Repository rep, string sql)
        {
            //--------------------------------------------------------------------------------------------
            // CONNECTOR ID
            // CONVEYED_ITEM_ID
            string currentConnectorTemplate = GetTemplateText(SqlTemplateId.ConnectorId);
            string currentConveyedItemTemplate = GetTemplateText(SqlTemplateId.ConveyedItemIds);

            if ((sql.Contains(currentConnectorTemplate) | sql.Contains(currentConveyedItemTemplate)))
            {
                // connector
                if (rep.GetContextItemType() == ObjectType.otConnector)
                {
                    // connector ID
                    Connector con = rep.GetContextObject();
                    if (sql.Contains(currentConnectorTemplate))
                    {
                        
                        sql = sql.Replace(currentConnectorTemplate, $"{con.ConnectorID}");
                    }
                    // conveyed items are a comma separated list of elementIDs
                    if (sql.Contains(currentConveyedItemTemplate))
                    {

                        // to avoid syntax error, 0 will never fit any conveyed item
                        string conveyedItems = "0";

                        // first get "InformationFlows" which carries the conveyed items
                        if (con.MetaType == "Connector")
                        {
                            // get semicolon delimiter list of information flow guids
                            string sqlInformationFlows = "select x.description " +
                                                         "    from  t_xref x " +
                                                         $"    where x.client = '{con.ConnectorGUID}' ";

                            // get semicolon delimiter list of guids of all dependent connectors/information flows
                            List<string> lFlows = rep.GetStringsBySql(sqlInformationFlows);
                            foreach (string flowGuids in lFlows) { 
                                string[] lFlowGuid = flowGuids.Split(',');
                                foreach (string flowGuid in lFlowGuid)
                                {
                                    EA.Connector flow = rep.GetConnectorByGuid(flowGuid);
                                    foreach (EA.Element el in flow.ConveyedItems)
                                    {
                                        conveyedItems = $"{conveyedItems}, {el.ElementID}";
                                    }
                                }

                            }
                        }
                        else
                        {


                            foreach (EA.Element el in con.ConveyedItems)
                            {
                                conveyedItems = $"{conveyedItems}, {el.ElementID}";
                            }

                        }
                        sql = sql.Replace(currentConveyedItemTemplate, $"{conveyedItems}");
                    }
                } else
                // no connector selected
                {
                    MessageBox.Show(sql, @"No connector selected!");
                    sql = "";
                }
            }
            return sql;
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:82,代码来源:SqlTemplates.cs

示例11: UpdateActivityParameter

        public static void UpdateActivityParameter(Repository rep)
        {
            ObjectType oType = rep.GetContextItemType();
            if (oType.Equals(ObjectType.otElement))
            {
                var el = (Element) rep.GetContextObject();
                if (el.Type.Equals("Activity"))
                {
                    // get the associated operation
                    Method m = Util.GetOperationFromBrehavior(rep, el);
                    if (el.Locked) return;
                    if (m == null) return;
                    ActivityPar.UpdateParameterFromOperation(rep, el, m); // get parameters from Operation for Activity
                    Diagram dia = rep.GetCurrentDiagram();
                    if (dia == null) return;

                    DiagramObject diaObj = Util.GetDiagramObjectById(rep, dia, el.ElementID);
                    //EA.DiagramObject diaObj = dia.GetDiagramObjectByID(el.ElementID,"");
                    if (diaObj == null) return;

                    int pos = 0;
                    rep.SaveDiagram(dia.DiagramID);
                    foreach (Element actPar in el.EmbeddedElements)
                    {
                        if (!actPar.Type.Equals("ActivityParameter")) continue;
                        Util.VisualizePortForDiagramobject(pos, dia, diaObj, actPar, null);
                        pos = pos + 1;
                    }
                    rep.ReloadDiagram(dia.DiagramID);
                }
                if (el.Type.Equals("Class") | el.Type.Equals("Interface"))
                {
                    UpdateActivityParameterForElement(rep, el);
                }
            }
            if (oType.Equals(ObjectType.otMethod))
            {
                var m = (Method) rep.GetContextObject();
                Element act = Appl.GetBehaviorForOperation(rep, m);
                if (act == null) return;
                if (act.Locked) return;
                ActivityPar.UpdateParameterFromOperation(rep, act, m); // get parameters from Operation for Activity
            }
            if (oType.Equals(ObjectType.otPackage))
            {
                var pkg = (Package) rep.GetContextObject();
                UpdateActivityParameterForPackage(rep, pkg);
            }
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:49,代码来源:EaServices.cs

示例12: GetParentPackageIdFromContextElement

        /// <summary>
        /// Get containing Package ID from context element of Package, Element, Diagram, Attribute, Operation
        /// </summary>
        /// <param name="rep"></param>
        /// <returns></returns>
        static int GetParentPackageIdFromContextElement(Repository rep)
        {
            ObjectType objectType = rep.GetContextItemType();
            int id = 0;
            switch (objectType)
            {
                case ObjectType.otDiagram:
                    Diagram dia = (Diagram)rep.GetContextObject();
                    id = dia.PackageID;
                    break;
                case ObjectType.otElement:
                    EA.Element el = (EA.Element)rep.GetContextObject();
                    id = el.PackageID;
                    break;
                case ObjectType.otPackage:
                    EA.Package pkg = (EA.Package)rep.GetContextObject();
                    id = pkg.PackageID;
                    break;
                case ObjectType.otAttribute:
                    EA.Attribute attr = (EA.Attribute)rep.GetContextObject();
                    EA.Element elOfAttr = rep.GetElementByID(attr.ParentID);
                    id = elOfAttr.PackageID;
                    break;
                case ObjectType.otMethod:
                    Method meth = (Method)rep.GetContextObject();
                    EA.Element elOfMeth = rep.GetElementByID(meth.ParentID);
                    id = elOfMeth.PackageID;
                    break;
            }

            return id;
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:37,代码来源:SqlTemplates.cs

示例13: macroItem_GUID

        /// <summary>
        /// Replace macro #CurrentItemGUID# by the GUID of the currently selected Item.
        /// Alias: #CurrentElementGUID#
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="sql">The sql string to replace the macro by the found ID</param>
        /// <returns>sql string with replaced macro</returns>
        static string macroItem_GUID(Repository rep, string sql)
        {
            // replace ID
            string template = GetTemplateText(SqlTemplateId.CurrentItemGuid);
            if (sql.Contains(template) | sql.Contains("#CurrentElementGUID#")) 
            {
                ObjectType objectType = rep.GetContextItemType();
                string guid = "";
                switch (objectType)
                {
                    case ObjectType.otElement:
                        EA.Element el = (EA.Element)rep.GetContextObject();
                        guid = el.ElementGUID;
                        break;
                    case ObjectType.otDiagram:
                        Diagram dia = (Diagram)rep.GetContextObject();
                        guid = dia.DiagramGUID;
                        break;
                    case ObjectType.otPackage:
                        EA.Package pkg = (EA.Package)rep.GetContextObject();
                        guid = pkg.PackageGUID;
                        break;
                    case ObjectType.otAttribute:
                        EA.Attribute attr = (EA.Attribute)rep.GetContextObject();
                        guid = attr.AttributeGUID;
                        break;
                    case ObjectType.otMethod:
                        Method method = (Method)rep.GetContextObject();
                        guid = method.MethodGUID;
                        break;
                }

                if (guid != "")
                {
                    sql = sql.Replace(template, $"{guid}");
                    sql = sql.Replace("#CurrentElementGUID#", $"{guid}");// Alias for EA compatibility
                }
                else
                // no diagram, element or package selected
                {
                    MessageBox.Show(sql, @"No item (Package, Element, Diagram, Operation, Attribute) selected!");
                    sql = "";
                }

            }
            return sql;
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:54,代码来源:SqlTemplates.cs

示例14: macroDiagramSelectedElements_IDS

        /// <summary>
        /// Replace macro #DiagramElements_IDS# by a comma separated list of all Element IDs in diagram.
        /// <para/>
        /// If no Element is in the diagram it return '0' for an empty list (not existing ID).
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="sql">The sql string to replace the macro by the found list of Diagram Element IDs</param>
        /// <returns>sql string with replaced macro</returns>
        static string macroDiagramSelectedElements_IDS(Repository rep, string sql)
        {
            // get template
            string template = GetTemplateText(SqlTemplateId.DiagramSelectedElementsIds);

            // template is used
            if (sql.Contains(template))
            {
                // get the diagram
                Diagram dia = rep.GetContextItemType() == ObjectType.otDiagram ? rep.GetContextObject() : rep.GetCurrentDiagram();
                // Diagram selected?
                if (dia == null)
                {
                    MessageBox.Show(sql, $"No Diagram  for '{template}' selected!");
                    sql = "";
                }
                else
                {
                    // make a list of comma separated IDs
                    string listId = "0";
                    foreach (var el in dia.SelectedObjects)
                    {
                        int id = ((EA.DiagramObject)el).ElementID;
                        listId = $"{listId},{id}";

                    }

                    // replace by list of IDs
                    sql = sql.Replace(template, $"{listId}");
                }
            }
            return sql;
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:41,代码来源:SqlTemplates.cs

示例15: JoinDiagramObjectsToLastSelected

        // ReSharper disable once UnusedMember.Global
        // dynamical usage as configurable service by reflection
        public static void JoinDiagramObjectsToLastSelected(Repository rep)
        {
            Diagram dia = rep.GetCurrentDiagram();
            if (dia == null) return;
            int count = dia.SelectedObjects.Count;
            if (count < 2) return;
            rep.SaveDiagram(dia.DiagramID);

            // target object/element
            var trgEl = (Element) rep.GetContextObject();

            for (int i = 0; i < count; i = i + 1)
            {
                var srcObj = (DiagramObject) dia.SelectedObjects.GetAt((short) i);
                var srcEl = rep.GetElementByID(srcObj.ElementID);
                if (srcEl.ElementID == trgEl.ElementID) continue;
                Connectors.Connector connector = GetConnectionDefault();

                var con = (Connector) srcEl.Connectors.AddNew("", connector.Type);
                con.SupplierID = trgEl.ElementID;
                con.Stereotype = connector.Stereotype;
                con.Update();
                srcEl.Connectors.Refresh();
                trgEl.Connectors.Refresh();
                dia.DiagramLinks.Refresh();
                // set line style
                DiagramLink link = GetDiagramLinkForConnector(dia, con.ConnectorID);
                if (link != null) Util.SetLineStyleForDiagramLink("LV", link);
            }

            rep.ReloadDiagram(dia.DiagramID);
            dia.SelectedObjects.AddNew(trgEl.ElementID.ToString(), trgEl.ObjectType.ToString());
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:35,代码来源:EaServices.cs


注:本文中的Repository.GetContextObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。