Example #1
0
        public IParseble Parse(SimpleJSON.JSONNode userNode)
        {
            if (userNode ["requisites"].Count > 1)
            {
                requisites = new Requisites(userNode ["requisites"] ["value"], userNode ["requisites"] ["isVisible"].AsBool, userNode ["requisites"] ["id_allow_modify"].AsBool);
            }
            country = new Country(userNode ["country"] ["value"], userNode ["country"] ["allow_modify"].AsBool);
            local   = userNode ["local"];
            savedPaymentMethodCount = userNode ["savedPaymentMethodCount"].AsInt;
            acceptLanguage          = userNode ["acceptLanguage"];
            acceptEncoding          = userNode ["acceptEncoding"];
            if ((userNode["user_balance"]["currency"] != null) && (userNode["user_balance"]["amount"] != null))
            {
                userBalance = new VirtualUserBalance(userNode["user_balance"]["currency"], userNode["user_balance"]["amount"].AsDecimal);
            }

            if (userNode["virtual_currency_balance"]["amount"] != null)
            {
                if (userNode["virtual_currency_balance"]["amount"] != null)
                {
                    virtualCurrencyBalance = new VirtualCurrencyBalance(userNode["virtual_currency_balance"]["amount"].AsDouble);
                }
            }

            return(this);
        }
Example #2
0
 public IParseble Parse(SimpleJSON.JSONNode userNode)
 {
     if (userNode ["requisites"].Count > 1)
     {
         requisites = new Requisites(userNode ["requisites"] ["value"], userNode ["requisites"] ["isVisible"].AsBool);
     }
     country = new Country(userNode ["country"] ["value"], userNode ["country"] ["allow_modify"].AsBool);
     local   = userNode ["local"];
     savedPaymentMethodCount = userNode ["savedPaymentMethodCount"].AsInt;
     acceptLanguage          = userNode ["acceptLanguage"];
     acceptEncoding          = userNode ["acceptEncoding"];
     return(this);
 }
Example #3
0
        public IParseble Parse(SimpleJSON.JSONNode userNode)
        {
            if(userNode ["requisites"].Count > 1)
                requisites = new Requisites (userNode ["requisites"] ["value"], userNode ["requisites"] ["isVisible"].AsBool);
            country = new Country (userNode ["country"] ["value"], userNode ["country"] ["allow_modify"].AsBool);
            local = userNode ["local"];
            savedPaymentMethodCount = userNode ["savedPaymentMethodCount"].AsInt;
            acceptLanguage = userNode ["acceptLanguage"];
            acceptEncoding = userNode ["acceptEncoding"];

            if (userNode["virtual_currency_balance"]["amount"] != null)
                virtualCurrencyBalance = new VirtualCurrencyBalance(userNode["virtual_currency_balance"]["amount"].AsDouble);

            return this;
        }
        public RequisitesControl(Requisites model)
        {
            Model = model;
            InitializeComponent();

            if (Model.Address != null)
            {
                textRequisitesIndex.Text    = Model.Address?.Index;
                textRequisitesCountry.Text  = Model.Address?.Country;
                textRequisitesRegion.Text   = Model.Address?.Region;
                textRequisitesDistrict.Text = Model.Address?.District;
                textRequisitesCity.Text     = Model.Address?.City;
                textRequisitesStreet.Text   = Model.Address?.Street;
                textRequisitesHouse.Text    = Model.Address?.House;
                textRequisitesFlat.Text     = Model.Address?.Flat;
            }
            textRequisitesSite.Text  = Model?.Site;
            textRequisitesEmail.Text = Model?.Email;

            EventSubscriptions();

            if (Model?.DepartmentPhones != null)
            {
                foreach (var phone in Model.DepartmentPhones)
                {
                    DepartmentsListView.Items.Add(new ListViewItem(new[]
                    {
                        phone.Key,
                        phone.Value
                    }));
                }
            }

            if (Model?.OtherRequisites != null)
            {
                foreach (var other in Model.OtherRequisites)
                {
                    OtherRequisitesListView.Items.Add(new ListViewItem(new[]
                    {
                        other.Key,
                        other.Value
                    }));
                }
            }

            IsDirty = false;
        }
Example #5
0
        private void ParseItem(string text)
        {
            // Start off optimistic with the results. Change the properties as necessary.
            var result = new ImportResult
            {
                Status = ImportStatus.Succeeded,
                Text   = text.Trim()
            };

            // Add the result to the results list.
            Results.Add(result);

            // See if there might be at least a token to parse, i.e., "t:text", the bare minimum.
            if (!text.ToLowerInvariant().Contains($"{Key.Text}{Delimiter.KeyValue}"))
            {
                // "t:" was not found, does it contain "e:", the alt?
                if (!text.ToLowerInvariant().Contains($"{Key.Text}{Delimiter.KeyValue}"))
                {
                    result.Status = ImportStatus.Error;
                    result.AddMessage($"{MessageType.ItemError} There were no recognizable tokens found.");
                    result.AddMessage($" The mandatory token ('t:' or 'e:') was not found.");

                    return;
                }

                // If we get here, the "e:" was used to specify the text
            }

            // Extract token of data from the text. Return if an error was found.
            var tokens = Tokenize(text, ref result);

            if (result.Status == ImportStatus.Error)
            {
                return;
            }

            // Now we can bother to create a stem since the text is passed error checks. Anything
            // found beyond this point is a warning, except for a missing value for the text key.
            Stem stem = new Stem();

            foreach (var token in tokens)
            {
                switch (token.Key)
                {
                case Key.Id:
                    if (Guid.TryParse(token.Value, out Guid guid))
                    {
                        result.Id = stem.Id = guid;
                    }
                    break;

                case Key.RootId:
                    if (Guid.TryParse(token.Value, out Guid rid))
                    {
                        stem.RootId = rid;
                    }
                    break;

                case Key.BaseId:
                    if (Guid.TryParse(token.Value, out Guid bid))
                    {
                        stem.BaseId = bid;
                    }
                    break;

                case Key.Text:
                case Key.TextAlt:
                    stem.Form = token.Value;
                    break;

                case Key.Category:
                    stem.Category = token.Value.ParseTag();
                    break;

                case Key.Root:

                    // Put the Id of this stem in the lookingForRoot
                    _lookingForRoot.Add(stem.Id, token.Value);
                    break;

                case Key.Base:

                    // Put the Id of this stem in the lookingForBase
                    _lookingForBase.Add(stem.Id, token.Value);
                    break;

                case Key.Requisite:
                    stem.RequisiteValues |= Requisites.ToValue(token.Value);
                    break;

                case Key.Suggestion:
                    stem.SuggestionValues |= Suggestion.ToValue(token.Value);
                    break;

                case Key.Compounding:
                    stem.CompoundingValues |= Compounding.ToValue(token.Value);
                    break;

                case Key.Affixes:
                case Key.AffixesAlt:
                    if (string.IsNullOrWhiteSpace(token.Value))
                    {
                        break;
                    }

                    stem.Affixes = new List <string>(token
                                                     .Value
                                                     .Split(new string[] { Delimiter.Item }, StringSplitOptions.RemoveEmptyEntries)
                                                     .Select(t => t.Trim())
                                                     .Distinct());

                    foreach (var affix in stem.Affixes)
                    {
                        if (!AffixExists(affix))
                        {
                            result.Status = ImportStatus.Warning;
                            result.AddMessage($"{MessageType.TokenWarning} Affix not found ('{affix}').");
                        }
                    }

                    break;

                case Key.Sense:

                    // Replace any space, ' ', with a period, '.'.
                    stem.Sense = token.Value?.Replace(Delimiter.Space, Delimiter.Morpheme)
                                 .Unescape()
                                 .Replace(Delimiter.Pipe, Delimiter.SemiColon);
                    break;

                case Key.Comments:
                    stem.Comments = token.Value?.Unescape()
                                    .Replace(Delimiter.Pipe, Delimiter.SemiColon);
                    break;

                default:
                    result.Status = ImportStatus.Warning;
                    result.AddMessage($"{MessageType.TokenWarning} Unrecognized key ('{token}').");
                    break;
                }
            }

            // Set the ID for the results for tracking. This is late as the ID might have been parsed
            // from the text.
            if (result.Id == Guid.Empty)
            {
                result.Id = stem.Id;
            }

            // Duplicate check
            if (_referenceStems.Where(s => s.Form == stem.Form & s.Category == stem.Category).Count() > 0)
            {
                result.Status = ImportStatus.Warning;
                result.AddMessage($"{MessageType.TokenWarning} Possible duplicate ('{stem.Form}').");

                DebugHelper.Warning(result.Message);
            }

            DebugHelper.Info($"Adding stem (text: '{stem.Form}')...");

            _referenceStems.Add(stem);
        }
Example #6
0
 public RequisitesListViewDropdownCell(Requisites model) : base(new RequisitesControl(model))
 {
 }