public int update(Object_Type object_Type) { db.Connection.Open(); int result = db.Connection.Execute(StoreProcedureNames.Object_Type.Update, new { Id = object_Type.id, Name = object_Type.Name, Description = object_Type.Description }, commandType: CommandType.StoredProcedure); db.Connection.Close(); return(result); }
public int delete(Object_Type object_Type) { db.Connection.Open(); var result = db.Connection.Execute(StoreProcedureNames.Object_Type.Delete, new { Id = object_Type.id }, commandType: CommandType.StoredProcedure); db.Connection.Close(); return(result); }
public ActionResult <object> Update(Object_Type object_Type) { AppDB db = provider.GetRequiredService <AppDB>(); Object_TypeDA object_TypeDA = new Object_TypeDA(db); var res = object_TypeDA.update(object_Type); return(new { result = res }); }
public Ns(string name, Type type) : this(name) { if (type == null) { throw new Exception("Type " + name + " does not resolve to a type"); } this.type = type; this.objType = ReflectionHelper.Instance.GetObjectType(type); }
private Ns Lookup(Type type) { Object_Type ot = ReflectionHelper.Instance.GetObjectType(type); if (ot == Object_Type.Enum) { Type t = Enum.GetUnderlyingType(type); Ns ns = reverseNsLookup[t]; return(new Ns(ns.Name, t, Object_Type.Enum)); } return(reverseNsLookup[type]); }
private void ProcessCollection(object obj, Type type, object value, bool preferBinarySerialization) { Object_Type ot = ReflectionHelper.Instance.GetObjectType(type); ProcessCollectionCallback callback = new ProcessCollectionCallback(GetNamespace); switch (ot) { case Object_Type.Array: case Object_Type.List: { IEnumerator e = ((IList)value).GetEnumerator(); while (e.MoveNext()) { callback(obj, e.Current.GetType(), e.Current, preferBinarySerialization); } } break; case Object_Type.Dictionary: { IDictionaryEnumerator e = ((IDictionary)value).GetEnumerator(); while (e.MoveNext()) { callback(obj, e.Key.GetType(), e.Key, preferBinarySerialization); callback(obj, e.Value.GetType(), e.Value, preferBinarySerialization); } } break; default: { throw new Exception("Collection type not implemented"); } } }
protected void GetNamespace(object objectToSerialize, Type type, object value, bool preferBinarySerialization) { //we do this because the type of value may not be the type //if (value != null) // type = value.GetType(); Object_Type ot = ReflectionHelper.Instance.GetObjectType(type); switch (ot) { case Object_Type.Struct: case Object_Type.Class: { if (!allTypes.Contains(type)) { allTypes.Add(type); } if (!Serializer.HasSerializer(type, preferBinarySerialization)) { if (value != null) { GetNamespaces(value); } } } break; case Object_Type.Primitive: { if (!allTypes.Contains(type)) { allTypes.Add(type); } } break; case Object_Type.Enum: { Type t = Enum.GetUnderlyingType(type); if (!allTypes.Contains(t)) { allTypes.Add(t); } } break; case Object_Type.List: case Object_Type.Dictionary: case Object_Type.Array: { if (!allTypes.Contains(type)) { allTypes.Add(type); } if (value != null) { ProcessCollection(objectToSerialize, type, value, preferBinarySerialization); } } break; default: //only time this is known to happen if the property is an interface and is assigned a value of null if (!allTypes.Contains(type)) { allTypes.Add(type); } break; } }
private void Update() { //Checking whether pointer is over UI Gameobject or not.. if (EventSystem.current.IsPointerOverGameObject()) { return; } //Spawnning and Destroying Selected Object in the Scene.. #region Objects if (Object_Spawn == null) { return; } else { //Instantiating Objects. #region Instantiating Objects if (Input.GetMouseButtonDown(0)) { var Inputpos = Camera.main.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D Hit = Physics2D.Raycast(Inputpos, Camera.main.transform.forward); if (Hit.collider.gameObject.CompareTag("Grid")) { //Spawnning Start Position if it is not Spawnned. if (Object_Spawn.name == "StartPosition" && !StartPoint_Spawnned && Object_Spawn != null) { Object_Spawn_Ref = Instantiate(Object_Spawn, Hit.collider.GetComponent <Transform>().position, Quaternion.identity); StartPoint_Spawnned = true; } //Spawnning End Position if it is not Spawnned. else if (Object_Spawn.name == "EndPosition" && !EndPoint_Spawnned && Object_Spawn != null) { Object_Spawn_Ref = Instantiate(Object_Spawn, Hit.collider.GetComponent <Transform>().position, Quaternion.identity); EndPoint_Spawnned = true; } //Spawnning Other Objects else if (Object_Spawn.name == "Coins" || Object_Spawn.name == "Platform" && Object_Spawn != null) { Object_Spawn_Ref = Instantiate(Object_Spawn, Hit.collider.GetComponent <Transform>().position, Quaternion.identity); } else { return; } Object_Spawn_Ref.transform.SetParent(Object_Spawn_Holder); //Add Data to List When Object get Instantiated. #region Data Manipulation //Taking References var Obj = Object_Spawn_Ref.GetComponent <Object_Ref>().Object_Info_Struct; //Position Reference.. float X = Object_Spawn_Ref.transform.position.x; float Y = Object_Spawn_Ref.transform.position.y; Vector2 Obj_Pos = new Vector2(X, Y); //Object Type Reference Object_Type Obj_Type_Ref = Obj.Obj_Type; //Creating new Object Object_Ref.Object_Info Obj_Info = new Object_Ref.Object_Info(); //Setting Values Obj_Info.Obj_Type = Obj_Type_Ref; Obj_Info.Object_Position = Obj_Pos; //Adding the Object Data to the List Go_Pos.Add(Obj_Info); #endregion } else { return; } } #endregion //Destroying Objects #region Destroying Objects if (Input.GetMouseButtonDown(1)) { var Inputpos_Destroy = Camera.main.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D Hit_Destroy = Physics2D.Raycast(Inputpos_Destroy, Camera.main.transform.forward); if (Hit_Destroy.collider.gameObject.CompareTag("Grid")) { return; } else if (Hit_Destroy.collider.gameObject.CompareTag("Start")) { Destroy(Hit_Destroy.collider.gameObject); StartPoint_Spawnned = false; } else if (Hit_Destroy.collider.gameObject.CompareTag("End")) { Destroy(Hit_Destroy.collider.gameObject); EndPoint_Spawnned = false; } else { Destroy(Hit_Destroy.collider.gameObject); } //Removes Data from List When Object gets Deleted. #region Data Manipulation //Taking References var Obj = Hit_Destroy.collider.GetComponent <Object_Ref>().Object_Info_Struct; //Position Reference.. float X = Hit_Destroy.collider.transform.position.x; float Y = Hit_Destroy.collider.transform.position.y; Vector2 Obj_Pos = new Vector2(X, Y); //Object Type Reference Object_Type Obj_Type_Ref = Obj.Obj_Type; //Creating new Object Object_Ref.Object_Info Obj_Info = new Object_Ref.Object_Info(); //Setting Values Obj_Info.Obj_Type = Obj_Type_Ref; Obj_Info.Object_Position = Obj_Pos; //Removing From the deleted Object Data from the List Go_Pos.Remove(Obj_Info); #endregion } #endregion } #endregion }
private void AddFromRecordSet(SQLiteDataReader rs) { try { if (!rs.IsDBNull(0)) { _name = rs.GetString(0); } if (!rs.IsDBNull(1)) { _object_id = rs.GetInt32(1); } if (!rs.IsDBNull(2)) { _principal_id = rs.GetInt32(2); } if (!rs.IsDBNull(3)) { _schema_id = rs.GetInt32(3); } if (!rs.IsDBNull(4)) { _parent_object_id = rs.GetInt32(4); } if (!rs.IsDBNull(5)) { _type = (Object_Type)Enum.Parse(typeof(Object_Type), rs.GetString(5)); } if (!rs.IsDBNull(6)) { _type_desc = rs.GetString(6); } if (!rs.IsDBNull(7)) { _create_date = rs.GetDateTime(7); } if (!rs.IsDBNull(8)) { _modify_date = rs.GetDateTime(8); } if (!rs.IsDBNull(9)) { _is_ms_shipped = rs.GetBoolean(9); } if (!rs.IsDBNull(10)) { _is_published = rs.GetBoolean(10); } if (!rs.IsDBNull(11)) { _is_schema_published = rs.GetBoolean(11); } if (!rs.IsDBNull(12)) { _unique_index_id = rs.GetInt32(12); } if (!rs.IsDBNull(13)) { _is_system_named = rs.GetBoolean(13); } } catch (Exception) { throw; } }
public Base_Object(string n, string d) { type = Object_Type.OBJ_BASE; name = n; desc = d; }
public Base_Object() { type = Object_Type.OBJ_BASE; name = "Unknown"; desc = "Unknown"; }
private void SerializeCollection(object obj, XElement parent, string name, Type type, object value, bool preferBinarySerialization) { Ns ns = Lookup(type); Object_Type ot = ns.ObjectType; XElement collectionElement = null; //first thing to do is create the base element that will hold the collection items switch (ot) { case Object_Type.List: case Object_Type.Dictionary: { collectionElement = XHelper.CreateElement(parent, ns.Name, name); } break; case Object_Type.Array: { int dimensions = type.GetArrayRank(); Array a = (Array)value; string dimensionsLengthString = string.Empty; for (int i = 0; i < dimensions; i++) { dimensionsLengthString += (a.GetLength(i).ToString() + ";"); } dimensionsLengthString = dimensionsLengthString.TrimEnd(new char[] { ';' }); collectionElement = XHelper.CreateElement(parent, ns.Name, name, null, new Dictionary <string, object>() { { "Dimensions", dimensionsLengthString } }); } break; default: { throw new Exception("Collection type not implemented"); } } SerializeCollectionCallback callback = new SerializeCollectionCallback(SerializeListCallback); //now iterate through the items and call a callback on each one switch (ot) { case Object_Type.Array: case Object_Type.List: { XElement valuesElement = XHelper.CreateElement(collectionElement, null, "Values"); IEnumerator e = ((IList)value).GetEnumerator(); while (e.MoveNext()) { callback(obj, valuesElement, e.Current, preferBinarySerialization); } } break; case Object_Type.Dictionary: { XElement keysElement = XHelper.CreateElement(collectionElement, null, "Keys"); XElement valuesElement = XHelper.CreateElement(collectionElement, null, "Values"); IDictionaryEnumerator e = ((IDictionary)value).GetEnumerator(); while (e.MoveNext()) { callback(obj, keysElement, e.Key, preferBinarySerialization); callback(obj, valuesElement, e.Value, preferBinarySerialization); } } break; default: { throw new Exception("Collection type not implemented"); } } }
protected void GetMember(object objectToSerialize, string name, Type type, object value, XElement e, bool preferBinarySerialization) { //this happens when the type of the member is different to the type of the value assigned to it //for example a member might be declared as a base class or interface and have a derived class assigned to it Type valType; if (value != null && (valType = value.GetType()) != type) { type = valType; } Ns ns = Lookup(type); Object_Type ot = ns.ObjectType; switch (ot) { case Object_Type.Struct: case Object_Type.Class: { bool isShared = Attribute.IsDefined(ns.Type, typeof(SerializeAsSharedObject), true); if (isShared) { //first thing we do is create an element that links this value to the shared object XElement assetObjectElement = XHelper.CreateElement(e, ns.Name, name); if (value == null) { XHelper.CreateAttribute(assetObjectElement, "ID", "null"); return; } byte[] hash = MD5.Create().ComputeHash(BitShifter.ToByte(value.GetHashCode())); //prefix with an X to make sure first character is a letter in accordance with XML standard string s = "X" + string.Concat(hash.Select(x => x.ToString("X2"))); XHelper.CreateAttribute(assetObjectElement, "ID", s); //then we actually create the shared object if it has not already been created if (!checksums.Contains(s)) { checksums.Add(s); XElement sharedObjectElement = XHelper.CreateElement(sharedElement, ns.Name, s); if (!Serializer.HasSerializer(type, preferBinarySerialization)) { if (value != null) { GetMembers(value, sharedObjectElement); } else { CreateValue(sharedObjectElement, type, value, false); } } else { CreateValue(sharedObjectElement, type, value, preferBinarySerialization); } } } else { //if this class has a serializer, use it, otherwise we recurse through the objects members and serialize the items individually if (!Serializer.HasSerializer(type, preferBinarySerialization)) { if (value != null) { GetMembers(value, XHelper.CreateElement(e, ns.Name, name)); } else { CreateValue(XHelper.CreateElement(e, ns.Name, name), type, value, false); } } else { CreateValue(XHelper.CreateElement(e, ns.Name, name), type, value, preferBinarySerialization); } } } break; case Object_Type.Primitive: { //any types that are Object_Type.Primitive have a built in serializer. so we know they can always be serialized CreateValue(XHelper.CreateElement(e, ns.Name, name), type, value, preferBinarySerialization); } break; case Object_Type.Enum: { //any types that are Object_Type.Enum use the built in IntSerializer. so we know they can always be serialized CreateValue(XHelper.CreateElement(e, ns.Name, name), ns.Type, value, preferBinarySerialization); } break; case Object_Type.List: case Object_Type.Dictionary: case Object_Type.Array: { //for collections. we need to iterate through the items and serialize each one //but we need to set this up recursively, in case the items in a collection are themselves collections if (value != null) { if (!Serializer.HasSerializer(type, preferBinarySerialization)) { SerializeCollection(objectToSerialize, e, name, type, value, preferBinarySerialization); } else { CreateValue(XHelper.CreateElement(e, ns.Name, name), type, value, preferBinarySerialization); } } else { CreateValue(XHelper.CreateElement(e, ns.Name, name), type, value, preferBinarySerialization); } } break; default: CreateValue(XHelper.CreateElement(e, ns.Name, name), type, null, preferBinarySerialization); //if we can't determine the object type, just serialize it as null break; } }
protected object SetMember(XElement e, bool isBinarySerialized) { Ns ns = deserializeNamespaceLookup[e.GetPrefixOfNamespace(e.Name.Namespace)]; Object_Type ot = ns.ObjectType; switch (ot) { case Object_Type.Struct: case Object_Type.Class: { bool isShared = Attribute.IsDefined(ns.Type, typeof(SerializeAsSharedObject), true); if (isShared) { string val = e.Attribute("ID").Value; if (val == "null") { return(null); } else { return(sharedObjects[val]); } } if (!Serializer.HasSerializer(ns.Type, isBinarySerialized)) { //In this case the serialized object had a value of null, so we just return null if (e.Attribute("Value") != null && e.Attribute("Value").Value == "null") { return(null); } else { object instance = Activator.CreateInstance(ns.Type); SetMembers(instance, e); return(instance); } } else { if (isBinarySerialized) { XCData cdataNode = e.FirstNode as XCData; int length = int.Parse(e.Attribute("Length").Value); byte[] bytes = Convert.FromBase64String(cdataNode.Value); return(Serializer.BinaryDeserialize(ns.Type, new BinarySerializerData(bytes, length))); } else { if (e.Attribute("Value") == null) { Log.Instance.Write(Log_Severity.Warning, "{0} does not appear to be using the built in serializer. Save to update file output", ns.Type.Name); object instance = Activator.CreateInstance(ns.Type); SetMembers(instance, e); return(instance); } return(Serializer.Deserialize(ns.Type, e.Attribute("Value").Value)); } } } case Object_Type.Primitive: { return(Serializer.Deserialize(ns.Type, e.Attribute("Value").Value)); } case Object_Type.Enum: { return(Enum.ToObject(ns.Type, Serializer.Deserialize(typeof(int), e.Attribute("Value").Value))); } case Object_Type.List: case Object_Type.Dictionary: case Object_Type.Array: { if (Serializer.HasSerializer(ns.Type, isBinarySerialized)) { if (isBinarySerialized) { XCData cdataNode = e.FirstNode as XCData; int length = int.Parse(e.Attribute("Length").Value); byte[] bytes = Convert.FromBase64String(cdataNode.Value); return(Serializer.BinaryDeserialize(ns.Type, new BinarySerializerData(bytes, length))); } else { return(Serializer.Deserialize(ns.Type, e.Attribute("Value").Value)); } } else { return(DeserializeCollection(ns, e, isBinarySerialized)); } } default: return(null); } }
public Ns(string name, Type type, Object_Type ot) : this(name) { this.type = type; this.objType = ot; }
private void AddFromRecordSet(SQLiteDataReader rs) { try { if (!rs.IsDBNull(0)) { _name = rs.GetString(0); } if (!rs.IsDBNull(1)) { _object_id = rs.GetInt32(1); } if (!rs.IsDBNull(2)) { _principal_id = rs.GetInt32(2); } if (!rs.IsDBNull(3)) { _schema_id = rs.GetInt32(3); } if (!rs.IsDBNull(4)) { _parent_object_id = rs.GetInt32(4); } if (!rs.IsDBNull(5)) { _type = (Object_Type)Enum.Parse(typeof(Object_Type), rs.GetString(5)); } if (!rs.IsDBNull(6)) { _type_desc = rs.GetString(6); } if (!rs.IsDBNull(7)) { _create_date = rs.GetDateTime(7); } if (!rs.IsDBNull(8)) { _modify_date = rs.GetDateTime(8); } if (!rs.IsDBNull(9)) { _is_ms_shipped = rs.GetBoolean(9); } if (!rs.IsDBNull(10)) { _is_published = rs.GetBoolean(10); } if (!rs.IsDBNull(11)) { _is_schema_published = rs.GetBoolean(11); } if (!rs.IsDBNull(12)) { _referenced_object_id = rs.GetInt32(12); } if (!rs.IsDBNull(13)) { _key_index_id = rs.GetInt32(13); } if (!rs.IsDBNull(14)) { _is_disabled = rs.GetBoolean(14); } if (!rs.IsDBNull(15)) { _is_not_for_replication = rs.GetBoolean(15); } if (!rs.IsDBNull(16)) { _is_not_trusted = rs.GetBoolean(16); } if (!rs.IsDBNull(17)) { _delete_referential_action = rs.GetByte(17); } if (!rs.IsDBNull(18)) { _delete_referential_action_desc = rs.GetString(18); } if (!rs.IsDBNull(19)) { _update_referential_action = rs.GetByte(19); } if (!rs.IsDBNull(20)) { _update_referential_action_desc = rs.GetString(20); } if (!rs.IsDBNull(21)) { _is_system_named = rs.GetBoolean(21); } } catch (Exception) { throw; } }
void Record_Player_Actions() { if (Input.GetKeyDown(KeyCode.E)) { is_grabbing = true; } Select_Time_Point_Slot_Input(); if (Input.GetKeyDown(KeyCode.T)) { Save_Time_Point(selected_time_slot - 1); } Check_If_Present(); if (Input.GetKeyDown(KeyCode.G)) { tm_jump_effect.is_activated = true; } if (Input.GetKeyDown(KeyCode.H)) // Present/Future { tm_jump_effect.is_activated = true; is_jumping_to_present = true; } if (Input.GetKeyDown(KeyCode.R)) // Past/Start { //Reset_Time_Event.Invoke(); } if (tm_jump_effect.has_jump_occured) { tm_jump_effect.has_jump_occured = false; is_jumping = true; is_jumping_to_custom_time_point = true; } // Record Movement if ((current_time >= last_update_time + update_frequency) || is_grabbing) { last_update_time = current_time; //Save_Global_Time_Point(); bool is_seen_by_player_original = false; List <Object_Type> obj_pos_array = new List <Object_Type>(); foreach (var dupe in dupe_objs) { if (dupe.obj != null) { if (dupe.vis.is_seen) { foreach (var cam in dupe.vis.seen_cams) { if (cam.gameObject == player_look_pivot.GetComponentInChildren <Camera>().gameObject) { is_seen_by_player_original = true; Object_Type input_obj = new Object_Type(); input_obj.position = dupe.obj.transform.position; input_obj.tag = dupe.obj.tag; obj_pos_array.Add(input_obj); } } } } } bool is_door_seen_by_player_original = false; List <Door_Data> door_data_list = new List <Door_Data>(); foreach (var door in door_list) { Visible_Check vis_check = door.gameObject.GetComponent <Visible_Check>(); if (door.GetComponentInChildren <Visible_Check>().is_seen) { foreach (var cam in vis_check.seen_cams) { if (cam.gameObject == player_look_pivot.GetComponentInChildren <Camera>().gameObject) { is_door_seen_by_player_original = true; Door_Data record_data = new Door_Data(); record_data.door_activation = door; record_data.door_obj = door.gameObject; record_data.last_state = door.is_open; door_data_list.Add(record_data); } } } } if ((timeline_memory[timeline_memory.Count - 1].position != player_target.position) || (timeline_memory[timeline_memory.Count - 1].view_rotation != player_look_pivot.localRotation) || (is_seen_by_player_original) || (is_grabbing) || (is_door_seen_by_player_original) || (is_jumping)) { if (is_jumping) { Log_Current_Timestamp(); } Add_To_Buffer(player_target.position, player_look_pivot.localRotation, door_data_list.ToArray(), obj_pos_array.ToArray(), current_time, is_jumping, is_grabbing); if (is_jumping) { float time_until_next_loop = (iteration_delay * iteration_num) - current_time; current_time += time_until_next_loop; Debug.Log("Jumped: " + time_until_next_loop); time_point_list[selected_time_slot - 1].timestamp += iteration_delay; int jump_index = selected_time_slot - 1; if (is_jumping_to_custom_time_point) { if (is_jumping_to_present) { jump_index = 10; } else if (is_jumping_to_start) { jump_index = 9; } is_jumping_to_present = false; is_jumping_to_start = false; current_time += time_point_list[jump_index].normalized_timestamp; Debug.Log("Jumped even more: " + time_point_list[jump_index].normalized_timestamp); Skip_Dupes_To_Custom(jump_index); Reset_Objects(time_point_list[jump_index].object_locations); Debug.Log(current_time); } else { Skip_Dupes_To_Custom(jump_index); } Add_To_Buffer(player_target.position, player_look_pivot.localRotation, door_data_list.ToArray(), obj_pos_array.ToArray(), current_time, false, false); is_jumping = false; } if (is_seen_by_player_original) { timeline_memory[last_obj_seen_timestamp].next_obj_seen_timestamp = timeline_memory.Count - 1; last_obj_seen_timestamp = timeline_memory.Count - 1; } if (is_grabbing) { is_grabbing = false; player_obj_holder.trigger_grab = true; } } int num_of_seen_objs = 0; foreach (var obj in dupe_objs) { foreach (var cam in obj.vis.seen_cams) { if (cam.gameObject == player_look_pivot.GetComponentInChildren <Camera>().gameObject) { num_of_seen_objs++; } } } } Check_If_Start(); }