Exemple #1
0
        public void MultiInstantiation()
        {
            MultiString multi = new MultiString(BASE_MULTI_STRING);

            Assert.AreEqual(BASE_MULTI_STRING, multi.Multi,
                            @"MULTI Instantiation failed");
        }
Exemple #2
0
        public void MultiToString()
        {
            MultiString multi = new MultiString(BASE_MULTI_STRING);

            Assert.AreEqual(BASE_TOSTRING_EXPECT, multi.ToString(),
                            @"MULTI --> ToString Conversion failed");
        }
Exemple #3
0
        public void MultiXml()
        {
            MultiString multi = new MultiString(BASE_MULTI_STRING);

            Assert.AreEqual(BASE_XML_EXPECT, multi.MultiDocument.ToString(),
                            @"MULTI --> HTML Conversion failed");
        }
        private async Task <List <string> > TranslateStringsUsingGoogleAsync(string language, string apiKey, string appName, List <string> strings)
        {
            string        from       = MultiString.GetPrimaryLanguage(MultiString.DefaultLanguage);
            string        to         = MultiString.GetPrimaryLanguage(language);
            List <string> newStrings = new List <string>();
            int           total      = strings.Count();
            int           skip       = 0;

            while (total > 0)
            {
                TranslateService service = new TranslateService(new BaseClientService.Initializer()
                {
                    ApiKey          = apiKey,
                    ApplicationName = appName,
                });
                TranslationsListResponse resp = await service.Translations.List(strings.Skip(skip).Take(40).ToList(), to).ExecuteAsync();

                List <string> returnedStrings = (from r in resp.Translations select r.TranslatedText).ToList();
                returnedStrings = (from r in returnedStrings select Utility.HtmlDecode(r)).ToList();
                newStrings.AddRange(returnedStrings);
                skip  += returnedStrings.Count();
                total -= returnedStrings.Count();
            }
            return(newStrings);
        }
Exemple #5
0
 public AlertConfig()
 {
     CompleteMessage = new MultiString();
     Enabled         = false;
     Message         = null;
     MessageHandling = MessageHandlingEnum.DisplayUntilOff;
 }
Exemple #6
0
            /// <summary>
            /// Add all string properties of an object as search terms.
            /// </summary>
            public void AddObjectContents(object searchObject)
            {
                if (searchObject == null)
                {
                    return;
                }
                Type tp = searchObject.GetType();

                foreach (var propData in ObjectSupport.GetPropertyData(tp))
                {
                    if (propData.PropInfo.CanRead && propData.PropInfo.CanWrite)
                    {
                        if (propData.PropInfo.PropertyType == typeof(string))
                        {
                            string s = (string)propData.PropInfo.GetValue(searchObject, null);
                            AddContent(s);
                        }
                        else if (propData.PropInfo.PropertyType == typeof(MultiString))
                        {
                            MultiString ms = (MultiString)propData.PropInfo.GetValue(searchObject, null);
                            AddContent(ms);
                        }
                    }
                }
            }
Exemple #7
0
 public void MultiString_Direct_Equals_01()
 {
     for (int j = 0; j < 21; j++)
     {
         var targetString  = j < 20 ? j.ToString() : "x"; // something not found for the last iteration
         var cap           = new CharArrayPool();
         var intPool       = new ColumnPool <int>();
         var shortPool     = new ColumnPool <short>();
         var bitvectorPool = new ColumnPool <long>(1 + (Config.DataBatchSize >> 6));
         var ms            = new MultiString(cap, intPool, shortPool, bitvectorPool);
         var input         = new string[20];
         for (int i = 0; i < 20; i++)
         {
             var s = i.ToString();
             input[i] = s;
             ms.AddString(s);
         }
         ms.Seal();
         bitvectorPool.Get(out var inBV);
         var result = ms.Equals(targetString, inBV, false);
         var output = new List <string>();
         for (int i = 0; i < 20; i++)
         {
             if ((result.col[i >> 6] & (1L << (i & 0x3f))) == 0)
             {
                 output.Add(ms[i]);
             }
         }
         var expected = input.Where(e => e.Equals(targetString));
         Assert.IsTrue(expected.SequenceEqual(output));
     }
 }
Exemple #8
0
 public BlogCategory()
 {
     UseCaptcha           = true;
     Category             = new MultiString();
     Description          = new MultiString();
     CommentApproval      = ApprovalType.AnonymousUsers;
     SyndicationCopyright = new MultiString();
 }
Exemple #9
0
 static void Main(string[] args)
 {
     MultiString example     = new MultiString(@"THIS IS [cb3]A TEST [cb]WITH COLOR CHANGE");
     string      xmlExample  = example.MultiDocument.ToString();
     string      textExample = example.ToString();
     string      htmlExpect  = @"<multi>THIS IS <cb3 />A TEST <cb />WITH COLOR CHANGE</multi>";
     string      textExpect  = @"THIS IS A TEST WITH COLOR CHANGE";
 }
Exemple #10
0
 public MenuEntry()
 {
     MenuText         = new MultiString();
     LinkText         = new MultiString();
     Tooltip          = new MultiString();
     Legend           = new MultiString();
     ConfirmationText = new MultiString();
     PleaseWaitText   = new MultiString();
 }
Exemple #11
0
 private bool MatchMultiString(MultiString value, string search)
 {
     foreach (var item in value.Values)
     {
         if (item != null && item.Contains(search))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #12
0
 public BlogEntry()
 {
     Title           = new MultiString();
     Keywords        = new MultiString();
     UniqueId        = Guid.NewGuid();
     DatePublished   = DateTime.UtcNow;
     DateCreated     = DateTime.UtcNow;
     DateUpdated     = null;
     OpenForComments = true;
     CompleteSummary = new MultiString();
     CompleteText    = new MultiString();
     Category        = new MultiString();
 }
Exemple #13
0
 public TinyLoginModule()
     : base()
 {
     Title                 = this.__ResStr("modTitle", "Tiny Login");
     Name                  = this.__ResStr("modName", "Tiny Login");
     Description           = this.__ResStr("modSummary", "Provides Login/Register links and displays a logged on user's account name. This module is typically added to every page (as a skin module) so anonymous users can log in or register a new account. For logged on users their account name is shown with a link to the user settings.");
     AllowUserRegistration = true;
     UserTooltip           = new MultiString();
     ShowTitle             = false;
     WantSearch            = false;
     WantFocus             = false;
     Print                 = false;
     UsePartialFormCss     = false;
 }
Exemple #14
0
 private void AddSearchTerms(MultiString ms, bool allowAnonymous, bool allowAnyUser, int weight)
 {
     if (ms == null)
     {
         return;
     }
     foreach (var lang in MultiString.Languages)
     {
         string culture = lang.Id;
         string val     = ms[culture];
         if (!string.IsNullOrEmpty(val))
         {
             AddSearchTerms(culture, val, allowAnonymous, allowAnyUser, weight);
         }
     }
 }
 public EditModel()
 {
     MultiString      = new MultiString();
     MultiString10    = new MultiString();
     MultiString20    = new MultiString();
     MultiString40    = new MultiString();
     MultiString80    = new MultiString();
     MultiStringOpt   = new MultiString();
     MultiString10Opt = new MultiString();
     MultiString20Opt = new MultiString();
     MultiString40Opt = new MultiString();
     MultiString80Opt = new MultiString();
     MultiStringRO    = MultiString;
     MultiString10RO  = MultiString10;
     MultiString20RO  = MultiString20;
     MultiString40RO  = MultiString40;
     MultiString80RO  = MultiString80;
 }
Exemple #16
0
      /// <summary>Creates a new <see cref="SiteInfo"/> instance from the given BPL site entity and given (optional) operator.</summary>
      public SiteInfo(Site site, Operator opco) {
         if (site == null) return;

         SiteId = Class.CreateId(site.Id.LocalId);
         Operator = opco;
         Type = site.PoiType;
         Position = site.Position;
         
         if (!site.LocalizedName.IsEmpty) {
            Name = site.LocalizedName;
         } else if (site.Name.NotEmpty()) {
            Name = new MultiString(site.Name);
         }
         
         if (!site.LocalizedAddress.IsEmpty) {
            Address = (MultiAddress)site.LocalizedAddress;
         } else if (site.Address != null) {
            Address = new MultiAddress(site.Address);
         }
         
         var biz = site.BusinessInfo;
         if (biz != null) {
            Description = biz.Description;
            WorkingHours = biz.WorkingHours;
            if (biz.RatingCount > 0) {
               RatingCount = biz.RatingCount;
               RatingScore = ((Percent)biz.RatingScore).Normalize();
            } else {
               RatingScore = Percent.Undefined;
            }
            foreach (var p in biz.PhoneNumbers) {
               Contacts.Add(new Contact { Type = ContactTypes.Phone, Value = p.ToString() });
            }
            if (biz.Email.NotEmpty()) {
               Contacts.Add(new Contact { Type = ContactTypes.Email, Value = biz.Email });
            }
            if (biz.Website.NotEmpty()) {
               Contacts.Add(new Contact { Type = ContactTypes.Website, Value = biz.Website });
            }
            CustomProperties = biz.CustomProperties;
         }
      }
        private async Task <List <string> > TranslateStringsUsingMicrosoftAsync(string language, string clientId, List <string> strings)
        {
            string from = MultiString.GetPrimaryLanguage(MultiString.DefaultLanguage);
            string to   = MultiString.GetPrimaryLanguage(language);

            MSTranslate msTrans = new MSTranslate(clientId);

            int           total      = strings.Count();
            int           skip       = 0;
            List <string> newStrings = new List <string>();

            while (total > 0)
            {
                List <string> returnedStrings = await msTrans.TranslateAsync(from, to, strings.Skip(skip).Take(40).ToList());

                newStrings.AddRange(returnedStrings);
                skip  += returnedStrings.Count();
                total -= returnedStrings.Count();
            }
            return(newStrings);
        }
Exemple #18
0
            public async Task <bool> SetUrlAsync(string url, PageDefinition.PageSecurityType pageSecurity, MultiString title, MultiString summary, DateTime dateCreated, DateTime?dateUpdated, bool allowAnonymous, bool allowUser, string customData)
            {
                YetaWFManager manager = YetaWFManager.Manager;

                if (CurrentUrl != null)
                {
                    throw new InternalError("Already have an active Url - {nameof(SetUrlAsync)} {url} called");
                }
                if (!url.StartsWith("/"))
                {
                    throw new InternalError("Urls for search terms must be local and start with \"/\"");
                }
                CurrentPageSecurity   = pageSecurity;
                CurrentAllowAnonymous = allowAnonymous;
                CurrentAllowAnyUser   = allowUser;
                CurrentTitle          = title;
                CurrentSummary        = summary;
                CurrentDateCreated    = dateCreated;
                CurrentDateUpdated    = dateUpdated;
                CurrentSearchData     = new List <SearchData>();
                CurrentCustomData     = customData;
                if (!CurrentAllowAnonymous && !CurrentAllowAnyUser)
                {
                    Logging.AddLog("No search keywords for Url {0} - neither Anonymous nor User role has access to the page", url);
                    return(false);
                }
                if (!await CurrentSearchDP.PageUpdated(url, CurrentDateCreated, CurrentDateUpdated))
                {
                    Logging.AddLog("Page {0} not evaluated as it has not changed", url);
                    return(false);
                }
                CurrentUrl = url;
                Logging.AddLog("Adding search keywords for page {0}", CurrentUrl);
                AddTitle(CurrentTitle);
                AddContent(CurrentSummary);
                return(true);
            }
 private string _createNewAuthorizationToken(BplIdentity driverId, IEnumerable<Contact> associatedContacts, MultiString contactName, AuthorizationSessionKind kind) {
    var session = new DriverAuthorizationSessionData {
       DriverId = driverId,
       SessionStart = TimeStamp.LocalNow,
       //SessionKind = kind
       IsRegistration = kind == AuthorizationSessionKind.Registration
    };
    if (associatedContacts != null) {
       session.LoginContacts.AddRange(associatedContacts.Select(c => new LoginContact(c)));
       session.LoginContacts.Apply(c => c.ContactName = contactName);
    }
    return CryptServices.Encode(session);
 }
Exemple #20
0
 public AddNewModuleModel()
 {
     ModuleTitle = new MultiString();
 }
Exemple #21
0
 public AddNewPageModel()
 {
     Title       = new MultiString();
     Description = new MultiString();
 }
Exemple #22
0
 public AddModel()
 {
     Category             = new MultiString();
     Description          = new MultiString();
     SyndicationCopyright = new MultiString();
 }
Exemple #23
0
 private void AddItems(MultiString content, int weight)
 {
     VerifyPage();
     AddSearchTerms(content, CurrentAllowAnonymous, CurrentAllowAnyUser, weight);
 }
 private static string ToEnglish(MultiString value)
 {
     return(value.ContainsKey("en") ? value["en"].ToString() : "<No Value>");
 }
 public PanelEntry()
 {
     Module  = Guid.Empty;
     Caption = new MultiString();
     ToolTip = new MultiString();
 }
Exemple #26
0
 public void AddContent(MultiString content)
 {
     AddItems(content, CONTENT_WEIGHT);
 }
Exemple #27
0
 public void AddTitle(MultiString content)
 {
     AddItems(content, TITLE_WEIGHT);
 }
Exemple #28
0
 public void AddKeywords(MultiString content)
 {
     AddItems(content, KEYWORDS_WEIGHT);
 }
Exemple #29
0
 public Task <bool> SetUrlAsync(string url, PageDefinition.PageSecurityType pageSecurity, MultiString title, MultiString summary, DateTime dateCreated, DateTime?dateUpdated, bool allowAnonymous, bool allowUser)
 {
     return(SetUrlAsync(url, pageSecurity, title, summary, dateCreated, dateUpdated, allowAnonymous, allowUser, null));
 }
Exemple #30
0
 public bool Get(out MultiString result)
 {
     result = new MultiString(this.charArrayPool, this.intPool, this.shortPool, this.bitvectorPool);
     return(true);
 }
Exemple #31
0
 public AddModel()
 {
     Title         = new MultiString();
     Keywords      = new MultiString();
     DatePublished = DateTime.UtcNow;
 }
 public PanelEntry()
 {
     Caption = new MultiString();
     ToolTip = new MultiString();
 }