public HttpResponseMessage Search() { bal = new T_Planing_Action_AfterRemovalBAL(); ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; T_Planing_Action_AfterRemovalDTO dto = null; List <T_Planing_Action_AfterRemovalDTO> objList = null; try { var context = HttpContext.Current; dto = ConvertX.GetReqeustForm <T_Planing_Action_AfterRemovalDTO>(); objList = bal.FindByObjList(dto); foreach (T_Planing_Action_AfterRemovalDTO mainDTO in objList) { //Find detail and push to main object in list T_Planing_Action_AfterRemovalDTO detailDTO = new T_Planing_Action_AfterRemovalDTO(); detailDTO.PID = mainDTO.PID; detailDTO = bal.FindByPK(detailDTO); mainDTO.RepairLength = detailDTO.RepairLength; mainDTO.WallThicknessNumber = detailDTO.WallThicknessNumber; mainDTO.RepairLength = detailDTO.RepairLength; mainDTO.DefectList = detailDTO.DefectList; mainDTO.WallThicknessList = detailDTO.WallThicknessList; if (!ObjUtil.isEmpty(mainDTO.UploadFileList)) { foreach (T_Planing_File file in mainDTO.UploadFileList) { file.HtmlFile = System.Web.VirtualPathUtility.ToAbsolute(planPath + "/" + file.PID + "/" + file.UploadType + "/" + file.FileName); string fullPath = context.Server.MapPath(planPath) + @"\" + file.PID + @"\" + file.UploadType + @"\" + file.FileName; file.Base64File = Utility.convertFileToBase64(fullPath); } } } response.statusCode = true; response.data = objList; } catch (Exception ex) { logger.error("Search error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }
public T[] GetTargets <T>() where T : class { if (_searchBy == SearchBy.Nothing) { var targ = ObjUtil.GetAsFromSource <T>(_target, true); return(targ != null ? new T[] { targ } : ArrayUtil.Empty <T>()); } else { return(ObjUtil.FindAll <T>(_searchBy, _queryString)); } }
public HttpResponseMessage Search() { var deserializer = new JavaScriptSerializer(); bal = new T_Planing_Action_SiteRecoveryBAL(); ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; T_Planing_Action_SiteRecoveryDTO dto = null; List <T_Planing_Action_SiteRecoveryDTO> objList = null; try { var context = HttpContext.Current; dto = ConvertX.GetReqeustForm <T_Planing_Action_SiteRecoveryDTO>(); logger.debug("Search dto :" + dto.ToString()); objList = bal.FindByObjList(dto); foreach (T_Planing_Action_SiteRecoveryDTO mainDTO in objList) { //Find detail and push to main object in list T_Planing_Action_SiteRecoveryDTO detailDTO = new T_Planing_Action_SiteRecoveryDTO(); detailDTO.PID = mainDTO.PID; detailDTO = bal.FindByPK(detailDTO); mainDTO.UploadFileList = detailDTO.UploadFileList; mainDTO.LogApporveHistorys = detailDTO.LogApporveHistorys; if (!ObjUtil.isEmpty(mainDTO.UploadFileList)) { foreach (T_Planing_File file in mainDTO.UploadFileList) { file.HtmlFile = System.Web.VirtualPathUtility.ToAbsolute(planPath + "/" + file.PID + "/" + file.UploadType + "/" + file.FileName); string fullPath = context.Server.MapPath(planPath) + @"\" + file.PID + @"\" + file.UploadType + @"\" + file.FileName; file.Base64File = Utility.convertFileToBase64(fullPath); } } } response.statusCode = true; response.data = objList; } catch (Exception ex) { logger.error("Search error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }
private static void UpdateTargetFromSource(SerializedProperty property, TargetSource esrc, System.Type targetType) { switch (esrc) { case TargetSource.Arg: { property.objectReferenceValue = null; } break; case TargetSource.Self: { UnityEngine.Object obj = property.serializedObject.targetObject; if (targetType != null) { obj = ObjUtil.GetAsFromSource(targetType, obj) as UnityEngine.Object; } property.objectReferenceValue = obj; } break; case TargetSource.Root: { UnityEngine.Object obj = property.serializedObject.targetObject; var go = GameObjectUtil.GetGameObjectFromSource(obj); if (go != null) { obj = go.FindRoot(); } if (targetType != null) { obj = ObjUtil.GetAsFromSource(targetType, obj) as UnityEngine.Object; } property.objectReferenceValue = obj; } break; case TargetSource.Config: { if (property.objectReferenceValue == null) { UnityEngine.Object obj = property.serializedObject.targetObject; if (targetType != null) { obj = ObjUtil.GetAsFromSource(targetType, obj) as UnityEngine.Object; } property.objectReferenceValue = obj; } } break; } }
public static void DestroyTarget(object target) { var go = GameObjectUtil.GetGameObjectFromSource(target); if (go != null) { ObjUtil.SmartDestroy(go); } else if (target is UnityEngine.Object) { ObjUtil.SmartDestroy(target as UnityEngine.Object); } }
protected void SetObjectData(object obj) { if (_bundle == null) { return; } var pobj = ObjUtil.GetAsFromSource <IPersistantAsset>(obj); if (pobj != null) { pobj.OnDeserialize(_info, _context, _bundle); } }
public IEntityComponent AddComponent(Type tp) { if (tp == null) { throw new ArgumentNullException("tp"); } if (!typeof(IEntityComponent).IsAssignableFrom(tp)) { throw new ArgumentException("Type must implement IEntityComponent."); } IEntityComponent comp = this.GetComponent(tp); if (comp != null) { return(comp); } try { comp = System.Activator.CreateInstance(tp) as IEntityComponent; } catch { return(null); } if (comp is EntityComponent) { _lst.Add(comp); (comp as EntityComponent).OnAddedToEntity(_owner); } else { var meth = ObjUtil.ExtractDelegate <Action <Entity> >(comp, EntityConstants.MSG_ONADDEDTOENTITY); if (meth != null) { _lst.Add(comp); meth(_owner); } else { throw new EntityComponentMalformedException("Custom rolled IEntityComponents must contain a 'OnAddedToEntity' method present as a member."); } } _owner.OnComponentAdd(comp); return(comp); }
internal void OnComponentAdd(IEntityComponent comp) { var meth = ObjUtil.ExtractDelegate <Action <GameTime> >(comp, EntityConstants.MSG_UPDATE); if (meth != null) { _updateDelegates += meth; } if (_manager != null) { _manager.RegisterComponent(comp); } }
protected override void OnSPInspectorGUI() { this.serializedObject.Update(); this.DrawDefaultInspectorExcept(PROP_WAYPOINTS); //clean nodes for(int i = 0; i < _nodesProp.arraySize; i++) { if(_nodesProp.GetArrayElementAtIndex(i).FindPropertyRelative(PROP_NODE_TRANSFORM).objectReferenceValue == null) { _nodesProp.DeleteArrayElementAtIndex(i); i--; } } //_currentNodes = this.GetCurrentNodes(); if (_nodesProp.arraySize != _lastNodeCache.Count || !_lastNodeCache.SequenceEqual(_currentNodes)) { //delete any nodes that are no longer in the collection for (int i = 0; i < _lastNodeCache.Count; i++ ) { if(_lastNodeCache[i] != null && !_currentNodes.Contains(_lastNodeCache[i]) && _lastNodeCache[i].parent == _targ.transform) { ObjUtil.SmartDestroy(_lastNodeCache[i].gameObject); } } //update cache _lastNodeCache.Clear(); _lastNodeCache.AddRange(_currentNodes); //update names var rx = new Regex(@"^Node\d+$"); for(int i = 0; i < _lastNodeCache.Count; i++) { var node = _lastNodeCache[i]; var nm = "Node" + i.ToString("000"); if (node != null && node.parent == _targ.transform && node.name != nm && rx.IsMatch(node.name)) { node.name = nm; } } } _nodeList.DoLayoutList(); this.serializedObject.ApplyModifiedProperties(); }
public override int SenseAll <T>(ICollection <T> lst, System.Func <T, bool> p = null) { if (lst == null) { throw new System.ArgumentNullException("lst"); } if (lst.IsReadOnly) { throw new System.ArgumentException("List to fill can not be read-only.", "lst"); } if (_intersectingColliders.Count == 0) { return(0); } if (p == null && !_requiresLineOfSight) { int cnt = 0; var e = _intersectingColliders.GetEnumerator(); while (e.MoveNext()) { var a = ColliderAspect.GetAspect(e.Current); var o = ObjUtil.GetAsFromSource <T>(a); if (o != null) { lst.Add(o); cnt++; } } return(cnt); } else { var e = _intersectingColliders.GetEnumerator(); int cnt = 0; while (e.MoveNext()) { var a = ColliderAspect.GetAspect(e.Current); var o = ObjUtil.GetAsFromSource <T>(a); if ((p == null || p(o)) && (!_requiresLineOfSight || this.IsLineOfSight(e.Current))) { lst.Add(e.Current as T); cnt++; } } return(cnt); } }
public HttpResponseMessage Search() { var deserializer = new JavaScriptSerializer(); bal = new T_PlaningBAL(); ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; T_PlaningDTO dto = null; List <T_PlaningDTO> objList = null; try { var context = HttpContext.Current; dto = ConvertX.GetReqeustForm <T_PlaningDTO>(); logger.debug("Search dto :" + dto.ToString()); objList = bal.FindByObjList(dto); if (!ObjUtil.isEmpty(objList)) { foreach (T_PlaningDTO obj in objList) { obj.SpecSDate = ConvertX.DDMMYY(obj.SpecSDate); obj.SpecEDate = ConvertX.DDMMYY(obj.SpecEDate); obj.POSDate = ConvertX.DDMMYY(obj.POSDate); obj.POEDate = ConvertX.DDMMYY(obj.POEDate); obj.ActionSDate = ConvertX.DDMMYY(obj.ActionSDate); obj.ActionEDate = ConvertX.DDMMYY(obj.ActionEDate); } } response.statusCode = true; response.data = objList; } catch (Exception ex) { logger.error("Search error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }
public void Insert(int index, IPostProcessingEffect item) { if (item == null) { throw new System.ArgumentNullException("item"); } var obj = ObjUtil.GetAsFromSource <UnityEngine.Object>(item); if (obj == null) { throw new System.ArgumentException("item must be a UnityEngine.Object", "value"); } _owner._globalEffects.Insert(index, obj); _owner.EffectsListChanged(); }
public void SyncTriggers() { using (var lst = TempCollection.GetList <Collider>()) { this.GetComponentsInChildren <Collider>(true, lst); //purge entries if necessary if (_colliders.Count > 0) { using (var purge = TempCollection.GetList <Collider>()) { var ed = _colliders.GetEnumerator(); while (ed.MoveNext()) { if (!ObjUtil.IsObjectAlive(ed.Current.Key) || ed.Current.Value == null || !lst.Contains(ed.Current.Key)) { purge.Add(ed.Current.Key); ObjUtil.SmartDestroy(ed.Current.Value); } } if (purge.Count > 0) { var e = purge.GetEnumerator(); while (e.MoveNext()) { _colliders.Remove(e.Current); } } } } //fill unknowns if (lst.Count > 0) { var e = lst.GetEnumerator(); while (e.MoveNext()) { if (!_colliders.Contains(e.Current)) { var m = e.Current.AddComponent <CompoundTriggerMember>(); m.Init(this, e.Current); _colliders.Add(e.Current, m); } } } } }
public IPostProcessingEffect this[int index] { get { return(_owner._globalEffects[index] as IPostProcessingEffect); } set { if (value == null) { throw new System.ArgumentNullException("value"); } var obj = ObjUtil.GetAsFromSource <UnityEngine.Object>(value); if (obj == null) { throw new System.ArgumentException("value must be a UnityEngine.Object", "value"); } _owner._globalEffects[index] = obj; } }
protected virtual void DoDragAndDrop(SerializedProperty property, Rect listArea) { if (Event.current == null) { return; } var ev = Event.current; switch (ev.type) { case EventType.DragUpdated: case EventType.DragPerform: { if (listArea.Contains(ev.mousePosition)) { var refs = (from o in DragAndDrop.objectReferences let obj = ObjUtil.GetAsFromSource <AnimationClip>(o) where obj != null select obj); DragAndDrop.visualMode = refs.Any() ? DragAndDropVisualMode.Link : DragAndDropVisualMode.Rejected; if (ev.type == EventType.DragPerform && refs.Any()) { DragAndDrop.AcceptDrag(); var names = _animList.serializedProperty.EnumerateArray().Select(o => o.FindPropertyRelative("_name").stringValue).ToHashSet(); foreach (var clip in refs) { var stateprop = this.AddNewState(_animList); stateprop.FindPropertyRelative("_clip").objectReferenceValue = clip; string nm = clip.name; string format = nm + "{0:00}"; int cnt = 0; while (names.Contains(nm)) { nm = string.Format(format, ++cnt); } stateprop.FindPropertyRelative("_name").stringValue = nm; } GUI.changed = true; } } } break; } }
public static void Init() { if (!object.ReferenceEquals(_instance, null)) { if (ObjUtil.IsDestroyed(_instance)) { ObjUtil.SmartDestroy(_instance.gameObject); _instance = null; } else { return; } } _instance = Services.Create <SPTween>(true, SPECIAL_NAME); }
public bool ApplyToGlobal() { var asset = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset").FirstOrDefault(); if (asset == null) { return(false); } var settings = ScriptableObject.CreateInstance <InputSettings>(); try { var serializedObject = new SerializedObject(asset); var axes = serializedObject.FindProperty(PROP_AXES); axes.arraySize = _entries.Count; for (int i = 0; i < _entries.Count; i++) { var axis = axes.GetArrayElementAtIndex(i); var config = _entries[i]; axis.FindPropertyRelative(PROP_TYPE).enumValueIndex = (int)config.Type; axis.FindPropertyRelative(PROP_NAME).stringValue = config.Name; axis.FindPropertyRelative(PROP_DESCRIPTIVENAME).stringValue = config.DescriptiveName; axis.FindPropertyRelative(PROP_DESCRIPTIVENEGATIVENAME).stringValue = config.DescriptiveNameNegative; axis.FindPropertyRelative(PROP_NEGATIVEBUTTON).stringValue = config.NegativeButton; axis.FindPropertyRelative(PROP_POSITIVEBUTTON).stringValue = config.PositiveButton; axis.FindPropertyRelative(PROP_ALTNEGATIVEBUTTON).stringValue = config.AltNegativeButton; axis.FindPropertyRelative(PROP_ALTPOSITIVEBUTTON).stringValue = config.AltPositiveButton; axis.FindPropertyRelative(PROP_GRAVITY).floatValue = config.Gravity; axis.FindPropertyRelative(PROP_DEAD).floatValue = config.Dead; axis.FindPropertyRelative(PROP_SENSITIVITY).floatValue = config.Sensitivity; axis.FindPropertyRelative(PROP_SNAP).boolValue = config.Snap; axis.FindPropertyRelative(PROP_INVERT).boolValue = config.Invert; axis.FindPropertyRelative(PROP_AXIS).enumValueIndex = (int)config.Axis; axis.FindPropertyRelative(PROP_JOYNUM).enumValueIndex = (int)config.JoyNum; } serializedObject.ApplyModifiedProperties(); return(true); } finally { ObjUtil.SmartDestroy(settings); } }
private static void ApplyDefaultAsSingle(SerializedProperty property, System.Type fieldType, string name, bool bUseEntity) { if (fieldType == null) { return; } var targ = GameObjectUtil.GetGameObjectFromSource(property.serializedObject.targetObject); if (targ == null) { return; } if (bUseEntity) { targ = targ.FindRoot(); } if (TypeUtil.IsType(fieldType, typeof(VariantReference))) { var variant = EditorHelper.GetTargetObjectOfProperty(property) as VariantReference; if (variant != null && variant.Value == null && variant.ValueType == VariantType.GameObject) { var go = targ.FindByName(name); if (go != null) { variant.GameObjectValue = go; property.serializedObject.Update(); return; } } } else if (property.objectReferenceValue == null) { foreach (var obj in targ.transform.FindAllByName(name)) { var o = ObjUtil.GetAsFromSource(fieldType, obj) as UnityEngine.Object; if (o != null) { property.objectReferenceValue = o; property.serializedObject.ApplyModifiedProperties(); return; } } } }
public void DestroyTarget(object target) { if (target is IProxy) { target = (target as IProxy).GetTarget(); } var go = GameObjectUtil.GetGameObjectFromSource(target); if (go != null) { ObjUtil.SmartDestroy(go); } else if (target is UnityEngine.Object) { ObjUtil.SmartDestroy(target as UnityEngine.Object); } }
public System.Type GetTargetType() { if (_memberName == null) { return(typeof(object)); } if (_target is IProxy) { var tp = (_target as IProxy).GetTargetType(); return(DynamicUtil.GetReturnType(DynamicUtil.GetMemberFromType(tp, _memberName, false)) ?? typeof(object)); } else { return(DynamicUtil.GetReturnType(DynamicUtil.GetMember(ObjUtil.ReduceIfProxy(_target), _memberName, false)) ?? typeof(object)); } }
public HttpResponseMessage GetProgressPlan() { bal = new T_PlaningBAL(); T_PlaningDTO dto = null; List <ColumnReportDTO> objList = null; ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; try { var context = HttpContext.Current; dto = ConvertX.GetReqeustForm <T_PlaningDTO>(); string RoleLevel = context.Request.Form["RoleLevel"]; if (ObjUtil.isEmpty(RoleLevel)) { throw new Exception("RoleLevel is require"); } if (RoleLevel == "1") { string UserID = context.Request.Form["UserID"]; if (ObjUtil.isEmpty(UserID)) { throw new Exception("UserID is require"); } dto.CreateBy = UserID; dto.UpdateBy = UserID; } T_PlaningBAL bal = new T_PlaningBAL(); objList = bal.GetGraphProgress(dto); response.statusCode = true; response.data = objList; } catch (Exception ex) { logger.error("GetProgressPlan error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }
public IEnumerable <T> GetAllAssets <T>() where T : class { if (!_clean) { this.SetupTable(); } var e = _table.Values.GetEnumerator(); while (e.MoveNext()) { var obj = ObjUtil.GetAsFromSource <T>(e.Current); if (!object.ReferenceEquals(obj, null)) { yield return(obj); } } }
/// <summary> /// Returns an InputSettings object for the current configuration in the global unity InputSettings. /// /// 'cleanInputConfigs' will clean up the input data pulled from the global settings, removing unnecessary /// data for inputs that don't need said data (example Gravity only applies to button/key configs, so is /// removed from non-button/key configs). /// </summary> /// <param name="cleanInputConfigs">Clean up the input data pulled from the global settings.</param> /// <returns></returns> public static InputSettings LoadGlobalInputSettings(bool cleanInputConfigs = false) { var asset = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset").FirstOrDefault(); if (asset == null) { return(null); } var settings = ScriptableObject.CreateInstance <InputSettings>(); if (!settings.CopyFromGlobal(cleanInputConfigs)) { ObjUtil.SmartDestroy(settings); settings = null; } return(settings); }
protected override void Awake() { base.Awake(); if (!(this is T)) { if (_destroyIfMultiple) { ObjUtil.SmartDestroy(this); } return; } if (this.ValidateService()) { this.OnValidAwake(); } }
private void OnComponentDestroyed(object sender, System.EventArgs e) { GameLoopEntry.LevelWasLoaded -= this.OnLevelWasLoaded; this.RemoveThisAsSingleton(); //if this isn't on the GameObjectSource, we should check if we need to delete our GameObject. if (!GameLoopEntry.ApplicationClosing) { if (_target.gameObject != null && _target.gameObject != Singleton.GameObjectSource) { var others = _target.gameObject.GetComponents <Singleton>(); if (!(others.Length > 1 && !(from s in others select s.LifeCycle.HasFlag(SingletonLifeCycleRule.LivesForever)).Any())) { ObjUtil.SmartDestroy(_target.gameObject); } } } }
public static void Unregister <T>(bool destroyIfCan = false, bool donotSignalUnregister = false) where T : class, IService { var inst = Entry <T> .Instance; if (!inst.IsNullOrDestroyed()) { Entry <T> .Instance = null; if (!donotSignalUnregister) { inst.SignalServiceUnregistered(); } if (destroyIfCan && inst is UnityEngine.Object) { ObjUtil.SmartDestroy(inst as UnityEngine.Object); } } }
public static void Init() { if (!object.ReferenceEquals(_instance, null)) { if (ObjUtil.IsDestroyed(_instance)) { ObjUtil.SmartDestroy(_instance.gameObject); _instance = null; } else { return; } } _instance = Services.Create <SPTween>(true, SPECIAL_NAME); //_instance = Singleton.CreateSpecialInstance<SPTween>(SPECIAL_NAME, SingletonLifeCycleRule.LivesForever); }
public bool SetValue(object value) { if (_target == null) { return(false); } var obj = ObjUtil.ReduceIfProxy(_target); if (obj == null) { return(false); } else { return(DynamicUtil.SetValue(_target, _memberName, value)); } }
public object GetValue() { if (_target == null) { return(null); } var obj = ObjUtil.ReduceIfProxy(_target); if (obj == null) { return(null); } else { return(DynamicUtil.GetValue(obj, _memberName)); } }
public HttpResponseMessage View() { var deserializer = new JavaScriptSerializer(); bal = new T_PlaningBAL(); ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; T_PlaningDTO dto = null; List <T_PlaningDTO> objList = null; try { var context = HttpContext.Current; dto = ConvertX.GetReqeustForm <T_PlaningDTO>(); if (dto.Year == null || "".Equals(dto.Year)) { dto.Year = DateTime.Now.Year.ToString(); } string UserID = context.Request.Form["UserID"]; if (ObjUtil.isEmpty(UserID)) { throw new Exception("UserID is require"); } dto.CreateBy = UserID; dto.UpdateBy = UserID; logger.debug("View dto :" + dto.ToString()); objList = bal.FindByObjListV2(dto); response.statusCode = true; response.data = objList; } catch (Exception ex) { logger.error("View error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }