/// <summary>
 ///     Get Global String
 /// </summary>
 /// <param name="tag"></param>
 /// <returns></returns>
 public String GetText(TextType tag)
 {
     String strText = String.Empty;
     _stringDic.TryGetValue(tag.ToString(), out strText);
     strText = String.IsNullOrEmpty(strText) ? tag.ToString() : strText.Replace("&amp;", "&");
     return strText;
 }
示例#2
0
        /// <summary>
        ///     Get Global String
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        public String GetText(TextType tag)
        {
            String strText = String.Empty;

            _stringDic.TryGetValue(tag.ToString(), out strText);
            strText = String.IsNullOrEmpty(strText) ? tag.ToString() : strText.Replace("&amp;", "&");
            return(strText);
        }
示例#3
0
 /// <summary>
 ///     获得文字
 /// </summary>
 /// <param name="defaultText"></param>
 /// <param name="tag"></param>
 /// <returns></returns>
 public static string GetText(string defaultText, TextType tag)
 {
     if (IsUseDefaultLanguage || tag == TextType.UseDefaultLanguage) return defaultText;
     string strText;
     StringResource.StringDic.TryGetValue(tag.ToString(), out strText);
     strText = string.IsNullOrEmpty(strText) ? tag.ToString() : strText.Replace("&amp;", "&");
     return strText;
 }
示例#4
0
        public String getTextFieldAndOption(String fieldName, TextType type = TextType.TEXT, int size = 255, Boolean isBinary = false, Boolean notNull = false, String Default = "", Boolean primaryKey = false, params Object[] numOrOptions)
        {
            String field = fieldName;

            if (type == TextType.CHAR || type == TextType.VARCHAR)
            {
                field += " " + type.ToString() + "(" + size.ToString() + ") ";
            }
            else if (type == TextType.ENUM || type == TextType.SET)
            {
                if (type == TextType.SET && numOrOptions.Length > 64)
                {
                    throw new Exception("SET형은 64개까지만 저장 가능합니다.");
                }
                else
                {
                    field += " " + type.ToString();
                    if (numOrOptions.Length > 0)
                    {
                        field += "(";
                        for (int i = 0; i < numOrOptions.Length; i++)
                        {
                            if (i != 0)
                            {
                                field += ", ";
                            }
                            field += numOrOptions[i] as String;
                        }
                        field += ")";
                    }
                }
            }
            else
            {
                field += " " + type.ToString();
                if (isBinary)
                {
                    field += " " + "BINARY";
                }
            }
            if (notNull)
            {
                field += " NOT NULL";
            }
            if (notNull && Default != null && Default.Length > 0)
            {
                field += " DEFAULT " + Default;
            }

            if (primaryKey)
            {
                field += " PRIMARY KEY";
            }

            return(field);
        }
示例#5
0
        /// <summary>
        ///     获得文字
        /// </summary>
        /// <param name="defaultText"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        public static string GetText(string defaultText, TextType tag)
        {
            if (IsUseDefaultLanguage || tag == TextType.UseDefaultLanguage)
            {
                return(defaultText);
            }
            string strText;

            StringResource.StringDic.TryGetValue(tag.ToString(), out strText);
            strText = string.IsNullOrEmpty(strText) ? tag.ToString() : strText.Replace("&amp;", "&");
            return(strText);
        }
示例#6
0
 /// <summary>
 /// Get Global String
 /// </summary>
 /// <param name="tag"></param>
 /// <returns></returns>
 public String GetText(TextType tag)
 {
     String strText = String.Empty;
     _stringDic.TryGetValue(tag.ToString(), out strText);
     if (String.IsNullOrEmpty(strText))
     {
         strText = tag.ToString();
     }
     else
     {
         strText = strText.Replace("&amp;", "&");
     }
     return strText;
 }
示例#7
0
        /// <summary>
        /// Get Global String
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        public String GetText(TextType tag)
        {
            String strText = String.Empty;

            _stringDic.TryGetValue(tag.ToString(), out strText);
            if (String.IsNullOrEmpty(strText))
            {
                strText = tag.ToString();
            }
            else
            {
                strText = strText.Replace("&amp;", "&");
            }
            return(strText);
        }
示例#8
0
 /// <summary>
 /// 获得国际化文字
 /// </summary>
 /// <param name="tag"></param>
 /// <returns></returns>
 public string GetText(TextType tag)
 {
     String strText = String.Empty ;
     //使用TryGetValue方法防止出现不存在的字符,同时比Exist提高效率
     _stringDic.TryGetValue(tag.ToString(),out strText);
     if (strText == null)
     {
         strText = tag.ToString();
     }
     else
     {
         strText = XMLUtility.XMLDecode(strText);
     }
     return strText;
 }
示例#9
0
        private static string ToEnumString(TextType type)
        {
            var enumType            = typeof(TextType);
            var name                = Enum.GetName(enumType, type);
            var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetTypeInfo().GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).FirstOrDefault();

            return(enumMemberAttribute?.Value ?? type.ToString());
        }
示例#10
0
        /// <summary>
        /// To the query string.
        /// </summary>
        /// <returns></returns>
        internal string ToQueryString()
        {
            if (!Validate())
            {
                throw new Exception("Invalid request parameter");
            }

            var qs = new StringBuilder();

            qs.Append($"to={string.Join("&to=", To)}&");
            if (!string.IsNullOrEmpty(From))
            {
                qs.Append($"from={From}&");
            }
            if (TextType != TextType.Plain)
            {
                qs.Append($"textType={TextType.ToString()}&");
            }
            if (!Category.Equals("general", StringComparison.OrdinalIgnoreCase))
            {
                qs.Append($"category={Category}&");
            }
            if (ProfanityAction != ProfanityAction.NoAction)
            {
                qs.Append($"profanityAction={ProfanityAction.ToString()}&");
            }
            if (ProfanityMarker != ProfanityMarker.Asterisk)
            {
                qs.Append($"profanityMarker={ProfanityMarker.ToString()}&");
            }
            if (IncludeAlignment)
            {
                qs.Append("includeAlignment=true&");
            }
            if (IncludeSentenceLength)
            {
                qs.Append("includeSentenceLength=true&");
            }
            if (!string.IsNullOrEmpty(SuggestedFrom))
            {
                qs.Append($"suggestedFrom={SuggestedFrom}&");
            }
            if (!string.IsNullOrEmpty(FromScript))
            {
                qs.Append($"fromScript={FromScript}&");
            }
            if (!string.IsNullOrEmpty(ToScript))
            {
                qs.Append($"toScript={ToScript}&");
            }

            // Remove the last character
            qs.Length = qs.Length - 1;

            // cref: https://docs.microsoft.com/en-us/azure/cognitive-services/translator/quickstarts/csharp
            return($"api-version={Constants.ApiVersion}&{qs.ToString()}");
        }
示例#11
0
        private string FilePath(TextType textType)
        {
            DataTypeItem typeItem = _dataPath.Value.DataTypes.Find(item =>
            {
                if (item.Type.ToLower() == textType.ToString().ToLower())
                {
                    return(true);
                }
                return(false);
            });

            return(Path.Combine(_dataPath.Value.DataRoot, typeItem.Value, "default.json"));
        }
示例#12
0
        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <param name="textType">Type of the text.</param>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public static string ToHtmlInputType(this TextType textType)
        {
            string typeString;

            if (textType == TextType.DateTimeLocal)
            {
                typeString = "datetime-local";
            }
            else
            {
                typeString = textType.ToString().ToLowerInvariant();
            }

            return(typeString);
        }
示例#13
0
 public override string ToString()
 {
     return(string.Concat(new object[]
     {
         Type.ToString(),
         " - ",
         TextType.ToString(),
         " - ",
         ((Kind & 2147483647u) >> 26).ToString(),
         "/",
         (Kind >> 24 & 3u).ToString(),
         " (",
         Length,
         ") = ",
         Value.ToString("X6")
     }));
 }
 /// <summary>
 /// Finds a value by a label's text using the Right-Down search algorithm. The value closest to the label's text in the right or down direction in the document will be chosen as the result.
 /// </summary>
 /// <param name="labelInDocument">The label we expect to find in the document, valid matches can be separated by ||</param>
 /// <param name="textTypeOfValue">Specifies the text type the capture operation needs to match</param>
 /// <param name="maxSteps">The maximum distance in terms of DocumentLab grid cells the label-value in the document can be. This is by default 6 which is sufficient for close-by elements but can be made longer or shorter depending on the type of the document.</param>
 /// <returns>Returns a DocumentLab FluentQuery with a script that performs the value extraction.</returns>
 public static string FindValueForLabel(this FluentQuery response, TextType textTypeOfValue = TextType.Text, int maxSteps = 6, params string[] labelInDocument)
 => FindValueForLabelBase(response, new string[] { textTypeOfValue.ToString() }, maxSteps, labelInDocument);
示例#15
0
 /// <summary>
 /// </summary>
 /// <param name="tag"></param>
 /// <returns></returns>
 public static string GetText(TextType tag)
 {
     return GetText(tag.ToString());
 }
 /// <summary>
 /// Gets value by label's text given that we know in which direction relative to the label the value is.
 /// </summary>
 /// <param name="labelInDocument">The label we expect to find in the document, valid matches can be separated by ||</param>
 /// <param name="textTypeOfValue">Specifies the text type the capture operation needs to match</param>
 /// <param name="direction">Direction relative to the label the value should be located at in the document</param>
 /// <returns>Returns a DocumentLab FluentQuery with a script that performs the value extraction.</returns>
 public static string GetValueAtLabel(this FluentQuery response, Direction direction, TextType textTypeOfValue = TextType.Text, params string[] labelInDocument)
 => GetValueAtLabelBase(response, direction, new string[] { textTypeOfValue.ToString() }, labelInDocument);
 /// <summary>
 /// Gets all values of the specified text type in a document.
 /// </summary>
 /// <param name="textType">The text type to capture all instances of in a document.</param>
 /// <returns>A DocumentLab FluentQuery with a script extension that performs the Any operation.</returns>
 public static string[] GetAny(this FluentQuery response, TextType textType)
 => GetAnyBase(response, new string[] { textType.ToString() });
示例#18
0
 /// <summary>
 ///     获得文字
 /// </summary>
 /// <param name="defaultText"></param>
 /// <param name="tag"></param>
 /// <returns></returns>
 public static string GetText(string defaultText, TextType tag) => GetText(defaultText, tag.ToString());
示例#19
0
 /// <summary>
 ///     获得文字
 /// </summary>
 /// <param name="tag"></param>
 /// <returns></returns>
 public static string GetText(TextType tag) => GetText(tag.ToString());
 /// <summary>
 /// Captures the value of the text matched in the document and includes it in the extracted output.
 /// </summary>
 /// <param name="captureTextType">The text type we want to capture in the document. In a pattern the text type specified in a pattern must yield a positive match in order for the capture to be valid.</param>
 /// <param name="propertyName">*Optional* Specify a name for the property associated with the capture. This is only applicable for multi-capture patterns.</param>
 /// <returns>Returns a DocumentLab FluentQuery with a script extension that performs the capture.</returns>
 public static FluentQuery Capture(this FluentQuery response, TextType captureTextType, string propertyName = "")
 {
     return(CaptureNamedBase(response, new string[] { captureTextType.ToString() }, propertyName));
 }
示例#21
0
 /// <summary>
 ///     获得文字
 /// </summary>
 /// <param name="tag"></param>
 /// <returns></returns>
 public static string GetText(TextType tag)
 {
     return(GetText(tag.ToString()));
 }
 /// <summary>
 /// Adds a text type and optional text match predicate to the pattern we want to match in a document.
 /// </summary>
 /// <param name="textType">The text type we want to match in the pattern</param>
 /// <param name="matchText">*Optional* Adds that the text type match also needs to match the text specified. This works by checking if the string we're evaluating with from the document contains the text we specify here + a Levensthein distance 2 (by default) check. Therefore the text here can be an abbreviation of common terms or at least in some simplified form in order to make it more durable to differences that might occur in OCR results.</param>
 /// <returns>Returns a DocumentLab FluentQuery with a script extension that performs the match.</returns>
 public static FluentQuery Match(this FluentQuery response, TextType textType, params string[] matchText) => MatchBase(response, new string[] { textType.ToString() }, matchText);
示例#23
0
 /// <summary>
 ///     获得文字
 /// </summary>
 /// <param name="defaultText"></param>
 /// <param name="tag"></param>
 /// <returns></returns>
 public static string GetText(string defaultText, TextType tag)
 {
     return GetText(defaultText, tag.ToString());
 }
示例#24
0
 /// <summary>
 ///     获得文字
 /// </summary>
 /// <param name="defaultText"></param>
 /// <param name="tag"></param>
 /// <returns></returns>
 public static string GetText(string defaultText, TextType tag)
 {
     return(GetText(defaultText, tag.ToString()));
 }
 /// <summary>
 /// At the end of a query, calling this method performs a capture operation on the document using the specified text type as a match predicate. The value returned is the value that corresponds to the pattern on the document.
 /// </summary>
 /// <param name="captureTextType">The text type predicate the capture must match for a result to be considered valid</param>
 /// <returns>Value extracted from document.</returns>
 public static string Capture(this FluentQuery response, TextType captureTextType) => CaptureBase(response, new string[] { captureTextType.ToString() });