本文整理匯總了Python中System.Type方法的典型用法代碼示例。如果您正苦於以下問題:Python System.Type方法的具體用法?Python System.Type怎麽用?Python System.Type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System
的用法示例。
在下文中一共展示了System.Type方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CreateAssemblyGenerator
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def CreateAssemblyGenerator(path, name):
dir = IO.Path.GetDirectoryName(path)
file = IO.Path.GetFileName(path)
aname = Reflection.AssemblyName(name)
domain = System.AppDomain.CurrentDomain
ab = domain.DefineDynamicAssembly(aname, Emit.AssemblyBuilderAccess.RunAndSave, dir, None)
mb = ab.DefineDynamicModule(file, file, True);
ab.DefineVersionInfoResource()
constructor = clr.GetClrType(Diagnostics.DebuggableAttribute).GetConstructor(MakeArray(System.Type, clr.GetClrType(Diagnostics.DebuggableAttribute.DebuggingModes)))
attributeValue = MakeArray(System.Object,
Diagnostics.DebuggableAttribute.DebuggingModes.Default |
Diagnostics.DebuggableAttribute.DebuggingModes.DisableOptimizations |
Diagnostics.DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints
)
cab = Emit.CustomAttributeBuilder(constructor, attributeValue)
ab.SetCustomAttribute(cab)
mb.SetCustomAttribute(cab)
return AssemblyGenerator(file, ab, mb, None)
示例2: test_methods_from_generic_class
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def test_methods_from_generic_class(self):
import System
from Merlin.Testing.BaseClass import Class320
class C(Class320[int]): pass
x = C()
self.assertEqual(x.m320(1), 11)
self.assertRaises(TypeError, x.m320, 'abc')
self.assertEqual(C.m320(x, 1), 11)
self.assertEqual(Class320[int].m320(x, 1), 11)
C.m320 = lambda self, arg: 100
self.assertEqual(x.m320(1), 100)
self.assertEqual(C.m320(x, 1), 100)
self.assertEqual(Class320[int].m320(x, 1), 11)
# ref type
class C(Class320[System.Type]): pass
x = C()
self.assertRaises(TypeError, x.m320, 1)
self.assertEqual(x.m320(None), 11)
C.m320 = lambda self: 200
self.assertEqual(x.m320(), 200)
示例3: test_neg_clrtype_returns_nonsense_values
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def test_neg_clrtype_returns_nonsense_values(self):
'''
The __clrtype__ implementation returns invalid values.
'''
global called
import System
for x, expected_msg in [[[], "expected Type, got list"],
[(None,), "expected Type, got tuple"],
[True, "expected Type, got bool"],
[False, "expected Type, got bool"],
[3.14, "expected Type, got float"],
["a string", "expected Type, got str"],
[System.UInt16(32), "expected Type, got UInt16"],
[1L, "expected Type, got long"],
]:
示例4: on_close
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def on_close(self, sender, args):
def _shutdown():
if is_cef:
CEF.shutdown()
WinForms.Application.Exit()
if is_cef:
CEF.close_window(self.uid)
del BrowserView.instances[self.uid]
# during tests windows is empty for some reason. no idea why.
if self.pywebview_window in windows:
windows.remove(self.pywebview_window)
self.closed.set()
if len(BrowserView.instances) == 0:
self.Invoke(Func[Type](_shutdown))
示例5: GetWinApiFunctionImpl
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def GetWinApiFunctionImpl(
functionName,
moduleName,
charSet,
returnType,
*parameterTypes
):
tbuilder = MODULE_BUILDER.DefineType("WIN_API_TYPE" + "_" + moduleName + "_" + functionName)
mbuilder = tbuilder.DefinePInvokeMethod(
functionName,
moduleName,
PINVOKE_METHOD_ATTRIBUTES,
Refl.CallingConventions.Standard,
clr.GetClrType(returnType),
[clr.GetClrType(t) for t in parameterTypes].ToArray[System.Type](),
WIN_API_CALLING_CONVENTION,
charSet
)
mbuilder.SetImplementationFlags(mbuilder.MethodImplementationFlags | Refl.MethodImplAttributes.PreserveSig)
winApiType = tbuilder.CreateType()
methodInfo = winApiType.GetMethod(functionName, PUBLIC_STATIC_BINDING_FLAGS)
def WinApiFunction(*parameters):
return methodInfo.Invoke(None, parameters.ToArray[System.Object]())
return WinApiFunction
示例6: __init__
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def __init__(self, dot_net_dict, path):
"""Contains the namespace_ modules, classes and `System.Type`_ objects of a .NET Assembly.
Do not instantiate this class directly.
.. _namespace: https://msdn.microsoft.com/en-us/library/z2kcy19k.aspx
.. _System.Type: https://msdn.microsoft.com/en-us/library/system.type(v=vs.110).aspx
"""
self.__dict__.update(dot_net_dict)
self._path = path
示例7: DefineMethod
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def DefineMethod(self, name, attributes, returnType, parameterTypes):
params = MakeArray(System.Type, parameterTypes)
mb = self.tb.DefineMethod(name, attributes, returnType, params)
ilg = mb.GetILGenerator()
return CodeGenerator(self, mb, ilg)
示例8: evaluate_js
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def evaluate_js(self, script):
def _evaluate_js():
self.browser.evaluate_js(script)
self.loaded.wait()
self.Invoke(Func[Type](_evaluate_js))
self.browser.js_result_semaphore.acquire()
return self.browser.js_result
示例9: load_html
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def load_html(self, content, base_uri):
def _load_html():
self.browser.load_html(content, base_uri)
self.Invoke(Func[Type](_load_html))
示例10: load_url
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def load_url(self, url):
def _load_url():
self.browser.load_url(url)
self.Invoke(Func[Type](_load_url))
示例11: hide
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def hide(self):
self.Invoke(Func[Type](self.Hide))
示例12: toggle_fullscreen
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def toggle_fullscreen(self):
def _toggle():
screen = WinForms.Screen.FromControl(self)
if not self.is_fullscreen:
self.old_size = self.Size
self.old_state = self.WindowState
self.old_style = self.FormBorderStyle
self.old_location = self.Location
self.FormBorderStyle = 0 # FormBorderStyle.None
self.Bounds = WinForms.Screen.PrimaryScreen.Bounds
self.WindowState = WinForms.FormWindowState.Maximized
self.is_fullscreen = True
windll.user32.SetWindowPos(self.Handle.ToInt32(), None, screen.Bounds.X, screen.Bounds.Y,
screen.Bounds.Width, screen.Bounds.Height, 64)
else:
self.Size = self.old_size
self.WindowState = self.old_state
self.FormBorderStyle = self.old_style
self.Location = self.old_location
self.is_fullscreen = False
if self.InvokeRequired:
self.Invoke(Func[Type](_toggle))
else:
_toggle()
示例13: on_top
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def on_top(self, on_top):
def _set():
z_order = -1 if on_top is True else -2
SWP_NOSIZE = 0x0001 # Retains the current size
windll.user32.SetWindowPos(self.Handle.ToInt32(), z_order, self.Location.X, self.Location.Y, None, None, SWP_NOSIZE)
if self.InvokeRequired:
self.Invoke(Func[Type](_set))
else:
_set()
示例14: minimize
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def minimize(self):
def _minimize():
self.WindowState = WinForms.FormWindowState.Minimized
self.Invoke(Func[Type](_minimize))
示例15: restore
# 需要導入模塊: import System [as 別名]
# 或者: from System import Type [as 別名]
def restore(self):
def _restore():
self.WindowState = WinForms.FormWindowState.Normal
self.Invoke(Func[Type](_restore))