Ejemplo n.º 1
0
        public IExplorerObject DeserializeExplorerObject(string FullName)
        {
            IExplorerObject cached = GetExObjectFromCache(FullName);

            if (cached != null)
            {
                return(cached);
            }

            PlugInManager compManager = new PlugInManager();

            foreach (XmlNode exNode in compManager.GetPluginNodes(Plugins.Type.IExplorerObject))
            {
                IExplorerObject exObject = (IExplorerObject)compManager.CreateInstance(exNode);
                if (!(exObject is ISerializableExplorerObject))
                {
                    continue;
                }

                exObject = ((ISerializableExplorerObject)exObject).CreateInstanceByFullName(FullName, this);
                if (exObject != null)
                {
                    return(exObject);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        internal static List <IExplorerObject> Refresh(IExplorerObject parent, string FullName)
        {
            List <IExplorerObject> childs = new List <IExplorerObject>();

            try
            {
                foreach (string subdir in Directory.GetDirectories(FullName))
                {
                    DirectoryInfo di = new DirectoryInfo(subdir);
                    childs.Add(new DirectoryObject(parent, di.FullName));
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return(null);
            }

            gView.Framework.system.PlugInManager manager = new gView.Framework.system.PlugInManager();

            foreach (XmlElement exObjectNode in manager.GetPluginNodes(Plugins.Type.IExplorerObject))
            {
                IExplorerObject exObj = (IExplorerObject)manager.CreateInstance(exObjectNode);
                if (!(exObj is IExplorerFileObject))
                {
                    continue;
                }

                foreach (string filter in ((IExplorerFileObject)exObj).Filter.Split('|'))
                {
                    foreach (string file in Directory.GetFiles(FullName, filter))
                    {
                        FileInfo            fi  = new FileInfo(file);
                        IExplorerFileObject obj = ((IExplorerFileObject)exObj).CreateInstance(parent, fi.FullName);
                        if (obj == null)
                        {
                            continue;
                        }

                        childs.Add(obj);
                    }
                }
            }

            return(childs);
        }
Ejemplo n.º 3
0
        public IExplorerObject DeserializeExplorerObject(Guid guid, string FullName)
        {
            IExplorerObject cached = GetExObjectFromCache(FullName);

            if (cached != null)
            {
                return(cached);
            }

            PlugInManager compManager = new PlugInManager();
            object        obj         = compManager.CreateInstance(guid);

            if (!(obj is ISerializableExplorerObject))
            {
                return(null);
            }

            return(((ISerializableExplorerObject)obj).CreateInstanceByFullName(FullName, this));
        }
Ejemplo n.º 4
0
        virtual public object Clone()
        {
            if (!(this is IPersistable))
            {
                return(null);
            }

            try
            {
                object clone = null;
                if (PlugInManager.IsPlugin(this))
                {
                    PlugInManager compMan = new PlugInManager();
                    clone = compMan.CreateInstance(PlugInManager.PlugInID(this));
                }
                else
                {
                    global::System.Reflection.Assembly assembly = global::System.Reflection.Assembly.GetAssembly(this.GetType());
                    clone = assembly.CreateInstance(this.GetType().ToString());
                }
                if (clone == null)
                {
                    return(null);
                }

                XmlStream stream = new XmlStream("root");
                ((IPersistable)this).Save(stream);
                ((IPersistable)clone).Load(stream);

                return(clone);
            }
            catch
            {
            }
            return(null);
        }