public SerializableObjectFactory(Assembly[] assemblies, bool forServer) { var types = ReflectionHelpers.GetTypesThatImplementInterfaces(assemblies, new Type[] { typeof(SerializableObject) }); foreach (var t in types) { var ctor = t.GetConstructor(System.Type.EmptyTypes); if (ctor != null) { var obj = ctor.Invoke(null) as SerializableObject; if ((forServer && (obj.serverType == t)) || (!forServer && (obj.clientType == t))) { if (objTypes.Contains(obj.classID)) { throw new System.Exception(t.FullName + " collides with an existing type!"); } else { objTypes.Add(obj.classID, ctor); } } } else { throw new TargetInvocationException(t.FullName + " does not have a constructor!", null); } } }
UnityNetDriverConnection CreateConnection(IntHashtable <UnityNetDriverConnection> connections, INetDriverCallbacks callbacks, int socketID, int connectionID, int reliableChannelID, int unreliableChannelID) { var hashCode = connectionID.GetHashCode(); if (connections.Contains(hashCode)) { throw new System.IO.IOException("Duplicate connection id! " + connectionID); } var conn = new UnityNetDriverConnection(connections, this, callbacks, socketID, connectionID, reliableChannelID, unreliableChannelID); connections[hashCode] = conn; return(conn); }
private static void FillDifferences(iText.Kernel.Font.DocFontEncoding fontEncoding, PdfArray diffs, CMapToUnicode toUnicode) { IntHashtable byte2uni = toUnicode != null?toUnicode.CreateDirectMapping() : new IntHashtable(); if (diffs != null) { int currentNumber = 0; for (int k = 0; k < diffs.Size(); ++k) { PdfObject obj = diffs.Get(k); if (obj.IsNumber()) { currentNumber = ((PdfNumber)obj).IntValue(); } else { String glyphName = ((PdfName)obj).GetValue(); int unicode = (int)AdobeGlyphList.NameToUnicode(glyphName); if (unicode != -1) { fontEncoding.codeToUnicode[currentNumber] = (int)unicode; fontEncoding.unicodeToCode.Put((int)unicode, currentNumber); fontEncoding.differences[currentNumber] = glyphName; fontEncoding.unicodeDifferences.Put((int)unicode, (int)unicode); } else { if (byte2uni.Contains(currentNumber)) { unicode = byte2uni.Get(currentNumber); fontEncoding.codeToUnicode[currentNumber] = (int)unicode; fontEncoding.unicodeToCode.Put((int)unicode, currentNumber); fontEncoding.differences[currentNumber] = glyphName; fontEncoding.unicodeDifferences.Put((int)unicode, (int)unicode); } } currentNumber++; } } } }
public NetMsgFactory(Assembly[] assemblies, bool forServer) { var types = ReflectionHelpers.GetTypesThatImplementInterfaces(assemblies, new[] { typeof(NetMsg) }); foreach (var t in types) { var ctor = t.GetConstructor(System.Type.EmptyTypes); if (ctor != null) { var netMsg = ctor.Invoke(null) as NetMsg; if ((netMsg.isServerMsg && forServer) || (netMsg.isClientMsg && !forServer)) { if (netMsg.shareInstance != null) { netMsg = netMsg.shareInstance; } else { netMsg.Init(); } if (netMsgs.Contains(netMsg.msgTypeID)) { throw new System.Exception(t.FullName + " collides with an existing type!"); } else { netMsgs.Add(netMsg.msgTypeID, netMsg); } } else if (netMsg.shareInstance == null) { netMsg.Init(); // clients need to init server net messages to send. } } else { throw new TargetInvocationException(t.FullName + " does not have a constructor!", null); } } }
public bool Contains(int k) { return(hashtable.Contains(k)); }