Exemple #1
0
        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
                    }
                }
            }
        }
Exemple #2
0
 private ApolloResult SendReceipt <TResp>(TalkerCommand command, IPackable request, uint asyncFlag) where TResp : IUnpackable
 {
     return(this.Send(TalkerMessageType.Response, command, request, new ApolloMessage
     {
         AsyncFlag = asyncFlag
     }));
 }
Exemple #3
0
        internal ApolloResult SendNotice(TalkerCommand command, IPackable request)
        {
            ADebug.Log("SendNotice:" + request);
            ApolloMessage message = new ApolloMessage();

            return(this.Send(TalkerMessageType.Notice, command, request, message));
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        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));
        }
Exemple #6
0
 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);
 }
Exemple #7
0
 public void Add(IPackable item)
 {
     if ((Weight() + item.Weight()) <= this.capacity)
     {
         items.Add(item);
     }
 }
Exemple #8
0
 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;
 }
Exemple #10
0
        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);
     }
 }
Exemple #13
0
 public void Add(IPackable item)
 {
     if (Weight() + item.Weight() <= this.capacity)
     {
         this.list.Add(item);
     }
 }
Exemple #14
0
 public void Add(IPackable item)
 {
     if (this.Weight() + item.Weight() <= this.tilavuus)
     {
         this.list.Add(item);
     }
 }
Exemple #15
0
 public Any(bool val)
 {
     type     = AnyType.Bool;
     _longVal = val ? 1 : 0;
     floatVal = 0.0f;
     strVal   = null;
     objVal   = null;
 }
Exemple #16
0
 public Any(IPackable val)
 {
     type     = AnyType.Object;
     _longVal = 0;
     floatVal = 0.0f;
     strVal   = null;
     objVal   = val;
 }
Exemple #17
0
 public Any(string val)
 {
     type     = AnyType.Float;
     _longVal = 0;
     floatVal = 0.0f;
     strVal   = val;
     objVal   = null;
 }
Exemple #18
0
 public Any(long val)
 {
     type     = AnyType.Long;
     _longVal = val;
     floatVal = 0.0f;
     strVal   = null;
     objVal   = null;
 }
Exemple #19
0
        /// <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);
        }
Exemple #20
0
 public Any(int val)
 {
     type     = AnyType.Int;
     _longVal = val;
     floatVal = 0.0f;
     strVal   = null;
     objVal   = null;
 }
Exemple #21
0
 public static byte[] ToByteArray(this IPackable packable)
 {
     using (var packer = new Packer())
     {
         packable.Pack(packer);
         return(packer.ToByteArray());
     }
 }
Exemple #22
0
 public void Drop(IPackable item)
 {
     if (Inventory.Packables.Contains(item))
     {
         item.PickedUp = false;
     }
     Inventory.Packables.Remove(item);
 }
Exemple #23
0
 public void Add(IPackable item)
 {
     if (item.Weight() <= this.capacity - weightOfTheBox)
     {
         this.box.Add(item);
         weightOfTheBox += item.Weight();
     }
 }
Exemple #24
0
 public Any(byte val)
 {
     type     = AnyType.Byte;
     _longVal = val;
     floatVal = 0.0f;
     strVal   = null;
     objVal   = null;
 }
Exemple #25
0
 public Any(short val)
 {
     type     = AnyType.Short;
     _longVal = val;
     floatVal = 0.0f;
     strVal   = null;
     objVal   = null;
 }
Exemple #26
0
 public Any(float val)
 {
     type     = AnyType.Float;
     _longVal = 0;
     floatVal = val;
     strVal   = null;
     objVal   = null;
 }
Exemple #27
0
 public void Add(IPackable item)
 {
     if (this.capacity - this.boxedTotalWeight >= item.Weight())
     {
         this.itemsInBox.Add(item);
         this.boxedTotalWeight += item.Weight();
     }
 }
Exemple #28
0
        public PackableResult(IPackable packable) : base(ResultTypes.Ok)
        {
            if (packable == null)
            {
                throw new ArgumentException("Is Null", nameof(packable));
            }

            _packable = packable;
        }
Exemple #29
0
 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());
 }
Exemple #30
0
 public void Add(IPackable item)
 {
     //itemCount = 0;
     if ((item.Weight() + this.boxWeight) <= this.maxCapacity)
     {
         this.boxWeight += item.Weight();
         itemCount++;
     }
 }
Exemple #31
0
 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);
     }
 }
 public static void WritePackable(this MemoryStream pMemoryStream, IPackable pValue)
 {
     MemoryStream stream = new MemoryStream();
     pValue.Write(stream);
     pMemoryStream.WritePrefixed(stream);
 }