Lukas00990 2021-09-25 18:10 采纳率: 40.8%
浏览 31
已结题

C#造实例,对象, 密封类

如下图所示,
var current = ProjectTree.SelectedItem.Tag, debug模式下可以看到 current 的value 是 {Siemens.Engineering.SW.Blocks.PlcBlockSystemGroup}, current的type 是 object {Siemens.Engineering.SW.Blocks.PlcBlockSystemGroup}

现在的问题是,这里的value 和 type指的什么意思。 用花括号代表着什么? 如果我想新造一个Siemens.Engineering.SW.Blocks.PlcBlockSystemGroup 的对象或者叫实例? 应该怎么弄?这个类长这样。 我这样写是报错的 PlcSystemBlockGroup current = new PlcSystemBlockGroup();

 
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security;
 
namespace Siemens.Engineering.SW.Blocks
{
    //
    // Summary:
    //     Group containing Plc system blocks & Plc system block groups
    [DebuggerNonUserCode]
    [SecuritySafeCritical]
    public sealed class PlcSystemBlockGroup : IEngineeringObject, IEngineeringCompositionOrObject, IEngineeringInstance, IInternalObjectAccess, IInternalInstanceAccess, IInternalBaseAccess, IEquatable<object>
    {
        //
        // Summary:
        //     Composition of Plc system blocks
        public PlcBlockComposition Blocks { get; }
        //
        // Summary:
        //     Composition of Plc system block groups
        public PlcSystemBlockGroupComposition Groups { get; }
        //
        // Summary:
        //     EOM parent of this object
        public IEngineeringObject Parent { get; }
        //
        // Summary:
        //     The name of the Plc system block group
        public string Name { get; }
 
        //
        // Summary:
        //     Determines whether the specified System.Object is equal to this instance.
        //
        // Parameters:
        //   obj:
        //     The System.Object to compare with this instance.
        //
        // Returns:
        //     true if the specified System.Object is equal to this instance; otherwise, false.
        [SecuritySafeCritical]
        public override bool Equals(object obj);
        //
        // Summary:
        //     Gets a list of attributes for the given names.
        //
        // Parameters:
        //   names:
        //     The names of the attributes to get.
        //
        // Returns:
        //     A list of the attributes for the given names with nulls for names not found.
        [SecuritySafeCritical]
        public IList<object> GetAttributes(IEnumerable<string> names);
        //
        // Summary:
        //     Returns a hash code for this instance.
        //
        // Returns:
        //     A hash code for this instance, suitable for use in hashing algorithms and data
        //     structures like a hash table.
        [SecuritySafeCritical]
        public override int GetHashCode();
        //
        // Summary:
        //     Sets a list of values for the given attributes.
        //
        // Parameters:
        //   attributes:
        //     The attributes value list.
        [SecuritySafeCritical]
        public void SetAttributes(IEnumerable<KeyValuePair<string, object>> attributes);
        //
        // Summary:
        //     Returns a System.String that represents the current System.Object.
        //
        // Returns:
        //     A System.String that represents the current System.Object.
        [SecuritySafeCritical]
        public override string ToString();
    }
}
 


  • 写回答

1条回答 默认 最新

  • 急速光粒 2021-09-25 18:16
    关注

    可以采用父节点的create方法创建节点。再执行导入挂到响应地节点下。有帮助望采纳,谢谢!

            PlcBlockGroup get_relate_group(PlcBlockGroup group, string str_root, string strfile)
            {
                string relate_path = get_relate_path(str_root, strfile);
                string[]dirs = relate_path.Split('\\');
                PlcBlockGroup temp = group;
                for (int i=0;i<dirs.Length-1;i++)
                {
                    if(i == 0)
                    {
                        if (group.Groups.Find(dirs[i]) == null)
                        {
                            group.Groups.Create(dirs[i]);
                        }
                        temp = group.Groups.Find(dirs[i]);
                    }
                    else
                    {
                        if(temp.Groups.Find(dirs[i]) == null)
                        {
                            temp.Groups.Create(dirs[i]);
                            temp = temp.Groups.Find(dirs[i]);
                        }
                    }
                }
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月3日
  • 已采纳回答 9月25日
  • 创建了问题 9月25日

悬赏问题

  • ¥15 在不同的执行界面调用同一个页面
  • ¥20 基于51单片机的数字频率计
  • ¥50 M3T长焦相机如何标定以及正射影像拼接问题
  • ¥15 keepalived的虚拟VIP地址 ping -s 发包测试,只能通过1472字节以下的数据包(相关搜索:静态路由)
  • ¥20 关于#stm32#的问题:STM32串口发送问题,偶校验(even),发送5A 41 FB 20.烧录程序后发现串口助手读到的是5A 41 7B A0
  • ¥15 C++map释放不掉
  • ¥15 Mabatis查询数据
  • ¥15 想知道lingo目标函数中求和公式上标是变量情况如何求解
  • ¥15 关于E22-400T22S的LORA模块的通信问题
  • ¥15 求用二阶有源低通滤波将3khz方波转为正弦波的电路