public static TInterface GetInstance <TInterface, TObj>() where TObj : MarshalByRefObject, new() { TObj proxyObj = Activator.CreateInstance(typeof(TObj)) as TObj; return((TInterface) new DynamicProxy <TObj>(proxyObj).GetTransparentProxy()); }
public static MyAbstractObject CreateObject() { Tobj subOb = new TObj(); MyAbstractObject parent = subOb.ToObject(); return(parent); }
static void Main(string[] args) { TObj tobj = new TObj(); app.Updated += onUpdate; while (true) { var key = Console.ReadKey(); // Console.WriteLine(key); if (key.Key == ConsoleKey.X) { break; } switch (key.Key) { case ConsoleKey.D1: case ConsoleKey.D2: case ConsoleKey.D3: case ConsoleKey.D4: // Console.WriteLine(key.Key.ToString().Replace("D","")); app.SwitchTab(Int16.Parse(key.Key.ToString().Replace("D", ""))); break; case ConsoleKey.Q: app.SwitchTab(5); break; case ConsoleKey.W: app.SwitchTab(6); break; case ConsoleKey.E: app.SwitchTab(7); break; case ConsoleKey.R: app.SwitchTab(8); break; case ConsoleKey.A: app.AddToQueue(app.SelectedEType, 1); break; case ConsoleKey.D: app.AddProduction(app.SelectedEType, 1); break; case ConsoleKey.S: app.AddProduction(app.SelectedEType, -1); break; } } }
public TObj Create <TInt, TObj>() where TObj : class where TInt : class { TObj obj = (TObj)Activator.CreateInstance(typeof(TObj)); _objectCache.Remove(typeof(TInt)); _objectCache.Add(typeof(TInt), obj); return(obj); }
protected TObj RequestArgs <TObj>() where TObj : class { StreamReader reader = new StreamReader(HttpContext.Request.InputStream); //这里不能用HttpUtility.UrlDecode,会把 + 号忽略掉! //例如日期时间序列化后会变为: //Date(1412957280374+0800) string json = reader.ReadToEnd();//HttpUtility.UrlDecode(reader.ReadToEnd()); TObj requestObj = JsonConvert.DeserializeObject <TObj>(json); return(requestObj); }
public TObj As <TObj>() where TObj : class, new() { try { var type = typeof(TObj); var obj = new TObj(); var methodInfos = type.GetMethods(); foreach (var item in _table.TableHeaderDict) { var property = type.GetProperty(item.Key); if (property != null && property.CanWrite) { var value = this[item.Value]; SetObj(obj, property, value, methodInfos); } } return(obj); } catch (Exception) { return(null); } }
public void ChangeRecordContainer <TType, TObj>() where TObj : new() => FactoriesDictionary[typeof(TType)] = new TObj();
this TObj objectToMonitor, Expression <Func <TObj, TReturn> > propertyExpression)
public pooledObject(TObj newObj) { _obj = newObj; returnToPool = null; }