public object GetDynamicParameters() { if (SmoContext.IsSet && SmoContext.IsConnected && _dynLib == null) { if (SmoContext.GetNullOrEmpty(SmoContext.Jobs)) { SmoContext.SetJobs(SmoContext.Connection.JobServer.Jobs); } _dynLib = new DynamicLibrary(); var dp = new DynamicParameter <Microsoft.SqlServer.Management.Smo.Agent.Job>("JobName", SmoContext.Jobs, x => x.Name, "Name", true) { Position = 0, Mandatory = false, ParameterSetName = "ByJobName" }; _dynLib.Add(dp); } else if (_dynLib == null) { _dynLib = new DynamicLibrary(); _dynLib.Add("JobName", new RuntimeDefinedParameter("JobName", typeof(string[]), new Collection <Attribute> { new ParameterAttribute { Mandatory = false, Position = 0, ParameterSetName = "ByJobName" } })); } return(_dynLib); }
public object GetDynamicParameters() { if (_dynLib == null) { _dynLib = new DynamicLibrary(); DynamicParameter <Assembly> dp = null; RuntimeDefinedParameter rtParam = null; Assembly[] Assemblies = AppDomain.CurrentDomain.GetAssemblies(); if (!Scope.Equals("File")) { dp = new DynamicParameter <Assembly>(PNAME, Assemblies, x => x.FullName, "FullName") { Mandatory = false }; rtParam = dp.AsRuntimeParameter(); } else { var pAtt = new ParameterAttribute { Mandatory = true }; rtParam = new RuntimeDefinedParameter(PNAME, PTYPE, new Collection <Attribute> { pAtt }); } _dynLib.Add(PNAME, rtParam); } return(_dynLib); }
public virtual object GetDynamicParameters() { if (this.OutputAs != OutputAs.String && this.OutputAs != OutputAs.SecureString) { _dynLib = new DynamicLibrary(); var dp = new RuntimeDefinedParameter(USERNAME, typeof(string), new Collection <Attribute> { new ParameterAttribute { Mandatory = true, HelpMessage = "Provide a username for the PSCredential that will be outputted." }, new ValidateNotNullOrEmptyAttribute() }); _dynLib.Add(dp); if (this.OutputAs == OutputAs.NetworkCredential) { var domParam = new RuntimeDefinedParameter(DOMAIN, typeof(string), new Collection <Attribute> { new ParameterAttribute { Mandatory = false } }); _dynLib.Add(domParam); } return(_dynLib); } else { return(null); } }
public static void Error() { IntPtr ptr; Assert.Throws <Exception>(() => DynamicLibrary.Open("NOT_EXISTING")); string failure = "FAILURE"; var fs = new System.IO.StreamWriter(System.IO.File.OpenWrite(failure)); fs.Write("foobar"); fs.Close(); Assert.IsTrue(System.IO.File.Exists(failure)); Assert.Throws <Exception>(() => DynamicLibrary.Open(failure)); System.IO.File.Delete(failure); var dl = DynamicLibrary.Open(DynamicLibrary.Decorate("uv")); Assert.IsTrue(dl.TryGetSymbol("uv_default_loop", out ptr)); Assert.AreNotEqual(ptr, IntPtr.Zero); Assert.IsFalse(dl.TryGetSymbol("NOT_EXISTING", out ptr)); Assert.AreEqual(ptr, IntPtr.Zero); Assert.Throws <Exception>(() => dl.GetSymbol("NOT_EXISTING")); Assert.IsFalse(dl.Closed); dl.Close(); Assert.IsTrue(dl.Closed); }
public object GetDynamicParameters() { if (!string.IsNullOrEmpty(this.SortBy) && this.SortBy == "Id") { _dynLib = new DynamicLibrary { { "Ascending", new RuntimeDefinedParameter("Ascending", typeof(SwitchParameter), new Collection <Attribute> { new ParameterAttribute { Mandatory = false, ParameterSetName = "None" }, new ParameterAttribute { Mandatory = false, ParameterSetName = "FromPipelineInput" }, new ParameterAttribute { Mandatory = false, ParameterSetName = "ByLoginName" } } ) } }; } return(_dynLib); }
public void test_load_and_bind_dynamic_library() { var lib = new DynamicLibrary("libextern"); var trigger = lib.symbol <rs_trigger>(); var val = trigger(100); this.Assert(val == 200); }
public void test_invalid_symbol() { try { var lib = new DynamicLibrary("libextern"); lib.symbol <rs_trigger_ADFASF>(); this.Assert(false); } catch (DynamicLibraryException e) { this.Assert(e.code == DynamicLibraryError.INVALID_SYMBOL); } }
protected private DynamicLibrary NewDynamicLibrary(MgSmoCollection <Database> dbCol) { var dl = new DynamicLibrary(); var dp = new DynamicParameter <Database>(BaseDatabaseCmdlet.DBNAME, SmoContext.Databases, x => x.Name, "Name", true) { Mandatory = true }; dl.Add(dp); return(dl); }
public object GetDynamicParameters() { _dynLib = new DynamicLibrary(); Server s = this.SqlServer == null && SmoContext.IsSet && SmoContext.IsConnected ? SmoContext.Connection : this.SqlServer; var dp = new DynamicParameter <string>("DefaultDatabase", typeof(string), s.Databases.Cast <Database>().Select(x => x.Name)); _dynLib.Add(dp); return(_dynLib); }
internal static void Init() { Module = DynamicLibrary.Open(); IntPtr ptr; Module.TryGetSymbol("COLORS", out ptr); colors = (int *)ptr.ToPointer(); Module.TryGetSymbol("COLOR_PAIRS", out ptr); color_pairs = (int *)ptr.ToPointer(); Terminal.Init(); }
public object GetDynamicParameters() { _lib = new DynamicLibrary(); if (Context.IsConnected) { var idp = new DynamicParameter <Tag>(PARAM, true, Context.TagManager.AllTags, x => x.Label) { Mandatory = false }; _lib.Add(idp); } return(_lib); }
public object GetDynamicParameters() { _lib = new DynamicLibrary(); if (Context.IsConnected) { var idp = new DynamicParameter <IndexerSchema>(PARAM, true, Context.IndexerSchemas, x => x.Name) { Mandatory = true, Position = 0 }; _lib.Add(idp); } return(_lib); }
public object GetDynamicParameters() { if (Context.IsConnected && _dynLib == null) { _dynLib = new DynamicLibrary { new DynamicParameter <Quality>(QUALITY, true, Context.AllQualities, x => x.Name, "Quality") { Mandatory = true, Position = 0 } }; } return(_dynLib); }
public object GetDynamicParameters() { if (_dynLib == null) { _dynLib = new DynamicLibrary(); var dp = new DynamicParameter <string>("Collation", typeof(string)) { AllowNull = true, Mandatory = false }; dp.ValidatedItems.AddRange(SmoContext.ServerCollations); _dynLib.Add(dp); } return(_dynLib); }
public virtual object GetDynamicParameters() { if (_info == null) { _info = Encoding.GetEncodings(); } _dynLib = new DynamicLibrary(); var dp = new DynamicParameter <EncodingInfo>(ENCODING, _info, x => x.Name, "Name") { Mandatory = false, Position = 1 }; _dynLib.Add(dp); return(_dynLib); }
public object GetDynamicParameters() { if (Context.IsConnected && _dynLib == null) { _dynLib = new DynamicLibrary { new DynamicParameter <Quality>(CUTOFF_QUALITY, false, Context.AllQualities, x => x.Name) { Mandatory = true }, new DynamicParameter <Quality>(ALLOWED_QUALITIES, true, Context.AllQualities, x => x.Name) { Mandatory = true } }; } return(_dynLib); }
public override object GetDynamicParameters() { if (_dynLib == null && (this.SqlServer != null || (SmoContext.IsSet && SmoContext.IsConnected))) { Server s = this.SqlServer != null ? this.SqlServer : SmoContext.Connection; _dynLib = new DynamicLibrary(); var dp = new DynamicParameter <Database>("Database", s.Databases.Cast <Database>(), x => x.Name, "Name", true) { Mandatory = false }; _dynLib.Add(dp); } return(_dynLib); }
protected private DynamicLibrary NewDynamicLibrary() { var dl = new DynamicLibrary { { BaseDatabaseCmdlet.DBNAME, new RuntimeDefinedParameter(BaseDatabaseCmdlet.DBNAME, typeof(string[]), new Collection <Attribute> { new ParameterAttribute { Mandatory = false } }) } }; return(dl); }
public object GetDynamicParameters() { if (_dynLib == null) { if (AllProps == null) { AllProps = this.GetPropsToLoad(); } _dynLib = new DynamicLibrary(); var dp = new DynamicParameter <string>(PROPERTIES, AllProps, x => x, null, true) { Mandatory = false }; dp.ValidatedItems.Add("*"); _dynLib.Add(dp); } return(_dynLib); }
public virtual object GetDynamicParameters() { if (_dynLib == null && SmoContext.IsSet && SmoContext.IsConnected) { if (SmoContext.GetNullOrEmpty(SmoContext.Databases)) { SmoContext.SetDatabases(SmoContext.Connection.Databases); } _dynLib = this.NewDynamicLibrary(SmoContext.Databases); } else if (_dynLib == null) { _dynLib = this.NewDynamicLibrary(); } return(_dynLib); }
public object GetDynamicParameters() { if (!string.IsNullOrEmpty(this.SortBy) && this.SortBy == "Name") { _dynLib = new DynamicLibrary(); _dynLib.Add("Ascending", new RuntimeDefinedParameter("Ascending", typeof(SwitchParameter), new Collection <Attribute> { new ParameterAttribute { Mandatory = false } })); return(_dynLib); } else { return(null); } }
public object GetDynamicParameters() { if (_dynLib == null) { _dynLib = new DynamicLibrary { new DynamicParameter <QualityDefinition>("Quality", Context.Qualities, x => x.Title, "Title", true) { Mandatory = true, Position = 1 }, new DynamicParameter <QualityDefinition>("Cutoff", Context.Qualities, x => x.Title, "Title", false) { Mandatory = true, Position = 2 } }; } return(_dynLib); }
public object GetDynamicParameters() { if (SearchMethod.Equals(BROWSER)) { if (_dynLib == null) { _dynLib = new DynamicLibrary { new DynamicParameter <int>(pName, pType) { Mandatory = false, ValidateRange = new KeyValuePair <int, int>(0, 3600) } }; } return(_dynLib); } else { return(null); } }
public object GetDynamicParameters() { if (_dynLib == null && SmoContext.IsSet && SmoContext.IsConnected) { if (SmoContext.GetNullOrEmpty(SmoContext.Databases)) { SmoContext.SetDatabases(SmoContext.Connection.Databases); } _dynLib = new DynamicLibrary(); IDynParam param = new DynamicParameter <Database>(DBNAME, SmoContext.Databases, x => x.Name, "Name", true) { Mandatory = false, Position = 0, }; param.Aliases.Add("n"); _dynLib.Add(param); } else if (_dynLib == null) { _dynLib = new DynamicLibrary { { DBNAME, new RuntimeDefinedParameter(DBNAME, typeof(string[]), new Collection <Attribute> { new ParameterAttribute { Mandatory = false, Position = 0 } }) } }; } return(_dynLib); }
public static void Main() { DynamicLibrary.PrintConsole("y943y943"); }
/// <summary> /// Load this library into Memory. /// </summary> /// <param name="Folder">Directory to Load from... <see langword="null"/> (default) = Load from Current Directory.</param> /// <returns><see langword="true" />, if the library loaded successfully, else <see langword="false" />.</returns> /// <remarks> /// <para> /// An external library is loaded into memory when any of its methods are called for the first time. /// This results in the first method call being slower than all subsequent calls. /// </para> /// <para> /// Some BASS libraries and add-ons may introduce new options to the main BASS lib like new parameters. /// But, before using these new options the respective library must be already loaded. /// This method can be used to make sure, that this library has been loaded. /// </para> /// </remarks> public static bool Load(string Folder = null) => (hLib = DynamicLibrary.Load(DllName, Folder)) != IntPtr.Zero;
/// <summary> /// Unloads this library from Memory. /// </summary> /// <returns><see langword="true" />, if the library unloaded successfully, else <see langword="false" />.</returns> public static bool Unload() => DynamicLibrary.Unload(hLib);
/// <summary> /// 调用动态加载 /// </summary> /// <param name="e"></param> private void actionFramework(FrmworkTreeNode e) { if (e.NodeType == "Window")//调用窗体 { System.Windows.Forms.Form fromCtrl = null; fromCtrl = FormExists(this, e.FormName);//根据窗体名查找窗体 if ((e.BlankWindows) || (!e.BlankWindows && fromCtrl==null))//允许在新窗口打开或者没有生成窗体的都重新创建窗体 { string DllPathName = Application.StartupPath + @"\" + e.DllFileName; Object[] objArray = new object[3];//dll中类构造函数必须具有的参数数组 objArray[0] = e.NodeId; objArray[1] = this.UserId; objArray[2] = this.UserName; DynamicLibrary myDll = new DynamicLibrary(); myDll.DllFileName = DllPathName; myDll.DllClassName = e.DllClassName; myDll.MainForm = this; myDll.ObjArray = objArray; if (e.WindowsSDI) { fromCtrl = myDll.CallSDIWindows(); } else { fromCtrl = myDll.CallMDIWindows(); fromCtrl.Text = e.Text;//设置窗体标题 } } else//窗体已经打开,最小化的还原,并显示在最前面 { if (fromCtrl.WindowState == FormWindowState.Minimized) fromCtrl.WindowState = FormWindowState.Normal; fromCtrl.BringToFront(); } } else if (e.NodeType == "Function")//调用功能 { string DllPathName = Application.StartupPath + @"\" + e.DllFileName; Object[] objArray = new object[2];//dll中类构造函数必须具有2个参数 objArray[0] = this.UserId; objArray[1] = this.UserName; Object[] objMethodArray = new object[2];//dll中类方法必须具有的参数 objMethodArray[0] = e.NodeId; objMethodArray[1] = treeFramework.SelectedNode.Nodes; DynamicLibrary myDll = new DynamicLibrary(); myDll.DllFileName = DllPathName; myDll.DllClassName = e.DllClassName; myDll.DllMethodName = e.DllMethodName; myDll.ObjArray = objArray; myDll.ObjMethodArray = objMethodArray; myDll.CallMethod(); } }