コード例 #1
0
        /// <summary>
        /// Create a new address.
        /// </summary>
        /// <param name="Street">The name of the street.</param>
        /// <param name="HouseNumber">The house number.</param>
        /// <param name="FloorLevel">The floor level.</param>
        /// <param name="PostalCode">The postal code</param>
        /// <param name="PostalCodeSub">The postal code sub</param>
        /// <param name="City">The city.</param>
        /// <param name="Country">The country.</param>
        /// <param name="Timezone">The timezone.</param>
        /// <param name="Comment">An optional text/comment to describe the address.</param>
        ///
        /// <param name="CustomData">An optional dictionary of customer-specific data.</param>
        public Address(String Street,
                       String HouseNumber,
                       String FloorLevel,
                       String PostalCode,
                       String PostalCodeSub,
                       I18NString City,
                       Country Country,
                       Time_Zone?Timezone = null,
                       I18NString Comment = null,

                       Dictionary <String, Object> CustomData = null)

            : base(CustomData)

        {
            this.Street        = Street ?? "";
            this.HouseNumber   = HouseNumber ?? "";
            this.FloorLevel    = FloorLevel ?? "";
            this.PostalCode    = PostalCode ?? "";
            this.PostalCodeSub = PostalCodeSub ?? "";
            this.City          = City ?? I18NString.Empty;
            this.Country       = Country;
            this.Timezone      = Timezone;
            this.Comment       = Comment ?? I18NString.Empty;
        }
コード例 #2
0
        /// <summary>
        /// Return a JSON representation of the given internationalized string.
        /// </summary>
        /// <param name="I18NString">An internationalized string.</param>
        /// <param name="JPropertyKey">The name of the JSON property key.</param>
        public static JProperty ToJSON(this I18NString I18NString, String JPropertyKey)
        {
            if (I18NString == null || !I18NString.Any())
            {
                return(null);
            }

            return(new JProperty(JPropertyKey, I18NString.ToJSON()));
        }
コード例 #3
0
ファイル: I18NTools.cs プロジェクト: alrehamy/Illias
        /// <summary>
        /// Return a substring of the given maximum length.
        /// </summary>
        /// <param name="I18NText">A text.</param>
        /// <param name="Length">The maximum length of the substring.</param>
        public static I18NString SubstringMax(this I18NString I18NText, Int32 Length)
        {
            if (I18NText == null)
            {
                return(null);
            }

            return(new I18NString(I18NText.Select(text => new I18NPair(
                                                      text.Language,
                                                      text.Text.Substring(0, Math.Min(text.Text.Length, Length))
                                                      ))));
        }
コード例 #4
0
        /// <summary>
        /// Trim all texts.
        /// </summary>
        /// <param name="I18NText">A text.</param>
        public static I18NString TrimAll(this I18NString I18NText)
        {
            if (I18NText == null)
            {
                return(null);
            }

            return(new I18NString(I18NText.Select(text => new I18NPair(
                                                      text.Language,
                                                      text.Text.Trim()
                                                      ))));
        }
コード例 #5
0
        /// <summary>
        /// Create a new minimal address.
        /// </summary>
        /// <param name="Country">The country.</param>
        /// <param name="PostalCode">The postal code</param>
        /// <param name="City">The city.</param>
        /// <param name="Street">The name of the street.</param>
        /// <param name="HouseNumber">The house number.</param>
        /// <param name="FloorLevel">The floor level.</param>
        /// <param name="Comment">A comment to this address.</param>
        /// <param name="CustomData">An optional dictionary of customer-specific data.</param>
        public static Address Create(Country Country,
                                     String PostalCode,
                                     I18NString City,
                                     String Street,
                                     String HouseNumber,
                                     String FloorLevel  = null,
                                     Time_Zone?TimeZone = null,
                                     I18NString Comment = null,
                                     Dictionary <String, Object> CustomData = null)


        => new Address(Street,
                       HouseNumber,
                       FloorLevel,
                       PostalCode,
                       "",
                       City,
                       Country,
                       TimeZone,
                       Comment,
                       CustomData);
コード例 #6
0
ファイル: Warning.cs プロジェクト: lanicon/Styx
        public static Warning Create(I18NString Text,
                                     Object Warning = null)

        => new Warning(Text,
                       Warning);
コード例 #7
0
ファイル: Warning.cs プロジェクト: lanicon/Styx
 private Warning(I18NString Text,
                 Object Context = null)
 {
     this.Text    = Text;
     this.Context = Context;
 }
コード例 #8
0
ファイル: Warning.cs プロジェクト: lanicon/Styx
 public static IList <Warning> AddAndReturnList(this IList <Warning> Warnings,
                                                I18NString Text)
 => Warnings?.AddAndReturnList(Warning.Create(Text));
コード例 #9
0
ファイル: I18NTools.cs プロジェクト: alrehamy/Illias
 /// <summary>
 /// Convert the given internationalized (I18N) text/string to a HTML link.
 /// </summary>
 /// <param name="I18NString">An internationalized (I18N) text/string.</param>
 /// <param name="URI">An URI.</param>
 public static String ToHTMLLink(this I18NString I18NString, String URI)
 {
     return(I18NString.
            Select(v => @"<span class=""I18N_" + v.Language + @"""><a href=""" + URI + @"?language=en"">" + v.Text + "</a></span>").
            AggregateWith(Environment.NewLine));
 }
コード例 #10
0
ファイル: I18NTools.cs プロジェクト: alrehamy/Illias
 /// <summary>
 /// Convert the given internationalized (I18N) text/string to HTML.
 /// </summary>
 /// <param name="I18NString">An internationalized (I18N) text/string.</param>
 /// <param name="Prefix">A prefix.</param>
 /// <param name="Postfix">A postfix.</param>
 public static String ToHTML(this I18NString I18NString, String Prefix, String Postfix)
 {
     return(I18NString.
            Select(v => @"<span class=""I18N_" + v.Language + @""">" + Prefix + v.Text + Postfix + "</span>").
            AggregateWith(Environment.NewLine));
 }
コード例 #11
0
 /// <summary>
 /// Return the first string of a multi-language string.
 /// </summary>
 public static I18NString ToI18NString(this String Text,
                                       Languages Language = Languages.en)
 => Text.IsNotNullOrEmpty()
            ? I18NString.Create(Language, Text)
            : null;
コード例 #12
0
 /// <summary>
 /// Return the first string of a multi-language string.
 /// </summary>
 public static String FirstText(this I18NString Text)
 => Text != null && Text.Any()
            ? Text.First().Text
            : null;
コード例 #13
0
 /// <summary>
 /// The multi-language string is neither null nor empty.
 /// </summary>
 public static Boolean IsNeitherNullNorEmpty(this I18NString Text)
 => Text != null && Text.Any();
コード例 #14
0
 /// <summary>
 /// The multi-language string is empty.
 /// </summary>
 public static Boolean IsNullOrEmpty(this I18NString Text)
 => Text == null || !Text.Any();
コード例 #15
0
ファイル: I18NString.cs プロジェクト: alrehamy/Illias
 /// <summary>
 /// The I18N text is not empty.
 /// </summary>
 public static Boolean IsNotNullOrEmpty(this I18NString Text)
 => Text != null && Text.Any();