protected virtual void OnTyping(MessengerUser user, MessengerThread thread, bool isTyping)
        {
            var args = new TypingEventArgs(user, thread, isTyping);

            Typing?.Invoke(this, args);
        }
Example #2
0
 public void UserTyping(Typing t)
 {
 }
Example #3
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            JobLog casted_other = other as JobLog;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.JobLogPK, casted_other.JobLogPK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.RunDt, casted_other.RunDt))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Status, casted_other.Status))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.JobName, casted_other.JobName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Log, casted_other.Log))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Duration, casted_other.Duration))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreateDate, casted_other.Audit_CreateDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorUserName, casted_other.Audit_CreatorUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorIP, casted_other.Audit_CreatorIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifyDate, casted_other.Audit_LastModifyDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierUserName, casted_other.Audit_LastModifierUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierIP, casted_other.Audit_LastModifierIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }
Example #4
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            SystemMessage casted_other = other as SystemMessage;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.MessagePK, casted_other.MessagePK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Code, casted_other.Code))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Subject, casted_other.Subject))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Text, casted_other.Text))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Media, casted_other.Media))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Culture, casted_other.Culture))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.IsEnable, casted_other.IsEnable))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorUserName, casted_other.Audit_CreatorUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorIP, casted_other.Audit_CreatorIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreateDate, casted_other.Audit_CreateDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifyDate, casted_other.Audit_LastModifyDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierUserName, casted_other.Audit_LastModifierUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierIP, casted_other.Audit_LastModifierIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }
Example #5
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            NewsCategory casted_other = other as NewsCategory;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.CategoryPk, casted_other.CategoryPk))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.CategoryTitle, casted_other.CategoryTitle))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorUserName, casted_other.Audit_CreatorUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreateDate, casted_other.Audit_CreateDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorIP, casted_other.Audit_CreatorIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifyDate, casted_other.Audit_LastModifyDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierUserName, casted_other.Audit_LastModifierUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierIP, casted_other.Audit_LastModifierIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.IsListable, casted_other.IsListable))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Code, casted_other.Code))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (this.News.Count != casted_other.News.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }
            List <int> News_compared = new List <int>(this.News.Count);

            for (int i = 0; i < this.News.Count; ++i)
            {
                if (this.News[i] != null)
                {
                    bool found = false;
                    for (int j = 0; j < this.News.Count; ++j)
                    {
                        if (News_compared.Contains(j))
                        {
                            continue;
                        }
                        if (this.News[i].Equals(casted_other.News[j], checked_objects))
                        {
                            News_compared.Add(j);
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        checked_objects.Remove(this);
                        return(false);
                    }
                }
                else
                {
                    for (int j = 0; j < this.News.Count; ++j)
                    {
                        if (News_compared.Contains(j))
                        {
                            continue;
                        }
                        if (casted_other.News[j] == null)
                        {
                            News_compared.Add(j);
                            break;
                        }
                    }
                }
            }

            if (News_compared.Distinct().Count() != this.News.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }

            checked_objects.Remove(this);

            return(true);
        }
Example #6
0
        static void Main(string[] args)
        {
            //bool dummyInput = true; // Made to pass into bool to method
            //GetSet obj = new GetSet();


            //Console.WriteLine($"{obj.OutputOne(7)}");
            //Console.WriteLine($"{obj.One}");

            Typing dicy      = new Typing();
            bool   isItThere = dicy.pair.ContainsKey(0);
            bool   isKd      = dicy.pair.ContainsValue("KD");

            dicy.pair.Add(9, "Cook");

            if (!dicy.pair.ContainsKey(10))
            {
                dicy.pair[11] = "my man";
            }

            bool isEleven = dicy.pair.ContainsKey(11);

            Console.WriteLine(isItThere + " Mother f****r");
            Console.WriteLine(isKd + " KD");
            Console.WriteLine(isEleven + " 11");
            Console.WriteLine(dicy.pair[11]);

            // Outputting the contents of a loop.
            int    addKeys  = 0;
            string conValue = "";

            foreach (KeyValuePair <int, string> KV in dicy.pair)
            {
                addKeys  += KV.Key;
                conValue += KV.Value;
                Console.WriteLine(KV.Key + " " + KV.Value);
            }

            Console.WriteLine("Key Total equals " + addKeys);
            Console.WriteLine("Value Total equals " + conValue);


            TryCatch.TryCatchWhile(); // This is the while loop on try catch.
            //BoolToMethod.BoolSubtract(dummyInput);
            TryCatch tcobject = new TryCatch();

            tcobject.TryAndCatchDoWhile();
            TryCatch.TryAndCatch();
            Adder      mathOne = new Adder("John", 41);
            Adder      mathTwo = new Adder("Carl", 31);
            Subtractor minus   = new Subtractor("Jenny", 53);

            Dictionary <int, string> Mydics = new Dictionary <int, string>();

            Mydics.Add(1, "One");
            Mydics.Add(2, "Two");
            Mydics.Add(3, "Three");
            Mydics.Add(4, "Four");
            Mydics.Add(5, "Five");
            Mydics.Add(6, "Six");
            Mydics.Add(7, "Seven");


            foreach (KeyValuePair <int, string> dic in Mydics)
            {
                switch (dic.Key) // have to use dic.key or dic.value
                {
                case 1:
                    Console.WriteLine("first level");
                    break;

                case 2:
                case 3:
                case 4:
                case 5:
                    Console.WriteLine("second level");
                    break;

                case 6:
                    Console.WriteLine("third level");
                    break;

                case 7:
                    Console.WriteLine("fourth level");
                    break;
                }
            }
            foreach (KeyValuePair <int, string> mic in Mydics)
            {
                switch (mic.Value)     // have to use dic.key or dic.value
                {
                case "One":
                    Console.WriteLine("first");
                    break;

                case "Two":
                case "Three":
                case "Four":
                case "Five":
                    Console.WriteLine("second");
                    break;

                case "Six":
                    Console.WriteLine("third");
                    break;

                case "Seven":
                    Console.WriteLine("fourth");
                    break;
                }
            }



            Console.WriteLine("Enter a Name: ");
            string enteredName = Console.ReadLine();

            Console.WriteLine("Enter one, two, three, or four for the dictionary: ");
            string getvar = Console.ReadLine();

            Console.WriteLine("Enter 9,8,7,6 For your int to string output ");
            int num = int.Parse(Console.ReadLine());

            CaseStatement.Cae('D');



            // working with dictionaries
            // Make a method out of this



            Console.WriteLine(mathOne.GetName());
            Console.WriteLine($"WIll it still print the name?:  {mathTwo.GetName()}");
            Console.WriteLine(mathOne.ChangeName("Bill"));
            Console.WriteLine(mathOne.ChangeName(enteredName));
            //Overload Method
            Console.WriteLine("Overload Method. Want to put the methods in there own class. OO classes also really helps with nameing conlisions. ");
            Console.WriteLine(minus.Subtract());
            Console.WriteLine(minus.Subtract(53));
            Console.WriteLine(minus.Subtract(53, 25));



            Console.WriteLine($" mathtwo is {mathTwo.AddAge(4)} years old");
            Console.WriteLine($" mathtwo is {mathTwo.SecondLevelAgeAdder(4, "Larry")} years old, and name is {mathTwo.GetName()}");
            Console.WriteLine($"{mathTwo.ChangeName("Paul")}");
            Console.WriteLine($" The new name is {mathOne.GetName()}");
            Console.WriteLine($" mathtwo is {mathTwo.SecondLevelAgeAdder(4, "Pearl")} years old, and name is {mathTwo.GetName()}");

            TowObjInteractAdderSubtract.TwoClasses(mathOne, minus);
            Console.WriteLine($"{mathOne.Name}, {minus.Age}");
            PracDict.Dicswitch(getvar);
            PracDict.IntStringTester(num);



            // working with dictionaries

            Console.ReadKey();
        }
 /// <summary>
 /// Render and begin indicator animation
 /// </summary>
 public TypingIndicator()
 {
     this.InitializeComponent();
     Typing.Begin();
 }
Example #8
0
        public async Task <IEnumerable <ObserverMessage> > GetNewMessagesAsync()
        {
            var html = await try_do_async(async() =>
            {
                var response = await Http.GetAsync("/Loader.aspx?ParTree=151313&Flow=0");
                response.EnsureSuccessStatusCode();
                var content = await response.Content.ReadAsStringAsync();
                return(content.ApplyCorrectYeKe());
            });

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(html);

            var trs = doc.DocumentNode.SelectNodes("//tr").ToList();

            var             messages     = new List <ObserverMessage>();
            ObserverMessage prev_message = null;

            foreach (var tr in trs)
            {
                if (tr.ChildNodes.Count == 4)
                {
                    prev_message = new ObserverMessage()
                    {
                        Subject   = tr.ChildNodes[0].InnerText,
                        MessageDt = Typing.ChangeType <DateTime>("13" + tr.ChildNodes[2].InnerText)
                    };
                }
                else
                {
                    if (prev_message != null)
                    {
                        prev_message.Description = tr.InnerText;
                    }

                    foreach (Match match in Regex.Matches(tr.InnerText, @"\(([^)]*)\)"))
                    {
                        var org_name = match.Groups[1].Value;

                        if (_blackList.Contains(org_name))
                        {
                            continue;
                        }

                        var instance_name = org_name.TrimEnd('1', '2', '3', '4');

                        var instance = StaticData.Instruments.FirstOrDefault(x => x.Symbol == org_name);
                        if (instance == null)
                        {
                            instance = StaticData.Instruments.FirstOrDefault(x => x.Symbol == instance_name);
                        }

                        if (instance != null)
                        {
                            if (prev_message.RelativeInstances == null)
                            {
                                prev_message.RelativeInstances = new List <long>();
                            }

                            if (!prev_message.RelativeInstances.Contains(instance.InsCode))
                            {
                                prev_message.RelativeInstances.Add(instance.InsCode);
                            }
                        }
                    }

                    messages.Add(prev_message);
                }
            }
            if (messages.Count == 0)
            {
                return(new ObserverMessage[0]);
            }

            if (LastObserverMessage == null)
            {
                LastObserverMessage = messages[0];
                return(messages);
            }

            int new_count = 0;

            for (int i = 0; i < messages.Count; ++i)
            {
                if (LastObserverMessage == messages[i])
                {
                    break;
                }
                else
                {
                    ++new_count;
                }
            }

            LastObserverMessage = messages[0];

            return(messages.Take(new_count));
        }
Example #9
0
        public async Task <InstrumentLastInfo> FindAsync(string symbole, long?insCode)
        {
            InstrumentLastInfo result = null;

            if (insCode != null && Data.ContainsKey(insCode.Value))
            {
                var row = Data[insCode.Value];
                result         = new InstrumentLastInfo();
                result.Symbole = row.l18;
                result.LSoc30  = row.l30;
                result.InsCode = row.RowId;
                result.CSecVal = row.cs;
            }

            if (result == null && insCode != null)
            {
                var ins = StaticData.Instruments.Where(x => x.InsCode == insCode.Value).FirstOrDefault();
                if (ins != null)
                {
                    result         = new InstrumentLastInfo();
                    result.Symbole = ins.Symbol;
                    result.LSoc30  = ins.LSoc30;
                    result.InsCode = ins.InsCode;
                    int cSecVal;
                    if (int.TryParse(ins.CSecVal, out cSecVal))
                    {
                        result.CSecVal = cSecVal;
                    }
                }
            }


            if (result == null && !String.IsNullOrEmpty(symbole))
            {
                var itemFromData = Data.Values.FirstOrDefault(x => x.l18 == symbole);
                if (itemFromData != null)
                {
                    result         = new InstrumentLastInfo();
                    result.Symbole = itemFromData.l18;
                    result.LSoc30  = itemFromData.l30;
                    result.InsCode = itemFromData.RowId;
                    result.CSecVal = itemFromData.cs;
                }
            }

            if (result == null)
            {
                var result_array = await try_do_async(async() =>
                {
                    var response = await Http.GetAsync("/tsev2/data/search.aspx?skey=" + symbole);
                    response.EnsureSuccessStatusCode();
                    var search_result = await response.Content.ReadAsStringAsync();
                    if (String.IsNullOrEmpty(search_result))
                    {
                        return(null);
                    }
                    return(search_result.ApplyCorrectYeKe().Split(';')[0]?.Split(','));
                });

                if (result_array != null && result_array.Length > 0)
                {
                    var item = result_array.FirstOrDefault(x => x == symbole);
                    if (item == null)
                    {
                        return(null);
                    }
                    result         = new InstrumentLastInfo();
                    result.Symbole = result_array[0];
                    result.LSoc30  = result_array[1]?.MaxLength(30);
                    result.InsCode = TryParseLong(result_array[2]);
                }
            }

            if (result != null)
            {
                //http://www.tsetmc.com/Loader.aspx?ParTree=151311&i=50792786683910016

                var t1 = try_do_async(async() =>
                {
                    var response = await Http.GetAsync("/Loader.aspx?ParTree=151311&i=" + result.InsCode);

                    response.EnsureSuccessStatusCode();
                    return(await response.Content.ReadAsStringAsync());
                });

                string loader_result = null;
                if (result.CSecVal == 0)
                {
                    await Task.WhenAll(t1);

                    loader_result  = t1.Result;
                    result.CSecVal = TryParseInt(extract(loader_result, "CSecVal"));
                }

                var t2 = try_do_async(async() =>
                {
                    var response = await Http.GetAsync(String.Format("/tsev2/data/instinfofast.aspx?i={0}&c={1}", result.InsCode, result.CSecVal));
                    response.EnsureSuccessStatusCode();
                    return(await response.Content.ReadAsStringAsync());
                });

                if (String.IsNullOrEmpty(loader_result))
                {
                    await Task.WhenAll(t1, t2);

                    loader_result = t1.Result;
                }
                else
                {
                    await Task.WhenAll(t2);
                }

                result.InstrumentID    = extract(loader_result, "InstrumentID");
                result.EstimatedEPS    = (float)TryParseDouble(extract(loader_result, "EstimatedEPS"));
                result.BaseVol         = TryParseLong(extract(loader_result, "BaseVol"));
                result.CSecVal         = TryParseInt(extract(loader_result, "CSecVal"));
                result.ZTitad          = TryParseLong(extract(loader_result, "ZTitad"));
                result.Flow            = (FlowTypes)TryParseInt(extract(loader_result, "Flow"));
                result.PSGelStaMin     = TryParseInt(extract(loader_result, "PSGelStaMin"));
                result.PSGelStaMax     = TryParseInt(extract(loader_result, "PSGelStaMax"));
                result.MinYear         = TryParseInt(extract(loader_result, "MinYear"));
                result.MaxYear         = TryParseInt(extract(loader_result, "MaxYear"));
                result.QTotTran5JAvg   = TryParseLong(extract(loader_result, "QTotTran5JAvg"));
                result.SectorPE        = (float)TryParseDouble(extract(loader_result, "SectorPE"));
                result.KAjCapValCpsIdx = TryParseLong(extract(loader_result, "KAjCapValCpsIdx"));
                result.PriceMin        = TryParseInt(extract(loader_result, "PriceMin"));
                result.PriceMax        = TryParseInt(extract(loader_result, "PriceMax"));


                var data    = t2.Result;
                var AllData = data.Split(';');
                var Ov      = AllData[0].Split(',');
                result.Status         = InsState(Ov[1]);
                result.PriceYesterday = TryParseInt(Ov[5]);
                result.PdrCotVal      = TryParseInt(Ov[2]);
                result.PClosing       = TryParseInt(Ov[3]);
                result.Last           = TryParseInt(Ov[11]);
                result.Count          = TryParseInt(Ov[8]);
                result.Vol            = TryParseLong(Ov[9]);
                result.Val            = TryParseDecimal(Ov[10]);
                if (result.Flow != FlowTypes.Ati)
                {
                    result.BVal = TryParseDecimal(Ov[11]);
                }

                if (!String.IsNullOrEmpty(result.InstrumentID) &&
                    result.InstrumentID.Length > 2 && result.InstrumentID[2] == 'T' &&
                    Ov.Length > 14 && Ov[15].Length != 0)
                {
                    result.NAV     = TryParseInt(Ov[15]);
                    result.NAVDate = Typing.ChangeType <DateTime>(Ov[14]);
                }

                DateTime date;
                if (DateTime.TryParseExact(extract(loader_result, "DEven"), "yyyyMMdd", Thread.CurrentThread.CurrentCulture.DateTimeFormat, System.Globalization.DateTimeStyles.None, out date))
                {
                    result.DEven = date.Date;
                }
                return(result);
            }
            return(null);
        }
Example #10
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            Notification casted_other = other as Notification;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.NotificationPK, casted_other.NotificationPK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PortfolioPK, casted_other.PortfolioPK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.EventObjectId, casted_other.EventObjectId))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.SendSms, casted_other.SendSms))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.SendEmail, casted_other.SendEmail))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Calling, casted_other.Calling))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Owner, casted_other.Owner))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Email, casted_other.Email))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PhoneNo, casted_other.PhoneNo))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (this.NotificationLogs.Count != casted_other.NotificationLogs.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }
            List <int> NotificationLogs_compared = new List <int>(this.NotificationLogs.Count);

            for (int i = 0; i < this.NotificationLogs.Count; ++i)
            {
                if (this.NotificationLogs[i] != null)
                {
                    bool found = false;
                    for (int j = 0; j < this.NotificationLogs.Count; ++j)
                    {
                        if (NotificationLogs_compared.Contains(j))
                        {
                            continue;
                        }
                        if (this.NotificationLogs[i].Equals(casted_other.NotificationLogs[j], checked_objects))
                        {
                            NotificationLogs_compared.Add(j);
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        checked_objects.Remove(this);
                        return(false);
                    }
                }
                else
                {
                    for (int j = 0; j < this.NotificationLogs.Count; ++j)
                    {
                        if (NotificationLogs_compared.Contains(j))
                        {
                            continue;
                        }
                        if (casted_other.NotificationLogs[j] == null)
                        {
                            NotificationLogs_compared.Add(j);
                            break;
                        }
                    }
                }
            }

            if (NotificationLogs_compared.Distinct().Count() != this.NotificationLogs.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (this.Portfolio != null)
            {
                if (!this.Portfolio.Equals(casted_other.Portfolio, checked_objects))
                {
                    checked_objects.Remove(this);
                    return(false);
                }
            }
            else
            if (casted_other.Portfolio != null)
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }
Example #11
0
        public async Task RefreshLiveStates(bool fast)
        {
            try
            {
                var watch = new Stopwatch();
                watch.Start();
                var indexCodes = StaticData.Instruments
                                 .Where(x => x.Flow != (byte)FlowTypes.Ati && x.CompanyCode != Constants.CompanyCodes.IDXS)
                                 .Select(x => x.InsCode)
                                 .ToList();

                if (fast)
                {
                    indexCodes.RemoveFromIList(x => !Online.Data.ContainsKey(x));
                }

                OnOperationStart?.Invoke(this, indexCodes.Count * 2 + 3);

                var liveSrv   = StaticServiceFactory.Create <ILiveInstDataService>();
                var today     = DateTime.Now.Date;
                var savedData = await liveSrv.GetDefaultQuery()
                                .Where(x => x.DEven >= today)
                                .ToListAsync();

                OnOperationStep?.Invoke(this, EventArgs.Empty);
                int i = 0;
                var readWebSiteBlock = new TransformBlock <long, LiveInstData>(
                    async inxCode =>
                {
                    InstrumentLastInfo ins = null;
                    try
                    {
                        ins = await Online.FindAsync(null, inxCode);
                    }
                    catch (Exception ex)
                    {
                        _logger.WarnFormat("Cannot find instrument by code {0}; operation skip from this error.", ex, inxCode);
                        return(null);
                    }
                    if (ins == null)
                    {
                        _logger.WarnFormat("cannot find instrument with code {0}", inxCode);
                        return(null);
                    }
                    else
                    {
                        _logger.InfoFormat("instance {0} live data fetched {1}% completed", inxCode, Math.Ceiling(i++ *1.0 / indexCodes.Count * 100));
                    }

                    var r = new LiveInstData();
                    foreach (var field in r.GetFields().Where(x => x.Kind == FieldKinds.Primitive))
                    {
                        var value = ins.GetPropertyValue(field.Name);
                        r.SetValue(field.Name, Typing.ChangeType(value, field.PropertyType));
                    }
                    OnOperationStep?.Invoke(this, EventArgs.Empty);
                    return(r);
                }, new ExecutionDataflowBlockOptions
                {
                    MaxDegreeOfParallelism = 15
                });

                List <LiveInstData> newData   = new List <LiveInstData>();
                List <LiveInstData> dirtyData = new List <LiveInstData>();
                var writeLiveInstData         = new ActionBlock <LiveInstData>(r =>
                {
                    if (r == null)
                    {
                        return;
                    }

                    var savedInst = savedData.FirstOrDefault(x => x.InsCode == r.InsCode);
                    if (savedInst != null)
                    {
                        savedInst.ResetChanges();
                        foreach (var field in r.GetFields().Where(x => x.Kind == FieldKinds.Primitive))
                        {
                            var value = r.GetPropertyValue(field.Name);
                            savedInst.SetValue(field.Name, Typing.ChangeType(value, field.PropertyType));
                        }
                        if (savedInst.ChangeTracker.State == ObjectState.Modified)
                        {
                            dirtyData.Add(savedInst);
                        }
                    }
                    else
                    {
                        r.DEven = today;
                        newData.Add(r);
                    }

                    OnOperationStep?.Invoke(this, EventArgs.Empty);
                });

                readWebSiteBlock.LinkTo(writeLiveInstData);


                foreach (var code in indexCodes)
                {
                    readWebSiteBlock.Post(code);
                }

                readWebSiteBlock.Complete();
                await readWebSiteBlock.Completion;

                var ov = ObjectRegistry.GetObject <IValidationProvider>();
                newData.RemoveFromIList(x => !ov.Validate(x, Mode.OnInsert.ToString()).IsValid);
                if (newData.Count > 0)
                {
                    await liveSrv.Repository.BulkInsertAsync(newData);
                }
                OnOperationStep?.Invoke(this, EventArgs.Empty);

                dirtyData.RemoveFromIList(x => !ov.Validate(x, Mode.OnUpdate.ToString()).IsValid);
                if (dirtyData.Count > 0)
                {
                    await liveSrv.SaveEntitiesAsync(dirtyData.ToArray());
                }
                OnOperationStep?.Invoke(this, EventArgs.Empty);

                newData.Clear();
                newData.TrimExcess();
                dirtyData.Clear();
                dirtyData.TrimExcess();

                watch.Stop();
                _logger.InfoFormat("RefreshLiveStates take {0}ms", watch.ElapsedMilliseconds);
                OnOperationCompleted?.Invoke(this, EventArgs.Empty);
            }
            catch (Exception exception)
            {
                _logger.Error("RefreshLiveStates", exception);
                OnOperationBreak?.Invoke(this, exception);
            }
        }
Example #12
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            Portfolio casted_other = other as Portfolio;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.PortfolioPK, casted_other.PortfolioPK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Name, casted_other.Name))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.OrderIndex, casted_other.OrderIndex))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorUserName, casted_other.Audit_CreatorUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorIP, casted_other.Audit_CreatorIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreateDate, casted_other.Audit_CreateDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifyDate, casted_other.Audit_LastModifyDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierUserName, casted_other.Audit_LastModifierUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierIP, casted_other.Audit_LastModifierIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Owner, casted_other.Owner))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (this.Instruments.Count != casted_other.Instruments.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }
            List <int> Instruments_compared = new List <int>(this.Instruments.Count);

            for (int i = 0; i < this.Instruments.Count; ++i)
            {
                if (this.Instruments[i] != null)
                {
                    bool found = false;
                    for (int j = 0; j < this.Instruments.Count; ++j)
                    {
                        if (Instruments_compared.Contains(j))
                        {
                            continue;
                        }
                        if (this.Instruments[i].Equals(casted_other.Instruments[j], checked_objects))
                        {
                            Instruments_compared.Add(j);
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        checked_objects.Remove(this);
                        return(false);
                    }
                }
                else
                {
                    for (int j = 0; j < this.Instruments.Count; ++j)
                    {
                        if (Instruments_compared.Contains(j))
                        {
                            continue;
                        }
                        if (casted_other.Instruments[j] == null)
                        {
                            Instruments_compared.Add(j);
                            break;
                        }
                    }
                }
            }

            if (Instruments_compared.Distinct().Count() != this.Instruments.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (this.Notifications.Count != casted_other.Notifications.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }
            List <int> Notifications_compared = new List <int>(this.Notifications.Count);

            for (int i = 0; i < this.Notifications.Count; ++i)
            {
                if (this.Notifications[i] != null)
                {
                    bool found = false;
                    for (int j = 0; j < this.Notifications.Count; ++j)
                    {
                        if (Notifications_compared.Contains(j))
                        {
                            continue;
                        }
                        if (this.Notifications[i].Equals(casted_other.Notifications[j], checked_objects))
                        {
                            Notifications_compared.Add(j);
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        checked_objects.Remove(this);
                        return(false);
                    }
                }
                else
                {
                    for (int j = 0; j < this.Notifications.Count; ++j)
                    {
                        if (Notifications_compared.Contains(j))
                        {
                            continue;
                        }
                        if (casted_other.Notifications[j] == null)
                        {
                            Notifications_compared.Add(j);
                            break;
                        }
                    }
                }
            }

            if (Notifications_compared.Distinct().Count() != this.Notifications.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }

            checked_objects.Remove(this);

            return(true);
        }
 private void AddAdapterToPipeline(Typing typing)
 => Use(typing);
        public AdapterWithErrorHandler(IConfiguration configuration, ILogger <BotFrameworkHttpAdapter> logger, Typing typing)
            : base(configuration, logger)
        {
            if (typing == null)
            {
                throw new NullReferenceException($"Could not load '{nameof(typing)}' in custom adapter.");
            }

            AddAdapterToPipeline(typing);

            OnTurnError = async(turnContext, exception) =>
            {
                // Log any leaked exception from the application.
                logger.LogError(exception, $"[OnTurnError] unhandled error : {exception.Message}");

                // Send a message to the user
                await turnContext.SendActivityAsync("The bot encountered an error or bug.");

                await turnContext.SendActivityAsync("To continue to run this bot, please fix the bot source code.");

                // Send a trace activity, which will be displayed in the Bot Framework Emulator
                await turnContext.TraceActivityAsync("OnTurnError Trace", exception.Message, "https://www.botframework.com/schemas/error", "TurnError");
            };
        }
Example #15
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            AspNetUser casted_other = other as AspNetUser;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.Id, casted_other.Id))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Access, casted_other.Access))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Email, casted_other.Email))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.EmailConfirmed, casted_other.EmailConfirmed))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PasswordHash, casted_other.PasswordHash))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.SecurityStamp, casted_other.SecurityStamp))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PhoneNumber, casted_other.PhoneNumber))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PhoneNumberConfirmed, casted_other.PhoneNumberConfirmed))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.TwoFactorEnabled, casted_other.TwoFactorEnabled))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.LockoutEndDateUtc, casted_other.LockoutEndDateUtc))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.LockoutEnabled, casted_other.LockoutEnabled))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.AccessFailedCount, casted_other.AccessFailedCount))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.UserName, casted_other.UserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (this.AspNetRoles.Count != casted_other.AspNetRoles.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }
            List <int> AspNetRoles_compared = new List <int>(this.AspNetRoles.Count);

            for (int i = 0; i < this.AspNetRoles.Count; ++i)
            {
                if (this.AspNetRoles[i] != null)
                {
                    bool found = false;
                    for (int j = 0; j < this.AspNetRoles.Count; ++j)
                    {
                        if (AspNetRoles_compared.Contains(j))
                        {
                            continue;
                        }
                        if (this.AspNetRoles[i].Equals(casted_other.AspNetRoles[j], checked_objects))
                        {
                            AspNetRoles_compared.Add(j);
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        checked_objects.Remove(this);
                        return(false);
                    }
                }
                else
                {
                    for (int j = 0; j < this.AspNetRoles.Count; ++j)
                    {
                        if (AspNetRoles_compared.Contains(j))
                        {
                            continue;
                        }
                        if (casted_other.AspNetRoles[j] == null)
                        {
                            AspNetRoles_compared.Add(j);
                            break;
                        }
                    }
                }
            }

            if (AspNetRoles_compared.Distinct().Count() != this.AspNetRoles.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }

            checked_objects.Remove(this);

            return(true);
        }
Example #16
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            ClientType casted_other = other as ClientType;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.ClintTypePK, casted_other.ClintTypePK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.DayDt, casted_other.DayDt))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Buy_CountI, casted_other.Buy_CountI))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Buy_CountN, casted_other.Buy_CountN))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Buy_I_Volume, casted_other.Buy_I_Volume))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Buy_N_Volume, casted_other.Buy_N_Volume))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Sell_CountI, casted_other.Sell_CountI))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Sell_CountN, casted_other.Sell_CountN))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Sell_I_Volume, casted_other.Sell_I_Volume))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Sell_N_Volume, casted_other.Sell_N_Volume))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Pl, casted_other.Pl))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.TVol, casted_other.TVol))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Prev_Buy_CountI, casted_other.Prev_Buy_CountI))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Prev_Buy_CountN, casted_other.Prev_Buy_CountN))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Prev_Buy_I_Volume, casted_other.Prev_Buy_I_Volume))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Prev_Buy_N_Volume, casted_other.Prev_Buy_N_Volume))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Prev_Sell_CountI, casted_other.Prev_Sell_CountI))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Prev_Sell_CountN, casted_other.Prev_Sell_CountN))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Prev_Sell_I_Volume, casted_other.Prev_Sell_I_Volume))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Prev_Sell_N_Volume, casted_other.Prev_Sell_N_Volume))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Prev_Pl, casted_other.Prev_Pl))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Prev_TVol, casted_other.Prev_TVol))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.heven, casted_other.heven))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.InsCode, casted_other.InsCode))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.VisitCount, casted_other.VisitCount))
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }
Example #17
0
        private Pokemon PickReplacement(
            Pokemon current,
            bool usePowerLevels,
            Typing type,
            bool noLegendaries,
            bool wonderGuard)
        {
            if (usePowerLevels)
            {
                //  start with within 10% and add 5% either direction till we find
                //  something
                var currentBst   = current.BstForPowerLevels();
                var minTarget    = currentBst - currentBst / 10;
                var maxTarget    = currentBst + currentBst / 10;
                var canPick      = new List <Pokemon>();
                var expandRounds = 0;

                while (canPick.Count == 0 || canPick.Count < 3 && expandRounds < 2)
                {
                    foreach (var pk in ValidPokemons)
                    {
                        if (pk.PrimaryType != type && pk.SecondaryType != type)
                        {
                            continue;
                        }
                        if (noLegendaries && pk.Legendary)
                        {
                            continue;
                        }
                        if (!wonderGuard && HasWonderGuard(pk))
                        {
                            continue;
                        }

                        var bst = pk.BstForPowerLevels();

                        if (bst >= minTarget && bst <= maxTarget)
                        {
                            canPick.Add(pk);
                        }
                    }

                    minTarget = minTarget - currentBst / 20;
                    maxTarget = maxTarget + currentBst / 20;
                    expandRounds++;
                }

                return(canPick[Random.Next(canPick.Count)]);
            }

            {
                Pokemon pk;

                while (true)
                {
                    pk = ValidPokemons[Random.Next(ValidPokemons.Count)];

                    if (pk.PrimaryType != type && pk.SecondaryType != type)
                    {
                        continue;
                    }
                    if (noLegendaries && pk.Legendary)
                    {
                        continue;
                    }
                    if (wonderGuard && HasWonderGuard(pk))
                    {
                        continue;
                    }

                    break;
                }

                return(pk);
            }
        }
Example #18
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            LiveInstData casted_other = other as LiveInstData;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.LiveInstDataPK, casted_other.LiveInstDataPK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.InsCode, casted_other.InsCode))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.EstimatedEPS, casted_other.EstimatedEPS))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.ZTitad, casted_other.ZTitad))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Flow, casted_other.Flow))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.MinYear, casted_other.MinYear))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.MaxYear, casted_other.MaxYear))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.QTotTran5JAvg, casted_other.QTotTran5JAvg))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.SectorPE, casted_other.SectorPE))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.KAjCapValCpsIdx, casted_other.KAjCapValCpsIdx))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PriceMin, casted_other.PriceMin))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PriceMax, casted_other.PriceMax))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.DEven, casted_other.DEven))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Status, casted_other.Status))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PriceYesterday, casted_other.PriceYesterday))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Last, casted_other.Last))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Count, casted_other.Count))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PdrCotVal, casted_other.PdrCotVal))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PClosing, casted_other.PClosing))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Vol, casted_other.Vol))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Val, casted_other.Val))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.BVal, casted_other.BVal))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.NAV, casted_other.NAV))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.NAVDate, casted_other.NAVDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PSGelStaMin, casted_other.PSGelStaMin))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PSGelStaMax, casted_other.PSGelStaMax))
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }
Example #19
0
        static void Main(string[] args)
        {
            Smi smi = new Smi()
            {
                text = "가<font face='궁서체'>나<font color='#abcdef' face=\"돋움체\" fade=\"in\">다</font>라</font>마<b>바</b>사<br>아<u>자</u>차<b>카<u>타<i>파</i></u></b>하"
            };
            Ass         ass;
            string      text;
            SmiFile     file;
            List <Attr> attrs;
            bool        doThis = false;

            doThis = false;
            if (doThis)
            {
                Console.WriteLine("샘플1");
                Console.WriteLine(smi);
                Console.WriteLine();

                Console.WriteLine("SMI -> 자체 형식");
                attrs = smi.ToAttr();
                Console.WriteLine();

                Console.WriteLine("자체 형식 -> ASS (fade 손실)");
                ass = new Ass().FromAttr(attrs);
                Console.WriteLine(ass.text);
                Console.WriteLine();

                Console.WriteLine("자체 형식 -> SMI");
                smi = new Smi().FromAttr(attrs);
                Console.WriteLine(smi.text);
                Console.WriteLine();

                Console.WriteLine("ASS -> 자체 형식");
                attrs = ass.ToAttr();
                Console.WriteLine();

                Console.WriteLine("자체 형식 -> SMI");
                smi = new Smi().FromAttr(attrs);
                Console.WriteLine(smi.text);
                Console.WriteLine();

                Console.WriteLine("자체 형식 -> ASS");
                ass = new Ass().FromAttr(attrs);
                Console.WriteLine(ass.text);
                Console.WriteLine();

                Console.WriteLine();
            }

            doThis = false;
            if (doThis)
            {
                Console.WriteLine("샘플2");
                text = "<Sync Start=1000><P Class=KRCC>\n"
                       + "asdf\n"
                       + "<Sync Start=1250><P Class=KRCC >\n"
                       + "가<font color='#abcdef'>나</font>다<font color='#9abcde' fade='in'>라</font>마<font color='#89abcd' fade='out'>바</font>사\n"
                       + "<Sync Start=1500><P Class=KRCC >\n"
                       + "가<font color='#abcdef'>나</font>다<font color='#9abcde'>라</font>마<font color='#000000'>바</font>사\n"
                ;
                Console.WriteLine(text);
                Console.WriteLine();

                Console.WriteLine("가공");
                file = new SmiFile().FromTxt(text);
                Smi.Normalize(file.body);
                text = Smi.Smi2txt(file.body);
                Console.WriteLine(text);
                Console.WriteLine();

                Console.WriteLine();
            }

            doThis = false;
            if (doThis)
            {
                Console.WriteLine("샘플3");
                text = "<Sync Start=61379><P Class=KRCC>\n"
                       + "<font color=\"#cccc88\">I</font><font color=\"#997722\">n the dreaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<font color=\"#cccc88\">In</font> <font color=\"#997722\">the dreaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=61687><P Class=KRCC>\n"
                       + "<font color=\"#cccc88\">In t</font><font color=\"#997722\">he dreaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<font color=\"#cccc88\">In th</font><font color=\"#997722\">e dreaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<font color=\"#cccc88\">In the</font> <font color=\"#997722\">dreaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=61957><P Class=KRCC>\n"
                       + "<font color=\"#cccc88\">In the d</font><font color=\"#997722\">reaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<font color=\"#cccc88\">In the dr</font><font color=\"#997722\">eaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<font color=\"#cccc88\">In the dre</font><font color=\"#997722\">aming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<font color=\"#cccc88\">In the drea</font><font color=\"#997722\">ming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=62595><P Class=KRCC>\n"
                       + "<font color=\"#cccc88\">In the dream</font><font color=\"#997722\">ing 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<font color=\"#cccc88\">In the dreami</font><font color=\"#997722\">ng 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<font color=\"#cccc88\">In the dreamin</font><font color=\"#997722\">g 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<font color=\"#cccc88\">In the dreaming</font> <font color=\"#997722\">誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=63710><P Class=KRCC>\n"
                ;
                Console.WriteLine(text);
                Console.WriteLine();

                Console.WriteLine("가공");
                file = new SmiFile().FromTxt(text);
                Smi.FillEmptySync(file.body);
                text = Smi.Smi2txt(file.body);
                Console.WriteLine(text);
                Console.WriteLine();

                Console.WriteLine();
            }

            doThis = false;
            if (doThis)
            {
                Console.WriteLine("샘플4");
                smi.text = "테스트<font typing='TypeWriter'>테스트</font>테스트";
                Console.WriteLine(smi.text);
                Console.WriteLine();

                Console.WriteLine("SMI -> 자체 형식");
                attrs = smi.ToAttr();
                Console.WriteLine();

                Console.WriteLine("자체 형식 -> ASS");
                ass = new Ass().FromAttr(attrs);
                Console.WriteLine(ass.text);
                Console.WriteLine();

                Console.WriteLine("자체 형식 -> SMI");
                smi = new Smi().FromAttr(attrs);
                Console.WriteLine(smi.text);
                Console.WriteLine();
            }

            doThis = false;
            if (doThis)
            {
                Console.WriteLine("샘플5");
                text = "<Sync Start=1000><P Class=KRCC>\n"
                       + "테스트   테스트\n"
                       + "<Sync Start=2000><P Class=KRCC>\n"
                       + "테스트<font typing='typewriter'>텍스트</font>테스트\n"
                       + "<Sync Start=3000><P Class=KRCC>\n"
                       + "테스트<font typing='keyboard'>텍스트</font>테스트\n"
                       + "<Sync Start=4000><P Class=KRCC>\n"
                       + "테스트<font typing='keyboard'>테스트</font>테스트\n"
                       + "<Sync Start=5000><P Class=KRCC>\n"
                       + "테스트<font typing='keyboard(0,1)'>테스트</font>테스트\n"
                       + "<Sync Start=6000><P Class=KRCC>\n"
                       + "테스트<font typing='keyboard(1,1)'>테스트</font>테스트\n"
                       + "<Sync Start=7000><P Class=KRCC>\n"
                       + "테스트<font typing='keyboard'>테test</font>테스트\n"
                       + "<Sync Start=8000><P Class=KRCC>\n"
                       + "테스트<font typing='keyboard invisible'>테test</font>테스트\n"
                       + "<Sync Start=9000><P Class=KRCC>\n"
                       + "테스트<font typing='keyboard hangeul'>테test</font><br>테스트\n"
                       + "<Sync Start=10000><P Class=KRCC>\n"
                       + "테스트테스트<font typing='keyboard'>테스트</font>\n"
                       + "<Sync Start=11000><P Class=KRCC>\n"
                       + "테스트테스트테스트\n"
                ;
                Console.WriteLine(text);
                Console.WriteLine();

                Console.WriteLine("가공");
                file = new SmiFile().FromTxt(text);
                Smi.Normalize(file.body);
                text = Smi.Smi2txt(file.body);
                Console.WriteLine(text);
                Console.WriteLine();
            }

            doThis = false;
            if (doThis)
            {
                string input = "실홰롻튄즤륢 ㅁㄴㅇㄻㄴ";
                Console.WriteLine("입력값");
                Console.WriteLine(input);
                Console.WriteLine();

                Console.WriteLine("타자기");
                char[] type   = Typing.ToType(input, Typing.Mode.typewriter);
                Typing typing = new Typing(Typing.Mode.typewriter, Typing.Cursor.invisible);
                foreach (char c in type)
                {
                    typing.Type(c);
                    Console.WriteLine(typing.Out());
                }

                Console.WriteLine();

                Console.WriteLine("키보드");
                type   = Typing.ToType(input, Typing.Mode.keyboard);
                typing = new Typing(Typing.Mode.keyboard, Typing.Cursor.invisible);
                foreach (char c in type)
                {
                    typing.Type(c);
                    Console.WriteLine(typing.Out());
                }
            }

            doThis = false;
            if (doThis)
            {
                Console.WriteLine("샘플 몇이냐");
                text = "<Sync Start=1379><P Class=KRCC>\n"
                       + "<font color=\"#cccc88\">I</font><font color=\"#997722\">n the dreaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=61533><P Class=KRCC	>\n"
                       + "<font color=\"#cccc88\">In</font> <font color=\"#997722\">the dreaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=1687><P Class=KRCC>\n"
                       + "<font color=\"#cccc88\">In t</font><font color=\"#997722\">he dreaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=61777><P Class=KRCC	>\n"
                       + "<font color=\"#cccc88\">In th</font><font color=\"#997722\">e dreaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=61867><P Class=KRCC	>\n"
                       + "<font color=\"#cccc88\">In the</font> <font color=\"#997722\">dreaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=1957><P Class=KRCC>\n"
                       + "<font color=\"#cccc88\">In the d</font><font color=\"#997722\">reaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=62116><P Class=KRCC	>\n"
                       + "<font color=\"#cccc88\">In the dr</font><font color=\"#997722\">eaming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=62276><P Class=KRCC	>\n"
                       + "<font color=\"#cccc88\">In the dre</font><font color=\"#997722\">aming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=62435><P Class=KRCC	>\n"
                       + "<font color=\"#cccc88\">In the drea</font><font color=\"#997722\">ming 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=2595><P Class=KRCC>\n"
                       + "<font color=\"#cccc88\">In the dream</font><font color=\"#997722\">ing 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=62873><P Class=KRCC	>\n"
                       + "<font color=\"#cccc88\">In the dreami</font><font color=\"#997722\">ng 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=63152><P Class=KRCC	>\n"
                       + "<font color=\"#cccc88\">In the dreamin</font><font color=\"#997722\">g 誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=63431><P Class=KRCC	>\n"
                       + "<font color=\"#cccc88\">In the dreaming</font> <font color=\"#997722\">誰かのために</font><br>In the dreaming 누군가를 위해서\n"
                       + "<Sync Start=3710><P Class=KRCC>asdf\n";
                Console.WriteLine(text);
                Console.WriteLine();

                Console.WriteLine("중간싱크 조절 가공");
                file = new SmiFile().FromTxt(text);
                Smi.Normalize(file.body);
                text = Smi.Smi2txt(file.body);
                Console.WriteLine(text);
                Console.WriteLine();

                Console.WriteLine();
            }

            doThis = false;
            if (doThis)
            {
                text = "<Sync Start=1293110><P Class=KRCC>"
                       + "<i><font color=\"#ccbbdd\">나란히 날아가는 한 쌍의 새</font></i>"
                       + "<Sync Start=1299594><P Class=KRCC>"
                       + "<i><font color=\"#ccbbdd\">손을 맞잡은</font></i>"
                       + "<Sync Start=1302545><P Class=KRCC>"
                       + "<i><font color=\"#ccbbdd\">부모·자식이 만드는 그림자</font></i>"
                       + "<Sync Start=1305823><P Class=KRCC>"
                       + "<i><font color=\"#ccbbdd\">저녁 해가 비춘 아름다운 것</font></i>"
                       + "<Sync Start=1312310><P Class=KRCC>"
                       + "<i><font color=\"#ccbbdd\">그런 “평범”한 게 눈부셨어</font></i>"
                       + "<Sync Start=1318632><P Class=KRCC>"
                       + "<i><font color=\"#ccbbdd\">푸른색 벤치가 허전해서</font></i>"
                       + "<Sync Start=1323976><P Class=KRCC>"
                       + "<i><font color=\"#ccbbdd\">나 혼자 외톨이 로 느껴졌어</font></i>"
                       + "<Sync Start=1331612><P Class=KRCC>"
                       + "&nbsp;"
                       + "<Sync Start=1333917><P Class=KRCC>"
                       + "<i><font color=\"#ccbbdd\">평범한 게 좋아서</font></i>";

                doThis = false;
                if (doThis)
                {
                    text = "<Sync Start=65483><P Class=KRCC >\n"
                           + "카나???\n"
                           + "<Sync Start=66293><P Class=KRCC >\n"
                           + "&nbsp;\n"
                           + "<Sync Start=68324><P Class=KRCC>\n"
                           + "하루코 ???\n"
                           + "<Sync Start=69054><P Class=KRCC >\n"
                           + "&nbsp;\n"
                           + "<Sync Start=72223><P Class=KRCC >\n"
                           + "슈퍼바이저\n"
                           + "<Sync Start=73504><P Class=KRCC >\n"
                           + "&nbsp;\n"
                           + "<Sync Start=169787><P Class=KRCC >\n"
                           + "히도미 미나세 이노리\n"
                           + "<Sync Start=170883><P Class=KRCC >\n"
                           + "&nbsp;\n"
                           + "<Sync Start=172325><P Class=KRCC >\n"
                           + "진유\n"
                           + "사와시로 미유키\n"
                           + "<Sync Start=173349><P Class=KRCC >\n"
                           + "&nbsp;\n"
                           + "<Sync Start=175555><P Class=KRCC >\n"
                           + "라하루\n"
                           + "하야시바라 메구미\n"
                           + "<Sync Start=176463><P Class=KRCC >\n"
                           + "슈퍼바이저 캐릭터 원안 주제가\n"
                           + "<Sync Start=177671><P Class=KRCC >\n"
                           + "&nbsp;";
                }

                file = new SmiFile().FromTxt(text);
                List <Ass> assBody = new AssFile().FromSync(file.ToSync()).body;
                foreach (Ass line in assBody)
                {
                    Console.WriteLine(line.ToTxt());
                }
            }

            System.Threading.Thread.Sleep(int.MaxValue);
        }
Example #20
0
 public void HandleUserTyping(Typing t)
 {
 }
Example #21
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            ClosingPrice casted_other = other as ClosingPrice;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.ClosingPricePK, casted_other.ClosingPricePK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.DateTime, casted_other.DateTime))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.InsCode, casted_other.InsCode))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PdrCotVal, casted_other.PdrCotVal))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.PClosing, casted_other.PClosing))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.First, casted_other.First))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Ystrdy, casted_other.Ystrdy))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Max, casted_other.Max))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Min, casted_other.Min))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.TradeCount, casted_other.TradeCount))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Vol, casted_other.Vol))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Val, casted_other.Val))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.BVal, casted_other.BVal))
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }
Example #22
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            BackstageJob casted_other = other as BackstageJob;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.BackstageJobPK, casted_other.BackstageJobPK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.RunAs, casted_other.RunAs))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.TimeToRun, casted_other.TimeToRun))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Status, casted_other.Status))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Service, casted_other.Service))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Action, casted_other.Action))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.SerializedArgs, casted_other.SerializedArgs))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.RemoveIfSuccess, casted_other.RemoveIfSuccess))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.RetryCount, casted_other.RetryCount))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Priority, casted_other.Priority))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.UniqueCode, casted_other.UniqueCode))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Dependency, casted_other.Dependency))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Queue, casted_other.Queue))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Server, casted_other.Server))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Tags, casted_other.Tags))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Debug, casted_other.Debug))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Error, casted_other.Error))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Duration, casted_other.Duration))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.RunDt, casted_other.RunDt))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.ExecutionLog, casted_other.ExecutionLog))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.MaxCpu, casted_other.MaxCpu))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.MaxMemory, casted_other.MaxMemory))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.MidCpu, casted_other.MidCpu))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.MidMemory, casted_other.MidMemory))
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }
Example #23
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            BestLimit casted_other = other as BestLimit;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.BestLimitPK, casted_other.BestLimitPK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.InsCode, casted_other.InsCode))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.DateTime, casted_other.DateTime))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Row, casted_other.Row))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Buy_Count, casted_other.Buy_Count))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Buy_Volume, casted_other.Buy_Volume))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Buy_Price, casted_other.Buy_Price))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Sell_Price, casted_other.Sell_Price))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Sell_Volume, casted_other.Sell_Volume))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Sell_Count, casted_other.Sell_Count))
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }
Example #24
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            HardLog casted_other = other as HardLog;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.Id, casted_other.Id))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.EntryDt, casted_other.EntryDt))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Level, casted_other.Level))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Kind, casted_other.Kind))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.UserName, casted_other.UserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.TraceKey, casted_other.TraceKey))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.IP, casted_other.IP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Method, casted_other.Method))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Type, casted_other.Type))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.ArgumentsCount, casted_other.ArgumentsCount))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Arguments, casted_other.Arguments))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.ElapsedMilliseconds, casted_other.ElapsedMilliseconds))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Result, casted_other.Result))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Message, casted_other.Message))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Exception, casted_other.Exception))
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }
Example #25
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            DashboardNote casted_other = other as DashboardNote;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.Id, casted_other.Id))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Text, casted_other.Text))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Color, casted_other.Color))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Roles, casted_other.Roles))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.StartDt, casted_other.StartDt))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.EndDt, casted_other.EndDt))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorUserName, casted_other.Audit_CreatorUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorIP, casted_other.Audit_CreatorIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreateDate, casted_other.Audit_CreateDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifyDate, casted_other.Audit_LastModifyDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierUserName, casted_other.Audit_LastModifierUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierIP, casted_other.Audit_LastModifierIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (this.DashboardUserNotes.Count != casted_other.DashboardUserNotes.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }
            List <int> DashboardUserNotes_compared = new List <int>(this.DashboardUserNotes.Count);

            for (int i = 0; i < this.DashboardUserNotes.Count; ++i)
            {
                if (this.DashboardUserNotes[i] != null)
                {
                    bool found = false;
                    for (int j = 0; j < this.DashboardUserNotes.Count; ++j)
                    {
                        if (DashboardUserNotes_compared.Contains(j))
                        {
                            continue;
                        }
                        if (this.DashboardUserNotes[i].Equals(casted_other.DashboardUserNotes[j], checked_objects))
                        {
                            DashboardUserNotes_compared.Add(j);
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        checked_objects.Remove(this);
                        return(false);
                    }
                }
                else
                {
                    for (int j = 0; j < this.DashboardUserNotes.Count; ++j)
                    {
                        if (DashboardUserNotes_compared.Contains(j))
                        {
                            continue;
                        }
                        if (casted_other.DashboardUserNotes[j] == null)
                        {
                            DashboardUserNotes_compared.Add(j);
                            break;
                        }
                    }
                }
            }

            if (DashboardUserNotes_compared.Distinct().Count() != this.DashboardUserNotes.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }

            checked_objects.Remove(this);

            return(true);
        }
Example #26
0
 public virtual bool TypeInGame(Typing type) => type.IsHackOnly == false;
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            IndexLastDayTimeValue casted_other = other as IndexLastDayTimeValue;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.IndexLastDayTimeValuePK, casted_other.IndexLastDayTimeValuePK))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.InsCode, casted_other.InsCode))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Dt, casted_other.Dt))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Value, casted_other.Value))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.ChangeValue, casted_other.ChangeValue))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.ChangePercent, casted_other.ChangePercent))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (this.Instrument != null)
            {
                if (!this.Instrument.Equals(casted_other.Instrument, checked_objects))
                {
                    checked_objects.Remove(this);
                    return(false);
                }
            }
            else
            if (casted_other.Instrument != null)
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }
Example #28
0
        public void RandomizeMovesLearnt(
            bool typeThemed,
            bool noBroken,
            bool forceFourStartingMoves,
            double goodDamagingProbability)
        {
            //  Get current sets
            var hms = RomHandler.Machines
                      .Where(machine => machine.Type == Machine.Kind.Hidden)
                      .Select(machine => machine.Move);

            var allBanned = new HashSet <Move>(noBroken ? RomHandler.Moves.Where(move => Move.GameBreaking.Contains(move.Id)) : Enumerable.Empty <Move>());

            allBanned.UnionWith(hms);

            //  Build sets of moves
            var validMoves             = new List <Move>();
            var validDamagingMoves     = new List <Move>();
            var validTypeMoves         = new Dictionary <Typing, List <Move> >();
            var validTypeDamagingMoves = new Dictionary <Typing, List <Move> >();

            foreach (var mv in ValidMoves)
            {
                if (mv == null || GlobalConstants.BannedRandomMoves[mv.Id] || allBanned.Contains(mv))
                {
                    continue;
                }

                validMoves.Add(mv);

                if (mv.Type != null)
                {
                    if (!validTypeMoves.ContainsKey(mv.Type))
                    {
                        validTypeMoves[mv.Type] = new List <Move>();
                    }

                    validTypeMoves[mv.Type].Add(mv);
                }

                if (GlobalConstants.BannedForDamagingMove[mv.Id])
                {
                    continue;
                }

                if (mv.Power < 2 * GlobalConstants.MinDamagingMovePower && (mv.Power < GlobalConstants.MinDamagingMovePower || !(mv.Hitratio >= 90)))
                {
                    continue;
                }

                validDamagingMoves.Add(mv);

                if (mv.Type == null)
                {
                    continue;
                }

                if (!validTypeDamagingMoves.ContainsKey(mv.Type))
                {
                    validTypeDamagingMoves[mv.Type] = new List <Move>();
                }

                validTypeDamagingMoves[mv.Type].Add(mv);
            }

            foreach (var pokemon in ValidPokemons)
            {
                var learnt = new HashSet <int>();
                var moves  = pokemon.MovesLearnt;
                //  4 starting moves?
                if (forceFourStartingMoves)
                {
                    var lv1Count = moves.Count(ml => ml.Level == 1);

                    if (lv1Count < 4)
                    {
                        for (var i = 0; i < 4 - lv1Count; i++)
                        {
                            var fakeLv1 = new MoveLearnt
                            {
                                Level = 1,
                                Move  = RomHandler.Moves[0]
                            };

                            moves.Insert(0, fakeLv1);
                        }
                    }
                }

                //  Find last lv1 move
                //  lv1index ends up as the index of the first non-lv1 move
                var lv1Index = 0;
                while (lv1Index < moves.Count &&
                       moves[lv1Index].Level == 1)
                {
                    lv1Index++;
                }

                //  last lv1 move is 1 before lv1index
                if (lv1Index != 0)
                {
                    lv1Index--;
                }

                //  Replace moves as needed
                for (var i = 0; i < moves.Count; i++)
                {
                    //  should this move be forced damaging?
                    var attemptDamaging = i == lv1Index || Random.NextDouble() < goodDamagingProbability;

                    //  type themed?
                    Typing typeOfMove = null;
                    if (typeThemed)
                    {
                        var picked = Random.NextDouble();
                        if (pokemon.PrimaryType == Typing.Normal ||
                            pokemon.SecondaryType == Typing.Normal)
                        {
                            if (pokemon.SecondaryType == null)
                            {
                                //  Pure NORMAL: 75% normal, 25% random
                                if (picked < 0.75)
                                {
                                    typeOfMove = Typing.Normal;
                                }

                                //  else random
                            }
                            else
                            {
                                //  Find the other type
                                //  Normal/OTHER: 30% normal, 55% other, 15% random
                                var otherType = pokemon.PrimaryType;
                                if (otherType == Typing.Normal)
                                {
                                    otherType = pokemon.SecondaryType;
                                }

                                if (picked < 0.3)
                                {
                                    typeOfMove = Typing.Normal;
                                }
                                else if (picked < 0.85)
                                {
                                    typeOfMove = otherType;
                                }

                                //  else random
                            }
                        }
                        else if (pokemon.SecondaryType != null)
                        {
                            //  Primary/Secondary: 50% primary, 30% secondary, 5%
                            //  normal, 15% random
                            if (picked < 0.5)
                            {
                                typeOfMove = pokemon.PrimaryType;
                            }
                            else if (picked < 0.8)
                            {
                                typeOfMove = pokemon.SecondaryType;
                            }
                            else if (picked < 0.85)
                            {
                                typeOfMove = Typing.Normal;
                            }

                            //  else random
                        }
                        else
                        {
                            //  Primary/None: 60% primary, 20% normal, 20% random
                            if (picked < 0.6)
                            {
                                typeOfMove = pokemon.PrimaryType;
                            }
                            else if (picked < 0.8)
                            {
                                typeOfMove = Typing.Normal;
                            }

                            //  else random
                        }
                    }

                    //  select a list to pick a move from that has at least one free
                    var pickList = validMoves;
                    if (attemptDamaging)
                    {
                        if (typeOfMove != null)
                        {
                            if (validTypeDamagingMoves.ContainsKey(typeOfMove) &&
                                CheckForUnusedMove(validTypeDamagingMoves[typeOfMove], learnt))
                            {
                                pickList = validTypeDamagingMoves[typeOfMove];
                            }
                            else if (CheckForUnusedMove(validDamagingMoves, learnt))
                            {
                                pickList = validDamagingMoves;
                            }
                        }
                        else if (CheckForUnusedMove(validDamagingMoves, learnt))
                        {
                            pickList = validDamagingMoves;
                        }
                    }
                    else if (typeOfMove != null)
                    {
                        if (validTypeMoves.ContainsKey(typeOfMove) &&
                            CheckForUnusedMove(validTypeMoves[typeOfMove], learnt))
                        {
                            pickList = validTypeMoves[typeOfMove];
                        }
                    }

                    //  now pick a move until we get a valid one
                    var mv = pickList[Random.Next(pickList.Count)];
                    while (learnt.Contains(mv.Id))
                    {
                        mv = pickList[Random.Next(pickList.Count)];
                    }

                    //  write it
                    moves[i].Move = mv;
                    if (i == lv1Index)
                    {
                        moves[i].Level = 1;
                    }

                    learnt.Add(mv.Id);
                }
            }

            bool CheckForUnusedMove(List <Move> potentialList, HashSet <int> alreadyUsed)
            {
                foreach (var mv in potentialList)
                {
                    if (!alreadyUsed.Contains(mv.Id))
                    {
                        return(true);
                    }
                }

                return(false);
            }
        }
Example #29
0
 private void Start()
 {
     typeManager = new Typing();
     isSpeaking  = false;
 }
Example #30
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            FeedBack casted_other = other as FeedBack;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.Id, casted_other.Id))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.UserName, casted_other.UserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.CreateDate, casted_other.CreateDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Description, casted_other.Description))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.LinkAddresss, casted_other.LinkAddresss))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Status, casted_other.Status))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.CategoryType, casted_other.CategoryType))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Mobile, casted_other.Mobile))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Email, casted_other.Email))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Response, casted_other.Response))
            {
                checked_objects.Remove(this);
                return(false);
            }
            checked_objects.Remove(this);

            return(true);
        }