private static List <IPackable> PackableThings = new List <IPackable>(); //2015.04.11. public static void LoadAll() { //2015.04.11. var types = Assembly.GetExecutingAssembly().GetTypes(); foreach (var type in types) { if (!typeof(IPackable).IsAssignableFrom(type) || type.IsInterface) { continue; } if (!Directory.Exists(GetName(type))) { Directory.CreateDirectory(GetName(type)); //2015.05.16. } string[] files = Directory.GetFiles(GetName(type)).Where(entry => Path.GetFileNameWithoutExtension(entry).Length > 0).ToArray(); //Where: 2015.07.06. if (files.Length == 0) { DownloadDefaults(type); //2015.06.14. } foreach (string file in files) { IPackable packable = Activator.CreateInstance(type, true) as IPackable; PackableThings.Add(packable); if (typeof(IPackWithSave).IsAssignableFrom(type) && !type.IsInterface) { (packable as IPackWithSave).FileName = file; //2015.06.06. } if (!packable.LoadFromPack(file)) { PackableThings.Remove(packable); //2015.05.24. - Ezzel elvileg előbb-utóbb törli } } } }
private ApolloResult SendReceipt <TResp>(TalkerCommand command, IPackable request, uint asyncFlag) where TResp : IUnpackable { return(this.Send(TalkerMessageType.Response, command, request, new ApolloMessage { AsyncFlag = asyncFlag })); }
internal ApolloResult SendNotice(TalkerCommand command, IPackable request) { ADebug.Log("SendNotice:" + request); ApolloMessage message = new ApolloMessage(); return(this.Send(TalkerMessageType.Notice, command, request, message)); }
private ApolloResult SendNotice(IPackable request) { ADebug.Log("SendNotice:" + request); ApolloMessage message = new ApolloMessage(); return(this.Send(TalkerMessageType.Notice, new TalkerCommand(TalkerCommand.CommandDomain.App, request), request, message)); }
internal ApolloResult SendReceipt <TResp>(IPackable request, uint asyncFlag) where TResp : IUnpackable { ApolloMessage apolloMessage = new ApolloMessage(); apolloMessage.AsyncFlag = asyncFlag; return(this.Send(TalkerMessageType.Response, new TalkerCommand(TalkerCommand.CommandDomain.App, request), request, apolloMessage)); }
public ApolloResult Send(TalkerMessageType type, TalkerCommand command, IPackable request, ApolloMessage message) { if (command == null || request == null) { return(ApolloResult.InvalidArgument); } byte[] array = null; if (message == null) { message = new ApolloMessage(); } if (message.PackRequestData(command, request, out array, type)) { ADebug.Log(string.Concat(new object[] { "Sending:", command, " data size:", array.Length })); ApolloResult apolloResult = this.connector.WriteData(array, -1); if (apolloResult == ApolloResult.Success && message.Handler != null) { ApolloMessageManager.Instance.SeqMessageCollection.Add(message.SeqNum, message); } return(apolloResult); } ADebug.LogError("Send: " + command + " msg.PackRequestDat error"); return(ApolloResult.InnerError); }
public void Add(IPackable item) { if ((Weight() + item.Weight()) <= this.capacity) { items.Add(item); } }
public void Add(IPackable item) { if (Weight() + item.Weight() <= this.volume) { list.Add(item); } }
public static bool ReadPackable(this MemoryStream pMemoryStream, IPackable pValue) { MemoryStream stream = null; if (!pMemoryStream.ReadPrefixed(out stream)) return false; if (!pValue.Read(stream)) return false; return true; }
public static byte[] pack(IPackable packableEx) { ByteBuf buffer = new ByteBuf(); packableEx.marshal(buffer); return(buffer.asBytes()); }
public static void WritePackable(this MemoryStream pMemoryStream, IPackable pValue) { MemoryStream stream = new MemoryStream(); pValue.Write(stream); pMemoryStream.WritePrefixed(stream); }
public void Add(IPackable item) { if ((Weight() + item.Weight()) <= this.maxCapacity) { list.Add(item); } }
public void Add(IPackable item) { if (Weight() + item.Weight() <= this.capacity) { this.list.Add(item); } }
public void Add(IPackable item) { if (this.Weight() + item.Weight() <= this.tilavuus) { this.list.Add(item); } }
public Any(bool val) { type = AnyType.Bool; _longVal = val ? 1 : 0; floatVal = 0.0f; strVal = null; objVal = null; }
public Any(IPackable val) { type = AnyType.Object; _longVal = 0; floatVal = 0.0f; strVal = null; objVal = val; }
public Any(string val) { type = AnyType.Float; _longVal = 0; floatVal = 0.0f; strVal = val; objVal = null; }
public Any(long val) { type = AnyType.Long; _longVal = val; floatVal = 0.0f; strVal = null; objVal = null; }
/// <summary> /// Unpack an object from JSON format. /// </summary> /// <param name="json"></param> /// <returns></returns> public static IPackable Unpack(Stream jsonFile) { StreamReader reader = new StreamReader(jsonFile); IPackable result = Unpack(reader.ReadToEnd()); jsonFile.Dispose(); return(result); }
public Any(int val) { type = AnyType.Int; _longVal = val; floatVal = 0.0f; strVal = null; objVal = null; }
public static byte[] ToByteArray(this IPackable packable) { using (var packer = new Packer()) { packable.Pack(packer); return(packer.ToByteArray()); } }
public void Drop(IPackable item) { if (Inventory.Packables.Contains(item)) { item.PickedUp = false; } Inventory.Packables.Remove(item); }
public void Add(IPackable item) { if (item.Weight() <= this.capacity - weightOfTheBox) { this.box.Add(item); weightOfTheBox += item.Weight(); } }
public Any(byte val) { type = AnyType.Byte; _longVal = val; floatVal = 0.0f; strVal = null; objVal = null; }
public Any(short val) { type = AnyType.Short; _longVal = val; floatVal = 0.0f; strVal = null; objVal = null; }
public Any(float val) { type = AnyType.Float; _longVal = 0; floatVal = val; strVal = null; objVal = null; }
public void Add(IPackable item) { if (this.capacity - this.boxedTotalWeight >= item.Weight()) { this.itemsInBox.Add(item); this.boxedTotalWeight += item.Weight(); } }
public PackableResult(IPackable packable) : base(ResultTypes.Ok) { if (packable == null) { throw new ArgumentException("Is Null", nameof(packable)); } _packable = packable; }
public TalkerCommand(TalkerCommand.CommandDomain domain, IPackable obj) { if (obj == null) { throw new Exception("TalkerCommand Invalid Argument"); } this.Domain = domain; this.Command = new TalkerCommand.CommandValue(obj.GetType().ToString()); }
public void Add(IPackable item) { //itemCount = 0; if ((item.Weight() + this.boxWeight) <= this.maxCapacity) { this.boxWeight += item.Weight(); itemCount++; } }
public void Add(IPackable item) { // System.Console.WriteLine(item.Weight() + " "); // System.Console.WriteLine(this.load + " "); // System.Console.WriteLine(this.capacity); if (item.Weight() + this.load <= this.capacity) { this.load += item.Weight(); this.items.Add(item); } }