Example #1
0
 public FieldEditor(System.Object data)
 {
     this.data = data;
     _fieldInfos = data.GetType().GetFields(BINDING);
     for (var i = 0; i < _fieldInfos.Length; i++)
         GuiFields.Add(GenerateGUI(_fieldInfos[i]));
 }
        private static void AddClassField(Dictionary <string, string> fieldInfo, System.Object obj)
        {
            System.Reflection.FieldInfo[] informations = obj.GetType().GetFields();

            for (int i = 0; i < informations.Length; i++)
            {
                if (IsComplex(informations[i].GetValue(obj).GetType()))
                {
                    AddClassField(fieldInfo, informations[i].GetValue(obj));
                }
                else
                {
                    if (fieldInfo.ContainsKey(informations[i].Name))
                    {
                        continue;
                    }

                    fieldInfo.Add(informations[i].Name, informations[i].GetValue(obj).ToString() ?? "");
                }
            }
        }
Example #3
0
            public override bool Equals(System.Object obj)
            {
                if (obj == null)
                {
                    return(false);
                }

                if (this == obj)
                {
                    return(true);
                }

                if (obj.GetType() != this.GetType())
                {
                    return(false);
                }

                UriAndFormatType t = (UriAndFormatType)obj;

                return(this.Uri.Equals(t.Uri) && this.Format.Equals(t.Format));
            }
Example #4
0
 public override bool Equals(System.Object righthand)
 {
     if (righthand.GetType() == this.GetType())
     {
         Product other = (Product)righthand;
         if (other == null)
         {
             return(false);
         }
         return(this.ProductID == other.ProductID &&
                this.Title == other.Title &&
                this.Description == other.Description &&
                this.Price == other.Price &&
                this.PriceAsString == other.PriceAsString &&
                this.CurrencySymbol == other.CurrencySymbol &&
                this.CurrencyCode == other.CurrencyCode &&
                this.LocaleIdentifier == other.LocaleIdentifier &&
                this.CountryCode == other.CountryCode);
     }
     return(false);
 }
Example #5
0
        // Utility function to log all public instance property to CustomerBuildEventArgs
        private static void AddAllPropertiesToCustomBuildWithPropertyEventArgs(CustomBuildWithPropertiesEventArgs cbpEventArg, System.Object obj)
        {
#if NET472
            if (obj != null)
            {
                System.Type thisType = obj.GetType();
                cbpEventArg.Add("ArgumentType", thisType.ToString());
                System.Reflection.MemberInfo[] arrayMemberInfo = thisType.FindMembers(System.Reflection.MemberTypes.Property, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, null);
                if (arrayMemberInfo != null)
                {
                    foreach (System.Reflection.MemberInfo memberinfo in arrayMemberInfo)
                    {
                        object val = thisType.InvokeMember(memberinfo.Name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty, null, obj, null, System.Globalization.CultureInfo.InvariantCulture);
                        if (val != null)
                        {
                            cbpEventArg.Add(memberinfo.Name, val);
                        }
                    }
                }
            }
#endif
        }
		/// <summary>
		/// Resolve a cross-scene reference piecewise.  This does the heavy lifting of figuring out how to parse the path.
		/// </summary>
		/// <param name="fromObject">The object that is the source of the cross-scene reference</param>
		/// <param name="toObject">The object that the cross-scene reference is referring to</param>
		/// <param name="fromFieldPath">The path of the field that fromObject uses to point to</param>
		/// <param name="debugThis">Debug information about which cross-scene reference this is coming from</param>
		private static void ResolveInternal( System.Object fromObject, Object toObject, string fromFieldPath, RuntimeCrossSceneReference debugThis )
		{
			// Sub-object path is indicated by a dot
			string[] splitPaths = fromFieldPath.Split('.');

			// Since the property is of the form: field1.field2.arrayName,arrayIndex.final_field or simply final_field, we need to chase
			// the property down the rabbit hole starting with the base fromObject and going all the way to final_field.
			for (int i = 0 ; i < splitPaths.Length - 1 ; ++i)
			{
				try
				{
					fromObject = GetObjectFromField( fromObject, splitPaths[i] );
					if ( fromObject == null )
					{
						throw new ResolveException( string.Format("Cross-Scene Ref: {0}. Could not follow path {1} because {2} was null", debugThis, fromFieldPath, splitPaths[i]) );
					}
					else if ( !fromObject.GetType().IsClass )
					{
						throw new ResolveException( string.Format("Cross-Scene Ref: {0}. Could not follow path {1} because {2} was not a class (probably a struct). This is unsupported.", debugThis, fromFieldPath, splitPaths[i]) );
					}
				}
				catch ( System.Exception ex )
				{
					throw new ResolveException( string.Format("Cross-Scene Ref: {0}. {1}", debugThis, ex.Message) );
				}
			}

			// Finally, get the final field.
			FieldInfo field;
			int arrayIndex;
			string fieldName = splitPaths[ splitPaths.Length-1 ];

			if ( !GetFieldFromObject(fromObject, fieldName, out field, out arrayIndex ) )
				throw new ResolveException( string.Format("Cross-Scene Ref: {0}. Could not parse piece of path {1} from {2}", debugThis, fieldName, fromFieldPath) );

			// Now we can finally assign it!
			AssignField( fromObject, toObject, field, arrayIndex );
		}
Example #7
0
            public override bool Equals(System.Object obj)
            {
                if (obj == null)
                {
                    return(false);
                }

                if (this == obj)
                {
                    return(true);
                }

                if (obj.GetType() != this.GetType())
                {
                    return(false);
                }

                DimensionType d = (DimensionType)obj;

                return(this.Name.Equals(d.Name) &&
                       this.Units.Equals(d.Units) &&
                       this.UnitSymbol.Equals(d.UnitSymbol));
            }
        private System.Object GetValue(RegistryPointer registryPointer, System.Type type)
        {
            lock (this.cache) {
                if (this.cache.ContainsKey(registryPointer))
                {
                    return(this.cache[registryPointer]);
                }

                using (Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.RegistryKey.OpenBaseKey(registryPointer.RegistryHive, Microsoft.Win32.RegistryView.Registry32).OpenSubKey(registryPointer.SubKey)) {
                    if (!(regKey is null))
                    {
                        System.Object obj = regKey.GetValue(registryPointer.Name);

                        if (type is null || obj.GetType() == type)
                        {
                            this.cache.Add(registryPointer, obj);
                            return(obj);
                        }
                    }
                }

                return(null);
            }
        }
Example #9
0
		public FieldEditor(System.Object data) {
			this.data = data;
			_fieldInfos = data.GetType().GetFields(BINDING);
			for (var i = 0; i < _fieldInfos.Length; i++)
				GuiFields.Add(GenerateGUI(_fieldInfos[i]));
		}
Example #10
0
        private void ThreadWorker(Object parameters)
        {
            // Thread cache items
            ThreadParamInfo setupInfo;
            Address         serverAddress = new Address();
            Host            serverENetHost;
            Event           serverENetEvent;

            Peer[] serverPeerArray;

            // Grab the setup information.
            if (parameters.GetType() == typeof(ThreadParamInfo))
            {
                setupInfo = (ThreadParamInfo)parameters;
            }
            else
            {
                return;
            }

            // Attempt to initialize ENet inside the thread.
            if (Library.Initialize())
            {
            }
            else
            {
                return;
            }

            // Configure the server address.
            serverAddress.SetHost(setupInfo.Address);
            serverAddress.Port = (ushort)setupInfo.Port;
            serverPeerArray    = new Peer[setupInfo.Peers];

            using (serverENetHost = new Host())
            {
                // Create the server object.
                serverENetHost.Create(serverAddress, setupInfo.Peers, setupInfo.Channels);

                // Loop until we're told to cease operations.
                while (!CeaseOperation)
                {
                    // Intermission: Command Handling
                    while (Commands.TryDequeue(out IgnoranceCommandPacket commandPacket))
                    {
                        switch (commandPacket.Type)
                        {
                        default:
                            break;

                        // Boot a Peer off the Server.
                        case IgnoranceCommandType.ServerKickPeer:
                            uint targetPeer = commandPacket.PeerId;

                            if (!serverPeerArray[targetPeer].IsSet)
                            {
                                continue;
                            }

                            IgnoranceConnectionEvent iced = new IgnoranceConnectionEvent()
                            {
                                WasDisconnect = true,
                                NativePeerId  = targetPeer
                            };

                            DisconnectionEvents.Enqueue(iced);

                            // Disconnect and reset the peer array's entry for that peer.
                            serverPeerArray[targetPeer].DisconnectNow(0);
                            serverPeerArray[targetPeer] = default;
                            break;
                        }
                    }

                    // Step One:
                    // ---> Sending to peers
                    while (Outgoing.TryDequeue(out IgnoranceOutgoingPacket outgoingPacket))
                    {
                        // Only create a packet if the server knows the peer.
                        if (serverPeerArray[outgoingPacket.NativePeerId].IsSet)
                        {
                            int ret = serverPeerArray[outgoingPacket.NativePeerId].Send(outgoingPacket.Channel, ref outgoingPacket.Payload);
                        }
                        else
                        {
                            // A peer might have disconnected, this is OK - just log the packet if set to paranoid.
                        }
                    }

                    // Step 2
                    // <--- Receiving from peers
                    bool pollComplete = false;

                    while (!pollComplete)
                    {
                        Packet incomingPacket;
                        Peer   incomingPeer;
                        int    incomingPacketLength;

                        // Any events happening?
                        if (serverENetHost.CheckEvents(out serverENetEvent) <= 0)
                        {
                            // If service time is met, break out of it.
                            if (serverENetHost.Service(setupInfo.PollTime, out serverENetEvent) <= 0)
                            {
                                break;
                            }

                            pollComplete = true;
                        }

                        // Setup the packet references.
                        incomingPeer = serverENetEvent.Peer;

                        switch (serverENetEvent.Type)
                        {
                        // Idle.
                        case EventType.None:
                        default:
                            break;

                        // Connection Event.
                        case EventType.Connect:
                            IgnoranceConnectionEvent ice = new IgnoranceConnectionEvent()
                            {
                                NativePeerId = incomingPeer.ID,
                                IP           = incomingPeer.IP,
                                Port         = incomingPeer.Port
                            };

                            ConnectionEvents.Enqueue(ice);

                            // Assign a reference to the Peer.
                            serverPeerArray[incomingPeer.ID] = incomingPeer;
                            break;

                        // Disconnect/Timeout. Mirror doesn't care if it's either, so we lump them together.
                        case EventType.Disconnect:
                        case EventType.Timeout:
                            if (!serverPeerArray[incomingPeer.ID].IsSet)
                            {
                                break;
                            }

                            IgnoranceConnectionEvent iced = new IgnoranceConnectionEvent()
                            {
                                WasDisconnect = true,
                                NativePeerId  = incomingPeer.ID
                            };

                            DisconnectionEvents.Enqueue(iced);

                            // Reset the peer array's entry for that peer.
                            serverPeerArray[incomingPeer.ID] = default;
                            break;

                        case EventType.Receive:
                            // Receive event type usually includes a packet; so cache its reference.
                            incomingPacket = serverENetEvent.Packet;
                            if (!incomingPacket.IsSet)
                            {
                                break;
                            }

                            incomingPacketLength = incomingPacket.Length;

                            // Firstly check if the packet is too big. If it is, do not process it - drop it.
                            if (incomingPacketLength > setupInfo.PacketSizeLimit)
                            {
                                incomingPacket.Dispose();
                                break;
                            }

                            IgnoranceIncomingPacket incomingQueuePacket = new IgnoranceIncomingPacket
                            {
                                Channel      = serverENetEvent.ChannelID,
                                NativePeerId = incomingPeer.ID,
                                Payload      = incomingPacket,
                            };

                            // Enqueue.
                            Incoming.Enqueue(incomingQueuePacket);
                            break;
                        }
                    }
                }


                // Cleanup and flush everything.
                serverENetHost.Flush();

                // Kick everyone.
                for (int i = 0; i < serverPeerArray.Length; i++)
                {
                    if (!serverPeerArray[i].IsSet)
                    {
                        continue;
                    }
                    serverPeerArray[i].DisconnectNow(0);
                }
            }

            // Flush again to ensure ENet gets those Disconnection stuff out.
            // May not be needed; better to err on side of caution


            Library.Deinitialize();
        }
Example #11
0
 public static void ClassMarker(System.Object o)
 {
     System.Console.Write(o.GetType().ToString());
 }
Example #12
0
 public override bool Equals(System.Object obj)
 {
     return((obj != null && obj.GetType() == typeof(Question)) ? (this.ID == ((Question)(obj)).ID)   : false);;
 }
Example #13
0
 public static void LogError(this System.Object obj, string message)
 {
     Debug.LogError("-ERROR- " + obj.GetType().FullName + "[" + obj.GetHashCode().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " + message);
 }
Example #14
0
        void UpdateCachedReferences()
        {
            if (TargetTypeName == null || TargetFieldName == null)
            {
                return;
            }

            if (target == null)
            {
                target = gameObject.GetComponent <ThisOtherThing.UI.Shapes.IShape>();
            }

            targetField = target.GetType()
                          .GetField(TargetFieldName, binding)
                          .GetValue(target);

            if (IsInArray)
            {
                FieldInfo fieldNameInfo = targetField.GetType().GetField(FieldName);

                if (fieldNameInfo == null)
                {
                    return;
                }

                System.Type elementType = fieldNameInfo.FieldType.GetElementType();

                if (elementType != null)
                {
                    fieldInfo = targetField.GetType()
                                .GetField(FieldName, binding)
                                .FieldType
                                .GetElementType()
                                .GetField(ArrayFieldName, binding);

                    System.Array arr = (System.Array)targetField.GetType()
                                       .GetField(FieldName, binding)
                                       .GetValue(targetField);
                    targetField = arr.GetValue(ArrayItemIndex);
                }
            }
            else
            {
                fieldInfo = System.Type.GetType(TargetTypeName)
                            .GetField(FieldName, BindingFlags.Instance | BindingFlags.Public);
            }

            if (IsInClass)
            {
                if (TargetClassFieldName.Length == 0 || ClassFieldName.Length == 0)
                {
                    return;
                }

                FieldInfo tmpTargetFieldInfo = targetField.GetType()
                                               .GetField(TargetClassFieldName, binding);

                if (tmpTargetFieldInfo == null)
                {
                    return;
                }

                targetField = tmpTargetFieldInfo
                              .GetValue(targetField);

                fieldInfo = targetField.GetType()
                            .GetField(ClassFieldName, binding);
            }
        }
Example #15
0
        /** 更新。
         */
        private bool Main_Item(WorkPool_Item a_item)
        {
            switch (a_item.mode)
            {
            case (int)ModeAddIndexArray.Start:
            {
                //IndexArray。追加。

                JsonItem t_jsonitem_listitem = null;

                if (a_item.nest < Config.CONVERTNEST_MAX)
                {
                    t_jsonitem_listitem = ConvertObjectToJsonItem.Convert(a_item.from_object, a_item.from_type, a_item.from_option, this, a_item.nest + 1);
                }
                else
                {
                                                #if (DEF_BLUEBACK_JSONITEM_ASSERT)
                    DebugTool.Assert(false);
                                                #endif

                    return(false);
                }

                if (a_item.to_jsonitem != null)
                {
                    a_item.to_jsonitem.AddItem(t_jsonitem_listitem, false);
                }
                else
                {
                                                #if (DEF_BLUEBACK_JSONITEM_ASSERT)
                    DebugTool.Assert(false);
                                                #endif

                    return(false);
                }
            } return(true);

            case (int)ModeSetIndexArray.Start:
            {
                //IndexArray。設定。

                JsonItem t_jsonitem_listitem = null;

                if (a_item.nest < Config.CONVERTNEST_MAX)
                {
                    t_jsonitem_listitem = ConvertObjectToJsonItem.Convert(a_item.from_object, a_item.from_type, a_item.from_option, this, a_item.nest + 1);
                }
                else
                {
                                                #if (DEF_BLUEBACK_JSONITEM_ASSERT)
                    DebugTool.Assert(false);
                                                #endif

                    return(false);
                }

                if (a_item.to_jsonitem != null)
                {
                    a_item.to_jsonitem.SetItem(a_item.to_index, t_jsonitem_listitem, false);
                }
                else
                {
                                                #if (DEF_BLUEBACK_JSONITEM_ASSERT)
                    DebugTool.Assert(false);
                                                #endif

                    return(false);
                }
            } return(true);

            case (int)ModeAddAssociativeArray.Start:
            {
                //AssociativeArray。追加。

                JsonItem t_jsonitem_member = null;

                if (a_item.nest < Config.CONVERTNEST_MAX)
                {
                    t_jsonitem_member = ConvertObjectToJsonItem.Convert(a_item.from_object, a_item.from_type, a_item.from_option, this, a_item.nest + 1);
                }
                else
                {
                                                #if (DEF_BLUEBACK_JSONITEM_ASSERT)
                    DebugTool.Assert(false);
                                                #endif

                    return(false);
                }

                if (a_item.to_jsonitem != null)
                {
                    a_item.to_jsonitem.SetItem(a_item.to_key_string, t_jsonitem_member, false);
                }
                else
                {
                                                #if (DEF_BLUEBACK_JSONITEM_ASSERT)
                    DebugTool.Assert(false);
                                                #endif

                    return(false);
                }
            } return(true);

            case (int)ModeFieldInfo.Start:
            {
                //FieldInfo。

                //ENUMの文字列化。
                if (a_item.from_fieldinfo.IsDefined(typeof(EnumString), false) == true)
                {
                    a_item.from_option = ConvertToJsonItemOption.EnumString;
                }
                else
                {
                    a_item.from_option = ConvertToJsonItemOption.None;
                }

                System.Object t_raw = a_item.from_fieldinfo.GetValue(a_item.from_parent_object);
                if (t_raw != null)
                {
                    JsonItem t_jsonitem_member = null;

                    if (a_item.nest < Config.CONVERTNEST_MAX)
                    {
                        t_jsonitem_member = ConvertObjectToJsonItem.Convert(t_raw, t_raw.GetType(), a_item.from_option, this, a_item.nest + 1);
                    }
                    else
                    {
                                                        #if (DEF_BLUEBACK_JSONITEM_ASSERT)
                        DebugTool.Assert(false);
                                                        #endif

                        return(false);
                    }

                    if (a_item.to_jsonitem != null)
                    {
                        a_item.to_jsonitem.SetItem(a_item.from_fieldinfo.Name, t_jsonitem_member, false);
                    }
                    else
                    {
                                                        #if (DEF_BLUEBACK_JSONITEM_ASSERT)
                        DebugTool.Assert(false);
                                                        #endif

                        return(false);
                    }
                }
                else
                {
                    //NULL処理。
                }
            } return(true);
            }

            return(false);
        }
Example #16
0
        /** Convert
         */
        public static JsonItem Convert(System.Object a_from_object, System.Type a_from_type, ConvertToJsonItemOption a_from_option, WorkPool a_workpool, int a_nest)
        {
            {
                //[]

                System.Array t_array_raw = (System.Array)a_from_object;

                JsonItem t_to_jsonitem = new JsonItem(new Value_IndexArray());

                //サイズ確保。
                t_to_jsonitem.ReSize(t_array_raw.Length);

                //値型。
                System.Type t_list_value_type = ReflectionTool.ReflectionTool.GetListValueType(a_from_type);

                if (t_list_value_type == typeof(System.Object))
                {
                    for (int ii = 0; ii < t_array_raw.Length; ii++)
                    {
                        //ワークに追加。
                        System.Object t_listitem_object = t_array_raw.GetValue(ii);
                        a_workpool.Add(WorkPool.ModeSetIndexArray.Start, t_to_jsonitem, ii, t_listitem_object, t_listitem_object.GetType(), a_from_option, a_nest + 1);
                    }
                }
                else
                {
                    for (int ii = 0; ii < t_array_raw.Length; ii++)
                    {
                        //ワークに追加。
                        System.Object t_listitem_object = t_array_raw.GetValue(ii);
                        a_workpool.Add(WorkPool.ModeSetIndexArray.Start, t_to_jsonitem, ii, t_listitem_object, t_list_value_type, a_from_option, a_nest + 1);
                    }
                }

                //成功。
                return(t_to_jsonitem);
            }
        }
Example #17
0
        private void ThreadWorker(Object parameters)
        {
            if (Verbosity > 0)
            {
                Debug.Log("Ignorance Server: Initializing. Please stand by...");
            }

            // Thread cache items
            ThreadParamInfo setupInfo;
            Address         serverAddress = new Address();
            Host            serverENetHost;
            Event           serverENetEvent;

            Peer[] serverPeerArray;

            // Grab the setup information.
            if (parameters.GetType() == typeof(ThreadParamInfo))
            {
                setupInfo = (ThreadParamInfo)parameters;
            }
            else
            {
                Debug.LogError("Ignorance Server: Startup failure; Invalid thread parameters. Aborting.");
                return;
            }

            // Attempt to initialize ENet inside the thread.
            if (Library.Initialize())
            {
                Debug.Log("Ignorance Server: ENet Native successfully initialized.");
            }
            else
            {
                Debug.LogError("Ignorance Server: Failed to initialize ENet Native. This threads' f****d.");
                return;
            }

            // Configure the server address.
            serverAddress.SetHost(setupInfo.Address);
            serverAddress.Port = (ushort)setupInfo.Port;
            serverPeerArray    = new Peer[setupInfo.Peers];

            using (serverENetHost = new Host())
            {
                // Create the server object.
                serverENetHost.Create(serverAddress, setupInfo.Peers, setupInfo.Channels);

                // Loop until we're told to cease operations.
                while (!CeaseOperation)
                {
                    // Intermission: Command Handling
                    while (Commands.TryDequeue(out IgnoranceCommandPacket commandPacket))
                    {
                        switch (commandPacket.Type)
                        {
                        default:
                            break;

                        // Boot a Peer off the Server.
                        case IgnoranceCommandType.ServerKickPeer:
                            uint targetPeer = commandPacket.PeerId;

                            if (!serverPeerArray[targetPeer].IsSet)
                            {
                                continue;
                            }

                            if (setupInfo.Verbosity > 0)
                            {
                                Debug.Log($"Ignorance Server: Booting ENet Peer {targetPeer} off this server instance.");
                            }

                            IgnoranceConnectionEvent iced = new IgnoranceConnectionEvent
                            {
                                EventType    = 0x01,
                                NativePeerId = targetPeer
                            };

                            DisconnectionEvents.Enqueue(iced);

                            // Disconnect and reset the peer array's entry for that peer.
                            serverPeerArray[targetPeer].DisconnectNow(0);
                            serverPeerArray[targetPeer] = default;
                            break;
                        }
                    }

                    // Step One:
                    // ---> Sending to peers
                    while (Outgoing.TryDequeue(out IgnoranceOutgoingPacket outgoingPacket))
                    {
                        // Only create a packet if the server knows the peer.
                        if (serverPeerArray[outgoingPacket.NativePeerId].IsSet)
                        {
                            int ret = serverPeerArray[outgoingPacket.NativePeerId].Send(outgoingPacket.Channel, ref outgoingPacket.Payload);

                            if (ret < 0 && setupInfo.Verbosity > 0)
                            {
                                Debug.LogWarning($"Ignorance Server: ENet error {ret} while sending packet to Peer {outgoingPacket.NativePeerId}.");
                            }
                        }
                        else
                        {
                            // A peer might have disconnected, this is OK - just log the packet if set to paranoid.
                            if (setupInfo.Verbosity > 1)
                            {
                                Debug.LogWarning("Ignorance Server: Can't send packet, a native peer object is not set. This may be normal if the Peer has disconnected before this send cycle.");
                            }
                        }
                    }

                    // Step 2
                    // <--- Receiving from peers
                    bool pollComplete = false;

                    while (!pollComplete)
                    {
                        Packet incomingPacket;
                        Peer   incomingPeer;
                        int    incomingPacketLength;

                        // Any events happening?
                        if (serverENetHost.CheckEvents(out serverENetEvent) <= 0)
                        {
                            // If service time is met, break out of it.
                            if (serverENetHost.Service(setupInfo.PollTime, out serverENetEvent) <= 0)
                            {
                                break;
                            }

                            pollComplete = true;
                        }

                        // Setup the packet references.
                        incomingPeer = serverENetEvent.Peer;

                        // What type are you?
                        switch (serverENetEvent.Type)
                        {
                        // Idle.
                        case EventType.None:
                        default:
                            break;

                        // Connection Event.
                        case EventType.Connect:
                            if (setupInfo.Verbosity > 1)
                            {
                                Debug.Log($"Ignorance Server: Hello new peer with ID {incomingPeer.ID}!");
                            }

                            IgnoranceConnectionEvent ice = new IgnoranceConnectionEvent()
                            {
                                NativePeerId = incomingPeer.ID,
                                IP           = incomingPeer.IP,
                                Port         = incomingPeer.Port
                            };

                            ConnectionEvents.Enqueue(ice);

                            // Assign a reference to the Peer.
                            serverPeerArray[incomingPeer.ID] = incomingPeer;
                            break;

                        // Disconnect/Timeout. Mirror doesn't care if it's either, so we lump them together.
                        case EventType.Disconnect:
                        case EventType.Timeout:
                            if (!serverPeerArray[incomingPeer.ID].IsSet)
                            {
                                break;
                            }

                            if (setupInfo.Verbosity > 1)
                            {
                                Debug.Log($"Ignorance Server: Bye bye Peer {incomingPeer.ID}; They have disconnected.");
                            }

                            IgnoranceConnectionEvent iced = new IgnoranceConnectionEvent
                            {
                                EventType    = 0x01,
                                NativePeerId = incomingPeer.ID
                            };

                            DisconnectionEvents.Enqueue(iced);

                            // Reset the peer array's entry for that peer.
                            serverPeerArray[incomingPeer.ID] = default;
                            break;

                        case EventType.Receive:
                            // Receive event type usually includes a packet; so cache its reference.
                            incomingPacket = serverENetEvent.Packet;
                            if (!incomingPacket.IsSet)
                            {
                                if (setupInfo.Verbosity > 0)
                                {
                                    Debug.LogWarning($"Ignorance Server: A receive event did not supply us with a packet to work with. This should never happen.");
                                }
                                break;
                            }

                            incomingPacketLength = incomingPacket.Length;

                            // Firstly check if the packet is too big. If it is, do not process it - drop it.
                            if (incomingPacketLength > setupInfo.PacketSizeLimit)
                            {
                                if (setupInfo.Verbosity > 0)
                                {
                                    Debug.LogWarning($"Ignorance Server: Incoming packet is too big. My limit is {setupInfo.PacketSizeLimit} byte(s) whilest this packet is {incomingPacketLength} bytes.");
                                }

                                incomingPacket.Dispose();
                                break;
                            }

                            IgnoranceIncomingPacket incomingQueuePacket = new IgnoranceIncomingPacket
                            {
                                Channel      = serverENetEvent.ChannelID,
                                NativePeerId = incomingPeer.ID,
                                Payload      = incomingPacket,
                            };

                            // Enqueue.
                            Incoming.Enqueue(incomingQueuePacket);
                            break;
                        }
                    }
                }

                if (Verbosity > 0)
                {
                    Debug.Log("Ignorance Server: Thread shutdown commencing. Flushing connections.");
                }

                // Cleanup and flush everything.
                serverENetHost.Flush();

                // Kick everyone.
                for (int i = 0; i < serverPeerArray.Length; i++)
                {
                    if (!serverPeerArray[i].IsSet)
                    {
                        continue;
                    }
                    serverPeerArray[i].DisconnectNow(0);
                }
            }

            if (setupInfo.Verbosity > 0)
            {
                Debug.Log("Ignorance Server: Shutdown complete.");
            }

            Library.Deinitialize();
        }
Example #18
0
 protected string GetStateMachineName(Object stateMachine)
 {
     return((string)stateMachine.GetType().GetField("name").GetValue(stateMachine));
 }
 public NotEnoughLayersException(int numberOfRoomLayers, int numberOfCOLayers, System.Object invokedFrom)
     : base("Room does not have enough layers to implement " + invokedFrom.GetType() +
            " [ RoomLayers: " + numberOfRoomLayers + " ]" + " [ComplexObjectLayers : " + numberOfCOLayers +
            " ]")
 {
 }
Example #20
0
        /** Convert
         */
        public static JsonItem Convert(System.Object a_from_object, System.Type a_from_type, ConvertToJsonItemOption a_from_option, WorkPool a_workpool, int a_nest)
        {
            {
                //IDictionary
                {
                    System.Collections.IDictionary t_from_dictionary = a_from_object as System.Collections.IDictionary;
                    if (t_from_dictionary != null)
                    {
                        System.Type t_list_key_type = ReflectionTool.ReflectionTool.GetDictionaryKeyType(a_from_type);
                        if (t_list_key_type == typeof(string))
                        {
                            //Generic.Dictionary<string.*>
                            //Generic.SortedDictionary<string,*>
                            //Generic.SortedList<string,*>

                            JsonItem t_to_jsonitem = new JsonItem(new Value_AssociativeArray());

                            //値型。
                            System.Type t_list_value_type = ReflectionTool.ReflectionTool.GetListValueType(a_from_object.GetType());

                            if (t_list_value_type == typeof(System.Object))
                            {
                                //ワークに追加。
                                foreach (System.Collections.DictionaryEntry t_from_pair in t_from_dictionary)
                                {
                                    string t_from_listitem_key_string = (string)t_from_pair.Key;
                                    if (t_from_listitem_key_string != null)
                                    {
                                        System.Object t_from_listitem_object = t_from_pair.Value;
                                        a_workpool.Add(WorkPool.ModeAddAssociativeArray.Start, t_to_jsonitem, t_from_listitem_key_string, t_from_listitem_object, t_from_listitem_object.GetType(), a_from_option, a_nest + 1);
                                    }
                                    else
                                    {
                                        //NULL処理。
                                        //keyがnullの場合は追加しない。
                                    }
                                }
                            }
                            else
                            {
                                //ワークに追加。
                                foreach (System.Collections.DictionaryEntry t_from_pair in t_from_dictionary)
                                {
                                    string t_from_listitem_key_string = (string)t_from_pair.Key;
                                    if (t_from_listitem_key_string != null)
                                    {
                                        System.Object t_from_listitem_object = t_from_pair.Value;
                                        a_workpool.Add(WorkPool.ModeAddAssociativeArray.Start, t_to_jsonitem, t_from_listitem_key_string, t_from_listitem_object, t_list_value_type, a_from_option, a_nest + 1);
                                    }
                                    else
                                    {
                                        //NULL処理。
                                        //keyがnullの場合は追加しない。
                                    }
                                }
                            }

                            //成功。
                            return(t_to_jsonitem);
                        }
                        else
                        {
                            //Generic.Dictionary<key != string.>

                            JsonItem t_to_jsonitem = new JsonItem(new Value_IndexArray());

                            //サイズがわかるので要素確保。
                            t_to_jsonitem.ReSize(t_from_dictionary.Count);

                            int t_index = 0;

                            //値型。
                            System.Type t_list_value_type = ReflectionTool.ReflectionTool.GetListValueType(a_from_type);

                            if (t_list_value_type == typeof(System.Object))
                            {
                                if (t_list_key_type == typeof(System.Object))
                                {
                                    //ワークに追加。
                                    foreach (System.Collections.DictionaryEntry t_from_listitem in t_from_dictionary)
                                    {
                                        JsonItem t_keyvalue_jsonitem = new JsonItem(new Value_AssociativeArray());
                                        t_to_jsonitem.SetItem(t_index, t_keyvalue_jsonitem, false);
                                        a_workpool.Add(WorkPool.ModeAddAssociativeArray.Start, t_keyvalue_jsonitem, "KEY", t_from_listitem.Key, t_from_listitem.Key.GetType(), a_from_option, a_nest + 1);
                                        a_workpool.Add(WorkPool.ModeAddAssociativeArray.Start, t_keyvalue_jsonitem, "VALUE", t_from_listitem.Value, t_from_listitem.Value.GetType(), a_from_option, a_nest + 1);
                                        t_index++;
                                    }
                                }
                                else
                                {
                                    //ワークに追加。
                                    foreach (System.Collections.DictionaryEntry t_from_listitem in t_from_dictionary)
                                    {
                                        JsonItem t_keyvalue_jsonitem = new JsonItem(new Value_AssociativeArray());
                                        t_to_jsonitem.SetItem(t_index, t_keyvalue_jsonitem, false);
                                        a_workpool.Add(WorkPool.ModeAddAssociativeArray.Start, t_keyvalue_jsonitem, "KEY", t_from_listitem.Key, t_list_key_type, a_from_option, a_nest + 1);
                                        a_workpool.Add(WorkPool.ModeAddAssociativeArray.Start, t_keyvalue_jsonitem, "VALUE", t_from_listitem.Value, t_from_listitem.Value.GetType(), a_from_option, a_nest + 1);
                                        t_index++;
                                    }
                                }
                            }
                            else
                            {
                                if (t_list_key_type == typeof(System.Object))
                                {
                                    //ワークに追加。
                                    foreach (System.Collections.DictionaryEntry t_from_listitem in t_from_dictionary)
                                    {
                                        JsonItem t_keyvalue_jsonitem = new JsonItem(new Value_AssociativeArray());
                                        t_to_jsonitem.SetItem(t_index, t_keyvalue_jsonitem, false);
                                        a_workpool.Add(WorkPool.ModeAddAssociativeArray.Start, t_keyvalue_jsonitem, "KEY", t_from_listitem.Key, t_from_listitem.Key.GetType(), a_from_option, a_nest + 1);
                                        a_workpool.Add(WorkPool.ModeAddAssociativeArray.Start, t_keyvalue_jsonitem, "VALUE", t_from_listitem.Value, t_list_value_type, a_from_option, a_nest + 1);
                                        t_index++;
                                    }
                                }
                                else
                                {
                                    //ワークに追加。
                                    foreach (System.Collections.DictionaryEntry t_from_listitem in t_from_dictionary)
                                    {
                                        JsonItem t_keyvalue_jsonitem = new JsonItem(new Value_AssociativeArray());
                                        t_to_jsonitem.SetItem(t_index, t_keyvalue_jsonitem, false);
                                        a_workpool.Add(WorkPool.ModeAddAssociativeArray.Start, t_keyvalue_jsonitem, "KEY", t_from_listitem.Key, t_list_key_type, a_from_option, a_nest + 1);
                                        a_workpool.Add(WorkPool.ModeAddAssociativeArray.Start, t_keyvalue_jsonitem, "VALUE", t_from_listitem.Value, t_list_value_type, a_from_option, a_nest + 1);
                                        t_index++;
                                    }
                                }
                            }

                            //成功。
                            return(t_to_jsonitem);
                        }
                    }
                }

                //ICollection
                {
                    System.Collections.ICollection t_from_collection = a_from_object as System.Collections.ICollection;
                    if (t_from_collection != null)
                    {
                        //Generic.List
                        //Generic.Stack
                        //Generic.LinkedList
                        //Generic.Queue
                        //Generic.SortedSet

                        JsonItem t_to_jsonitem = new JsonItem(new Value_IndexArray());

                        //サイズがわかるので要素確保。
                        t_to_jsonitem.ReSize(t_from_collection.Count);

                        int t_index = 0;

                        //値型。
                        System.Type t_list_value_type = ReflectionTool.ReflectionTool.GetListValueType(a_from_type);

                        if (t_list_value_type == typeof(System.Object))
                        {
                            //Collections.ArrayList

                            //ワークに追加。
                            foreach (System.Object t_from_listitem in t_from_collection)
                            {
                                a_workpool.Add(WorkPool.ModeSetIndexArray.Start, t_to_jsonitem, t_index, t_from_listitem, t_from_listitem.GetType(), a_from_option, a_nest + 1);
                                t_index++;
                            }
                        }
                        else
                        {
                            //ワークに追加。
                            foreach (System.Object t_from_listitem in t_from_collection)
                            {
                                a_workpool.Add(WorkPool.ModeSetIndexArray.Start, t_to_jsonitem, t_index, t_from_listitem, t_list_value_type, a_from_option, a_nest + 1);
                                t_index++;
                            }
                        }

                        //成功。
                        return(t_to_jsonitem);
                    }
                }

                //IEnumerable
                {
                    System.Collections.IEnumerable t_from_enumerable = a_from_object as System.Collections.IEnumerable;
                    if (t_from_enumerable != null)
                    {
                        //Generic.HashSet

                        JsonItem t_to_jsonitem = new JsonItem(new Value_IndexArray());

                        //値型。
                        System.Type t_list_value_type = ReflectionTool.ReflectionTool.GetListValueType(a_from_type);

                        if (t_list_value_type == typeof(System.Object))
                        {
                            //ワークに追加。
                            foreach (System.Object t_from_listitem in t_from_enumerable)
                            {
                                a_workpool.Add(WorkPool.ModeAddIndexArray.Start, t_to_jsonitem, t_from_listitem, t_from_listitem.GetType(), a_from_option, a_nest + 1);
                            }
                        }
                        else
                        {
                            //ワークに追加。
                            foreach (System.Object t_from_listitem in t_from_enumerable)
                            {
                                a_workpool.Add(WorkPool.ModeAddIndexArray.Start, t_to_jsonitem, t_from_listitem, t_list_value_type, a_from_option, a_nest + 1);
                            }
                        }

                        //成功。
                        return(t_to_jsonitem);
                    }
                }

                //class,struct
                {
                    JsonItem t_to_jsonitem = new JsonItem(new Value_AssociativeArray());

                    //メンバーリスト。取得。
                    System.Collections.Generic.List <System.Reflection.FieldInfo> t_fieldinfo_list = new System.Collections.Generic.List <System.Reflection.FieldInfo>();
                    ConvertTool.GetMemberListAll(a_from_type, t_fieldinfo_list);

                    //ワークに追加。
                    foreach (System.Reflection.FieldInfo t_fieldinfo in t_fieldinfo_list)
                    {
                        a_workpool.Add(WorkPool.ModeFieldInfo.Start, t_to_jsonitem, t_fieldinfo, a_from_object, a_nest + 1);
                    }

                    //成功。
                    return(t_to_jsonitem);
                }
            }
        }
 void Write4_Object(string n, string ns, System.Object o, bool isNullable, bool needType)
 {
     if ((object)o == null)
     {
         if (isNullable)
         {
             WriteNullTagLiteral(n, ns);
         }
         return;
     }
     if (!needType)
     {
         System.Type t = o.GetType();
         if (t == typeof(System.Object))
         {
             ;
         }
         else if (t == typeof(System.Web.Services.Discovery.DiscoveryDocument))
         {
             Write1_DiscoveryDocument(n, ns, (System.Web.Services.Discovery.DiscoveryDocument)o, isNullable, true);
             return;
         }
         else if (t == typeof(System.Web.Services.Discovery.SoapBinding))
         {
             Write9_SoapBinding(n, ns, (System.Web.Services.Discovery.SoapBinding)o, isNullable, true);
             return;
         }
         else if (t == typeof(System.Web.Services.Discovery.DiscoveryReference))
         {
             Write8_DiscoveryReference(n, ns, (System.Web.Services.Discovery.DiscoveryReference)o, isNullable, true);
             return;
         }
         else if (t == typeof(System.Web.Services.Discovery.SchemaReference))
         {
             Write7_SchemaReference(n, ns, (System.Web.Services.Discovery.SchemaReference)o, isNullable, true);
             return;
         }
         else if (t == typeof(System.Web.Services.Discovery.DiscoveryReference))
         {
             Write6_DiscoveryReference(n, ns, (System.Web.Services.Discovery.DiscoveryReference)o, isNullable, true);
             return;
         }
         else if (t == typeof(System.Web.Services.Discovery.ContractReference))
         {
             Write5_ContractReference(n, ns, (System.Web.Services.Discovery.ContractReference)o, isNullable, true);
             return;
         }
         else if (t == typeof(System.Web.Services.Discovery.DiscoveryReference))
         {
             Write3_DiscoveryReference(n, ns, (System.Web.Services.Discovery.DiscoveryReference)o, isNullable, true);
             return;
         }
         else if (t == typeof(System.Web.Services.Discovery.DiscoveryDocumentReference))
         {
             Write2_DiscoveryDocumentReference(n, ns, (System.Web.Services.Discovery.DiscoveryDocumentReference)o, isNullable, true);
             return;
         }
         else
         {
             WriteTypedPrimitive(n, ns, o, true);
             return;
         }
     }
     WriteStartElement(n, ns, o);
     WriteEndElement(o);
 }
Example #22
0
 	public override bool Equals(System.Object obj){
 		if(obj==null || GetType()!=obj.GetType()) return false;
 		return (this == (LABColor)obj);
 	}
Example #23
0
 static string GenerateLogMessage(string type, System.Object obj, string message)
 {
     return(GenerateLogMessage(type, "{0}][{1}".FormatInvarient(obj.GetType().FullName, obj.GetHashCode().ToString("X")), message));
 }
Example #24
0
        /// <summary>
        /// An extension to the property value class that allows us to create a
        /// Property value from a C# object, for example, integer, float, or string.<br />
        /// </summary>
        /// <param name="obj">An object to create.</param>
        /// <returns>The created value.</returns>
        /// <exception cref="global::System.ArgumentNullException"> Thrown when obj is null. </exception>
        /// <since_tizen> 3 </since_tizen>
        static public PropertyValue CreateFromObject(System.Object obj)
        {
            if (null == obj)
            {
                throw new global::System.ArgumentNullException(nameof(obj));
            }

            System.Type   type = obj.GetType();
            PropertyValue value;

            if (type.IsEnum)
            {
                value = new PropertyValue((int)obj);//Enum.Parse(type, str);
            }
            else if (type.Equals(typeof(int)))
            {
                value = new PropertyValue((int)obj);
            }
            else if (type.Equals(typeof(System.Int32)))
            {
                value = new PropertyValue((int)obj);
            }
            else if (type.Equals(typeof(bool)))
            {
                value = new PropertyValue((bool)obj);
            }
            else if (type.Equals(typeof(float)))
            {
                value = new PropertyValue((float)obj);
            }
            else if (type.Equals(typeof(string)))
            {
                value = new PropertyValue((string)obj);
            }
            else if (type.Equals(typeof(Vector2)))
            {
                value = new PropertyValue((Vector2)obj);
            }
            else if (type.Equals(typeof(Vector3)))
            {
                value = new PropertyValue((Vector3)obj);
            }
            else if (type.Equals(typeof(Vector4)))
            {
                value = new PropertyValue((Vector4)obj);
            }
            else if (type.Equals(typeof(Position)))
            {
                value = new PropertyValue((Position)obj);
            }
            else if (type.Equals(typeof(Position2D)))
            {
                value = new PropertyValue((Position2D)obj);
            }
            else if (type.Equals(typeof(Size)))
            {
                value = new PropertyValue((Size)obj);
            }
            else if (type.Equals(typeof(Size2D)))
            {
                value = new PropertyValue((Size2D)obj);
            }
            else if (type.Equals(typeof(Color)))
            {
                value = new PropertyValue((Color)obj);
            }
            else if (type.Equals(typeof(Rotation)))
            {
                value = new PropertyValue((Rotation)obj);
            }
            else if (type.Equals(typeof(RelativeVector2)))
            {
                value = new PropertyValue((RelativeVector2)obj);
            }
            else if (type.Equals(typeof(RelativeVector3)))
            {
                value = new PropertyValue((RelativeVector3)obj);
            }
            else if (type.Equals(typeof(RelativeVector4)))
            {
                value = new PropertyValue((RelativeVector4)obj);
            }
            else if (type.Equals(typeof(Extents)))
            {
                value = new PropertyValue((Extents)obj);
            }
            else if (type.Equals(typeof(Rectangle)))
            {
                value = new PropertyValue((Rectangle)obj);
            }
            else
            {
                throw new global::System.InvalidOperationException("Unimplemented type for Property Value :" + type.Name);
            }
            return(value);
        }
Example #25
0
 public static MemberField[] GetFields(System.Object obj, int level = 0)
 {
     return(GetFieldsFromType(obj.GetType(), obj, level));
 }
        public void SortingLayerField(Rect position, GUIContent label, SerializedProperty layerID, GUIStyle style, GUIStyle labelStyle)
        {
            Event e = Event.current;

            int[]    sortingLayerUniqueIDs = EditorUtils.GetSortingLayerUniqueIDs();
            string[] sortingLayerNames     = EditorUtils.GetSortingLayerNames();

            ArrayUtility.Add <string>(ref sortingLayerNames, string.Empty);
            ArrayUtility.Add <string>(ref sortingLayerNames, "Add Sorting Layer...");

            GUIContent[] array = new GUIContent[sortingLayerNames.Length];
            for (int i = 0; i < sortingLayerNames.Length; i++)
            {
                array[i] = new GUIContent(sortingLayerNames[i]);
            }

            EditorUtility.SelectMenuItemFunction setEnumValueDelegate = (object userData, string[] options, int selected) =>
            {
                if (selected == options.Length - 1)
                {
                    //((TagManager)EditorApplication.tagManager).m_DefaultExpandedFoldout = "SortingLayers";
                    PropertyInfo tagManagerPropertyInfo = typeof(EditorApplication).GetProperty("tagManager", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetProperty);
                    if (tagManagerPropertyInfo != null)
                    {
                        System.Object tagManager = (System.Object)tagManagerPropertyInfo.GetValue(typeof(EditorApplication), null);
                        FieldInfo     fieldInfo  = tagManager.GetType().GetField("m_DefaultExpandedFoldout");
                        if (fieldInfo != null)
                        {
                            fieldInfo.SetValue(tagManager, "SortingLayers");
                        }
                    }
                    EditorApplication.ExecuteMenuItem("Edit/Project Settings/Tags and Layers");
                }
                else
                {
                    m_hasChanged     = true;
                    layerID.intValue = m_property.intValue = sortingLayerUniqueIDs[selected];
                    m_property.serializedObject.ApplyModifiedProperties();
                    m_property.serializedObject.Update();
                    EditorUtility.SetDirty(m_property.serializedObject.targetObject);
                }
            };

            int sortingLayerIdx = System.Array.IndexOf(sortingLayerUniqueIDs, layerID.intValue);

            Rect rPopup = position;

            rPopup.x     += EditorGUIUtility.labelWidth;
            rPopup.width -= EditorGUIUtility.labelWidth;

            if (e.type == EventType.Repaint)
            {
                labelStyle.Draw(position, label, false, false, false, false);
                string sortingLayerName = sortingLayerIdx >= 0 && sortingLayerIdx < sortingLayerNames.Length ? sortingLayerNames[sortingLayerIdx] : "";
                style.Draw(rPopup, sortingLayerName, false, false, false, false);
            }

            if (position.Contains(e.mousePosition) && e.isMouse && e.button == 0)
            {
                EditorUtility.DisplayCustomMenu(rPopup, array, sortingLayerIdx, setEnumValueDelegate, null);
            }
        }
Example #27
0
        private async void ModelEnter(System.Object obj)
        {
            try
            {
                if (!BuscarImputadoHabilitado)
                {
                    (new Dialogos()).ConfirmacionDialogo("Advertencia!", "No cuenta con suficientes privilegios para realizar esta acción.");
                    return;
                }

                if (obj == null)
                {
                    (new Dialogos()).ConfirmacionDialogo("Advertencia!", "Ocurrió un error al realizar la búsqueda de imputados.");
                    return;
                }

                if (obj != null)
                {
                    if (!obj.GetType().Name.Equals("String"))
                    {
                        var textbox = obj as System.Windows.Controls.TextBox;
                        if (textbox != null)
                        {
                            switch (textbox.Name)
                            {
                            case "NombreBuscar":
                                NombreBuscar = textbox.Text;
                                NombreD      = NombreBuscar;
                                FolioBuscar  = FolioD;
                                AnioBuscar   = AnioD;
                                break;

                            case "ApellidoPaternoBuscar":
                                ApellidoPaternoBuscar = textbox.Text;
                                PaternoD    = ApellidoPaternoBuscar;
                                FolioBuscar = FolioD;
                                AnioBuscar  = AnioD;
                                break;

                            case "ApellidoMaternoBuscar":
                                ApellidoMaternoBuscar = textbox.Text;
                                MaternoD    = ApellidoMaternoBuscar;
                                FolioBuscar = FolioD;
                                AnioBuscar  = AnioD;
                                break;

                            case "FolioBuscar":
                                if (!string.IsNullOrEmpty(textbox.Text))
                                {
                                    FolioBuscar = int.Parse(textbox.Text);
                                }
                                else
                                {
                                    FolioBuscar = null;
                                }
                                AnioBuscar = AnioD;
                                break;

                            case "AnioBuscar":
                                if (!string.IsNullOrEmpty(textbox.Text))
                                {
                                    AnioBuscar = int.Parse(textbox.Text);
                                }
                                else
                                {
                                    AnioBuscar = null;
                                }
                                FolioBuscar = FolioD;
                                break;
                            }
                        }
                    }
                }

                ListExpediente = new RangeEnabledObservableCollection <SSP.Servidor.IMPUTADO>();

                if (string.IsNullOrEmpty(NombreD))
                {
                    NombreBuscar = string.Empty;
                }
                else
                {
                    NombreBuscar = NombreD;
                }

                if (string.IsNullOrEmpty(PaternoD))
                {
                    ApellidoPaternoBuscar = string.Empty;
                }
                else
                {
                    ApellidoPaternoBuscar = PaternoD;
                }

                if (string.IsNullOrEmpty(MaternoD))
                {
                    ApellidoMaternoBuscar = string.Empty;
                }
                else
                {
                    ApellidoMaternoBuscar = MaternoD;
                }

                if (AnioBuscar != null && FolioBuscar != null)
                {
                    ListExpediente = new RangeEnabledObservableCollection <SSP.Servidor.IMPUTADO>();
                    ListExpediente.InsertRange(await SegmentarResultadoBusqueda());
                    if (ListExpediente.Count == 1)
                    {
                        if (ListExpediente[0].INGRESO != null && !ListExpediente[0].INGRESO.Any())
                        {
                            SelectExpediente = null;
                            SelectIngreso    = null;
                            ImagenImputado   = ImagenIngreso = new Imagenes().getImagenPerson();
                            PopUpsViewModels.ShowPopUp(this, PopUpsViewModels.TipoPopUp.BUSQUEDA);
                            new Dialogos().ConfirmacionDialogo("Notificación!", "No se encontró ningún ingreso activo en este imputado.");
                            return;
                        }
                        ;

                        foreach (var item in Parametro.ESTATUS_ADMINISTRATIVO_INACT)
                        {
                            if (ListExpediente[0].INGRESO.OrderByDescending(o => o.ID_INGRESO).FirstOrDefault().ID_ESTATUS_ADMINISTRATIVO == item)
                            {
                                SelectExpediente = null;
                                SelectIngreso    = null;
                                ImagenImputado   = ImagenIngreso = new Imagenes().getImagenPerson();
                                PopUpsViewModels.ShowPopUp(this, PopUpsViewModels.TipoPopUp.BUSQUEDA);
                                new Dialogos().ConfirmacionDialogo("Notificación!", "No se encontró ningún ingreso activo en este imputado.");
                                return;
                            }
                            ;
                        }
                        ;

                        if (ListExpediente[0].INGRESO.OrderByDescending(o => o.ID_INGRESO).FirstOrDefault().ID_UB_CENTRO != GlobalVar.gCentro)
                        {
                            SelectExpediente = null;
                            SelectIngreso    = null;
                            ImagenImputado   = ImagenIngreso = new Imagenes().getImagenPerson();
                            PopUpsViewModels.ShowPopUp(this, PopUpsViewModels.TipoPopUp.BUSQUEDA);
                            new Dialogos().ConfirmacionDialogo("Validación", "El ingreso seleccionado no pertenece a su centro.");
                            return;
                        }
                        ;

                        if (ListExpediente[0].INGRESO.OrderByDescending(o => o.ID_INGRESO).FirstOrDefault().TRASLADO_DETALLE.Any(a => a.ID_ESTATUS != "CA" ? a.TRASLADO.ORIGEN_TIPO != "F" : false))
                        {
                            new Dialogos().ConfirmacionDialogo("Notificación!", "El interno [" + ListExpediente[0].ID_ANIO.ToString() + "/" +
                                                               ListExpediente[0].ID_IMPUTADO.ToString() + "] tiene un traslado próximo y no tiene permitido ningún cambio de información.");
                            return;
                        }
                        ;


                        SelectExpediente = ListExpediente[0];
                        SelectIngreso    = ListExpediente[0].INGRESO.OrderByDescending(o => o.ID_INGRESO).FirstOrDefault();
                        SelectedInterno  = SelectExpediente;
                        var toleranciaTraslado = Parametro.TOLERANCIA_TRASLADO_EDIFICIO;
                        if (SelectIngreso.TRASLADO_DETALLE.Any(a => (a.ID_ESTATUS != "CA" ? a.TRASLADO.ORIGEN_TIPO != "F" : false) && a.TRASLADO.TRASLADO_FEC.AddHours(-toleranciaTraslado) <= Fechas.GetFechaDateServer))
                        {
                            new Dialogos().ConfirmacionDialogo("Notificación!", "El interno [" + SelectIngreso.ID_ANIO.ToString() + "/" +
                                                               SelectIngreso.ID_IMPUTADO.ToString() + "] tiene un traslado próximo y no tiene permitido ningún cambio de información.");
                            return;
                        }

                        SeleccionaIngreso();
                        StaticSourcesViewModel.SourceChanged = false;
                        PopUpsViewModels.ClosePopUp(PopUpsViewModels.TipoPopUp.BUSQUEDA);
                        return;
                    }
                    else
                    {
                        SelectExpediente = null;
                        SelectIngreso    = null;
                        ImagenImputado   = ImagenIngreso = new Imagenes().getImagenPerson();
                        PopUpsViewModels.ShowPopUp(this, PopUpsViewModels.TipoPopUp.BUSQUEDA);
                    }

                    SeleccionaIngreso();
                }
                else
                {
                    ListExpediente = new RangeEnabledObservableCollection <SSP.Servidor.IMPUTADO>();
                    ListExpediente.InsertRange(await SegmentarResultadoBusqueda());
                    if (ListExpediente.Count > 0)//Empty row
                    {
                        EmptyExpedienteVisible = false;
                    }
                    else
                    {
                        EmptyExpedienteVisible = true;
                    }

                    ImagenImputado = ImagenIngreso = new Imagenes().getImagenPerson();
                    PopUpsViewModels.ShowPopUp(this, PopUpsViewModels.TipoPopUp.BUSQUEDA);
                }
            }
            catch (System.Exception ex)
            {
                StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al ingresar búsqueda", ex);
            }
        }
Example #28
0
        // This runs in a seperate thread, be careful accessing anything outside of it's thread
        // or you may get an AccessViolation/crash.
        private void ThreadWorker(Object parameters)
        {
            if (Verbosity > 0)
            {
                Debug.Log("Ignorance Client: Initializing. Please stand by...");
            }

            ThreadParamInfo      setupInfo;
            Address              clientAddress = new Address();
            Peer                 clientPeer;  // The peer object that represents the client's connection.
            Host                 clientHost;  // NOT related to Mirror "Client Host". This is the client's ENet Host Object.
            Event                clientEvent; // Used when clients get events on the network.
            IgnoranceClientStats icsu = default;
            bool                 alreadyNotifiedAboutDisconnect = false;

            // Unused for now
            // bool emergencyStop = false;

            // Grab the setup information.
            if (parameters.GetType() == typeof(ThreadParamInfo))
            {
                setupInfo = (ThreadParamInfo)parameters;
            }
            else
            {
                Debug.LogError("Ignorance Client: Startup failure; Invalid thread parameters. Aborting.");
                return;
            }

            // Attempt to initialize ENet inside the thread.
            if (Library.Initialize())
            {
                Debug.Log("Ignorance Client: ENet Native successfully initialized.");
            }
            else
            {
                Debug.LogError("Ignorance Client: Failed to initialize ENet Native. This threads' f****d.");
                return;
            }

            // Attempt to connect to our target.
            clientAddress.SetHost(setupInfo.Address);
            clientAddress.Port = (ushort)setupInfo.Port;

            using (clientHost = new Host())
            {
                // TODO: Maybe try catch this
                clientHost.Create();
                clientPeer = clientHost.Connect(clientAddress, setupInfo.Channels);

                while (Commands.TryDequeue(out IgnoranceCommandPacket commandPacket))
                {
                    switch (commandPacket.Type)
                    {
                    default:
                        break;

                    case IgnoranceCommandType.ClientWantsToStop:
                        CeaseOperation = true;
                        break;

                    case IgnoranceCommandType.ClientStatusRequest:
                        // Respond with statistics so far.
                        if (!clientPeer.IsSet)
                        {
                            break;
                        }

                        icsu.RTT = clientPeer.RoundTripTime;

                        icsu.BytesReceived = clientPeer.BytesReceived;
                        icsu.BytesSent     = clientPeer.BytesSent;

                        icsu.PacketsReceived = clientHost.PacketsReceived;
                        icsu.PacketsSent     = clientPeer.PacketsSent;
                        icsu.PacketsLost     = clientPeer.PacketsLost;

                        StatusUpdates.Enqueue(icsu);
                        break;
                    }
                }

                // Process network events as long as we're not ceasing operation.
                while (!CeaseOperation)
                {
                    bool pollComplete = false;

                    // Step 1: Sending to Server
                    while (Outgoing.TryDequeue(out IgnoranceOutgoingPacket outgoingPacket))
                    {
                        // TODO: Revise this, could we tell the Peer to disconnect right here?
                        // Stop early if we get a client stop packet.
                        // if (outgoingPacket.Type == IgnorancePacketType.ClientWantsToStop) break;

                        int ret = clientPeer.Send(outgoingPacket.Channel, ref outgoingPacket.Payload);

                        if (ret < 0 && setupInfo.Verbosity > 0)
                        {
                            Debug.LogWarning($"Ignorance Client: ENet error {ret} while sending packet to Server via Peer {outgoingPacket.NativePeerId}.");
                        }
                    }

                    // If something outside the thread has told us to stop execution, then we need to break out of this while loop.
                    // while loop to break out of is while(!CeaseOperation).
                    if (CeaseOperation)
                    {
                        break;
                    }

                    // Step 2: Receive Data packets
                    // This loops until polling is completed. It may take a while, if it's
                    // a slow networking day.
                    while (!pollComplete)
                    {
                        Packet incomingPacket;
                        Peer   incomingPeer;
                        int    incomingPacketLength;

                        // Any events worth checking out?
                        if (clientHost.CheckEvents(out clientEvent) <= 0)
                        {
                            // If service time is met, break out of it.
                            if (clientHost.Service(setupInfo.PollTime, out clientEvent) <= 0)
                            {
                                break;
                            }

                            // Poll is done.
                            pollComplete = true;
                        }

                        // Setup the packet references.
                        incomingPeer = clientEvent.Peer;

                        // Now, let's handle those events.
                        switch (clientEvent.Type)
                        {
                        case EventType.None:
                        default:
                            break;

                        case EventType.Connect:
                            if (setupInfo.Verbosity > 0)
                            {
                                Debug.Log("Ignorance Client: ENet has connected to the server.");
                            }

                            ConnectionEvents.Enqueue(new IgnoranceConnectionEvent
                            {
                                EventType    = 0x00,
                                NativePeerId = incomingPeer.ID,
                                IP           = incomingPeer.IP,
                                Port         = incomingPeer.Port
                            });
                            break;

                        case EventType.Disconnect:
                        case EventType.Timeout:
                            if (setupInfo.Verbosity > 0)
                            {
                                Debug.Log("Ignorance Client: ENet has been disconnected from the server.");
                            }

                            ConnectionEvents.Enqueue(new IgnoranceConnectionEvent {
                                EventType = 0x01
                            });
                            CeaseOperation = true;
                            alreadyNotifiedAboutDisconnect = true;
                            break;

                        case EventType.Receive:
                            // Receive event type usually includes a packet; so cache its reference.
                            incomingPacket = clientEvent.Packet;

                            if (!incomingPacket.IsSet)
                            {
                                if (setupInfo.Verbosity > 0)
                                {
                                    Debug.LogWarning($"Ignorance Client: A receive event did not supply us with a packet to work with. This should never happen.");
                                }
                                break;
                            }

                            incomingPacketLength = incomingPacket.Length;

                            // Never consume more than we can have capacity for.
                            if (incomingPacketLength > setupInfo.PacketSizeLimit)
                            {
                                if (setupInfo.Verbosity > 0)
                                {
                                    Debug.LogWarning($"Ignorance Client: Incoming packet is too big. My limit is {setupInfo.PacketSizeLimit} byte(s) whilest this packet is {incomingPacketLength} bytes.");
                                }

                                incomingPacket.Dispose();
                                break;
                            }

                            IgnoranceIncomingPacket incomingQueuePacket = new IgnoranceIncomingPacket
                            {
                                Channel      = clientEvent.ChannelID,
                                NativePeerId = incomingPeer.ID,
                                Payload      = incomingPacket
                            };

                            Incoming.Enqueue(incomingQueuePacket);
                            break;
                        }
                    }

                    // If something outside the thread has told us to stop execution, then we need to break out of this while loop.
                    // while loop to break out of is while(!CeaseOperation).
                    if (CeaseOperation)
                    {
                        break;
                    }
                }

                Debug.Log("Ignorance Client: Thread shutdown commencing. Disconnecting and flushing connection.");

                // Flush the client and disconnect.
                clientPeer.Disconnect(0);
                clientHost.Flush();

                // Fix for client stuck in limbo, since the disconnection event may not be fired until next loop.
                if (!alreadyNotifiedAboutDisconnect)
                {
                    ConnectionEvents.Enqueue(new IgnoranceConnectionEvent {
                        EventType = 0x01
                    });
                    alreadyNotifiedAboutDisconnect = true;
                }
            }

            // Fix for client stuck in limbo, since the disconnection event may not be fired until next loop, again.
            if (!alreadyNotifiedAboutDisconnect)
            {
                ConnectionEvents.Enqueue(new IgnoranceConnectionEvent {
                    EventType = 0x01
                });
            }

            // Deinitialize
            Library.Deinitialize();

            if (setupInfo.Verbosity > 0)
            {
                Debug.Log("Ignorance Client: Shutdown complete.");
            }
        }
Example #29
0
 public static string ToString(System.Object obj)
 {
     if (obj == null)
     {
         return("null");
     }
     if (obj is Dictionary <string, string> )
     {
         Dictionary <string, string> dick = obj as Dictionary <string, string>;
         if (dick.Count == 0)
         {
             return("{}");
         }
         var b = "{";
         foreach (var e in dick)
         {
             b += e.Key + "=" + ToString(e.Value) + ", ";
         }
         return(b.Substring(0, b.Length - 2) + "}");
         //		} else if (obj.GetType(). {
         //			List<_> list = obj as List<_>;
         //			if (list.Count == 0) return "[]";
         //			var b = "[";
         //			foreach(object e in list) {
         //				b += ToString(e) + ", ";
         //			}
         //			return b.Substring(0, b.Length - 2)+ "]";
     }
     else if (obj is HashSet <string> )
     {
         var set = obj as HashSet <string>;
         return(ToString(set.ToArray()));
     }
     else if (obj.GetType().IsArray)
     {
         // TODO this don't f**k work
         var array = (object[])obj;
         if (array.Length == 0)
         {
             return("[]");
         }
         var b = "[";
         foreach (var i in array)
         {
             b += ToString(i) + ", ";
         }
         return(b.Substring(0, b.Length - 2) + "]");
     }
     else if (obj is List <string> )
     {
         // TODO this don't f**k work
         var list = (List <string>)obj;
         if (list.Count == 0)
         {
             return("[]");
         }
         var b = "[";
         foreach (var i in list)
         {
             b += i + ", ";
         }
         return(b.Substring(0, b.Length - 2) + "]");
     }
     else
     {
         var sb   = new System.Text.StringBuilder();
         var type = obj.GetType();
         sb.Append(type.Name);
         sb.Append("(");
         var fields = type.GetFields();
         if (fields.Length > 0)
         {
             foreach (System.Reflection.FieldInfo field in fields)
             {
                 sb.Append(field.Name);
                 sb.Append(": ");
                 sb.Append(field.GetValue(obj));
                 sb.Append(",");
             }
             sb.Remove(0, sb.Length - 1);
         }
         sb.Append(")");
         return(sb.ToString());
     }
 }
        //public static void XMLQuickEditor(Object obj){
        //    System.Type type = obj.GetType();
        //    var fields = type.GetFields();
        //    foreach (var item in fields) {
        //        //object[] objs = item.GetCustomAttributes(typeof(SerializeField),false);
        //        var att = item.GetCustomAttributes(typeof(XMLLayoutAttribute), false);
        //        if (att.Length > 0) {
        //            XMLLayoutAttribute xml = att[0] as XMLLayoutAttribute;
        //            item.GetValue(obj);
        //            //Debug.Log(item.Name);
        //        }
        //        //objs as SerializeFieldAttribute;
        //    }
        //}
        /// <summary>
        /// 分析XML自动编辑器属性生成编辑器,如果有修改返回true
        /// </summary>
        /// <returns><c>true</c>, if XML Editor was modified, <c>false</c> otherwise.</returns>
        /// <param name="obj">Object.</param>
        public static bool AnalyseXMLEditor(System.Object obj)
        {
            var fields = obj.GetType().GetFields();

            return(GUIMemb(fields, obj));
        }
Example #31
0
 protected void SetStateMachineName(Object stateMachine, string name)
 {
     stateMachine.GetType().GetField("name").SetValue(stateMachine, name);
 }