/////////////////////////////////////////////////////////////////////// #if ISOLATED_PLUGINS public static bool IsIsolated( IPluginData pluginData ) { return((pluginData != null) && FlagOps.HasFlags(pluginData.Flags, PluginFlags.Isolated, true)); }
/////////////////////////////////////////////////////////////////////// public static bool IsSame( IPluginData pluginData1, IPluginData pluginData2 ) { return(IsSameId(pluginData1, pluginData2)); }
public override void EventHandler(object _sender, IPluginData _data) { // Load status.js and update necessary variables Hashtable status = (Hashtable)JSON.JsonDecodeFromVar(m_statusFileName); switch (_data.DataType()) { case ThingSpeakFields.pH: status["pH"] = _data.GetValue().ToString("F"); break; case ThingSpeakFields.Temperature: status["Temperature"] = _data.GetValue().ToString("F"); break; default: break; } status["time"] = DateTime.Now.ToString("s"); foreach (DictionaryEntry item in status) { Debug.Print(item.Key.ToString() + "=" + item.Value.ToString()); } // write status.js back down to fs, including the var declaration string statusString = JSON.JsonEncode(status); statusString = "var aq=" + statusString; byte[] statusBytes = Encoding.UTF8.GetBytes(statusString); using (FileStream fs = new FileStream(m_statusFileName, FileMode.Truncate)) { fs.Write(statusBytes, 0, statusBytes.Length); } }
/// <summary> /// Records the last temperature reading from the Temperature Plugin /// </summary> /// <param name="_sender">Object that raised the callback</param> /// <param name="_data">Last reading</param> public override void EventHandler(object _sender, IPluginData _data) { // Only worry about Temperature data, so check data units. // If it's 'C' then assume it's the one we want. Debug.Print("Got Temperature Value"); if (_data.DataUnits().Equals("C")) m_Temperature = _data.GetValue(); }
public MPPictureShares(IPluginData data) : base(data) { if (!Mediaportal.HasValidConfigFile()) { Supported = false; return; } IEnumerable<KeyValuePair<string, string>> list = Mediaportal.ReadSectionFromConfigFile("pictures"); Extensions = list.Where(x => x.Key == "extensions").Select(x => x.Value).First().Split(','); shares = new List<Share>(); int count = list.Where(x => x.Key.StartsWith("sharename")).Count(); for (int i = 0; i < count; i++) { if (list.Where(x => x.Key == "sharetype" + i).Select(x => x.Value).First() == "yes") { continue; } shares.Add(new Share() { Name = list.Where(x => x.Key == "sharename" + i).Select(x => x.Value).First(), Path = Path.GetFullPath(list.Where(x => x.Key == "sharepath" + i).Select(x => x.Value).First()), Index = i }); } shareCache = new Dictionary<string, Share>(); Supported = true; }
public MPPictureShares(IPluginData data) : base(data) { if (!Mediaportal.HasValidConfigFile()) { Supported = false; return; } IEnumerable <KeyValuePair <string, string> > list = Mediaportal.ReadSectionFromConfigFile("pictures"); Extensions = list.Where(x => x.Key == "extensions").Select(x => x.Value).First().Split(','); shares = new List <Share>(); int count = list.Where(x => x.Key.StartsWith("sharename")).Count(); for (int i = 0; i < count; i++) { if (list.Where(x => x.Key == "sharetype" + i).Select(x => x.Value).First() == "yes") { continue; } shares.Add(new Share() { Name = list.Where(x => x.Key == "sharename" + i).Select(x => x.Value).First(), Path = Path.GetFullPath(list.Where(x => x.Key == "sharepath" + i).Select(x => x.Value).First()), Index = i }); } shareCache = new Dictionary <string, Share>(); Supported = true; }
public IPluginData TransformData(IPluginData data) { _logger?.LogInformation("Logging stuff"); return(new PluginData { Message = $"Hola {data.Message} - {JsonConvert.SerializeObject(new { X = 1 })}" }); }
public override void EventHandler(object _sender, IPluginData _data) { try { // Load status.js and update necessary variables Hashtable status = (Hashtable)JSON.JsonDecodeFromVar(m_statusFileName); foreach (PluginData _pd in _data.GetData()) { if (_pd.LastReadSuccess) status[_pd.Name] = _pd.Value.ToString("F"); } status["time"] = DateTime.Now.ToString("s"); // write status.js back down to fs, including the var declaration string statusString = JSON.JsonEncode(status); statusString = "var aq=" + statusString; byte[] statusBytes = Encoding.UTF8.GetBytes(statusString); using (FileStream fs = new FileStream(m_statusFileName, FileMode.Create)) { fs.Write(statusBytes, 0, statusBytes.Length); } } catch (Exception e) { Debug.Print(e.Message); } }
public Test( IPluginData pluginData ) : base(pluginData) { this.Flags |= GetConstructorPluginFlags(); this.ExtraFlags = GetDefaultExtraFlags(); }
public void ProcessInputData(IPluginData _data) { Debug.Print("Process INput Data = " + _data.GetValue().ToString()); OutputPluginEventHandler ope = m_eventHandler; Debug.Print(ope.Method.ToString()); // walk through all available output plugins if (ope != null) ope(this, _data); }
public Notify( IPluginData pluginData ) : base(pluginData) { this.Flags |= AttributeOps.GetPluginFlags(GetType().BaseType) | AttributeOps.GetPluginFlags(this); }
public Toolkit( IPluginData pluginData ) : base(pluginData) { this.Flags |= Utility.GetPluginFlags(GetType().BaseType) | Utility.GetPluginFlags(this); }
public static IPluginData Wrap(IPluginData data) { if (data.GetType().IsSerializable) { return(data); } return(new Data(data)); }
//////////////////////////////////////////////////////////////////////// #region ISetup Members public override ReturnCode Setup( ref Result error ) { try { IPluginData pluginData = this.Plugin; if (pluginData != null) { Assembly assembly = pluginData.Assembly; if (assembly != null) { Type type = assembly.GetType( this.TypeName, true, false); /* throw */ if (type != null) { MethodInfo methodInfo = type.GetMethod( this.MethodName, this.BindingFlags); /* throw */ if (methodInfo != null) { this.Callback = Delegate.CreateDelegate( typeof(TraceCallback), null, methodInfo, false) as TraceCallback; return(ReturnCode.Ok); } else { error = "cannot get method from trace type"; } } else { error = "cannot get trace type from plugin assembly"; } } else { error = "plugin data has invalid assembly"; } } else { error = "invalid plugin data"; } } catch (Exception e) { error = e; } return(ReturnCode.Error); }
public void Callback(IPluginData data) { _writer.Write(new { method = "Callback", type = typeof(IPluginHost).AssemblyQualifiedName, args = new[] { data } }); }
/// <summary> /// Records the last temperature reading from the Temperature Plugin /// </summary> /// <param name="_sender">Object that raised the callback</param> /// <param name="_data">Last reading</param> public override void EventHandler(object _sender, IPluginData _data) { // Only worry about Temperature data, so check data units. // If it's 'C' then assume it's the one we want. Debug.Print("Got Temperature Value"); if (_data.DataUnits().Equals("C")) { m_Temperature = _data.GetValue(); } }
/////////////////////////////////////////////////////////////////////// #region Public Constructors public TestForm( _Forms.TestForm form, IPluginData pluginData ) : base(pluginData) { this.Flags |= Utility.GetPluginFlags(GetType().BaseType) | Utility.GetPluginFlags(this); this.form = form; }
/// <summary> /// Delegate for signaling output plugins that data is available. /// This is called from inside each Input Plugin Callback /// </summary> /// <param name="_data">data passed up from input plugin</param> private static void DataAvailable(IPluginData _data) { // data should be available in the queue // raise the event to handle it. OutputPluginEventHandler ope = (OutputPluginEventHandler)m_eventHandlerList["OutputPlugins"]; // walk through all available output plugins if (ope != null) { ope(ope, _data); } }
public void ProcessInputData(IPluginData _data) { Debug.Print("Process INput Data = " + _data.GetValue().ToString()); OutputPluginEventHandler ope = m_eventHandler; Debug.Print(ope.Method.ToString()); // walk through all available output plugins if (ope != null) { ope(this, _data); } }
public ShareLibrary(IPluginData data, string[] sections) { this.data = data; this.configuration = data.GetConfiguration("MP Shares"); if (!Mediaportal.HasValidConfigFile()) { Supported = false; return; } var localsharelist = new List <Share>(); foreach (string section in sections) { IEnumerable <KeyValuePair <string, string> > list = Mediaportal.ReadSectionFromConfigFile(section); string[] extensions = list.Where(x => x.Key == "extensions").Select(x => x.Value).First().Split(','); int count = list.Where(x => x.Key.StartsWith("sharename")).Count(); for (int i = 0; i < count; i++) { if (list.Where(x => x.Key == "sharetype" + i).Select(x => x.Value).First() == "yes") { continue; } string path = list.Where(x => x.Key == "sharepath" + i).Select(x => x.Value).First(); localsharelist.Add(new Share() { Name = list.Where(x => x.Key == "sharename" + i).Select(x => x.Value).First(), Path = path, Extensions = extensions.ToList(), }); } } // make shares unique shares = localsharelist.GroupBy(x => x.Path, (path, gshares) => new Share() { Name = gshares.First().Name, Path = path, Extensions = gshares.SelectMany(x => x.Extensions).ToList() }).ToList(); int shareNr = 0; foreach (Share share in shares) { share.Id = "s" + (shareNr++); } Supported = true; }
/////////////////////////////////////////////////////////////////////// public static bool IsCross( IPluginData pluginData ) { #if ISOLATED_PLUGINS if (IsIsolated(pluginData)) { return(true); } #endif return(IsCrossNoIsolated(pluginData)); }
/////////////////////////////////////////////////////////////////////// #region Public Constructors public Trace( IPluginData pluginData ) : base(pluginData) { this.Flags |= AttributeOps.GetPluginFlags(GetType().BaseType) | AttributeOps.GetPluginFlags(this); /////////////////////////////////////////////////////////////////// /* IGNORED */ UseDefaultSettings(); }
/// <summary> /// Constructs an instance of this custom plugin class. /// </summary> /// <param name="pluginData"> /// An instance of the plugin data class containing the properties /// used to initialize the new instance of this custom plugin class. /// Typically, the only thing done with this parameter is to pass it /// along to the base class constructor. /// </param> public Class4( IPluginData pluginData /* in */ ) : base(pluginData) { // // NOTE: Typically, nothing much is done here. Any non-trivial // initialization should be done in IState.Initialize and // cleaned up in IState.Terminate. // this.Flags |= Utility.GetPluginFlags(GetType().BaseType) | Utility.GetPluginFlags(this); /* HIGHLY RECOMMENDED */ }
public ShareLibrary(IPluginData data, string[] sections) { this.data = data; this.configuration = data.GetConfiguration("MP Shares"); if (!Mediaportal.HasValidConfigFile()) { Supported = false; return; } var localsharelist = new List<Share>(); foreach (string section in sections) { IEnumerable<KeyValuePair<string, string>> list = Mediaportal.ReadSectionFromConfigFile(section); string[] extensions = list.Where(x => x.Key == "extensions").Select(x => x.Value).First().Split(','); int count = list.Where(x => x.Key.StartsWith("sharename")).Count(); for (int i = 0; i < count; i++) { if (list.Where(x => x.Key == "sharetype" + i).Select(x => x.Value).First() == "yes") { continue; } string path = list.Where(x => x.Key == "sharepath" + i).Select(x => x.Value).First(); localsharelist.Add(new Share() { Name = list.Where(x => x.Key == "sharename" + i).Select(x => x.Value).First(), Path = path, Extensions = extensions.ToList(), }); } } // make shares unique shares = localsharelist.GroupBy(x => x.Path, (path, gshares) => new Share() { Name = gshares.First().Name, Path = path, Extensions = gshares.SelectMany(x => x.Extensions).ToList() }).ToList(); int shareNr = 0; foreach (Share share in shares) { share.Id = "s" + (shareNr++); } Supported = true; }
public ShareLibrary(IPluginData data, string[] sections) { this.data = data; this.configuration = data.GetConfiguration("MP Shares"); this.sections = sections; Supported = Mediaportal.HasValidConfigFile(); if (Supported) { ReadConfiguration(); ConfigurationChangeListener.ConfigurationChanged += ReadConfiguration; ConfigurationChangeListener.Enable(); } }
public Core( IPluginData pluginData ) : base(pluginData) { // // NOTE: This plugin adds the "core" command set into the specified // interpreter. These commands will typically always be // available in a given interpreter; however, this is not // absolutely guaranteed as they can be explicitly unloaded. // this.Flags |= AttributeOps.GetPluginFlags(GetType().BaseType) | AttributeOps.GetPluginFlags(this); }
public MVCentral(IPluginData data) { var config = data.GetConfiguration("mvCentral"); if (config.ContainsKey("database") && File.Exists(config["database"])) { DatabasePath = config["database"]; Supported = true; ReadSettings(); } else { Supported = false; } }
/////////////////////////////////////////////////////////////////////// // // BUGBUG: Should this just use the IsTransparentProxy method instead? // public static bool IsCrossNoIsolated( Interpreter interpreter, IPluginData pluginData ) { AppDomain interpreterAppDomain; if (interpreter != null) { // // NOTE: If the interpreter is not a master interpreter // and it is running in a non-default application // domain, it MUST be considered as cross-domain. // The master interpreter may call [interp eval] // on it, and that result could be of a type from // an assembly that has not been (and cannot be) // loaded into the master interpreter application // domain. // if (!interpreter.IsMasterInterpreter() && !IsCurrentDefault()) { return(true); } interpreterAppDomain = GetFrom(interpreter); } else { interpreterAppDomain = null; } AppDomain pluginAppDomain = (pluginData != null) ? pluginData.AppDomain : null; if (!IsSame(interpreterAppDomain, pluginAppDomain)) { return(true); } if (!IsSameId(interpreter, pluginData)) { return(true); } return(false); }
/////////////////////////////////////////////////////////////////////// #region Public Constructor (Required) /// <summary> /// Constructs an instance of this custom plugin class. /// </summary> /// <param name="pluginData"> /// An instance of the plugin data class containing the properties /// used to initialize the new instance of this custom plugin class. /// Typically, the only thing done with this parameter is to pass it /// along to the base class constructor. /// </param> public Class3( IPluginData pluginData /* in */ ) : base(pluginData) { // // NOTE: Typically, nothing much is done here. Any non-trivial // initialization should be done in IState.Initialize and // cleaned up in IState.Terminate. // this.Flags |= Utility.GetPluginFlags(GetType().BaseType) | Utility.GetPluginFlags(this); /* HIGHLY RECOMMENDED */ // // HACK: For now, skip adding policies if we are being loaded into // an isolated application domain. // // if (Utility.HasFlags(this.Flags, PluginFlags.Isolated, true)) // this.Flags |= PluginFlags.NoPolicies; }
public override void EventHandler(object _sender, IPluginData _data) { // build field string from _data and append to the post string string fieldData = "field" + (uint)_data.DataType() + "=" + _data.GetValue().ToString("F"); // add content length to post string, then data string postString = m_httpPost + fieldData.Length + "\n\n" + fieldData; //Open the Socket and post the data // create required networking parameters using (Socket thingSpeakSocket = ConnectSocket(m_thingSpeakIP, 80)) { Byte[] sendBytes = Encoding.UTF8.GetBytes(postString); thingSpeakSocket.Send(sendBytes, sendBytes.Length, 0); // wait for a response to see what happened Byte[] buffer = new Byte[256]; String page = String.Empty; // Poll for data until 30-second timeout. Returns true for data and connection closed. while (thingSpeakSocket.Poll(20 * 1000000, SelectMode.SelectRead)) { // If there are 0 bytes in the buffer, then the connection is closed, or we have timed out. if (thingSpeakSocket.Available == 0) { break; } // Zero all bytes in the re-usable buffer. Array.Clear(buffer, 0, buffer.Length); // Read a buffer-sized HTML chunk. Int32 bytesRead = thingSpeakSocket.Receive(buffer); // Append the chunk to the string. page = page + new String(Encoding.UTF8.GetChars(buffer)); } Debug.Print(page); } }
public override void EventHandler(Object sender, IPluginData data) { StringBuilder sb = new StringBuilder(); // Format string for output sb.Append(DateTime.Now.ToString("s")); sb.Append(","); sb.Append(data.GetValue().ToString("F")); sb.Append(data.DataUnits()); sb.Append("\n"); // take data and write it out to text using (FileStream fs = new FileStream(m_logFile, FileMode.Append)) { var buf = Encoding.UTF8.GetBytes(sb.ToString()); fs.Write(buf, 0, buf.Length); fs.Flush(); } Debug.Print("Written " + sb.ToString()); }
/////////////////////////////////////////////////////////////////////// // // BUGBUG: Should this just use the IsTransparentProxy method instead? // public static bool IsCrossNoIsolated( IPluginData pluginData ) { AppDomain pluginAppDomain = (pluginData != null) ? pluginData.AppDomain : null; AppDomain currentAppDomain = GetCurrent(); if (!IsSame(pluginAppDomain, currentAppDomain)) { return(true); } if (!IsSameId(pluginData, currentAppDomain)) { return(true); } return(false); }
//////////////////////////////////////////////////////////////////////// private static IBinder GetBinder( Interpreter interpreter, IPluginData pluginData ) { // // BUGFIX: We cannot use the ScriptBinder if this plugin has been // loaded into an AppDomain different from the interpreter // -OR- there is no interpreter to obtain it from. // if (interpreter != null) { if (Utility.IsCrossAppDomain(interpreter, pluginData)) { return(null); } return(interpreter.Binder); } else { return(null); } }
public PictureShares(IPluginData data) : base(data, "pictures") { }
protected PluginDataEditControl(IPluginData data) { Data = data; }
public FSPictures(IPluginData data) : base(data) { root = data.GetConfiguration("FS Pictures")["root"]; }
public AllShares(IPluginData data) : base(data) { Sections = new string[] { "movies", "music", "pictures" }; }
public ShareLibrary(IPluginData data) { this.data = data; this.configuration = data.GetConfiguration("MP Shares"); }
public abstract void EventHandler(Object sender, IPluginData data);
public XBMCMusic(IPluginData data) : base(data.Configuration["database"].ConfigValue) { }
public AllShares(IPluginData data) : base(data, new string[] { "movies", "music", "pictures" }) { }
public MusicShares(IPluginData data) : base(data, "music") { }
public PictureShares(IPluginData data) : base(data) { Sections = new string[] { "pictures" }; }
public MovieShares(IPluginData data) : base(data, "movies") { }
public LeafTreeNode(IPluginData data) { _data = data; Text = _data.ToString(); _data.DataChanged += Data_DataChanged; }
public MovieShares(IPluginData data) : base(data) { Sections = new string[] { "movies" }; }
public void Callback(IPluginData data) { Console.WriteLine($"Callback {data.Message}"); }
/// <summary> /// Delegate for signaling output plugins that data is available. /// This is called from inside each Input Plugin Callback /// </summary> /// <param name="_data">data passed up from input plugin</param> private static void DataAvailable(IPluginData _data) { // data should be available in the queue // raise the event to handle it. OutputPluginEventHandler ope = (OutputPluginEventHandler)m_eventHandlerList["OutputPlugins"]; // walk through all available output plugins if (ope != null) ope(ope, _data); }
// Temperature doesn't need the Output Handler public override void EventHandler(object sender, IPluginData data) { throw new System.NotImplementedException(); }
public ShareLibrary(IPluginData data, string section) : this(data, new string[] { section }) { }
public MPVideos(IPluginData data) { this.data = data; }
public PluginDataEditControl GetEditControl(IPluginData data) { return new ChartControl((ChartData)data); }
public MusicShares(IPluginData data) : base(data) { Sections = new string[] { "music" }; }
public PictureLibraryBase(IPluginData data) { this.data = data; Extensions = new string[] { ".jpg", ".png", ".bmp" }; Supported = true; }
public FSPictures(IPluginData data) : base(data) { root = data.GetConfiguration("FS Pictures")["root"]; Supported = Directory.Exists(root); }