/// <summary> /// Loads assemblt /// </summary> /// <param name="editor">Assembly editor</param> public static void LoadAssembly(this ISeparatedAssemblyEditedObject editor) { ISeparatedPropertyEditor ed = editor.Editor; if (ed != null) { return; } Type type = editor.GetType(); Func <Type, bool> f = (Type t) => { bool b = false; if (t.GetInterface(typeof(ISeparatedPropertyEditor).FullName) == null) { return(false); } b = type.CompareLinkedType(t); if (b) { ConstructorInfo ci = t.GetConstructor(new Type[0]); ISeparatedPropertyEditor pe = ci.Invoke(new object[0]) as ISeparatedPropertyEditor; editor.Editor = pe; } return(b); }; f.GetFirstAssemblyBytes(AppDomain.CurrentDomain.BaseDirectory); }
/// <summary> /// Gets editor /// </summary> /// <param name="editor">Edited object</param> /// <returns>Editor</returns> public static object GetEditor(this ISeparatedAssemblyEditedObject editor) { try { ISeparatedPropertyEditor ed = editor.Editor; Type type = editor.GetType(); if (ed == null) { byte[] b = editor.AssemblyBytes; if (b != null) { Assembly ass = Assembly.Load(b); Type[] types = ass.GetTypes(); foreach (Type t in types) { if (t.GetInterface(typeof(ISeparatedPropertyEditor).FullName) != null) { if (type.CompareLinkedType(t)) { ConstructorInfo ci = t.GetConstructor(new Type[0]); ISeparatedPropertyEditor se = ci.Invoke(new object[0]) as ISeparatedPropertyEditor; ed = se; break; } } } } } if (ed == null) { Func <Type, bool> f = (Type t) => { if (t.GetInterface(typeof(ISeparatedPropertyEditor).FullName) == null) { return(false); } if (t.CompareLinkedType(type)) { ConstructorInfo ci = t.GetConstructor(new Type[0]); ISeparatedPropertyEditor pe = ci.Invoke(new object[0]) as ISeparatedPropertyEditor; ed = pe; return(true); } return(false); }; f.GetFirstAssemblyBytes(AppDomain.CurrentDomain.BaseDirectory); } editor.Editor = ed; if (ed == null) { return(false); } return(ed.GetEditor(editor)); } catch (Exception ex) { ex.ShowError(10); } return(null); }