private bool HandleMenuCommand(FormsDesignerViewContent formDesigner, IComponent activeComponent, Keys keyPressed) { System.Type serviceType = typeof(WindowsFormsDesignerOptionService).Assembly.GetType("System.Windows.Forms.Design.ToolStripKeyboardHandlingService"); object service = formDesigner.Host.GetService(serviceType); if (service == null) { //LoggingService.Debug("no ToolStripKeyboardHandlingService found"); return(false); } if (activeComponent is ToolStripItem) { if (keyPressed == Keys.Up) { serviceType.InvokeMember("ProcessUpDown", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, service, new object[] { false }); return(true); } if (keyPressed == Keys.Down) { serviceType.InvokeMember("ProcessUpDown", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, service, new object[] { true }); return(true); } } return((bool)serviceType.InvokeMember("TemplateNodeActive", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance, null, service, null)); }
public static void PatchResourceManager(Type resourceManagerType) { if (resourceManagerType.GetProperty("ResourceManager", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public) != null) { try { var resManager = resourceManagerType.InvokeMember("ResourceManager", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.Public, null, resourceManagerType, new object[] { }); var fileName = resourceManagerType.Name + ".resx"; var databaseResourceManager = new DBResourceManager(fileName, resManager as ResourceManager); resourceManagerType.InvokeMember("resourceMan", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.SetField, null, resourceManagerType, new object[] { databaseResourceManager }); } catch (TargetInvocationException e) { if (e.InnerException is FileNotFoundException && ((FileNotFoundException)e.InnerException).FileName == "App_GlobalResources") { // ignore } else { throw; } } } }
static void ShowTimeline() { if (TimelineWindowType == null) { return; } if (Timeline == null) { EditorUtility.DisplayDialog("Error", "No timeline found in scene!", "OK"); return; } EditorWindow timelineWindow = EditorWindow.GetWindow(TimelineWindowType); MethodInfo setTimelineMethod = TimelineWindowType.GetMethod("SetCurrentTimeline", new System.Type[] { typeof(PlayableDirector), typeof(TimelineClip) }); setTimelineMethod.Invoke(timelineWindow, new object[] { Director, null }); TimelineWindowType.InvokeMember( "locked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty, System.Type.DefaultBinder, timelineWindow, new object[] { true } ); }
public static long LongFromLargeInteger(object largeInteger) { System.Type type = largeInteger.GetType(); int highPart = (int)type.InvokeMember("HighPart", BindingFlags.GetProperty, null, largeInteger, null); int lowPart = (int)type.InvokeMember("LowPart", BindingFlags.GetProperty, null, largeInteger, null); return((long)highPart << 32 | (uint)lowPart); }
public Integrator(string login, string password, string pathToDb) { _type1C = Type.GetTypeFromProgID("v77.Application"); _object1C = Activator.CreateInstance(_type1C); object rmtrade = _type1C.InvokeMember("RMTrade", BindingFlags.GetProperty, null, _object1C, null); var connectionString = String.Format("/D\"{0}\" /N\"{1}\" /P\"{2}\"", pathToDb, login, password); var arguments = new object[] { rmtrade, connectionString, "NO_SPLASH_SHOW" }; bool res = (bool)_type1C.InvokeMember("Initialize", BindingFlags.InvokeMethod, null, _object1C, arguments); }
// Private functions ============================= // Set a WindZone property value void SetWindZoneValue(string MemberName, object[] args) { // Call the setter m_WindzoneType.InvokeMember( MemberName, BindingFlags.InvokeMethod | BindingFlags.Instance, null, m_WindzoneComponent, args); }
public ViewDesignerDoc(int itemId, DataViewHierarchyAccessor accessor, string viewName) { _accessor = accessor; _connection = accessor.Connection; _itemId = itemId; InitializeComponent(); _init = true; try { _typeQB = SQLiteDataAdapterToolboxItem._vsdesigner.GetType("Microsoft.VSDesigner.Data.Design.QueryBuilderControl"); if (_typeQB != null) { _queryDesigner = Activator.CreateInstance(_typeQB) as UserControl; _typeQB.InvokeMember("Provider", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { SQLiteOptions.GetProviderName() }); _typeQB.InvokeMember("ConnectionString", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { _connection.ConnectionSupport.ConnectionString }); _typeQB.InvokeMember("EnableMorphing", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { false }); Controls.Add(_queryDesigner); _queryDesigner.Dock = DockStyle.Fill; _queryDesigner.Visible = true; } StringBuilder tables = new StringBuilder(); using (DataReader reader = _connection.Command.Execute("SELECT * FROM sqlite_master", 1, null, 30)) { while (reader.Read()) { tables.Append(reader.GetItem(2).ToString()); tables.Append(","); } } int n = 1; if (String.IsNullOrEmpty(viewName)) { string alltables = tables.ToString(); do { viewName = String.Format(CultureInfo.InvariantCulture, "View{0}", n); n++; } while (alltables.IndexOf(viewName + ",", StringComparison.OrdinalIgnoreCase) > -1 || _editingTables.ContainsValue(viewName)); _editingTables.Add(GetHashCode(), viewName); } _view = new SQLite.Designer.Design.View(viewName, _connection.ConnectionSupport.ProviderObject as DbConnection, this); } finally { _init = false; } }
public ViewableFile(EFEFile File, Type Format, bool CreateNew = false) { if (!Format.GetInterfaces().Contains(typeof(IViewable))) throw new ArgumentException("This format is not viewable!"); this.File = File; if (CreateNew) FileFormat = Format.InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, null, new object[0]); else FileFormat = Format.InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, null, new object[] { File.Data }); Dialog = FileFormat.GetDialog(); Dialog.Tag = this; Dialog.Text = File.Name; Dialog.FormClosing += new FormClosingEventHandler(Dialog_FormClosing); }
protected void NewSourceImageSet() { if (_UIEL != null) { _TheType.InvokeMember("SetSourceImage", System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod, null, _UIEL, new object[1] { this._SourceImage }); } //UIEL.SourceImage = this._SourceImage; }
//获得属性与设置属性 public object this[string propName] { get { return(_ObjType.InvokeMember(propName, System.Reflection.BindingFlags.GetProperty, null, ComInstance, null)); } set { _ObjType.InvokeMember(propName, System.Reflection.BindingFlags.SetProperty, null, ComInstance, new object[] { value }); } }
private int _languageId = 1033; // English public WordSpellChecker(Main main, string languageId) { _mainHandle = main.Handle; SetLanguageId(languageId); _wordApplicationType = Type.GetTypeFromProgID("Word.Application"); _wordApplication = Activator.CreateInstance(_wordApplicationType); Application.DoEvents(); _wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateNormal }); _wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -5000 }); // hide window - it's a hack Application.DoEvents(); }
// Private functions ============================= // Set a WindZone property value void SetWindZoneValue(string MemberName, object[] args) { // Call the setter if (m_WindzoneType == null || m_WindzoneComponent == null || args == null || MemberName == null) { return; } m_WindzoneType.InvokeMember( MemberName, BindingFlags.InvokeMethod | BindingFlags.Instance, null, m_WindzoneComponent, args); }
/// <summary> /// Tests for the presence of AGX /// </summary> /// <returns>Is AGX installed?</returns> public bool Installed() { if (calledType == null) { return(false); } try { return((bool)calledType.InvokeMember("AGXInstalled", BINDINGS, null, null, null)); } catch { return(false); } }
/// <summary> /// Loads the ClientDomain DLL into the Client's AppDomain, instantiates the /// main Class (TClientDomainManager) and initialises the AppDomain by calling /// several functions of that Class. /// /// </summary> /// <param name="AClientID">ClientID as assigned by the ClientManager</param> /// <param name="AClientServerConnectionType">Tells in which way the Client connected /// to the PetraServer</param> /// <param name="AClientManagerRef">A reference to the ClientManager object /// (Note: .NET Remoting will be working behind the scenes since calls to /// this Object will cross AppDomains!)</param> /// <param name="ASystemDefaultsCacheRef">A reference to the SystemDefaultsCache object /// (Note: .NET Remoting will be working behind the scenes since calls to /// this Object will cross AppDomains!)</param> /// <param name="ACacheableTablesManagerRef"></param> /// <param name="AUserInfo">An instantiated PetraPrincipal Object, containing User /// information</param> /// <param name="AServerSettings">A copy of the ServerSettings</param> /// <param name="ARemotingURLPollClientTasks">The .NET Remoting URL of the /// TPollClientTasks Class which the Client needs to calls to retrieve /// ClientTasks.</param> /// <param name="ARemotedPollClientTasksObject"></param> public void LoadDomainManagerAssembly(Int32 AClientID, TClientServerConnectionType AClientServerConnectionType, TClientManagerCallForwarder AClientManagerRef, object ASystemDefaultsCacheRef, object ACacheableTablesManagerRef, IPrincipal AUserInfo, TSrvSetting AServerSettings, out String ARemotingURLPollClientTasks, out ICrossDomainService ARemotedPollClientTasksObject) { // Console.WriteLine('TRemoteLoader.LoadDomainManagerAssembly in AppDomain: ' + AppDomain.CurrentDomain.ToString); Assembly LoadedAssembly = Assembly.Load(CLIENTDOMAIN_DLLNAME); FRemoteClientDomainManagerClass = LoadedAssembly.GetType(CLIENTDOMAIN_CLASSNAME); FRemoteClientDomainManagerObject = Activator.CreateInstance(FRemoteClientDomainManagerClass, (BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance), null, new Object[] { AClientID.ToString(), AClientServerConnectionType, AClientManagerRef, ASystemDefaultsCacheRef, ACacheableTablesManagerRef, AUserInfo }, null); FRemoteClientDomainManagerClass.InvokeMember("InitAppDomain", (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, new Object[] { AServerSettings }); // Create and remote the TPollClientTasks Class ARemotingURLPollClientTasks = Convert.ToString(FRemoteClientDomainManagerClass.InvokeMember("GetPollClientTasksURL", (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null)); ARemotedPollClientTasksObject = (ICrossDomainService)FRemoteClientDomainManagerClass.InvokeMember("GetRemotedPollClientTasksObject", (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null); // Establish (separate) DataBase connection for the AppDomain Convert.ToString(FRemoteClientDomainManagerClass.InvokeMember("EstablishDBConnection", (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null)); // Perform any other initialisation required by the AppDomain FRemoteClientDomainManagerClass.InvokeMember("PostAppDomainSetupInitialisation", (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null); // LoadClientDomainManager.ClientTaskAdd('USERMESSAGE','This is just for testing purposes!', 'blabla_1', 'blabla_2', 'blabla_3', 'blabla_4', 1); }
private static object InvokeMemberOnType(Type type, object target, string name, object[] args) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; try { // Try to invokethe method return type.InvokeMember( name, BindingFlags.InvokeMethod | bindingFlags, null, target, args); } catch (MissingMethodException) { // If we couldn't find the method, try on the base class if (type.GetTypeInfo().BaseType != null) { return InvokeMemberOnType(type.GetTypeInfo().BaseType, target, name, args); } //Don't care if the method don't exist. return null; } }
/// <summary> /// Adds a value to the end of a collection. /// </summary> public static void AddToCollection(Type collectionType, object collectionInstance, XamlPropertyValue newElement) { IAddChild addChild = collectionInstance as IAddChild; if (addChild != null) { if (newElement is XamlTextValue) { addChild.AddText((string)newElement.GetValueFor(null)); } else { addChild.AddChild(newElement.GetValueFor(null)); } } else if (collectionInstance is ResourceDictionary) { object val = newElement.GetValueFor(null); object key = newElement is XamlObject ? ((XamlObject)newElement).GetXamlAttribute("Key") : null; if (key == null) { if (val is Style) key = ((Style)val).TargetType; } ((ResourceDictionary)collectionInstance).Add(key, val); } else { collectionType.InvokeMember( "Add", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance, null, collectionInstance, new object[] { newElement.GetValueFor(null) }, CultureInfo.InvariantCulture); } }
/// <summary> /// Создает источник данных, на основе типа инициалайзера и его параметров, Источник добавляется в глобальный список /// </summary> /// <param name="initializerType">Тип инициализатора, наследуется от IInitializer</param> /// <param name="initializerProperties">Обязательные для заполнения поля инициализатора</param> /// <returns>Новый источник данных</returns> public static DataSource CreateDataSource(Type initializerType, Dictionary<string, object> initializerProperties) { DataSource dataSource = null; if (initializerType != null && initializerType.BaseType != null && initializerType.BaseType.Name == "Initializer") { dataSource = new DataSource(Activator.CreateInstance(initializerType) as Abstract.Initializer); if (initializerProperties != null) { foreach (var currProperty in initializerProperties) { initializerType.InvokeMember("SetProperty", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, dataSource.Initializer, new[] { currProperty.Key, currProperty.Value }); } } } if (dataSource == null) { dataSource = new DataSource(); } DataSources.Add(dataSource); return dataSource; }
private void Compile(CodeDom.CodeDomProvider provider, string source) { CodeDom.CompilerParameters param = new CodeDom.CompilerParameters(); param.GenerateExecutable = false; param.IncludeDebugInformation = false; param.GenerateInMemory = true; CodeDom.CompilerResults cr = provider.CompileAssemblyFromSource(param, source); Specialized.StringCollection output = cr.Output; if (cr.Errors.Count != 0) { System.Console.WriteLine("Error invoking scripts."); CodeDom.CompilerErrorCollection es = cr.Errors; foreach (CodeDom.CompilerError s in es) { System.Console.WriteLine(s.ErrorText); } } else { object o = cr.CompiledAssembly.CreateInstance("Script"); System.Type type = o.GetType(); type.InvokeMember("ScriptExecute", Reflection.BindingFlags.InvokeMethod | Reflection.BindingFlags.Default, null, o, null); } }
public static object InvokeMethod(Type type, string methodName, object[] args) { object objResult = null; object obj = Activator.CreateInstance(type); objResult = type.InvokeMember(methodName, bindingFlags | BindingFlags.InvokeMethod, null, obj, args); return objResult; }
/// <summary> /// 定義エディタをコントローラへ登録し、開く。 /// </summary> /// <param name="editorType">登録する定義エディタの型。</param> /// <param name="definition">対象定義のインスタンス。</param> /// <param name="parameters">固有パラメータ。</param> private void RegisterDefinitionEditor( Type editorType, dynamic definition = null, KeyValueMap parameters = null) { DefinitionEditorTab tab = null; tab = FindDefinitionEditor(definition); if (tab != null) { tab.Activate(); return; } tab = (DefinitionEditorTab)editorType.InvokeMember( null, BindingFlags.CreateInstance, null, null, null ); tab.Definition = definition; tab.Parameters = parameters; tab.FormClosed += DefinitionEditor_FormClosed; tab.Apply += DefinitionEditor_Apply; MainForm.ShowContent(tab, DockState.Document); }
public static bool EnableUnsafeHeaderParsing() { //Get the assembly that contains the internal class Assembly aNetAssembly = Assembly.GetAssembly(typeof(System.Net.Configuration.SettingsSection)); if (aNetAssembly != null) { //Use the assembly in order to get the internal type for the internal class System.Type aSettingsType = aNetAssembly.GetType("System.Net.Configuration.SettingsSectionInternal"); if (aSettingsType != null) { //Use the internal static property to get an instance of the internal settings class. //If the static instance isn't created allready the property will create it for us. object anInstance = aSettingsType.InvokeMember("Section", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.NonPublic, null, null, new object[] { }); if (anInstance != null) { //Locate the private bool field that tells the framework is unsafe header parsing should be allowed or not FieldInfo aUseUnsafeHeaderParsing = aSettingsType.GetField("useUnsafeHeaderParsing", BindingFlags.NonPublic | BindingFlags.Instance); if (aUseUnsafeHeaderParsing != null) { aUseUnsafeHeaderParsing.SetValue(anInstance, true); return(true); } } } } return(false); }
/// <summary> /// 从枚举类型和它的特性读出并返回一个键值对 /// </summary> /// <param name="enumType">Type,该参数的格式为typeof(需要读的枚举类型)</param> /// <returns>键值对</returns> public static NameValueCollection GetNameValueCollectionFromEnumValue(Type enumType) { var nvc = new NameValueCollection(); var typeDescription = typeof(DescriptionAttribute); var fields = enumType.GetFields(); foreach (var field in fields) { if (field.FieldType.IsEnum) { var strValue = Convert.ToInt32(enumType.InvokeMember(field.Name, BindingFlags.GetField, null, null, null)); var arr = field.GetCustomAttributes(typeDescription, true); string strText; if (arr.Length > 0) { var aa = (DescriptionAttribute)arr[0]; strText = aa.Description; } else { strText = field.Name; } nvc.Add(strValue.ToString(), strText); } } return nvc; }
internal object GetValue(object target, object[] arguments) { System.Type type = target.GetType(); try { object[] objArray; Collection <int> methods = new Collection <int> { this.getterIndex }; MethodInformation[] informationArray = ComUtil.GetMethodInformationArray(this.typeInfo, methods, false); MethodInformation methodInformation = Adapter.GetBestMethodAndArguments(this.Name, informationArray, arguments, out objArray); object obj2 = type.InvokeMember(this.name, BindingFlags.GetProperty | BindingFlags.IgnoreCase, null, target, objArray, ComUtil.GetModifiers(methodInformation.parameters), CultureInfo.CurrentCulture, null); Adapter.SetReferences(objArray, methodInformation, arguments); return(obj2); } catch (TargetInvocationException exception) { CommandProcessorBase.CheckForSevereException(exception.InnerException); COMException innerException = exception.InnerException as COMException; if ((innerException == null) || (innerException.ErrorCode != -2147352573)) { throw; } } catch (COMException exception3) { if (exception3.ErrorCode != -2147352570) { throw; } } return(null); }
internal object GetValue(object target) { System.Type type = target.GetType(); try { return(type.InvokeMember(this.name, BindingFlags.GetProperty | BindingFlags.IgnoreCase, null, target, null, CultureInfo.CurrentCulture)); } catch (TargetInvocationException exception) { CommandProcessorBase.CheckForSevereException(exception.InnerException); COMException innerException = exception.InnerException as COMException; if ((innerException == null) || (innerException.ErrorCode != -2147352573)) { throw; } } catch (COMException exception3) { if (exception3.ErrorCode != -2147352570) { throw; } } return(null); }
internal void SetValue(object target, object setValue) { System.Type type = target.GetType(); object[] args = new object[1]; setValue = Adapter.PropertySetAndMethodArgumentConvertTo(setValue, this.Type, CultureInfo.InvariantCulture); args[0] = setValue; try { type.InvokeMember(this.name, BindingFlags.SetProperty | BindingFlags.IgnoreCase, null, target, args, CultureInfo.CurrentCulture); } catch (TargetInvocationException exception) { CommandProcessorBase.CheckForSevereException(exception.InnerException); COMException innerException = exception.InnerException as COMException; if ((innerException == null) || (innerException.ErrorCode != -2147352573)) { throw; } } catch (COMException exception3) { if (exception3.ErrorCode != -2147352570) { throw; } } }
private static Control LoadControl(Manager manager, XmlNode node, Type type, Control parent) { Control c = null; Object[] args = new Object[] { manager }; c = (Control)type.InvokeMember(null, BindingFlags.CreateInstance, null, null, args); if (parent != null) c.Parent = parent; c.Name = node.Attributes["Name"].Value; if (node != null && node["Properties"] != null && node["Properties"].HasChildNodes) { LoadProperties(node["Properties"].GetElementsByTagName("Property"), c); } if (node != null && node["Controls"] != null && node["Controls"].HasChildNodes) { foreach (XmlElement e in node["Controls"].GetElementsByTagName("Control")) { string cls = e.Attributes["Class"].Value; Type t = Type.GetType(cls); if (t == null) { cls = "GodLesZ.Library.Xna.WindowLibrary.Controls." + cls; t = Type.GetType(cls); } LoadControl(manager, e, t, c); } } return c; }
/// <summary> /// Cria uma instância com tipo e parâmetros definidos. /// </summary> /// <param name="type">O tipo da instância a ser criada.</param> /// <param name="args">Os parâmetros da instância.</param> /// <returns>A instância. Uma conversão explicita será necessária.</returns> public static object Create(System.Type type, object[] args) { System.Type t = type.Assembly.GetType(type.FullName); return(t.InvokeMember(string.Empty, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, args)); }
public static Rect TopLevel_GetLast() { System.Type guiLayoutGroup = System.Type.GetType("UnityEngine.GUILayoutGroup, UnityEngine"); var topLevel = GUILayoutUtilityEx.Type.GetProperty("topLevel", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null, null); return(( Rect )guiLayoutGroup.InvokeMember("GetLast", BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, topLevel, new object[] { })); }
private void GetDataFromClass(object sender) { System.Type _sendertype = sender.GetType(); this._parametros.Clear(); foreach (string paramkey in _attributesFromTask.Keys) { object paramvalue = _sendertype.InvokeMember(Convert.ToString(_attributesFromTask[paramkey]), System.Reflection.BindingFlags.GetProperty, null, sender, new object[] {}); this._parametros.Add(new ReportParameter(paramkey, Convert.ToString(paramvalue))); } /* Silvina 20100601 - Tarea 525 */ if (_sendertype.Name.Equals("ComprobanteDeEntrega")) { ComprobanteDeEntrega comp = (ComprobanteDeEntrega)sender; string orden = Variables.GetValueString("Reportes.ComprobantesEntregas.Orden"); this._parametros.Add(new ReportParameter("@Orden", orden)); } /* Fin Silvina */ if (_configPersonalizado) { _dataSource = mz.erp.businessrules.reportes.StatementSQLFactory.GetSQLForGenericReport(_configName, this._parametros).DefaultView; } else { _dataSource = mz.erp.businessrules.reportes.StatementSQLFactory.GetSQLForGenericReport(_reportName, this._parametros).DefaultView; } }
private MQCommonServices() { lock (initialiseLock) { if (this.nativeManager == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly assembly = null; for (int i = 0; i < assemblies.Length; i++) { if (assemblies[i].FullName.Contains("amqmdnet")) { assembly = assemblies[i]; break; } } if (assembly == null) { assembly = Assembly.Load("amqmdnet, PublicKeyToken=dd3cb1c9aae9ec97, Version=" + CommonServices.GetVRMF() + ", Culture=Neutral"); } nativeManagerType = assembly.GetType("IBM.WMQ.Nmqi.NativeManager"); this.nativeManager = assembly.CreateInstance("IBM.WMQ.Nmqi.NativeManager"); try { nativeManagerType.InvokeMember("InitializeNativeApis", BindingFlags.InvokeMethod, null, this.nativeManager, new object[] { "IBM.WMQ.MQCommonServices" }); } catch (Exception exception) { throw exception; } this.Initialize(); } } }
public override object Deserialize(string value) { string[] data = SplitTypeValue(value); if (data == null) { return(null); } // Wir holen uns den Typen, und rufen von diesem dann die statische Methode "Parse" auf System.Type type = null; try { type = Type.GetType(data[0]); } catch (FileLoadException) { // Typ unbekannt o.ä. return(null); } if (type == null || !type.IsPrimitive) { return(null); } object result = null; try { result = type.InvokeMember("Parse", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.InvokeMethod, null, type, new object[] { data[1] }); } catch (Exception) { // Umwandlung ungültig, also null zurückgeben return(null); } return(result); }
string GetAttrValue(System.Reflection.Assembly assy, Type attrType, string field) { object[] ary = assy.GetCustomAttributes(attrType, false); if (ary == null || ary.Length != 1) return "(not set)"; object value = attrType.InvokeMember(field, System.Reflection.BindingFlags.GetProperty, null, ary[0], new object[] { }); return value == null ? "(not set)" : (string)value; }
/// <summary> /// 根据枚举类型得到其所有的 值 与 枚举定义Description属性 的集合 /// </summary> /// <param name="enumType"></param> /// <returns></returns> public static NameValueCollection GetNVCFromEnumValue(Type enumType) { var nvc = new NameValueCollection(); Type typeDescription = typeof(DescriptionAttribute); FieldInfo[] fields = enumType.GetFields(); foreach (FieldInfo field in fields) { if (field.FieldType.IsEnum) { string strValue = ((int)enumType.InvokeMember(field.Name, BindingFlags.GetField, null, null, null)).ToString(CultureInfo.InvariantCulture); object[] arr = field.GetCustomAttributes(typeDescription, true); string strText; if (arr.Length > 0) { var aa = (DescriptionAttribute)arr[0]; strText = aa.Description; } else { strText = ""; } nvc.Add(strValue, strText); } } return nvc; }
/// <summary> /// 执行 ANT 打包 /// </summary> public static void DoneAnts(BuildingAssetsAnt[] sAnts) { for (int i = 0; null != sAnts && i < sAnts.Length; i++) { if (null == sAnts[i]) { Debug.LogErrorFormat("Unfind ants[{0}]", i); continue; } System.Reflection.Assembly assembly = System.Reflection.Assembly.Load(sAnts[i].typeAssembly); System.Type type = assembly.GetType(sAnts[i].typeName); if (null == type) { Debug.LogErrorFormat("Unfind Type [{0}] = {1}", i, sAnts[i].typeName); continue; } if (string.IsNullOrEmpty(sAnts[i].functionName)) { Debug.LogFormat("Pass Ant [{0}] = {1}.{2}", i, sAnts[i].typeName, sAnts[i].functionName); continue; } /// 调用 try { Debug.LogFormat("Done Ant [{0}] = {1}.{2} Begin", i, sAnts[i].typeName, sAnts[i].functionName); type.InvokeMember(sAnts[i].functionName, BindingFlags.InvokeMethod, null, null, null); Debug.LogFormat("Done Ant [{0}] = {1}.{2} Succeed", i, sAnts[i].typeName, sAnts[i].functionName); } catch (System.Exception sE) { Debug.LogErrorFormat("Done Ant [{0}] = {1}.{2} Error : \n{3}", i, sAnts[i].typeName, sAnts[i].functionName, sE); } } }
/// <summary> /// 从文件加载对象(反序列化XML格式为该类类型) /// </summary> /// <param name="type"></param> /// <param name="file"></param> /// <returns></returns> public static object LoadFromFile(System.Type type, string file) { object obj = new object(); System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(type); if (System.IO.File.Exists(file)) { System.IO.FileStream fs = null; try { fs = System.IO.File.Open(file, System.IO.FileMode.Open, System.IO.FileAccess.Read); } catch { obj = type.InvokeMember(null, System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance, null, null, null); } try { obj = xs.Deserialize(fs); } catch (Exception e) { string s = e.Message; obj = type.InvokeMember(null, System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance, null, null, null); } finally { fs.Close(); } } else { try { obj = type.InvokeMember(null, System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance, null, null, null); SaveToFile(obj, file); } #pragma warning disable CS0168 // The variable 'ex' is declared but never used catch (System.Exception ex) { } #pragma warning restore CS0168 // The variable 'ex' is declared but never used } return(obj); }
/// <summary> /// Lê a o valor da propriedade em um objeto. /// </summary> /// <param name="obj">O objeto.</param> /// <param name="propertyName">Nome da propriedade.</param> /// <returns></returns> public static object Get(object obj, string propertyName) { System.Type t = obj.GetType(); PropertyInfo[] property = t.GetProperties(); return(t.InvokeMember(propertyName, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty, null, obj, null)); }
/// <summary> /// Executa um método de um objeto. /// </summary> /// <param name="obj">O objeto.</param> /// <param name="methodName">Nome do método.</param> /// <param name="args">Os parâmetros do método.</param> /// <returns>O retorto do método. Uma conversão explicita pode ser necessária.</returns> public static object Method(object obj, string methodName, object[] args) { System.Type t = obj.GetType(); PropertyInfo[] property = t.GetProperties(); return(t.InvokeMember(methodName, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, obj, args)); }
/// <summary> /// Executes the ClientTaskAdd procedure on the TClientDomainManager Object. /// /// </summary> /// <param name="ATaskGroup">Group of the Task</param> /// <param name="ATaskCode">Code of the Task (depending on the TaskGroup this can be /// left empty)</param> /// <param name="ATaskParameter1">Parameter #1 for the Task (depending on the TaskGroup /// this can be left empty)</param> /// <param name="ATaskParameter2">Parameter #2 for the Task (depending on the TaskGroup /// this can be left empty)</param> /// <param name="ATaskParameter3">Parameter #3 for the Task (depending on the TaskGroup /// this can be left empty)</param> /// <param name="ATaskParameter4">Parameter #4 for the Task (depending on the TaskGroup /// this can be left empty)</param> /// <param name="ATaskPriority">Priority of the Task</param> /// <returns>TaskID /// </returns> public Int32 ClientTaskAdd(String ATaskGroup, String ATaskCode, System.Object ATaskParameter1, System.Object ATaskParameter2, System.Object ATaskParameter3, System.Object ATaskParameter4, Int16 ATaskPriority) { return(Convert.ToInt32( FRemoteClientDomainManagerClass.InvokeMember("ClientTaskAdd", (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, new Object[] { ATaskGroup, ATaskCode, ATaskParameter1, ATaskParameter2, ATaskParameter3, ATaskParameter4, (System.Object)ATaskPriority }, null))); }
//IModule instance = null; //{if (type == null || type.GetInterface("IModule") == null) continue; //instance = (IModule)type.InvokeMember(String.Empty, BindingFlags.CreateInstance, null, null, null); //CurrentModules.Add(instance.ModuleId.ToString(), instance); //instance.Initializer();} #endregion private IModule CreateModuleByType(Type type) { if (type == null || type.GetInterface("IModule") == null) return null; var instance = (IModule)type.InvokeMember(String.Empty, BindingFlags.CreateInstance, null, null, null); CurrentModules.Add(instance.ModuleId, instance); instance.Initializer(); return instance; }
/// <param name="animatorController">присваеваемый контроллер</param> /// <param name="animator">Аниматор, которому присваивается контроллер</param> private void SetAnimatorController(Animator animator, Object animatorController) { System.Type engineAnimatorController = animatorController.GetType(); engineAnimatorController.InvokeMember("SetAnimatorController", System.Reflection.BindingFlags.InvokeMethod, System.Type.DefaultBinder, "", new object[] { animator, animatorController }); }
/// <summary> /// Display the specified workflow type. /// </summary> /// <param name="root">Type of the workflow.</param> public void DisplayType(Type root) { if (!typeof(Activity).IsAssignableFrom(root)) { throw new ArgumentException("WorkflowViewPanel only supports displaying Activity objects.", "root"); } this.surface = new DesignSurface(); this.host = this.surface.GetService(typeof(IDesignerHost)) as IDesignerHost; TypeProvider provider = new TypeProvider(this.surface); provider.AddAssembly(typeof(string).Assembly); IServiceContainer container = this.surface.GetService(typeof(IServiceContainer)) as IServiceContainer; container.AddService(typeof(ITypeProvider), provider); if (this.host == null) { throw new ApplicationException("Cannot work with a null host."); } Queue<Activity> toProcess = new Queue<Activity>(); try { toProcess.Enqueue((Activity)root.InvokeMember(string.Empty, System.Reflection.BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture)); } catch (Exception exc) { MessageBox.Show("Could not load workflow type: " + exc.ToString()); this.surface = null; this.host = null; return; } // Do a non-recursive walk of the activity // tree to display all activities. while (toProcess.Count > 0) { Activity activity = toProcess.Dequeue(); host.Container.Add(activity, activity.QualifiedName); if (activity is CompositeActivity) { foreach (Activity child in ((CompositeActivity)activity).Activities) { toProcess.Enqueue(child); } } } this.surface.BeginLoad(new WorkflowLoader()); workflowView = new MouseDisabledWorkflowView(host as IServiceProvider); workflowView.Dock = DockStyle.Fill; this.Controls.Add(workflowView); }
public static object InvokeStatic(System.Type klass, string name, object variable) { object[] args = null; if (variable != null) { args = new object[] { variable }; } return(klass.InvokeMember(name, BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static, null, null, args, null, null, null)); }
/// <summary> /// Cria uma instância de uma classe presente em um assembly. /// </summary> /// <param name="assemblyFile">O assembly.</param> /// <param name="typeFullName">Nome completo do tipo.</param> /// <param name="args">Os argumentos.</param> /// <returns>A instância. Uma conversão explicita será necessária.</returns> public static object Create(string assemblyFile, string typeFullName, object[] args) { Assembly a = Assembly.LoadFrom(assemblyFile); System.Type type = a.GetType(typeFullName); return(type.InvokeMember(string.Empty, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, args)); }
/// <summary> /// Instantiate Microsoft Excel /// </summary> /// <returns>void</returns> public TExcel() : base() { // eg HKEY_CLASSES_ROOT\Excel.Application.11 'Excel.Application.11' MSExcelType = System.Type.GetTypeFromProgID("Excel.Application", true); if (MSExcelType == null) { throw new Exception("no Excel available"); } MSExcel = Activator.CreateInstance(MSExcelType); // Get a new workbook. // oWB = (Excel._Workbook)(oXL.Workbooks.Add( Missing.Value )); workbooks = MSExcelType.InvokeMember("Workbooks", BindingFlags.GetProperty, null, MSExcel, null); workbook = MSExcelType.InvokeMember("Add", BindingFlags.InvokeMethod, null, workbooks, null); countFixedSheets = 0; }
/// <summary> /// 调用程式 /// </summary> /// <param name="type">调用类型</param> /// <param name="file">调用路径</param> /// <returns></returns> public static object OpenProject(System.Type type, string file) { object obj = new object(); BinaryFormatter bf = new BinaryFormatter(); if (System.IO.File.Exists(file)) { System.IO.FileStream fs = null; try { fs = System.IO.File.Open(file, System.IO.FileMode.Open, System.IO.FileAccess.Read); } catch { obj = type.InvokeMember(null, System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance, null, null, null); } try { obj = bf.Deserialize(fs); } catch (Exception e) { string s = e.Message; obj = type.InvokeMember(null, System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance, null, null, null); } finally { fs.Close(); } } else { try { obj = type.InvokeMember(null, System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance, null, null, null); SaveProject(obj, file); } catch { } } return(obj); }
/// <summary> /// 从文件加载对象 /// </summary> /// <param name="type"></param> /// <param name="file"></param> /// <returns></returns> public static object LoadFromFile(System.Type type, string file) { object obj = new object(); XmlSerializer xs = new XmlSerializer(type); if (File.Exists(file)) { FileStream fs = null; try { fs = File.Open(file, FileMode.Open, FileAccess.Read); } catch { obj = type.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null); } try { obj = xs.Deserialize(fs); } catch (Exception e) { string s = e.Message; obj = type.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null); } finally { fs.Close(); } } else { try { obj = type.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null); SaveToFile(obj, file); } catch { } } return(obj); }
public object Invoke(Type type, string method, params object[] args) { const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.InvokeMethod; return type.InvokeMember(method, flags, null, null, args); }
public static void tryFindFile(Type t, string filePattern, string fileParam) { DirectoryInfo dir = new DirectoryInfo("."); var files = dir.GetFiles(filePattern); foreach (var file in files)//.Length>0) { t.InvokeMember(fileParam,BindingFlags.InvokeMethod,null,null,new Object[] {file.Name}); }; //parse current directory }
public override object FromStringValue(Type type, string str) { if(!type.IsSubclassOf(typeof(FlexibleProperty))) throw new Exception(Resources.ExceptionDesignerAttributeInvalidType); FlexibleProperty flexible= (FlexibleProperty)type.InvokeMember(string.Empty, System.Reflection.BindingFlags.CreateInstance, null, null, new object[0]); flexible.FromStringValue(str); return flexible; }
internal static Object Invoke(Type type, params Object[] args) { //if(Util.containsNull(args)) { return type.InvokeMember(type.Name, BindingFlags.CreateInstance//|BindingFlags.FlattenHierarchy //|(isStatic?BindingFlags.Static:BindingFlags.Instance) , null, null, args); } }
/// <summary> /// Creates an attachment from a given type. /// </summary> /// <param name="type">The type we want to create an attachment of.</param> /// <param name="node">The node this will be added to.</param> /// <returns>Returns the created event.</returns> public static Attachment Create(Type type, Nodes.Node node) { Debug.Check(type != null); Attachment atta = (Attachment)type.InvokeMember(string.Empty, System.Reflection.BindingFlags.CreateInstance, null, null, new object[] { node }); if (atta == null) { throw new Exception(Resources.ExceptionMissingEventConstructor); } return atta; }
/// <summary> /// Creates an event from a given type. /// </summary> /// <param name="type">The type we want to create an event of.</param> /// <param name="node">The node the event will be added to.</param> /// <returns>Returns the created event.</returns> public static Event Create(Type type, Nodes.Node node) { Debug.Check(type !=null); Event evnt= (Event)type.InvokeMember(string.Empty, System.Reflection.BindingFlags.CreateInstance, null, null, new object[] { node }); if(evnt ==null) throw new Exception(Resources.ExceptionMissingEventConstructor); return evnt; }
public static object InvokeStatic(Type klass, string name, object variable) { object[] args = null; if (variable != null) { args = new object[] { variable }; } return klass.InvokeMember(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, args, null, null, null); }
/// <summary> /// returns the boxed content for a boxed value type, if a one dimensional array of a non-array /// or of an array type should be boxed /// </summary> /// <remarks> /// This method is called via reflection /// </remarks> public static object BoxOneDimArray(Type valueBoxType, object arrayToBox) { if (!(arrayToBox is Array)) { // invalid argument type: arrayToBox.GetType(), expected: System.Array throw new INTERNAL(30009, CompletionStatus.Completed_MayBe); } Array array = (Array) arrayToBox; object boxContent = null; // the boxed content for the valueBox if (array == null) { // array: can't box null throw new BAD_PARAM(30010, CompletionStatus.Completed_MayBe); } else if (array.Rank > 1) { // array: only one dim-arrays are supported (array of array of array is also possible, but not true moredim) throw new INTERNAL(30010, CompletionStatus.Completed_MayBe); } // array is ok Type boxed = null; try { boxed = (Type)valueBoxType.InvokeMember(BoxedValueBase.GET_BOXED_TYPE_METHOD_NAME, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly, null, null, new object[0]); } catch (Exception) { // invalid type: valueBoxType static method missing or not callable: BoxedValueBase.GET_BOXED_TYPE_METHOD_NAME throw new INTERNAL(30011, CompletionStatus.Completed_MayBe); } if (array.GetType().GetElementType().IsArray) { boxContent = Array.CreateInstance(boxed.GetElementType(), array.Length); for (int i = 0; i < array.Length; i++) { // box array elements of the array of array object boxedElement = null; if ((Array)array.GetValue(i) != null) { object boxedElementContent = BoxOneDimArray(boxed.GetElementType(), (Array)array.GetValue(i)); boxedElement = Activator.CreateInstance(boxed.GetElementType(), new object[] { boxedElementContent }); } ((Array)boxContent).SetValue(boxedElement, i); } } else if (!boxed.GetElementType().IsSubclassOf(ReflectionHelper.BoxedValueBaseType)) { // array elements are non boxed / no arrays boxContent = array; } else { // array elements are boxed values --> box the values here boxContent = Array.CreateInstance(boxed.GetElementType(), array.Length); for (int i = 0; i < array.Length; i++) { object boxedElement = Activator.CreateInstance(boxed.GetElementType(), new object[] { array.GetValue(i) }); ((Array)boxContent).SetValue(boxedElement, i); } } return boxContent; }
public static void parseCommandLine (Type t, string[] args) { try { CommandLineDictionary d = CommandLineDictionary.FromArguments(args); //var p = new Program.NodeServerParams(); //Type t = typeof(paramclass); foreach (KeyValuePair<string, string> param in d) t.InvokeMember("Param" + param.Key.ToUpper(), BindingFlags.InvokeMethod, null, null, new Object[] { param.Value }); } catch (Exception e) { Console.WriteLine("unknown parameter " + e.Message); try { t.InvokeMember("ParamH", BindingFlags.InvokeMethod, null, null, new object[] { null }); } catch(Exception e2) { Console.WriteLine("No help is presented. "+ e2.Message); } } }
/// <summary> /// 根据枚举类型得到其所有的 值 与 枚举定义字符串 的集合 /// </summary> /// <param name="enumType"></param> /// <returns></returns> public static NameValueCollection GetEnumStringFromEnumValue(Type enumType) { var nvc = new NameValueCollection(); FieldInfo[] fields = enumType.GetFields(); string strText = string.Empty; string strValue = string.Empty; foreach (FieldInfo field in fields) { if (field.FieldType.IsEnum) { strValue = ((int)enumType.InvokeMember(field.Name, BindingFlags.GetField, null, null, null)).ToString(); nvc.Add(strValue, field.Name); } } return nvc; }
public static void RunThoseTests(IEnumerable<MethodInfo> tests, Type type, FullRunDescription report, bool log) { var specificTests = tests as IList<MethodInfo> ?? tests.ToList(); if (specificTests.Count <= 0) { return; } Log(string.Format("TestFixture :{0}", type.FullName)); #if !CORE // creates an instance var test = type.InvokeMember( string.Empty, BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, new object[] { }); // run TestFixtureSetup RunAllMethodsWithASpecificAttribute(type, typeof(TestFixtureSetUpAttribute), test); try { // run all tests foreach (var specificTest in specificTests.Where( specificTest => specificTest.GetCustomAttributes(typeof(ExplicitAttribute), false).Length == 0 && specificTest.GetCustomAttributes(typeof(IgnoreAttribute), false).Length == 0)) { RunAllMethodsWithASpecificAttribute(type, typeof(SetUpAttribute), test); try { // we have to caputre eceptions RunMethod(specificTest, test, report, log); } finally { RunAllMethodsWithASpecificAttribute(type, typeof(TearDownAttribute), test); } } } finally { RunAllMethodsWithASpecificAttribute(type, typeof(TestFixtureTearDownAttribute), test); } #endif }
public static object CallStaticMethod(string methodName, Type t, params object[] args) { if (args.Length == 0) { FieldInfo f = GetField(t,methodName, true); if (f != null) return f.GetValue(t); PropertyInfo p = GetProperty(t, methodName, true); if (p != null) return p.GetValue(t, null); } BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod | BindingFlags.GetField | BindingFlags.GetProperty; return t.InvokeMember(methodName, flags, Type.DefaultBinder, null, args); }
internal static void InternalStart() { Platform.Log(LogLevel.Info, "Starting Server Shred Host Service..."); // the default startup path is in the system folder // we need to change this to be able to scan for plugins and to log string startupPath = AppDomain.CurrentDomain.BaseDirectory; System.IO.Directory.SetCurrentDirectory(startupPath); // we choose to dynamically load the ShredHost dll so that we can bypass // the requirement that the ShredHost dll be Strong Name signed, i.e. // if we were to reference it directly in the the project at design time // ClearCanvas.Server.ShredHost.dll would also need to be Strong Name signed _assembly = Assembly.Load("ClearCanvas.Server.ShredHost"); _shredHostType = _assembly.GetType("ClearCanvas.Server.ShredHost.ShredHost"); _shredHostType.InvokeMember("Start", BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public,null, null, new object[] { }); }
private static object InvokeMemberOnType(Type type, object target, string name, object[] args) { try { return type.InvokeMember(name, System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic, null, target, args); } catch (MissingMethodException) { if (type.BaseType != null) { return InvokeMemberOnType(type.BaseType, target, name, args); } return null; } }