コード例 #1
0
ファイル: EnumFormatter.cs プロジェクト: gkinsman/Typescriptr
        public static string UnionStringEnumPropertyTypeFormatter(Type enumType, QuoteStyle quoteStyle)
        {
            var quote = quoteStyle == QuoteStyle.Double ? "\"" : "'";
            var names = enumType.GetEnumNames();

            return(string.Join(" | ", names.Select(n => $"{quote}{n}{quote}")));
        }
コード例 #2
0
ファイル: Dialect.cs プロジェクト: ssharunas/LibCSV4Net
        public Dialect(bool doubleQuote, char delimiter, char quote, char escape,
			bool skipInitialSpace, string lineTerminator, QuoteStyle quoting,
			bool strict, bool hasHeader)
        {
            _doubleQuote = doubleQuote;
            _delimiter = delimiter;
            _quote = quote;
            _escape = escape;
            _skipInitialSpace = skipInitialSpace;
            _lineTerminator = lineTerminator;
            _quoting = quoting;
            _strict = strict;
            _hasHeader = hasHeader;

            if (_delimiter == '\0')
                _error = "Delimiter must be set";

            if (CheckQuoting() == false)
                _error = "Bad \"quoting\" value";

            if (_quoting != QuoteStyle.QUOTE_NONE && _quote == '\0')
                _error = "Quotechar must be set if quoting enabled";

            if (_lineTerminator == null)
                _error = "Line terminator must be set";
        }
コード例 #3
0
ファイル: Extensions.cs プロジェクト: evanw/minisharp
        public static string Quote(this string text, QuoteStyle style)
        {
            // Use whichever quote character is less frequent
            if (style == QuoteStyle.SingleOrDouble) {
                var singleQuotes = 0;
                var doubleQuotes = 0;
                foreach (var c in text) {
                    if (c == '"') doubleQuotes++;
                    else if (c == '\'') singleQuotes++;
                }
                style = singleQuotes <= doubleQuotes ? QuoteStyle.Single : QuoteStyle.Double;
            }

            // Generate the string using substrings of unquoted stuff for speed
            var quote = style == QuoteStyle.Single ? "'" : "\"";
            var builder = new StringBuilder();
            var start = 0;
            builder.Append(quote);
            for (var i = 0; i < text.Length; i++) {
                var c = text[i];
                string escape;
                if (c == quote[0]) escape = "\\" + quote;
                else if (c == '\\') escape = "\\\\";
                else if (c == '\t') escape = "\\t";
                else if (c == '\n') escape = "\\n";
                else continue;
                builder.Append(text.Substring(start, i - start));
                builder.Append(escape);
                start = i + 1;
            }
            builder.Append(text.Substring(start));
            builder.Append(quote);
            return builder.ToString();
        }
コード例 #4
0
 public static Quote CreateInstance(string text, QuoteStyle style, SuperHero superHero)
 {
     return(new Quote()
     {
         Text = text,
         QuoteStyle = style,
         SuperHero = superHero
     });
 }
コード例 #5
0
 public static ICollection <string> ListAllQuotesOfType(QuoteStyle quoteStyle)
 {
     using (var context = new SamuraiContext())
     {
         return(context.Quotes
                .Where(q => q.QuoteStyle == quoteStyle)
                .Select(q => q.Text).ToList());
     }
 }
コード例 #6
0
 public static List <Quote> ReadAllQuotesWithSpecificQuoteStyle(QuoteStyle quoteStyle)
 {
     using (var context = new SamuraiContext())
     {
         return(context.Quotes
                .Where(q => q.QuoteStyle == quoteStyle)
                .Include(q => q.Samurai)
                .ToList());;
     }
 }
コード例 #7
0
ファイル: Quote.cs プロジェクト: keel-210/DesktopMascot4VRM
    public void MakeQuote(Animator animator, string QuoteString, Color PanelColor, Color TextColor,
                          HumanBodyBones PlaceBone, Vector2 PlaceOffset, Vector2 PanelCollar, AnchorPresets anchor,
                          PivotPresets pivot, QuoteStyle quoteStyle, int ListMax, AlphaStyle alphaStyle, BackImage backImage, float alphaTime,
                          Vector3 moveDirection, float movingTime, int fontSize, Font font)
    {
        GameObject    imObj  = new GameObject();
        RectTransform imRect = imObj.AddComponent <RectTransform>();

        imRect.SetPivot(pivot);
        imRect.SetAnchor(anchor);
        imObj.transform.SetParent(GameObject.Find("Canvas").GetComponent <RectTransform>());
        Image image = imObj.AddComponent <Image>();

        image.color = PanelColor;
        if (backImage == BackImage.None)
        {
            image.color = new Color(0, 0, 0, 0);
        }
        else
        {
            image.type   = Image.Type.Sliced;
            image.sprite = Resources.Load <Sprite>("_Sprites/" + backImage.ToString());
        }

        GameObject    texObj = new GameObject();
        RectTransform tra    = texObj.AddComponent <RectTransform>();

        texObj.transform.SetParent(imObj.GetComponent <RectTransform>());
        Text text = texObj.AddComponent <Text>();

        text.supportRichText = true;
        text.font            = font;
        text.fontSize        = fontSize;
        text.text            = QuoteString;
        text.color           = TextColor;

        text.rectTransform.sizeDelta  = new Vector2(text.preferredWidth, text.preferredHeight);
        text.rectTransform.sizeDelta  = new Vector2(text.preferredWidth, text.preferredHeight);
        image.rectTransform.sizeDelta = text.rectTransform.sizeDelta + PanelCollar;
        tra.anchoredPosition          = Vector2.zero;

        if (!quoteCtrl.Select(q => q.anim).Any(a => a == animator) || quoteCtrl.Count == 0)
        {
            QuoteController c = gameObject.AddComponent <QuoteController>();
            c.anim = animator;
            quoteCtrl.Add(c);
        }
        int CtrlIndex = quoteCtrl.Select(q => q.anim).ToList().IndexOf(animator);

        QuoteEnter(new QuoteStyles(imRect, PlaceBone, PlaceOffset, quoteStyle, alphaStyle, ListMax, alphaTime, movingTime, moveDirection), CtrlIndex);
        imObj.transform.localScale = Vector3.one;
        //imObj.SetActive(false);
        //imObj.SetActive(true);
    }
コード例 #8
0
ファイル: Program.cs プロジェクト: cbirkeland/Repetition
 private static void ListAllQuotesOfType(QuoteStyle quoteStyle)
 {
     ch.Line("ListAllQuotesOfType");
     using (var context = new SamuraiContext())
     {
         foreach (var quote in context.Quotes.Where(q => q.Style == quoteStyle))
         {
             ch.Green(quote.Text);
         }
     }
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: cbirkeland/Repetition
 private static void ListAllQuotesOfType_WithSamurai(QuoteStyle quoteStyle)
 {
     ch.Line("ListAllQuotesOfType_WithSamurai");
     using (var context = new SamuraiContext())
     {
         foreach (var quote in context.Quotes.Where(q => q.Style == quoteStyle).Include(q => q.Samurai))
         {
             ch.Green($"'{quote.Text}' is a {quoteStyle.ToString().ToLower()} quote by {quote.Samurai.Name}");
         }
     }
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: cbirkeland/Repetition
 private static void ListAllQuotesOfType_WithSamurai_Fail(QuoteStyle quoteStyle)
 {
     ch.Line("ListAllQuotesOfType_WithSamurai");
     using (var context = new SamuraiContext())
     {
         foreach (var quote in context.Quotes.Where(q => q.Style == quoteStyle))
         {
             // quote.Samurai will be null
             ch.Green($"'{quote.Text}' is a {quoteStyle} quote by {quote.Samurai.Name}");
         }
     }
 }
コード例 #11
0
ファイル: CsvFormat.cs プロジェクト: Neo-Ciber94/FastCSV
        /// <summary>
        /// Initializes a new instance of the <see cref="CsvFormat"/> class.
        /// </summary>
        /// <param name="delimiter">The delimiter.</param>
        /// <param name="quote">The quote.</param>
        /// <param name="style">The style.</param>
        /// <param name="ignoreWhitespaces">if set to <c>true</c> leading and trailing whitespaces will be ignored.</param>
        /// <exception cref="ArgumentException">If the delimiter is equals to the quote</exception>
        public CsvFormat(char delimiter = ',', char quote = '"', QuoteStyle style = QuoteStyle.WhenNeeded, bool ignoreWhitespaces = true)
        {
            if (delimiter == quote)
            {
                throw new ArgumentException("delimiter cannot be equals to the quote");
            }

            Delimiter        = delimiter;
            Quote            = quote;
            Style            = style;
            IgnoreWhitespace = ignoreWhitespaces;
        }
コード例 #12
0
        public static void ListAllQuotesOfType(QuoteStyle quoteStyle)
        {
            using (var context = new SamuraiContext())
            {
                var quotes = context.Quotes.Where(s => s.QuoteStyle == quoteStyle);

                foreach (var quote in quotes)
                {
                    Console.WriteLine(quote.Text);
                }
            }
        }
コード例 #13
0
 private static void ListAllQuotesOfType(QuoteStyle quoteStyle)
 {
     using (var context = new SamuraiContext())
     {
         var quotes = from s in context.Quotes
                      where s.Quality == quoteStyle
                      select s;
         foreach (var quote in quotes)
         {
             Console.WriteLine(quote.Text);
         }
     }
 }
コード例 #14
0
 public QuoteStyles(RectTransform _panel, HumanBodyBones _bone, Vector3 _PosOffset, QuoteStyle _quoteStyle, AlphaStyle _alphaStyle,
                    float _listMax, float _alphaTime, float _moveTime, Vector3 _moveDirection)
 {
     panel         = _panel;
     bone          = _bone;
     PosOffset     = _PosOffset;
     quoteStyle    = _quoteStyle;
     alphaStyle    = _alphaStyle;
     ListMax       = _listMax;
     alphaTime     = _alphaTime;
     moveTime      = _moveTime;
     moveDirection = _moveDirection;
 }
コード例 #15
0
        public static char ToChar(this QuoteStyle quoteStyle)
        {
            switch (quoteStyle)
            {
            case QuoteStyle.SingleQuote: return('\'');

            case QuoteStyle.DoubleQuote: return('"');

            case QuoteStyle.Backtick: return('`');

            default: throw new NotSupportedException();
            }
        }
コード例 #16
0
        private static void ListQuoteAndSamurai(QuoteStyle quoteStyle)
        {
            using (var context = new SamuraiContext())
            {
                var quotes = from s in context.Quotes
                             join Samurai in context.Samurais on s.SamuraiId equals Samurai.Id
                             where s.Quality.Equals(quoteStyle)
                             select new { s.Text, Samurai.Name };

                foreach (var quote in quotes)
                {
                    Console.WriteLine($"\"{quote.Text}\" is a {quoteStyle} quote by {quote.Name}");
                }
            }
        }
コード例 #17
0
        public static void ListAllQuotesOfType_WithSamurai(QuoteStyle quoteStyle)
        {
            using (var context = new SamuraiContext())
            {
                var samurai = context.Samurais.Include(s => s.Quotes.Where(q => q.QuoteStyle == quoteStyle));

                foreach (var s in samurai)
                {
                    foreach (var q in s.Quotes)
                    {
                        Console.WriteLine($"{q.Text} is a quote by {s.Name}");
                    }
                }
            }
        }
コード例 #18
0
ファイル: EnumFormatter.cs プロジェクト: gkinsman/Typescriptr
        public static string ValueNumberEnumFormatter(Type enumType, QuoteStyle quoteStyle)
        {
            var builder = new StringBuilder();

            builder.AppendLine($"enum {enumType.Name} {{");

            foreach (var enumName in enumType.GetEnumNames())
            {
                var value = (int)Enum.Parse(enumType, enumName);
                builder.AppendLine($"{TypeScriptGenerator.TabString}{enumName} = {value},");
            }

            builder.AppendLine("}");

            return(builder.ToString());
        }
コード例 #19
0
ファイル: Dialect.cs プロジェクト: gedbac/LibCSV4Net
        public Dialect(bool doubleQuote, char delimiter, char quote, char escape,
                       bool skipInitialSpace, string lineTerminator, QuoteStyle quoting,
                       bool strict, bool hasHeader)
        {
            _doubleQuote      = doubleQuote;
            _delimiter        = delimiter;
            _quote            = quote;
            _escape           = escape;
            _skipInitialSpace = skipInitialSpace;
            _lineTerminator   = lineTerminator;
            _quoting          = quoting;
            _strict           = strict;
            _hasHeader        = hasHeader;

            Check();
        }
コード例 #20
0
ファイル: Dialect.cs プロジェクト: emmorts/LibCSV4Net
        public Dialect(bool doubleQuote, char delimiter, char quote, char escape,
			bool skipInitialSpace, string lineTerminator, QuoteStyle quoting,
			bool strict, bool hasHeader)
        {
            _doubleQuote = doubleQuote;
            _delimiter = delimiter;
            _quote = quote;
            _escape = escape;
            _skipInitialSpace = skipInitialSpace;
            _lineTerminator = lineTerminator;
            _quoting = quoting;
            _strict = strict;
            _hasHeader = hasHeader;

            Check();
        }
コード例 #21
0
ファイル: EnumFormatter.cs プロジェクト: gkinsman/Typescriptr
        public static string ValueNamedEnumFormatter(Type enumType, QuoteStyle quoteStyle)
        {
            var builder = new StringBuilder();

            builder.AppendLine($"enum {enumType.Name} {{");

            foreach (var enumName in enumType.GetEnumNames())
            {
                var value = quoteStyle == QuoteStyle.Single ? $"'{enumName}'" : $"\"{enumName}\"";
                builder.AppendLine($"{TypeScriptGenerator.TabString}{enumName} = {value},");
            }

            builder.AppendLine("}");

            return(builder.ToString());
        }
コード例 #22
0
        public static ICollection <string> ListAllQuotesOfType_WithSamurai(QuoteStyle quoteStyle)
        {
            ICollection <string> output = new List <string>();

            using (var context = new SamuraiContext())
            {
                var relevantQuotes = context.Quotes
                                     .Where(q => q.QuoteStyle == quoteStyle)
                                     .Include(q => q.Samurai);
                foreach (var quote in relevantQuotes)
                {
                    output.Add($"\"{quote.Text}\" is a {quote.QuoteStyle} quote by {quote.Samurai.Name}");
                }
            }

            return(output);
        }
コード例 #23
0
        public static Quote CreateRandom(Random rng, SuperHero hero)
        {
            var length = rng.Next(1, 10);

            var words = new List <string>()
            {
                "do", "since", "the", "man", "work", "money", "love", "self-importance", "smash", "important", "life", "lives", "hero"
            };

            string text = "";

            for (int i = 0; i < length; i++)
            {
                var currRngIndex = rng.Next(0, words.Count);
                text += words[currRngIndex];
                words.RemoveAt(currRngIndex);
            }

            var quoteStyleRng = rng.Next(0, 4);

            // if RNG lands on either 2 or 3, then it'll be 'Awesome'
            QuoteStyle quoteStyle = Enums.QuoteStyle.Awesome;


            switch (quoteStyleRng)
            {
            case 0:

                quoteStyle = Enums.QuoteStyle.Cheesy;
                break;

            case 1:

                quoteStyle = Enums.QuoteStyle.Lame;
                break;
            }

            return(Quote.CreateInstance(text, quoteStyle, hero));
        }
コード例 #24
0
ファイル: Quote.cs プロジェクト: keel-210/DesktopMascot4VRM
 public void Settings(out Color panelColor, out Color textColor,
                      out HumanBodyBones placeBone, out Vector2 placeOffset, out Vector2 panelCollar,
                      out AnchorPresets anchor, out PivotPresets pivot, out QuoteStyle quoteStyle, out int listMax, out AlphaStyle _alphaStyle,
                      out float alphaChangingTime, out Vector3 moveDirection, out float movingTime,
                      out BackImage backImage, out int fontSize, out Font fonts)
 {
     panelColor        = PanelColor;
     textColor         = TextColor;
     placeBone         = PlaceBone;
     placeOffset       = PlaceOffset;
     panelCollar       = PanelCollar;
     anchor            = Anchor;
     pivot             = Pivot;
     quoteStyle        = QuoteStyle;
     listMax           = ListMax;
     _alphaStyle       = alphaStyle;
     alphaChangingTime = AlphaChangingTime;
     moveDirection     = MoveDirection;
     movingTime        = MovingTime;
     backImage         = BackImg;
     fontSize          = FontSize;
     fonts             = font;
 }
コード例 #25
0
        public string[] ReportQuotesOfType(QuoteStyle style)
        {
            var    result      = new List <string>();
            string stylestring = style.ToString().ToLower();

            foreach (var sam in _context.Samurais)
            {
                string name      = sam.Name;
                int    numQuotes = sam.Quotes.Count(x => x.Style == style);
                if (numQuotes == 0)
                {
                    result.Add($"{name} has no {stylestring} quotes");
                }
                else if (numQuotes == 1)
                {
                    result.Add($"{name} has 1 {stylestring} quote");
                }
                else
                {
                    result.Add($"{name} has {numQuotes} {stylestring} quotes");
                }
            }
            return(result.ToArray());
        }
コード例 #26
0
 public static InjectionOptions IntoForm(this InjectionOptions injector, string fieldName, string initialValue, Func <IEnumerable <KeyValuePair <string, string> > > formFields = null, QuoteStyle quoteStyle = QuoteStyle.SingleQuote)
 {
     injector.ParameterName = fieldName;
     injector.Location      = InjectionLocation.Form;
     injector.FormFields    = formFields;
     injector.InitialValue  = initialValue;
     injector.ParameterType = typeof(string);
     injector.QuoteStyle    = quoteStyle;
     return(injector);
 }
コード例 #27
0
 public string[] ReportQuotesOfType(QuoteStyle style)
 {
     throw new NotImplementedException();
 }
コード例 #28
0
 public CsvRecord WithStyle(QuoteStyle style)
 {
     return(WithFormat(Format.WithStyle(style)));
 }
コード例 #29
0
ファイル: StyleDesc.cs プロジェクト: ssharunas/LibCSV4Net
 public StyleDesc(QuoteStyle style, string name)
 {
     this.style = style;
     this.name = name;
 }
コード例 #30
0
ファイル: Program.cs プロジェクト: gopitha/EFSamurai
 public static void ListAllQuotesOfType_WithSamurai(QuoteStyle quoteStyle)
 {
 }
コード例 #31
0
ファイル: CsvHeader.cs プロジェクト: Neo-Ciber94/FastCSV
 public CsvHeader WithStyle(QuoteStyle style)
 {
     return(WithFormat(Format.WithStyle(style)));
 }
コード例 #32
0
 public static InjectionOptions AsString(this InjectionOptions injector, string initialValue = null, QuoteStyle quoteStyle = QuoteStyle.SingleQuote)
 {
     injector.InitialValue = initialValue;
     injector.QuoteStyle   = quoteStyle;
     return(injector);
 }
コード例 #33
0
 public static InjectionOptions IntoQueryStringParameter(this InjectionOptions injector, string parameterName, string initialValue, QuoteStyle quoteStyle = QuoteStyle.SingleQuote)
 {
     injector.ParameterName = parameterName;
     injector.Location      = InjectionLocation.QueryString;
     injector.InitialValue  = initialValue;
     injector.ParameterType = typeof(string);
     injector.QuoteStyle    = quoteStyle;
     return(injector);
 }
コード例 #34
0
 public TypeScriptGenerator WithQuoteStyle(QuoteStyle style)
 {
     _quoteStyle = style;
     return(this);
 }