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 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大