예제 #1
0
        public BaseChannel(string name, bool readOnly, ICommunicationPlug plugin, Type type)
        {
            this.name     = name;
            this.readOnly = readOnly;
            this.plugin   = plugin;
            this.type     = type;

            defaultValue = type.IsValueType ? Activator.CreateInstance(type) : null;
            if (type == typeof(string))
            {
                defaultValue = "";
            }
            value = defaultValue;

            modifyTime = DateTime.MinValue;
            status     = ChannelStatusFlags.Unknown;
        }
        public void Load()
        {
            DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);

            foreach (FileInfo fi in di.GetFiles("Communication.*.dll"))
            {
                Assembly lib = Assembly.LoadFrom(fi.FullName);
                foreach (Type t in lib.GetExportedTypes())
                {
                    if (t.GetInterface(typeof(ICommunicationPlug).FullName) != null)
                    {
                        ICommunicationPlug plug = (ICommunicationPlug)Activator.CreateInstance(t);
                        InitializePlugin(Env.Current, plug);
                    }
                }
            }
        }
예제 #3
0
        public ChannelInfo[] GetChannels()
        {
            List <ChannelInfo> channels = new List <ChannelInfo>();

            foreach (string pluginId in Env.Current.CommunicationPlugins.PluginIds)
            {
                ICommunicationPlug plug = Env.Current.CommunicationPlugins[pluginId];
                foreach (IChannel channel in plug.Channels)
                {
                    ChannelInfo info = new ChannelInfo();
                    info.FullId     = channel.FullId;
                    info.IsReadOnly = channel.IsReadOnly;
                    info.Name       = channel.Name;
                    info.PluginId   = channel.PluginId;
                    info.Type       = channel.Type.FullName;

                    channels.Add(info);
                }
            }

            return(channels.ToArray());
        }
 private void InitializePlugin(IEnvironment env, ICommunicationPlug plug)
 {
     plug.Initialize(env);
     plug.ChannelsChanged += new EventHandler(OnPluginChannelsChanged);
     commPlugs.Add(plug);
 }