コード例 #1
0
ファイル: JCompDevice.cs プロジェクト: dionext/nettools
        //public object RemoteSession;

        static public void CloneDependencies(object cloningObject, object targetObject)
        {
            //Console.WriteLine("---- -------- CloneDependencies");
            IList <JSoftInstance> siList = Dm.Instance.ResolveOneToManyRelation <JSoftInstance>(cloningObject);

            foreach (var si in siList)
            {
                JSoftInstance siClone = (JSoftInstance)Dm.CloneObject(si, CloneObjectType.ForNew);
                siClone.JCompDevice = targetObject as JCompDevice;
                Dm.Instance.SaveObject(siClone);

                //cloning user accounts
                IList <JUserAccount> uaList = Dm.Instance.ResolveOneToManyRelation <JUserAccount>(si);
                foreach (var ua in uaList)
                {
                    JUserAccount uaClone = (JUserAccount)Dm.CloneObject(ua, CloneObjectType.ForNew);
                    uaClone.JSoftInstance = siClone;
                    Dm.Instance.SaveObject(uaClone);
                }
            }
            IList <JCompDeviceStorage> sdsList = Dm.Instance.ResolveOneToManyRelation <JCompDeviceStorage>(cloningObject);

            foreach (var sds in sdsList)
            {
                JCompDeviceStorage sdsClone = (JCompDeviceStorage)Dm.CloneObject(sds, CloneObjectType.ForNew);
                sdsClone.JCompDevice = targetObject as JCompDevice;
                Dm.Instance.SaveObject(sdsClone);
            }
        }
コード例 #2
0
 override protected void ComplateNodeFromObject(TreeNode node, object o)
 {
     base.ComplateNodeFromObject(node, o);
     object x = (node.Tag is TreeObjectWrap) ? (node.Tag as TreeObjectWrap).Tag : node.Tag;
     if (x == null) return;
     if (x is JCompDeviceStorage)
     {
         JCompDeviceStorage h = (x as JCompDeviceStorage);
         if (h.MasterStorage != null && h.MasterStorage.JCompDevice != h.JCompDevice)
         {
             node.Text = h.JCompDevice.Name + " " + node.Text;
             node.ToolTipText = h.JCompDevice.Name + " " + node.ToolTipText;
         }
     }
     else if (x is JSoftInstance)
     {
         JSoftInstance h = (x as JSoftInstance);
         if (h.IsDocker)
         {
             SetImageForNode(node, NetworkAccountHelperLibRes.docker, "JSoftInstance_IsDocker");
         }
     }
     else if (x is JCompDevice)
     {
         JCompDevice h = (x as JCompDevice);
         if (CompDeviceTypeEnum.Virtual.ToString().Equals(h.Stage))
         {
             SetImageForNode(node, NetworkAccountHelperLibRes.virtualbox, "JCompDevice_virtualbox");
         }
     }
 }