// dynamically create provider private static void CreateProvider() { string providerName = null; _providerList = new Dictionary<string, ShippingInterface>(); var pluginData = new PluginData(PortalSettings.Current.PortalId); var l = pluginData.GetShippingProviders(); foreach (var p in l) { var prov = p.Value; ObjectHandle handle = null; handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass")); var objProvider = (ShippingInterface) handle.Unwrap(); var ctrlkey = prov.GetXmlProperty("genxml/textbox/ctrl"); var lp = 1; while (_providerList.ContainsKey(ctrlkey)) { ctrlkey = ctrlkey + lp.ToString(""); lp += 1; } objProvider.Shippingkey = ctrlkey; _providerList.Add(ctrlkey, objProvider); } }
protected virtual void HandlePluginLoadException(PluginData data, Exception e) { String err = "Error creating plugin from dll \"" + data.dll + "\" of: " + e.Message; data.last_error = err; data.state = PluginData.PluginDataState.ERROR_LOADING; Utils.PluginLog(PluginManagerName(), err); }
protected virtual void HandlePluginLoadReflectionException(PluginData data, ReflectionTypeLoadException ex) { String err = "Error creating plugin from dll \"" + data.dll + "\" due to a loader exception error was:\n"; foreach (Exception e in ex.LoaderExceptions) err += e.Message + "\n"; data.last_error = err; data.state = PluginData.PluginDataState.ERROR_LOADING; Utils.PluginLog(PluginManagerName(), err); }
public Comment(PluginData data) { if (data == null) { throw new ArgumentNullException("data"); } this.Key = data.Key; this.Id = data.Id; this.RawData = data.RawData; }
private void InsertRow(PluginData pd) { PluginInfoBase pib = pd.PluginBase.PluginInfoBase; DataRow dr = _dtPluginList.NewRow(); dr["Title"] = pib.Title; dr["PluginType"] = pd.PluginType.ToString(); dr["Version"] = pd.Version; dr["Author"] = pib.Author; dr["Contact"] = pib.Contact; dr["Url"] = pib.Url; _dtPluginList.Rows.Add(dr); }
public FormEntry(PluginData data) { if (data == null) { throw new ArgumentNullException("data"); } this.Key = data.Key; this.Id = data.Id; this.RawData = data.RawData; //Key and Form are same this.Form = data.Key; }
public void SaveData(string key, byte[] binarySerializedObject) { CUDQuery save; var existingData = GetPluginData(key); if (existingData != null) { existingData.Binary = binarySerializedObject; save = session => session.SaveOrUpdate(existingData); } else { var pluginData = new PluginData {PluginId = key, Binary = binarySerializedObject}; save = session => session.SaveOrUpdate(pluginData); } QueryExecutor.UpdateDelete(save); }
public void TestConstructor() { PluginData data = new PluginData(); Assert.IsNotNull(data, "Constructor of type, PluginData failed to create instance."); Assert.AreEqual("model1", data.ModelID, "ModelID is unexpected value."); Assert.AreEqual("key1", data.Key, "Key is unexpected value."); data.ModelID = "newModel"; data.Key = "newKey"; Assert.AreEqual("newModel", data.ModelID, "ModelID is unexpected value."); Assert.AreEqual("newKey", data.Key, "Key is unexpected value."); data = new PluginData("Model", "Key"); Assert.IsNotNull(data, "Constructor of type, PluginData failed to create instance."); Assert.AreEqual("Model", data.ModelID, "ModelID is unexpected value."); Assert.AreEqual("Key", data.Key, "Key is unexpected value."); }
// dynamically create provider private static void CreateProvider() { _providerList = new Dictionary<string, EntityTypeInterface>(); var pluginData = new PluginData(PortalSettings.Current.PortalId); var l = pluginData.GetEntityTypeProviders(); foreach (var p in l) { var prov = p.Value; ObjectHandle handle = null; handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass")); var objProvider = (EntityTypeInterface)handle.Unwrap(); var ctrlkey = prov.GetXmlProperty("genxml/textbox/ctrl"); if (!_providerList.ContainsKey(ctrlkey)) { _providerList.Add(ctrlkey, objProvider); } } }
public void SetUp() { _unitUnderTest = new PluginData(); }
public void Save(PluginData data) { #region argument checking if (data == null) { throw new ArgumentNullException("data"); } if (!data.IsValid()) { throw new InvalidOperationException("data is invalid"); } #endregion EnsurePluginCorrectness(); PluginStore.Instance.Save(this, data); }
/// <summary> /// Sets the visibility state of a character. If no optional parameters are set the character's visiblity state will be read from the character file and set from that. /// </summary> /// <param name="chaControl">Character for which to set visible state.</param> /// <param name="toggleVisible">Toggles the character from visible to invisible and vice versa. Not used if forceVisible is set.</param> /// <param name="forceVisible">Forces the character to the state set in forceVisibleState. Overrides default visibility state and toggleVisible.</param> /// <param name="forceVisibleState">The visibility state to set a character. Only used if forceVisible is set.</param> /// <param name="saveVisibleState">Whether or not the visible state should be saved to the card.</param> private static void SetVisibleState(ChaControl chaControl, bool toggleVisible = false, bool forceVisible = false, bool forceVisibleState = false, bool saveVisibleState = true) { bool Visible; PluginData ExtendedData = ExtendedSave.GetExtendedDataById(chaControl.chaFile, "KK_InvisibleBody"); GameObject CharacterObject = GameObject.Find(chaControl.name); if (ExtendedData == null) { Logger.Log(LogLevel.Debug, "No KK_InvisibleBody marker found"); Visible = true; //character has no extended data, create some so it will save and load with the scene ExtendedData = new PluginData(); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("Visible", Visible); ExtendedData.data = dic; } else { Logger.Log(LogLevel.Debug, $"KK_InvisibleBody marker found, Visible was {ExtendedData.data["Visible"]}"); Visible = (bool)ExtendedData.data["Visible"]; } if (forceVisible) { Visible = forceVisibleState; } else if (toggleVisible) { Visible = !Visible; } if (saveVisibleState) { ExtendedData.data["Visible"] = Visible; ExtendedSave.SetExtendedDataById(chaControl.chaFile, "KK_InvisibleBody", ExtendedData); } //No need to IterateVisible for visible characters that haven't changed if (!(Visible == true && toggleVisible == false && forceVisible == false)) { Transform cf_j_root = CharacterObject.transform.Find("BodyTop/p_cf_body_bone/cf_j_root"); if (cf_j_root != null) { IterateVisible(cf_j_root.gameObject, Visible); } //female Transform cf_o_rootf = CharacterObject.transform.Find("BodyTop/p_cf_body_00/cf_o_root/"); if (cf_o_rootf != null) { IterateVisible(cf_o_rootf.gameObject, Visible); } //male Transform cf_o_rootm = CharacterObject.transform.Find("BodyTop/p_cm_body_00/cf_o_root/"); if (cf_o_rootm != null) { IterateVisible(cf_o_rootm.gameObject, Visible); } } }
public static string GetPaymentUrl() { try { var currentcart = new CartData(PortalSettings.Current.PortalId); if (currentcart.GetCartItemList().Count > 0) { currentcart.SetValidated(true); if (currentcart.EditMode == "E") { currentcart.ConvertToOrder(); } } else { currentcart.SetValidated(true); } currentcart.Save(); var rtnurl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId); if (currentcart.EditMode == "E") { // is order being edited, so return to order status after edit. // ONLY if the cartsummry is being displayed to the manager. currentcart.ConvertToOrder(); // redirect to back office var param = new string[2]; param[0] = "ctrl=orders"; param[1] = "eid=" + currentcart.PurchaseInfo.ItemID.ToString(""); var strbackofficeTabId = StoreSettings.Current.Get("backofficetabid"); var backofficeTabId = PortalSettings.Current.ActiveTab.TabID; if (Utils.IsNumeric(strbackofficeTabId)) { backofficeTabId = Convert.ToInt32(strbackofficeTabId); } rtnurl = Globals.NavigateURL(backofficeTabId, "", param); } // get payment providers, if only 1 then return payment url. if (StoreSettings.Current.GetBool("singlepaymentoption")) { var pluginData = new PluginData(PortalSettings.Current.PortalId); var provList = pluginData.GetPaymentProviders(); if (provList.Count() == 1) { foreach (var d in provList) { var p = d.Value; var key = p.GetXmlProperty("genxml/textbox/ctrl"); var prov = PaymentsInterface.Instance(key); if (prov != null) { rtnurl += "?provider=" + prov.Paymentskey; } } } } return(rtnurl); } catch (Exception ex) { Exceptions.LogException(ex); return("ERROR"); } }
/// <summary> /// Should be called if the page needs to be updated. /// <para> /// This method should be called manually. /// </para> /// <para> /// This method will also set <see cref="CachedData"/>. /// </para> /// </summary> /// <param name="pluginData">The data the page will receive.</param> /// <returns></returns> public void UpdateData(PluginData pluginData) { CachedData = pluginData; OnUpdateData(pluginData); }
private static Task <PluginOutput <COutput> > ExecutePlugin(IPluginServices pluginServices, PluginData <BOutput> input) { var data = pluginServices.CreatePluginData <COutput>(); return(pluginServices.PluginCompleted(data)); }
/// <summary> /// Set extended data for this coordinate card /// </summary> /// <param name="dataId">Key to save the data under (usually plugin GUID)</param> /// <param name="data">Data to set</param> public void SetCoordinateExtData(string dataId, PluginData data) => ExtendedSave.SetExtendedDataById(LoadedCoordinate, dataId, data);
private void HandleError(ContactPluginData plugin, Exception e, PluginData.PluginDataState failed_state = PluginData.PluginDataState.DISABLED_ERROR) { Utils.PluginLog(PluginManagerName(), "Plugin \"" + plugin.contact_plugin.ProviderName() + "\" had an error Due to: " + e.Message); plugin.state = failed_state; plugin.last_error = e.Message; active_plugin = null; }
public ContactPluginData(PluginData data) : base(data) { }
protected abstract void PluginLoadRegisterPlugin(PluginData plugin);
protected override void PluginLoadAddPlugin(PluginData plugin) { plugins.Add(plugin as ContactPluginData); }
protected override void HandlePluginLoadReflectionException(PluginData data, ReflectionTypeLoadException ex) { base.HandlePluginLoadReflectionException(data, ex); active_plugin = null; }
protected override void HandlePluginLoadException(PluginData data, Exception e) { base.HandlePluginLoadException(data, e); active_plugin = null; }
public HeadsetPluginData(PluginData data) : base(data) { }
protected override void PluginLoadAddPlugin(PluginData plugin) { plugins.Add(plugin as HeadsetPluginData); }
public virtual void SetPluginEnabled(bool enabled, PluginData plugin) { plugin.enabled = enabled; }
protected override void OnInit(EventArgs e) { _pluginData = new PluginData(PortalId); base.OnInit(e); try { if (UserId > 0) //do nothing if user not logged on { var ctrl = Utils.RequestQueryStringParam(Context, "ctrl"); // anyone only in the client role is only allowed in the products control if (UserInfo.IsInRole(StoreSettings.ClientEditorRole) && (!UserInfo.IsInRole(StoreSettings.EditorRole) && !UserInfo.IsInRole(StoreSettings.ManagerRole) && !UserInfo.IsInRole("Administrators"))) { // ctrl = "products"; } if (ctrl == "") { ctrl = (String)HttpContext.Current.Session["nbrightbackofficectrl"]; } else { HttpContext.Current.Session["nbrightbackofficectrl"] = ctrl; } if (String.IsNullOrEmpty(ctrl)) { var p = _pluginData.GetPlugin(0); if (p != null) { ctrl = p.GUIDKey; } if (ctrl == "") { ctrl = "orders"; } if (StoreSettings.Current.Settings().Count == 0) { ctrl = "settings"; } HttpContext.Current.Session["nbrightbackofficectrl"] = ctrl; } var ctlpath = GetControlPath(ctrl); if (ctlpath == "") // ctrl may not exist in system, so default to products { ctrl = "products"; ctlpath = GetControlPath(ctrl); } // check for group data, this MUST be there otherwise this is the first time into the BO, so redirect to Admin. var l = NBrightBuyUtils.GetCategoryGroups(Utils.GetCurrentCulture(), true, ""); // don't test for grouptype, on upgrade it might not be there!! if (!l.Any()) { // redisplay settings ctrl = "settings"; ctlpath = GetControlPath(ctrl); NBrightBuyUtils.SetNotfiyMessage(ModuleId, "settingssetup", NotifyCode.fail); } if (ctlpath != "" && CheckSecurity(ctrl)) { // make compatible with running DNN in virtual directory if (HttpContext.Current.Request.ApplicationPath != null && !ctlpath.StartsWith(HttpContext.Current.Request.ApplicationPath)) { ctlpath = HttpContext.Current.Request.ApplicationPath + ctlpath; } var c1 = LoadControl(ctlpath); phData.Controls.Add(c1); } else { var c1 = new Literal(); c1.Text = "INVALID CONTROL: " + ctrl; phData.Controls.Add(c1); } } } catch (Exception exc) //Module failed to load { //display the error on the template (don;t want to log it here, prefer to deal with errors directly.) var l = new Literal(); l.Text = exc.ToString(); phData.Controls.Add(l); } }
protected override void PluginLoadAddPlugin(PluginData plugin) { plugins.Add(plugin as ContactPluginData); }
/// <summary> /// Set extended data for character's face (face sliders, eye settings). /// Always call Set right after changing any of the data, or the change might not be saved if the data is changed for whatever reason (clothing change, reload, etc.) /// This data is saved alongside game data, which means it is automatically copied and moved as necessary. /// </summary> /// <param name="data">Extended data to save.</param> public void SetFaceExtData(PluginData data) { KoikatuAPI.Assert(ChaFileControl.custom != null, "ChaFileControl.custom != null"); KoikatuAPI.Assert(ChaFileControl.custom.face != null, "ChaFileControl.custom.face != null"); ChaFileControl.custom.face.SetExtendedDataById(ExtendedDataId, data); }
// =================================================================================== // METHODS --------------------------------------------------------------------------- /// <summary> /// Gathers all needed HOTween informations via reflection. /// </summary> static void ReflectHOTween() { pluginDatas = new List<PluginData>(); validPropTypes = new List<Type>(); // Find and all plugin classes and store valid value types. Assembly hoAssembly = Assembly.GetAssembly(typeof(HOTween)); Type[] ts = hoAssembly.GetTypes(); PluginData plugD; BindingFlags flags = BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField; foreach (Type t in ts) { if (t.IsSubclassOf(typeof(ABSTweenPlugin)) && Array.IndexOf(invalidPlugins, t) == -1) { plugD = new PluginData(t); // Valid target types. try { plugD.validTargetTypes = t.InvokeMember("validTargetTypes", flags, null, null, new object[] { }) as Type[]; } catch (MissingFieldException) { plugD.validTargetTypes = null; } // Valid property types. try { plugD.validPropTypes = t.InvokeMember("validPropTypes", flags, null, null, new object[] { }) as Type[]; foreach (Type p in plugD.validPropTypes) { if (validPropTypes.IndexOf(p) == -1) validPropTypes.Add(p); } } catch (MissingFieldException) { plugD.validPropTypes = null; } // Valid value types. try { plugD.validValueTypes = t.InvokeMember("validValueTypes", flags, null, null, new object[] { }) as Type[]; } catch (MissingFieldException) { plugD.validValueTypes = null; } pluginDatas.Add(plugD); } } }
/// <summary> /// Set extended data for character's parameters (personality, preferences, traits). /// Always call Set right after changing any of the data, or the change might not be saved if the data is changed for whatever reason (clothing change, reload, etc.) /// This data is saved alongside game data, which means it is automatically copied and moved as necessary. /// </summary> /// <param name="data">Extended data to save.</param> public void SetParameterExtData(PluginData data) { KoikatuAPI.Assert(ChaFileControl.parameter != null, "ChaFileControl.parameter != null"); ChaFileControl.parameter.SetExtendedDataById(ExtendedDataId, data); }
private static async Task <PluginOutput <CancellableTaskOutput> > ExecutePlugin(IPluginServices pluginServices, PluginData <CancellationWorkflowInput> input) { var cancellableTask = pluginServices.GetOrCreatePlugin <CancellableTask>(); if (input.Data.CancelExecution) { pluginServices.Cancel(); } if (input.Data.CancelPlugin) { cancellableTask.Cancel(); } var cancellableTaskOutput = await cancellableTask.Execute <CancellableTaskOutput>(new PluginInputs { { "input", input } }); return(await pluginServices.PluginCompleted(cancellableTaskOutput)); }
private void RetrieveDataFromFTPServer() { FtpWebRequest ftpRequest; FtpWebResponse ftpResponse; xDoc = new XmlDocument(); #region Attempt to download plugin database file try { // Create a request for the database file ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPdbFile); // Set default authentication for retrieving the file info ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); ftpRequest.Method = WebRequestMethods.Ftp.GetFileSize; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); // Ask the server for the file size and store it long fileSize = ftpResponse.ContentLength; ftpResponse.Close(); WebClient wc = new WebClient(); wc.Credentials = ftpRequest.Credentials; xDoc.LoadXml(wc.DownloadString(pluginsFTPdbFile)); } catch { xDoc.AppendChild(xDoc.CreateElement("Plugins")); } #endregion #region Retrieve list of all files & directories from FTP server try { // Create a request to the directory we are working in ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer); // Set default authentication for retrieving the file info ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); ftpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); StreamReader streamReader = new StreamReader(ftpResponse.GetResponseStream()); string line = streamReader.ReadLine(); while (!string.IsNullOrEmpty(line)) { listing.Add(new FileData(line)); line = streamReader.ReadLine(); } ftpResponse.Close(); } catch (Exception ex) { } #endregion ProgressForm formPB = new ProgressForm(); formPB.Show(); HashSet <string> hashTable = new HashSet <string>(); bool xDocChange = false; foreach (FileData fd in listing) { // We only want files (non-directories) if ((fd.attrib | FileAttributes.Directory) != FileAttributes.Directory) { string[] fName = fd.name.ToLower().Split('.', '-'); string modifiedName = fName[0].Replace('!', '_').Replace('+', '_'); #region Update information box formPB.Text = "Analyzing: \n" + fd.name; formPB.Value = listing.IndexOf(fd) * 100 / listing.Count; Application.DoEvents(); #endregion if (fName[fName.Length - 1] != "ent") { continue; } /* * if (fName.Length > 3) * { * string ver = fName[1]; * for (int i = 2; i < fName.Length - 1; i++) * ver += '.' + fName[i]; * fVer = new Version(ver); * } */ // Check for the matching tag HASHCODE name XmlNodeList xnl = null; XmlNode xNode = null; if (fName.Length > 2) { xnl = xDoc.GetElementsByTagName("_" + fName[1]); } // Search through each return value for the one in the desired parent TAG TYPE if (xnl != null && xnl.Count > 0) { foreach (XmlNode xn in xnl) { if (xn.ParentNode.Name == modifiedName) { xNode = xn; break; } } } @updatePlugin: // If we do not get any results for the HASHCODE, check for parent TAG TYPE if (xNode == null) { // Search for a matching TAG TYPE XmlNodeList xml = xDoc.GetElementsByTagName(modifiedName); // No matching TAG TYPE was found, so create a tag placeholder (eg. SCNR) if (xml.Count == 0) { xNode = xDoc.CreateElement(modifiedName); xDoc.FirstChild.AppendChild(xNode); } // We found a matching TAG TYPE, so select it else { xNode = xml[0]; } // Retrieve the plugin from the server & parse for needed info WebClient wc = new WebClient(); wc.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); try { string tempPlugin = wc.DownloadString(pluginsFTPServer + fd.name); XmlDocument xd = new XmlDocument(); xd.LoadXml(tempPlugin); XmlNodeList XList; XmlNode xnA; // Holds author attribute info XmlNode xnV; // Holds version attribute info string tag; try { XList = xd.GetElementsByTagName("revision"); xnA = XList[0].Attributes.GetNamedItem("author"); xnV = XList[0].Attributes.GetNamedItem("version"); try { tag = XList[0].Attributes.GetNamedItem("class").Value; } catch { tag = fName[1].ToLower(); } } catch { try { XList = xd.GetElementsByTagName("plugin"); xnA = XList[0].Attributes.GetNamedItem("author"); xnV = XList[0].Attributes.GetNamedItem("version"); tag = XList[0].Attributes.GetNamedItem("class").Value; } catch { // Bad plugin? continue; } } // // Need to generate name first & will rename later // System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); string md5 = GetChecksum(encoding.GetBytes(tempPlugin)); if (fName.Length > 2) { xNode = xNode.AppendChild(xDoc.CreateElement("_" + fName[1])); } else { xNode = xNode.AppendChild(xDoc.CreateElement("_---")); } // Append author & version to xNode // (This needs to be after the xNode is possibly set to xNode.Child) // MD5 Hashcode XmlAttribute xAttr = xDoc.CreateAttribute("md5"); xAttr.InnerText = md5; xNode.Attributes.Append(xAttr); // Author info xAttr = xDoc.CreateAttribute("tagtype"); xAttr.InnerText = tag; xNode.Attributes.Append(xAttr); // Author info xAttr = xDoc.CreateAttribute("author"); xAttr.InnerText = xnA.Value; xNode.Attributes.Append(xAttr); // Version info xAttr = xDoc.CreateAttribute("version"); xAttr.InnerText = xnV.Value; xNode.Attributes.Append(xAttr); // States that changes need to be made to database file xDocChange = true; } catch (Exception ex) { Globals.Global.ShowErrorMsg("Error from plugin server: ", ex); } } PluginData pd = new PluginData(fd, xNode); if (pd.md5 == string.Empty) { xNode = null; goto @updatePlugin; } if (hashTable.Contains(pd.md5)) { // Duplicate file found, erase file & remove entry try { ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + fd.name); // Set default authentication for retrieving the file info ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); ftpRequest.Method = WebRequestMethods.Ftp.DeleteFile; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); // Ask the server for the file size and store it ftpResponse.Close(); xDocChange = true; } catch { } continue; } hashTable.Add(pd.md5); // 1827 // "_fx_-87943969.ent" // {27/10/2012 1:49:00 AM} // "Grimdoomer" // "0.99" // Create a unique short hash code for this plugin using author, version & file date/time stamp string hashcode = pd.GetHashCode().ToString(); string fileName = fName[0] + '-' + hashcode + ".ent"; if (fd.name.ToLower() != fileName) { // Rename the node to reflect the [new] hashcode if (xNode.Name != "_" + hashcode) { xNode = RenameNode(xNode, string.Empty, '_' + hashcode); } #region Rename file to naming sequence // Create a request to the directory we are working in ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + fd.name); // Set default authentication for retrieving the file info ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); ftpRequest.Method = WebRequestMethods.Ftp.Rename; ftpRequest.RenameTo = fileName; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); ftpResponse.Close(); #endregion fd.name = fileName; } if (pd.version == "0.0") { int a = 0; } this.Add(fName[0], pd); } } // Clean up our loading form formPB.Dispose(); if (xDocChange) { // WriteXDoc back out WebClient wc = new WebClient(); wc.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); wc.UploadString(pluginsFTPdbFile, xDoc.InnerXml); } }
private static async Task <PluginOutput <IdentifyRequestTypeOutput> > ExecutePlugin(IPluginServices pluginServices, PluginData <IdentifyRequestTypeInput> input) { // First Plugin "Identify Request Type Task" var identifyTask = pluginServices.GetOrCreatePlugin <IdentifyRequestTypeTask>(); var identifyTaskOutput = await identifyTask.Execute <IdentifyRequestTypeOutput>(new PluginInputs { { "input", input } }); // Second Plugin "Print Request Type to Console" var printTask = pluginServices.GetOrCreatePlugin <PrintToConsoleTask>(); await printTask.Execute <Schema>(new PluginInputs { { "input", identifyTaskOutput } }); return(await pluginServices.PluginCompleted(identifyTaskOutput)); }
protected override void OnSceneSave() { var data = new PluginData(); List <int> IDsToPurge = new List <int>(); foreach (int texID in TextureDictionary.Keys) { if (!MaterialTexturePropertyList.Any(x => x.TexID == texID)) { IDsToPurge.Add(texID); } } foreach (int texID in IDsToPurge) { TextureDictionary.Remove(texID); } if (TextureDictionary.Count > 0) { data.data.Add(nameof(TextureDictionary), MessagePackSerializer.Serialize(TextureDictionary.ToDictionary(pair => pair.Key, pair => pair.Value.Data))); } else { data.data.Add(nameof(TextureDictionary), null); } if (RendererPropertyList.Count > 0) { data.data.Add(nameof(RendererPropertyList), MessagePackSerializer.Serialize(RendererPropertyList)); } else { data.data.Add(nameof(RendererPropertyList), null); } if (MaterialFloatPropertyList.Count > 0) { data.data.Add(nameof(MaterialFloatPropertyList), MessagePackSerializer.Serialize(MaterialFloatPropertyList)); } else { data.data.Add(nameof(MaterialFloatPropertyList), null); } if (MaterialColorPropertyList.Count > 0) { data.data.Add(nameof(MaterialColorPropertyList), MessagePackSerializer.Serialize(MaterialColorPropertyList)); } else { data.data.Add(nameof(MaterialColorPropertyList), null); } if (MaterialTexturePropertyList.Count > 0) { data.data.Add(nameof(MaterialTexturePropertyList), MessagePackSerializer.Serialize(MaterialTexturePropertyList)); } else { data.data.Add(nameof(MaterialTexturePropertyList), null); } if (MaterialShaderList.Count > 0) { data.data.Add(nameof(MaterialShaderList), MessagePackSerializer.Serialize(MaterialShaderList)); } else { data.data.Add(nameof(MaterialShaderList), null); } SetExtendedData(data); }
public static bool GetIsScoutMode(ref bool __result)// , bool value { MyLog.LogMessage("ScoutManager.GetIsScoutMode"); __result = Product.type == Product.Type.JpAdult && PluginData.IsEnabled("GP001FB"); return(false); }
/// <summary> /// Will send updated data to the connected clients. /// </summary> /// <param name="pluginData">The data the page will receive.</param> /// <returns></returns> internal virtual void OnUpdateData(PluginData pluginData) { }
public void TestEquals() { PluginData data1 = new PluginData("Model", "Key"); PluginData data2 = new PluginData("Model1", "Key"); PluginData data3 = new PluginData("Model", "Key1"); PluginData data4 = new PluginData("Model", "Key"); Assert.IsFalse(data1.Equals(data2), "Equals method returned unexpected value."); Assert.IsFalse(data1.Equals(data3), "Equals method returned unexpected value."); Assert.IsTrue(data1.Equals(data4), "Equals method returned unexpected value."); }
/// <summary> /// Will be called when the settings needs to be shown on a client. Optionally add some logic here before sending the settings data. /// <para> /// This method will be called for you and should not be called manually. /// </para> /// </summary> /// <returns>Return a PluginData object to send to the settings page.</returns> public virtual Task <PluginData> OnUpdateDataRequest(PluginData settingsData) => Task.FromResult(settingsData);
public void TearDown() { _unitUnderTest = null; }
private static async Task <PluginOutput <EOutput> > ExecutePlugin(IPluginServices pluginServices, PluginData <AInput> input) { var aTask1 = pluginServices.GetOrCreatePlugin <ATask>(); var aOutput1 = await aTask1.Execute <AOutput>(new PluginInputs { { "input", input } }); var aTask2 = pluginServices.GetOrCreatePlugin <ATask>(); var aOutput2 = await aTask2.Execute <AOutput>(new PluginInputs { { "input", input } }); var eTaskInput = pluginServices.CreatePluginDataList <AOutput>(); eTaskInput.Add(aOutput1.Data); eTaskInput.Add(aOutput2.Data); var eTask = pluginServices.GetOrCreatePlugin <ETask>(); var eOutput = await eTask.Execute <EOutput>(new PluginInputs { { "aOutputs", eTaskInput } }); return(await pluginServices.PluginCompleted(eOutput)); }
protected abstract void PluginLoadAddPlugin(PluginData plugin);
private void RetrieveDataFromFTPServer() { FtpWebRequest ftpRequest; FtpWebResponse ftpResponse; xDoc = new XmlDocument(); ProgressForm formPB = new ProgressForm(); formPB.Show(); try { formPB.Text = "Downloading Database"; formPB.Value = 0; formPB.Refresh(); #region Attempt to download plugin database file try { // Create a request for the database file ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPdbFile); // Set default authentication for retrieving the file info ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); ftpRequest.Method = WebRequestMethods.Ftp.GetFileSize; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); // Ask the server for the file size and store it long fileSize = ftpResponse.ContentLength; ftpResponse.Close(); WebClient wc = new WebClient(); wc.Credentials = ftpRequest.Credentials; xDoc.LoadXml(wc.DownloadString(pluginsFTPdbFile)); } catch { xDoc.AppendChild(xDoc.CreateElement("Plugins")); } #endregion formPB.Text = "Check File Dates/Times"; #region Retrieve list of all files & directories from FTP server try { // Create a request to the directory we are working in ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer); // Set default authentication for retrieving the file info ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); ftpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); StreamReader streamReader = new StreamReader(ftpResponse.GetResponseStream()); List<string> files = new List<string>(); string line = streamReader.ReadLine(); while (!string.IsNullOrEmpty(line)) { files.Add(line); line = streamReader.ReadLine(); } foreach (string s in files) { formPB.Value = files.IndexOf(s) * 100 / files.Count; formPB.Refresh(); if (s[0].ToString().ToLower() == "d") continue; // Create a request to the directory we are working in ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + s.Substring(62)); ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); ftpRequest.Method = WebRequestMethods.Ftp.GetDateTimestamp; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); DateTime dt = ftpResponse.LastModified; listing.Add(new FileData(s, dt)); ftpResponse.Close(); } } catch (Exception ex) { } #endregion HashSet<string> hashTable = new HashSet<string>(); bool xDocChange = false; foreach (FileData fd in listing) { // We only want files (non-directories) if ((fd.attrib | FileAttributes.Directory) != FileAttributes.Directory) { string[] fName = fd.name.ToLower().Split('.', '-'); string modifiedName = fName[0].Replace('!', '_').Replace('+', '_'); #region Update information box formPB.Text = "Analyzing: \n" + fd.name; formPB.Value = listing.IndexOf(fd) * 100 / listing.Count; formPB.Refresh(); #endregion if (fName[fName.Length - 1] != "ent") continue; /* if (fName.Length > 3) { string ver = fName[1]; for (int i = 2; i < fName.Length - 1; i++) ver += '.' + fName[i]; fVer = new Version(ver); } */ // Check for the matching tag HASHCODE name XmlNodeList xnl = null; XmlNode xNode = null; if (fName.Length > 2) xnl = xDoc.GetElementsByTagName("_" + fName[1]); // Search through each return value for the one in the desired parent TAG TYPE if (xnl != null && xnl.Count > 0) foreach (XmlNode xn in xnl) { if (xn.ParentNode.Name == modifiedName) { xNode = xn; break; } } @updatePlugin: // If we do not get any results for the HASHCODE, check for parent TAG TYPE if (xNode == null) { // Search for a matching TAG TYPE XmlNodeList xml = xDoc.GetElementsByTagName(modifiedName); // No matching TAG TYPE was found, so create a tag placeholder (eg. SCNR) if (xml.Count == 0) { xNode = xDoc.CreateElement(modifiedName); xDoc.FirstChild.AppendChild(xNode); } // We found a matching TAG TYPE, so select it else { xNode = xml[0]; } // Retrieve the plugin from the server & parse for needed info WebClient wc = new WebClient(); wc.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); try { string tempPlugin = wc.DownloadString(pluginsFTPServer + fd.name); XmlDocument xd = new XmlDocument(); xd.LoadXml(tempPlugin); XmlNodeList XList; XmlNode xnA; // Holds author attribute info XmlNode xnV; // Holds version attribute info string tag; try { XList = xd.GetElementsByTagName("revision"); xnA = XList[0].Attributes.GetNamedItem("author"); xnV = XList[0].Attributes.GetNamedItem("version"); try { XList = xd.GetElementsByTagName("plugin"); tag = XList[0].Attributes.GetNamedItem("class").Value; } catch { tag = fName[0].ToLower(); } } catch { try { XList = xd.GetElementsByTagName("plugin"); xnA = XList[0].Attributes.GetNamedItem("author"); xnV = XList[0].Attributes.GetNamedItem("version"); tag = XList[0].Attributes.GetNamedItem("class").Value; } catch { // Bad plugin? continue; } } // // Need to generate name first & will rename later // System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); string md5 = GetChecksum(encoding.GetBytes(tempPlugin)); if (fName.Length > 2) xNode = xNode.AppendChild(xDoc.CreateElement("_" + fName[1])); else xNode = xNode.AppendChild(xDoc.CreateElement("_---")); // Append author & version to xNode // (This needs to be after the xNode is possibly set to xNode.Child) // MD5 Hashcode XmlAttribute xAttr = xDoc.CreateAttribute("md5"); xAttr.InnerText = md5; xNode.Attributes.Append(xAttr); // Author info xAttr = xDoc.CreateAttribute("tagtype"); xAttr.InnerText = tag; xNode.Attributes.Append(xAttr); // Author info xAttr = xDoc.CreateAttribute("author"); xAttr.InnerText = xnA.Value; xNode.Attributes.Append(xAttr); // Version info xAttr = xDoc.CreateAttribute("version"); xAttr.InnerText = xnV.Value; xNode.Attributes.Append(xAttr); // States that changes need to be made to database file xDocChange = true; } catch (Exception ex) { Globals.Global.ShowErrorMsg("Error from plugin server: ", ex); } } PluginData pd = new PluginData(fd, xNode); if (pd.md5 == string.Empty) { xNode = null; goto @updatePlugin; } if (hashTable.Contains(pd.md5)) { // Duplicate file found, erase file & remove entry try { ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + fd.name); // Set default authentication for retrieving the file info ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); ftpRequest.Method = WebRequestMethods.Ftp.DeleteFile; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); // Ask the server for the file size and store it ftpResponse.Close(); xDocChange = true; } catch { } continue; } hashTable.Add(pd.md5); // 1827 // "_fx_-87943969.ent" // {27/10/2012 1:49:00 AM} // "Grimdoomer" // "0.99" // Create a unique short hash code for this plugin using author, version & file date/time stamp string hashcode = pd.GetHashCode().ToString(); string fileName = fName[0] + '-' + hashcode + ".ent"; if (fd.name.ToLower() != fileName) { // Rename the node to reflect the [new] hashcode if (xNode.Name != "_" + hashcode) xNode = RenameNode(xNode, string.Empty, '_' + hashcode); #region Rename file to naming sequence // Create a request to the directory we are working in ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + fd.name); // Set default authentication for retrieving the file info ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); ftpRequest.Method = WebRequestMethods.Ftp.Rename; ftpRequest.RenameTo = fileName; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); ftpResponse.Close(); #endregion fd.name = fileName; } if (pd.version == "0.0") { int a = 0; } this.Add(fName[0], pd); } } if (xDocChange) { // WriteXDoc back out WebClient wc = new WebClient(); wc.Credentials = new NetworkCredential(updateFTPName, updateFTPPass); wc.UploadString(pluginsFTPdbFile, xDoc.InnerXml); } } finally { // Clean up our loading form formPB.Dispose(); } }
public PluginData(PluginData data) { dll = data.dll; enabled = data.enabled; state = data.state; plugin = data.plugin; last_error = data.last_error; }
protected override void HandlePluginLoadException(PluginData data, Exception e) { base.HandlePluginLoadException(data, e); active_plugin = null; }
/// <summary> /// 載入擴充資料 /// </summary> /// <param name="ocichar">要被替換的對象</param> /// <param name="file">新角色存檔路徑</param> /// <param name="sex">性別</param> /// <returns></returns> private static bool LoadExtendedData(OCIChar ocichar, string file, byte sex) { ChaFileControl tmpChaFile = new ChaFileControl(); tmpChaFile.LoadCharaFile(file, sex); foreach (string ext in StudioCharaOnlyLoadBody.ExtendedDataToCopy) { switch (ext) { case "KKABMPlugin.ABMData": #region ABMX //取得BoneController MonoBehaviour BoneController = ocichar.charInfo.GetComponents <MonoBehaviour>().FirstOrDefault(x => Equals(x.GetType().Namespace, "KKABMX.Core")); if (null == BoneController) { Logger.LogDebug("No ABMX BoneController found"); break; } //建立重用function void GetModifiers(Action <object> action) { foreach (string boneName in (IEnumerable <string>)BoneController.Invoke("GetAllPossibleBoneNames")) { object modifier = BoneController.Invoke("GetModifier", new object[] { boneName }); if (null != modifier) { action(modifier); } } } //取得舊角色衣服ABMX數據 List <object> previousModifier = new List <object>(); GetModifiers(x => { if ((bool)x.Invoke("IsCoordinateSpecific")) { previousModifier.Add(x); } }); //將擴充資料由暫存複製到角色身上 ExtendedSave.SetExtendedDataById(ocichar.charInfo.chaFile, ext, ExtendedSave.GetExtendedDataById(tmpChaFile, ext)); //把擴充資料載入ABMX插件 BoneController.Invoke("OnReload", new object[] { 2, false }); //清理新角色數據,將衣服數據刪除 List <object> newModifiers = new List <object>(); int i = 0; GetModifiers(x => { if ((bool)x.Invoke("IsCoordinateSpecific")) { Logger.LogDebug("Clean new coordinate ABMX BoneData: " + (string)x.GetProperty("BoneName")); x.Invoke("MakeNonCoordinateSpecific"); object y = x.Invoke("GetModifier", new object[] { (ChaFileDefine.CoordinateType) 0 }); y.Invoke("Clear"); x.Invoke("MakeCoordinateSpecific"); //保險起見以免後面沒有成功清除 i++; } else { newModifiers.Add(x); } }); //將舊的衣服數據合併回到角色身上 i = 0; foreach (object modifier in previousModifier) { string bonename = (string)modifier.GetProperty("BoneName"); if (!newModifiers.Any(x => string.Equals(bonename, (string)x.GetProperty("BoneName")))) { BoneController.Invoke("AddModifier", new object[] { modifier }); Logger.LogDebug("Rollback cooridnate ABMX BoneData: " + bonename); } else { Logger.LogError("Duplicate coordinate ABMX BoneData: " + bonename); } i++; } Logger.LogDebug($"Merge {i} previous ABMX Bone Modifiers"); //重整 BoneController.SetProperty("NeedsFullRefresh", true); BoneController.SetProperty("NeedsBaselineUpdate", true); BoneController.Invoke("LateUpdate"); //把ABMX的數據存進擴充資料 BoneController.Invoke("OnCardBeingSaved", new object[] { 1 }); BoneController.Invoke("OnReload", new object[] { 2, false }); ////列出角色身上所有ABMX數據 //Logger.LogDebug("--List all exist ABMX BoneData--"); //foreach (string boneName in (IEnumerable<string>)BoneController.Invoke("GetAllPossibleBoneNames", null)) { // object modifier = BoneController.Invoke("GetModifier", new object[] { boneName }); // if (null != modifier) { // Logger.LogDebug(boneName); // } //} //Logger.LogDebug("--List End--"); break; #endregion case "com.bepis.sideloader.universalautoresolver": #region SideloaderUAS //判斷CategoryNo分類function bool isBelongsToCharaBody(ChaListDefine.CategoryNo categoryNo) { Type StructReference = typeof(UniversalAutoResolver).Assembly.GetType("Sideloader.AutoResolver.StructReference"); return(StructReference.GetPropertyStatic("ChaFileFaceProperties").ToDictionary <object, object>().Keys.Any(x => (ChaListDefine.CategoryNo)x.GetField("Category") == categoryNo) || StructReference.GetPropertyStatic("ChaFileBodyProperties").ToDictionary <object, object>().Keys.Any(x => (ChaListDefine.CategoryNo)x.GetField("Category") == categoryNo) || StructReference.GetPropertyStatic("ChaFileHairProperties").ToDictionary <object, object>().Keys.Any(x => (ChaListDefine.CategoryNo)x.GetField("Category") == categoryNo) || StructReference.GetPropertyStatic("ChaFileMakeupProperties").ToDictionary <object, object>().Keys.Any(x => (ChaListDefine.CategoryNo)x.GetField("Category") == categoryNo)); } //extInfo整理 int cleanExtData(ref PluginData tmpExtData, bool keepBodyData) { tmpExtData = ExtendedSave.GetExtendedDataById(ocichar.charInfo.chaFile, ext); if (tmpExtData != null && tmpExtData.data.ContainsKey("info")) { if (tmpExtData.data.TryGetValue("info", out object tmpExtInfo)) { if (null != tmpExtInfo as object[]) { List <object> tmpExtList = new List <object>(tmpExtInfo as object[]); Logger.LogDebug($"Sideloader count: {tmpExtList.Count}"); ResolveInfo tmpResolveInfo; for (int j = 0; j < tmpExtList.Count;) { tmpResolveInfo = typeof(ResolveInfo).InvokeStatic("Deserialize", new object[] { (byte[])tmpExtList[j] }) as ResolveInfo; if (keepBodyData == isBelongsToCharaBody(tmpResolveInfo.CategoryNo)) { Logger.LogDebug($"Add Sideloader info: {tmpResolveInfo.GUID} : {tmpResolveInfo.Property} : {tmpResolveInfo.Slot}"); j++; } else { Logger.LogDebug($"Remove Sideloader info: {tmpResolveInfo.GUID} : {tmpResolveInfo.Property} : {tmpResolveInfo.Slot}"); tmpExtList.RemoveAt(j); } } tmpExtData.data["info"] = tmpExtList.ToArray(); return(tmpExtList.Count); } } } return(0); } //提出角色身上原始的Sideloader extData PluginData oldExtData = ExtendedSave.GetExtendedDataById(ocichar.charInfo.chaFile, ext); Logger.LogDebug($"Get Old Sideloader Start"); int L1 = cleanExtData(ref oldExtData, false); Logger.LogDebug($"Get Old Sideloader: {L1}"); //將擴充資料由暫存複製到角色身上 ExtendedSave.SetExtendedDataById(ocichar.charInfo.chaFile, ext, ExtendedSave.GetExtendedDataById(tmpChaFile, ext)); //清理新角色數據 PluginData newExtData = ExtendedSave.GetExtendedDataById(ocichar.charInfo.chaFile, ext); Logger.LogDebug($"Get New Sideloader Start"); int L2 = cleanExtData(ref newExtData, true); Logger.LogDebug($"Get New Sideloader: {L2}"); //合併新舊數據 object[] tmpObj = new object[L1 + L2]; (oldExtData?.data?["info"] as object[])?.CopyTo(tmpObj, 0); (newExtData?.data?["info"] as object[])?.CopyTo(tmpObj, L1); PluginData extData = null; if (tmpObj.Length != 0) { extData = new PluginData { data = new Dictionary <string, object> { ["info"] = tmpObj } }; } //儲存 ExtendedSave.SetExtendedDataById(ocichar.charInfo.chaFile, ext, extData); Logger.LogDebug($"Merge and Save Sideloader: {tmpObj.Length}"); //調用原始sideloader載入hook function typeof(UniversalAutoResolver).GetNestedType("Hooks", BindingFlags.NonPublic).InvokeStatic("ExtendedCardLoad", new object[] { ocichar.charInfo.chaFile }); break; #endregion default: ExtendedSave.SetExtendedDataById(ocichar.charInfo.chaFile, ext, ExtendedSave.GetExtendedDataById(tmpChaFile, ext)); break; } Logger.LogDebug($"Change Extended Data: {ext}"); } return(true); }
protected bool Equals(PluginData other) { return string.Equals(PluginDllPath, other.PluginDllPath) && string.Equals(DataType, other.DataType); }
override protected void OnInit(EventArgs e) { base.OnInit(e); if (ModSettings.Get("themefolder") == "") // if we don't have module setting jump out { rpPaymentGateways.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS"); return; } try { var pluginData = new PluginData(PortalSettings.Current.PortalId); _provList = pluginData.GetPaymentProviders(); _cartInfo = new CartData(PortalId); var orderid = Utils.RequestQueryStringParam(Context, "orderid"); var templOk = ModSettings.Get("paymentoktemplate"); var templFail = ModSettings.Get("paymentfailtemplate"); var templHeader = ""; var templFooter = ""; var templText = ""; if ((_provList.Count == 0 || _cartInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedtotal") <= 0) && orderid == "") { #region "No Payment providers, so process as a ordering system" var displayTempl = templOk; if (!_cartInfo.IsValidated()) { displayTempl = templFail; } rpDetailDisplay.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, displayTempl, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory); _templateHeader = (GenXmlTemplate)rpDetailDisplay.ItemTemplate; // we may have voucher discounts that give a zero appliedtotal, so process. var discountprov = DiscountCodeInterface.Instance(); if (discountprov != null) { discountprov.UpdatePercentUsage(PortalId, UserId, _cartInfo.PurchaseInfo); discountprov.UpdateVoucherAmount(PortalId, UserId, _cartInfo.PurchaseInfo); } #endregion } else { #region "Payment Details" // display the payment method by default templHeader = ModSettings.Get("paymentordersummary"); templFooter = ModSettings.Get("paymentfooter"); var templPaymentText = ""; var msg = ""; if (Utils.IsNumeric(orderid)) { // orderid exists, so must be return from bank; Process it!! _orderData = new OrderData(PortalId, Convert.ToInt32(orderid)); _prov = PaymentsInterface.Instance(_orderData.PaymentProviderKey); msg = _prov.ProcessPaymentReturn(Context); if (msg == "") // no message so successful { _orderData = new OrderData(PortalId, Convert.ToInt32(orderid)); // get the updated order. _orderData.PaymentOk("050"); templText = templOk; } else { _orderData = new OrderData(PortalId, Convert.ToInt32(orderid)); // reload the order, becuase the status and typecode may have changed by the payment provider. _orderData.AddAuditMessage(msg, "paymsg", "payment.ascx", "False"); _orderData.Save(); templText = templFail; } templFooter = ""; // return from bank, hide footer } else { // not returning from bank, so display list of payment providers. rpPaymentGateways.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(GetPaymentProviderTemplates(), ModSettings.Settings(), PortalSettings.HomeDirectory); } if (templText == "") { templText = templHeader; // if we are NOT returning from bank, then display normal header summary template } templPaymentText = ModCtrl.GetTemplateData(ModSettings, templText, Utils.GetCurrentCulture(), DebugMode); rpDetailDisplay.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(templPaymentText, ModSettings.Settings(), PortalSettings.HomeDirectory); _templateHeader = (GenXmlTemplate)rpDetailDisplay.ItemTemplate; if (templFooter != "") { var templPaymentFooterText = ModCtrl.GetTemplateData(ModSettings, templFooter, Utils.GetCurrentCulture(), DebugMode); rpDetailFooter.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(templPaymentFooterText, ModSettings.Settings(), PortalSettings.HomeDirectory); } #endregion } // insert page header text NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode); } catch (Exception exc) { //display the error on the template (don;t want to log it here, prefer to deal with errors directly.) var l = new Literal(); l.Text = exc.ToString(); phData.Controls.Add(l); } }
protected void LoadActualPlugins(String file_end, Type plugin_type, IEnumerable <PluginData> plugins) { PluginScan(); file_end += "Plugin.dll"; foreach (PossiblePlugin pos_plug in possible_plugins) { String dll = pos_plug.file_info.Name; if (!dll.EndsWith(file_end, StringComparison.CurrentCultureIgnoreCase)) { continue; } PluginData data = (from p in plugins where p.dll == dll select p).SingleOrDefault(); bool add_to_list = false; if (data == null) { add_to_list = true; data = NewPluginData(dll); data.dll = dll; } if (data.enabled == false && !add_to_list) //if not yet on the list we have to continue to see if we should be on the list { data.state = PluginData.PluginDataState.SKIPPED; continue; } try { Assembly asm = pos_plug.asm; if (asm == null || pos_plug.types == null) { continue; } foreach (Type type in pos_plug.types) { if (type.IsAbstract) { continue; } if (!IsTypeOf(type, plugin_type)) { continue; } if (add_to_list) { PluginLoadAddPlugin(data); } if (data.enabled == false) { data.state = PluginData.PluginDataState.SKIPPED; continue; } data.plugin = asm.CreateInstance(type.FullName) as IPlugin; PluginLoadRegisterPlugin(data); } } catch (ReflectionTypeLoadException ex) { HandlePluginLoadReflectionException(data, ex); } catch (Exception e) { HandlePluginLoadException(data, e); } } }
private void Add(string name, PluginData pluginData) { string info = "<missing>"; Version currentVer = new Version(0,0); try { HaloMap.Plugins.IFPIO ifpio = HaloMap.Plugins.IFPHashMap.GetIfp(name, HaloVersionEnum.Halo2); if (ifpio.revisions.Length > 2) { currentVer = new Version(ifpio.revisions[1]); info = currentVer + " (" + ifpio.revisions[0] + ")"; } else { currentVer = new Version(ifpio.version); info = currentVer + " (" + ifpio.author + ")"; } } catch { } dgvPluginData.Rows.Add( currentVer < new Version(pluginData.version), name, info, pluginData.version + " (" + pluginData.author + ")", pluginData.md5); dgvPluginData.Rows[dgvPluginData.Rows.Count - 1].Tag = pluginData; }
protected abstract void PluginLoadAddPlugin(PluginData plugin);
/// <summary> /// Launches ComputeCombination for each "plugin status combination". /// Gets the lower cost among all the combinations generated. /// </summary> internal ExecutionPlan ObtainBestPlan( Dictionary<object, SolvedConfigStatus> finalConfig, bool stopLaunchedOptionals ) { _finalConfig = finalConfig; if( _parseMap == null ) _parseMap = new BitArray( _discoverer.Plugins.Count ); else _parseMap.Length = _discoverer.Plugins.Count; _mappingArray.Clear(); _mappingDic.Clear(); int disabledCount = 0; // Locking plugins : // - If a plugin is disabled, it should not be launched, we do not add it to the map // - If a plugin needs to be started (MustExistAndRun), we lock its value to true // - If a plugin is the only implemention of a service and that this service has to be started, we lock this plugin's value to true // - If a plugin has no service references and does not implement any services as well, and that it is not asked to be // started and it is NOT running or it is running but stopLaunchedOptionals is true, we lock its value to false; int index = 0; foreach( IPluginInfo pI in _discoverer.Plugins ) { // SolvedConfigStatus of the actual plugin. SolvedConfigStatus pluginStatus = _finalConfig.GetValueWithDefault( pI, SolvedConfigStatus.Optional ); if( pluginStatus == SolvedConfigStatus.Disabled ) { // If a plugin is disabled, it should not be launched, we do not add it to the map. disabledCount++; continue; } // SolvedConfigStatus of the implemented service if any. SolvedConfigStatus serviceStatus = pI.Service != null ? _finalConfig.GetValueWithDefault( pI.Service, SolvedConfigStatus.Optional ) : SolvedConfigStatus.Optional; if( serviceStatus == SolvedConfigStatus.Disabled ) { // If a plugin is disabled, it should not be launched, we do not add it to the map disabledCount++; continue; } // Here, we have no more disabled plugins. // Initializes a PluginData for this particular plugin and allocates // a new index in the bit array. Debug.Assert( index == _mappingArray.Count ); PluginData pluginData = new PluginData( pI, index, IsPluginRunning( pI ) ); _mappingArray.Add( pluginData ); _mappingDic.Add( pI, pluginData ); if( pluginStatus == SolvedConfigStatus.MustExistAndRun || (serviceStatus == SolvedConfigStatus.MustExistAndRun && pI.Service.Implementations.Count == 1) ) { // If a plugin needs to be started (MustExistAndRun), we lock its value to true. // If a plugin is the only implemention of a service and that this service has to be started, we lock this plugin's value to true. _parseMap.Set( index, true ); pluginData.Locked = true; } else if( pI.Service == null && pI.ServiceReferences.Count == 0 ) // This plugin is independent. { // This is only an optimization. // The cost function gives a cost to the stop or the start of a plugin. When a plugin is independant like in this case, we lock its // status by taking into account the requirement (should it run? MustExistTryStart/OptionalTryStart) and its current status (IsPluginRunning) // and the stopLaunchedOptionals boolean. if( (pluginStatus != SolvedConfigStatus.MustExistTryStart || pluginStatus != SolvedConfigStatus.OptionalTryStart) && ( !pluginData.IsRunning || stopLaunchedOptionals )) { // If a plugin has no service references and does not implement any services as well, // and that it is not asked to be started AND it is not running, we lock its value to false; _parseMap.Set( index, false ); // We do not set thereWillBeNoChange to false: there will ACTUALLY be no changes // since the plugin is NOT running. } else { // If a plugin has no service references and does not implement any services as well, // and that it is asked to be started OR is currently running, we lock its value to true; _parseMap.Set( index, true ); } pluginData.Locked = true; } index++; } // Trim the parseMap, to remove indexes that should have been filled by disabled plugins. Debug.Assert( _parseMap.Length >= disabledCount ); _parseMap.Length -= disabledCount; // If the parseMap has a length of 0, it means either that there are no plugins or that all plugins are disabled. // In either of these cases, we don't calculate any execution plan. But we still have a valid execution plan, it just doesn't have any plugins to launch. BitArray bestCombination = _parseMap; if( _parseMap.Length > 0 ) { int bestCost = Int32.MaxValue; double combinationsCount = Math.Pow( 2, _parseMap.Length - _mappingDic.Values.Count( ( e ) => { return e.Locked == true; } ) ); for( int i = 0; i < combinationsCount; i++ ) { int cost = ComputeCombination(stopLaunchedOptionals); Debug.Assert( cost >= 0 ); // Return if the cost is equal to 0 (no better solution). if( cost == 0 ) { return _lastBestPlan = GenerateExecutionPlan( _parseMap ); } if( cost < bestCost ) { bestCost = cost; bestCombination = (BitArray)_parseMap.Clone(); } GenerateNextCombination(); } // If there is no valid combination, we return an impossible plan and // we do not keep it as the LastBestPlan. if( bestCost == Int32.MaxValue ) return GenerateExecutionPlan( null ); } return _lastBestPlan = GenerateExecutionPlan( bestCombination ); }
protected abstract void PluginLoadRegisterPlugin(PluginData plugin);
protected override void HandlePluginLoadReflectionException(PluginData data, ReflectionTypeLoadException ex) { base.HandlePluginLoadReflectionException(data, ex); active_plugin = null; }
public virtual void SetPluginEnabled(bool enabled, PluginData plugin) { plugin.enabled = enabled; }
protected override void PluginLoadRegisterPlugin(PluginData plugin) { ContactPluginData data = plugin as ContactPluginData; if (active_plugin != null) throw new Exception("Can only handle one contact plugin at a time right now and the current one is: " + active_plugin.plugin.ProviderName()); try { data.contact_plugin.Initialize(); active_plugin = data; Application.Current.Dispatcher.BeginInvoke((Action)ContactInit); } catch (Exception e) { HandleError(data, e, PluginData.PluginDataState.ERROR_LOADING); } }
internal static void ExtendedCoordinateImport(Dictionary <string, PluginData> importedExtendedData) { if (importedExtendedData.TryGetValue(UARExtID, out var pluginData)) { if (pluginData != null && pluginData.data.ContainsKey("info")) { var tmpExtInfo = (object[])pluginData.data["info"]; var extInfo = tmpExtInfo.Select(x => ResolveInfo.Deserialize((byte[])x)).ToList(); for (int i = 0; i < extInfo.Count;) { Sideloader.Logger.Log(LogLevel.Debug, $"External info: {extInfo[i].GUID} : {extInfo[i].Property} : {extInfo[i].Slot} : {extInfo[i].CategoryNo}"); if (extInfo[i].Property.EndsWith("ClothesShoesInner")) { //KK had inner shoes, EC does not extInfo.RemoveAt(i); } else { extInfo[i].Property = extInfo[i].Property.Replace("outfit0", "outfit"); //KK originally had only one emblem if (extInfo[i].Property.EndsWith("Emblem")) { extInfo[i].Property += "0"; } //KK has multiple shoes slots, convert to one shoes slot extInfo[i].Property = extInfo[i].Property.Replace("ClothesShoesOuter", "ClothesShoes"); i++; } } importedExtendedData[UARExtID] = new PluginData { data = new Dictionary <string, object> { ["info"] = extInfo.Select(x => x.Serialize()).ToList() } }; } } if (Sideloader.DebugLogging.Value && importedExtendedData.TryGetValue(UARExtID, out var extData)) { if (extData == null || !extData.data.ContainsKey("info")) { Sideloader.Logger.Log(LogLevel.Debug, "Imported coordinate data: No sideloader marker found"); } else { var tmpExtInfo = (List <byte[]>)extData.data["info"]; var extInfo = tmpExtInfo.Select(ResolveInfo.Deserialize).ToList(); Sideloader.Logger.Log(LogLevel.Debug, $"Imported coordinate data: Sideloader marker found, external info count: {extInfo.Count}"); foreach (ResolveInfo info in extInfo) { Sideloader.Logger.Log(LogLevel.Debug, $"External info: {info.GUID} : {info.Property} : {info.Slot} : {info.CategoryNo}"); } } } }
public ContactPluginData(PluginData data) : base(data) { }
private static Task <PluginOutput <StringData> > ExecutePlugin(IPluginServices pluginServices, PluginData <T> input) { var output = pluginServices.CreatePluginData <StringData>(); output.Data.String = JsonConvert.SerializeObject(input.Data); return(pluginServices.PluginCompleted(output)); }
static int SortPluginDatas(PluginData p1, PluginData p2) { return String.Compare(p1.name, p2.name); }
public DateTime last_error_time = DateTime.Now; //start with now so error count will not reset right away #endregion Fields #region Constructors public HeadsetPluginData(PluginData data) : base(data) { }