public object setWbo(string comId, string wboName, string wboJSON) { WboSchema objectSchema = WboSchemaContainer.Instance().GetItem(comId); WboProxy wboProxy = WboProxyFactory.getWboProxy(objectSchema); object wbo; try { wbo = JsonConvert.DeserializeObject(wboJSON, wboProxy.getWboType()); } catch { throw new XException(string.Format(Lang.WboTypeNotMatchComId, comId)); } if (wboProxy.getWboType().IsSubclassOf(typeof(ISessionWbo))) { objectSchema.LifeCycle = LifeCycle.Session; } string objHashKey = getObjHashKey(objectSchema.Id, wboName); switch (objectSchema.LifeCycle) { case LifeCycle.Global: if (objects.ContainsKey(objHashKey)) { objects[objHashKey] = wbo; } else { objects.Add(objHashKey, wbo); } break; case LifeCycle.Session: string sesssionId = Session.SessionID; if (SessionObjects.ContainsKey(objHashKey)) { SessionObjects[objHashKey] = wbo; } else { SessionObjects.Add(objHashKey, wbo); } break; } return(wbo); }
public static void regType(Type type, string src, AssemblyCategory srcType, string filePath) { WboSchema os = WboSchemaRegisterUtils.BuildObjectSchema <WboSchema>(type); os.Src = src; os.AssemblyCategory = AssemblyCategory.DotNet; os.AssemblyFile = filePath; if (!WboSchemaContainer.Instance().Contains(os.Id)) { WboSchemaContainer.Instance().AddItem(os.Id, os); } else { WboSchemaContainer.Instance().UpdateItem(os.Id, os); } }
public T GetObject <T>(string objectName) { string comId = WboSchemaRegisterUtils.getTypeRegId(typeof(T)); if (!WboSchemaContainer.Instance().Contains(comId)) { throw new E_UmcNotFindRegObjcect(comId); } WboSchema objectSchema = WboSchemaContainer.Instance().GetItem(comId); object obj = GetObject(objectName, objectSchema); if (obj == null) { throw new E_UmcNotFindRegObjcect(objectName); } if (!(obj is T)) { throw new E_UmcNoMatchObjectType(obj.GetType().ToString() + ":" + typeof(T).ToString()); } return((T)obj); }
protected BaseWboProxy(string objectTypeName) { this.wboSchema = WboSchemaContainer.Instance().GetItem(objectTypeName); loadAssembly(); }