/// <summary>
        /// Gets the name deduction by email.
        /// </summary>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="casing">The casing.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">A email address is required to get a name deduction.</exception>
        public NameResponse GetNameDeductionByEmail(string emailAddress, Casing? casing = null)
        {
            if (string.IsNullOrEmpty(emailAddress)) throw new ArgumentNullException("emailAddress", "An email address is required to get a name deduction.");

            var request = GetNameDeductionRequest(casing);
            request.AddParameter("email", emailAddress);
            return Execute<NameResponse>(request);
        }
        /// <summary>
        /// Gets the normalized location.
        /// </summary>
        /// <param name="place">The place.</param>
        /// <param name="includeZeroPopulation">The include zero population.</param>
        /// <param name="casing">The casing.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">An email address is required to lookup a person by email.</exception>
        public NormalizedLocationResponse GetNormalizedLocation(string place, bool? includeZeroPopulation = null, Casing? casing = null)
        {
            if (string.IsNullOrWhiteSpace(place)) throw new ArgumentNullException("place", "A place is required to get a normalized location.");

            var request = GetLocationRequest("locationNormalizer", includeZeroPopulation, casing);
            request.AddParameter("place", place);
            return Execute<NormalizedLocationResponse>(request);
        }
        /// <summary>
        /// Gets the name deduction by username.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="casing">The casing.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">A username is required to get a name deduction.</exception>
        public NameResponse GetNameDeductionByUsername(string username, Casing? casing = null)
        {
            if (string.IsNullOrEmpty(username)) throw new ArgumentNullException("username", "A username is required to get a name deduction.");

            var request = GetNameDeductionRequest(casing);
            request.AddParameter("username", username);
            return Execute<NameResponse>(request);
        }
Exemplo n.º 4
0
        // ----------------------------------------------------------------------
        // Manipulating names
        // ----------------------------------------------------------------------

        private static string Recase(string str, Casing casing)
        {
            if (casing == Casing.Camel && Char.IsUpper(str, 0))
                return Char.ToLowerInvariant(str[0]) + str.Substring(1);
            else if (casing == Casing.Pascal && Char.IsLower(str, 0))
                return Char.ToUpperInvariant(str[0]) + str.Substring(1);
            else
                return str;
        }
Exemplo n.º 5
0
        public static string Get(int length, CharacterSetType characterSetType, Spaces spaces, Casing casing,
            Language language = Language.English)
        {
            SetLanguageCharacterSets(language);
            SetLanguageNumbers(language);
            var characters = GetCharacterSet(characterSetType, casing);

            var sb = BuildRandomString(length, spaces, characters);

            return ConvertToProperCaseIfRequired(sb.ToString(), casing);
        }
        /// <summary>
        /// Gets the name normalization.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="casing">The casing.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">A name is required to get a name normalization.</exception>
        public NameResponse GetNameNormalization(string name, Casing? casing = null)
        {
            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "A name is required to get a name normalization.");

            var request = new RestRequest("/name/normalizer.json", Method.GET);
            request.AddParameter("q", name);

            if (casing.HasValue)
            {
                request.AddParameter("casing", casing.Value);
            }

            return Execute<NameResponse>(request);
        }
        /// <summary>
        /// Gets the location request.
        /// </summary>
        /// <param name="resource">The resource.</param>
        /// <param name="includeZeroPopulation">The include zero population.</param>
        /// <param name="casing">The casing.</param>
        /// <returns></returns>
        private RestRequest GetLocationRequest(string resource, bool? includeZeroPopulation = null, Casing? casing = null)
        {
            var request = new RestRequest(string.Format("/address/{0}.json", resource), Method.GET);

            if (includeZeroPopulation.HasValue)
            {
                request.AddParameter("includeZeroPopulation", includeZeroPopulation.Value);
            }

            if (casing.HasValue)
            {
                request.AddParameter("casing", casing.Value);
            }

            return request;
        }
        /// <summary>
        /// Uploads the card.
        /// </summary>
        /// <param name="frontBase64Encoded">The front base64 encoded.</param>
        /// <param name="backBase64Encoded">The back base64 encoded.</param>
        /// <param name="webhookUrl">The webhook URL.</param>
        /// <param name="casing">The casing.</param>
        /// <param name="sandbox">The sandbox.</param>
        /// <param name="verified">The verified.</param>
        /// <param name="verifiedOnly">The verified only.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">frontBase64Encoded;A front image is required to process a card.</exception>
        public CardReaderResponse UploadCard(
            string frontBase64Encoded,
            string backBase64Encoded,
            string webhookUrl,
            Casing? casing = null,
            SandboxMode? sandbox = null,
            Verified? verified = null,
            bool? verifiedOnly = null)
        {
            if (string.IsNullOrWhiteSpace(frontBase64Encoded)) throw new ArgumentNullException("frontBase64Encoded", "A front image is required to process a card.");

            var request = GetCardReaderRequest(webhookUrl, casing, sandbox, verified, verifiedOnly);
            request.RequestFormat = DataFormat.Json;
            request.AddBody(new { front = frontBase64Encoded, back = backBase64Encoded });
            return Execute<CardReaderResponse>(request);
        }
Exemplo n.º 9
0
 public static string Convert(this string me, Casing from, Casing to)
 {
     string result;
     if (me.IsNull())
         result = null;
     else if (to == Casing.Raw)
         result = me;
     else
     {
         System.Text.StringBuilder builder = new System.Text.StringBuilder();
         foreach (var c in me.ConvertFrom(from).ConvertTo(to))
             builder.Append(c);
         result = builder.ToString();
     //				Console.WriteLine(result);
     }
     return result;
 }
Exemplo n.º 10
0
 static Generic.IEnumerable<char> ConvertFrom(this string me, Casing from)
 {
     switch (from)
     {
         default:
         case Casing.Raw:
             bool lastSpace = true;
             foreach (var c in me)
             {
                 if (lastSpace = (c == ' ' || c == '_') && !lastSpace)
                     yield return ' ';
                 else
                 {
                     if (lastSpace = char.IsUpper(c) && !lastSpace)
                         yield return ' ';
                     yield return char.ToLower(c);
                 }
             }
             break;
         case Casing.Normal:
             foreach (var c in me)
                 yield return char.ToLower(c);
             break;
         case Casing.Pascal:
         case Casing.Camel:
             bool first = from == Casing.Pascal;
             foreach (var c in me)
             {
                 if (char.IsUpper(c) && !first)
                     yield return ' ';
                 yield return char.ToLower(c);
                 first = false;
             }
             break;
         case Casing.Lower:
         case Casing.Upper:
             foreach (var c in me)
             {
                 if (c == '_')
                     yield return ' ';
                 yield return char.ToLower(c);
             }
             break;
     }
 }
        /// <summary>
        /// Uploads the card.
        /// </summary>
        /// <param name="front">The front.</param>
        /// <param name="back">The back.</param>
        /// <param name="webhookUrl">The webhook URL.</param>
        /// <param name="casing">The casing.</param>
        /// <param name="sandbox">The sandbox.</param>
        /// <param name="verified">The verified.</param>
        /// <param name="verifiedOnly">The verified only.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">A webhook is required to process a card.</exception>
        public CardReaderResponse UploadCard(
            byte[] front,
            byte[] back,
            string webhookUrl,
            Casing? casing = null,
            SandboxMode? sandbox = null,
            Verified? verified = null,
            bool? verifiedOnly = null)
        {
            if (front == null || front.Length == 0) throw new ArgumentNullException("front", "A front image is required to process a card.");

            var request = GetCardReaderRequest(webhookUrl, casing, sandbox, verified, verifiedOnly);
            request.AddFile("front", front, "front.png|jpg|gif", "image/png|jpg|gif");

            if (back != null && back.Length > 0)
            {
                request.AddFile("back", back, "back.png|jpg|gif", "image/png|jpg|gif");
            }

            return Execute<CardReaderResponse>(request);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Convert a string to a string of the specified casing
        /// </summary>
        /// <param name="Text">The text to change the case of</param>
        /// <param name="Case">The casing to apply</param>
        /// <returns>A string changed to the specified case</returns>
        public static string ChangeCase(this string Text, Casing Case)
        {
            switch (Case)
            {
                case Casing.Caps:
                    return Text.ToUpper();

                case Casing.Lower:
                    return Text.ToLower();

                case Casing.Proper:
                    return String.Join(" ", Text
                        .Trim()
                        .Split(' ')
                        .Where(str => str.Length > 0)
                        .Select(str => Char.ToUpper(str[0]) + str.Substring(1))
                        .ToArray());

                case Casing.Sentence:
                    return String.Join(" ", Text
                        .Trim()
                        .Split(' ')
                        .Where(str => str.Length > 0)
                        .Select((str, i) => i == 0 ? Char.ToUpper(str[0]) + str.Substring(1) : str.ToLower())
                        .ToArray());

                case Casing.Camel:
                    return String.Join("", Text
                        .Trim()
                        .Split(' ')
                        .Where(str => str.Length > 0)
                        .Select((str, i) => i != 0 ? Char.ToUpper(str[0]) + str.Substring(1) : str.ToLower())
                        .ToArray());

                default:
                    return Text;
            }
        }
Exemplo n.º 13
0
        private static List<string> GetCharacterSet(CharacterSetType characterSetType, Casing casing)
        {
            var characters = new List<string>();

            switch (characterSetType)
            {
                case CharacterSetType.Alpha:
                    GetAlphaCharacterSet(casing, characters);
                    break;
                case CharacterSetType.AlphaNumeric:
                    GetAlphaNumericCharacterSet(casing, characters);
                    break;
                case CharacterSetType.Numeric:
                    GetNumericCharacterSet(characters);
                    break;
                default:
                    GetAnythingCharacterSet(casing, characters);
                    break;
            }
            return characters;
        }
Exemplo n.º 14
0
 private static void GetAlphaNumericCharacterSet(Casing casing, List<string> characters)
 {
     switch (casing)
     {
         case Casing.Lowered:
         case Casing.ProperCase:
             characters.AddRange(Numbers);
             characters.AddRange(Lowercase);
             break;
         case Casing.Uppered:
             characters.AddRange(Numbers);
             characters.AddRange(Uppercase);
             break;
         default:
             characters.AddRange(Numbers);
             characters.AddRange(Lowercase);
             characters.AddRange(Uppercase);
             break;
     }
 }
Exemplo n.º 15
0
 public void locator_for_number(Casing casing, string memberName)
 {
     JsonLocatorField.For <User>(EnumStorage.AsInteger, casing, x => x.Age)
     .SqlLocator.ShouldBe($"CAST(d.data ->> '{memberName}' as integer)");
 }
Exemplo n.º 16
0
 public void locator_for_enum_in_string_mode(Casing casing, string memberName)
 {
     JsonLocatorField.For <Target>(EnumStorage.AsString, casing, x => x.Color)
     .SqlLocator.ShouldBe($"d.data ->> '{memberName}'");
 }
 public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
 {
     output.Write(Casing.Format(_value, format));
 }
 /// <summary>
 /// Gets the name stats request.
 /// </summary>
 /// <param name="casing">The casing.</param>
 /// <returns></returns>
 private RestRequest GetNameStatsRequest(Casing? casing = null)
 {
     return GetNameRequest("stats");
 }
 /// <summary>
 /// Gets the name deduction request.
 /// </summary>
 /// <param name="casing">The casing.</param>
 /// <returns></returns>
 private RestRequest GetNameDeductionRequest(Casing? casing = null)
 {
     return GetNameRequest("deducer");
 }
        /// <summary>
        /// Gets the card reader request.
        /// </summary>
        /// <param name="webhookUrl">The webhook URL.</param>
        /// <param name="casing">The casing.</param>
        /// <param name="sandbox">The sandbox.</param>
        /// <param name="verified">The verified.</param>
        /// <param name="verifiedOnly">The verified only.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">A webhook is required to process a card.</exception>
        private RestRequest GetCardReaderRequest(
            string webhookUrl,
            Casing? casing = null,
            SandboxMode? sandbox = null,
            Verified? verified = null,
            bool? verifiedOnly = null)
        {
            if (string.IsNullOrWhiteSpace(webhookUrl)) throw new ArgumentNullException("webhookUrl", "A webhook is required to process a card.");

            var request = new RestRequest("/cardReader.json", Method.POST);
            request.AddQueryParameter("webhookUrl", webhookUrl);

            if (casing.HasValue)
            {
                request.AddQueryParameter("casing", casing.Value.ToString());
            }

            if (sandbox.HasValue)
            {
                request.AddQueryParameter("sandbox", sandbox.Value.ToString());
            }

            if (verified.HasValue)
            {
                request.AddQueryParameter("verified", verified.Value.ToString());
            }

            if (verifiedOnly.HasValue && verifiedOnly.Value)
            {
                request.AddQueryParameter("returnedData", "verifiedOnly");
            }

            return request;
        }
Exemplo n.º 21
0
        public static void EncodeToUtf16(ReadOnlySpan <byte> bytes, Span <char> chars, Casing casing = Casing.Upper)
        {
            Debug.Assert(chars.Length >= bytes.Length * 2);

            for (int pos = 0; pos < bytes.Length; ++pos)
            {
                ToCharsBuffer(bytes[pos], chars, pos * 2, casing);
            }
        }
Exemplo n.º 22
0
        public static void ToCharsBuffer(byte value, Span <char> buffer, int startingIndex = 0, Casing casing = Casing.Upper)
        {
            uint difference   = ((value & 0xF0U) << 4) + (value & 0x0FU) - 0x8989U;
            uint packedResult = ((((uint)(-(int)difference) & 0x7070U) >> 4) + difference + 0xB9B9U) | (uint)casing;

            buffer[startingIndex + 1] = (char)(packedResult & 0xFF);
            buffer[startingIndex]     = (char)(packedResult >> 8);
        }
Exemplo n.º 23
0
        private static void EncodeToUtf16_Ssse3(ReadOnlySpan <byte> bytes, Span <char> chars, Casing casing)
        {
            Debug.Assert(bytes.Length >= 4);
            nint pos = 0;

            Vector128 <byte> shuffleMask = Vector128.Create(
                0xFF, 0xFF, 0, 0xFF, 0xFF, 0xFF, 1, 0xFF,
                0xFF, 0xFF, 2, 0xFF, 0xFF, 0xFF, 3, 0xFF);

            Vector128 <byte> asciiTable = (casing == Casing.Upper) ?
                                          Vector128.Create((byte)'0', (byte)'1', (byte)'2', (byte)'3',
                                                           (byte)'4', (byte)'5', (byte)'6', (byte)'7',
                                                           (byte)'8', (byte)'9', (byte)'A', (byte)'B',
                                                           (byte)'C', (byte)'D', (byte)'E', (byte)'F') :
                                          Vector128.Create((byte)'0', (byte)'1', (byte)'2', (byte)'3',
                                                           (byte)'4', (byte)'5', (byte)'6', (byte)'7',
                                                           (byte)'8', (byte)'9', (byte)'a', (byte)'b',
                                                           (byte)'c', (byte)'d', (byte)'e', (byte)'f');

            do
            {
                // Read 32bits from "bytes" span at "pos" offset
                uint block = Unsafe.ReadUnaligned <uint>(
                    ref Unsafe.Add(ref MemoryMarshal.GetReference(bytes), pos));

                // Calculate nibbles
                Vector128 <byte> lowNibbles = Ssse3.Shuffle(
                    Vector128.CreateScalarUnsafe(block).AsByte(), shuffleMask);
                Vector128 <byte> highNibbles = Sse2.ShiftRightLogical(
                    Sse2.ShiftRightLogical128BitLane(lowNibbles, 2).AsInt32(), 4).AsByte();

                // Lookup the hex values at the positions of the indices
                Vector128 <byte> indices = Sse2.And(
                    Sse2.Or(lowNibbles, highNibbles), Vector128.Create((byte)0xF));
                Vector128 <byte> hex = Ssse3.Shuffle(asciiTable, indices);

                // The high bytes (0x00) of the chars have also been converted
                // to ascii hex '0', so clear them out.
                hex = Sse2.And(hex, Vector128.Create((ushort)0xFF).AsByte());

                // Save to "chars" at pos*2 offset
                Unsafe.WriteUnaligned(
                    ref Unsafe.As <char, byte>(
                        ref Unsafe.Add(ref MemoryMarshal.GetReference(chars), pos * 2)), hex);

                pos += 4;
            } while (pos < bytes.Length - 3);

            // Process trailing elements (bytes.Length % 4)
            for (; pos < bytes.Length; pos++)
            {
                ToCharsBuffer(Unsafe.Add(ref MemoryMarshal.GetReference(bytes), pos), chars, (int)pos * 2, casing);
            }
        }
Exemplo n.º 24
0
        public static void EncodeToUtf16(ReadOnlySpan <byte> bytes, Span <char> chars, Casing casing = Casing.Upper)
        {
            Debug.Assert(chars.Length >= bytes.Length * 2);

#if SYSTEM_PRIVATE_CORELIB
            if (Ssse3.IsSupported && bytes.Length >= 4)
            {
                EncodeToUtf16_Ssse3(bytes, chars, casing);
                return;
            }
#endif
            for (int pos = 0; pos < bytes.Length; pos++)
            {
                ToCharsBuffer(bytes[pos], chars, pos * 2, casing);
            }
        }
Exemplo n.º 25
0
 public DateTimeField(string dataLocator, string schemaName, Casing casing, MemberInfo[] members) : base(dataLocator, "timestamp without time zone", casing, members)
 {
     TypedLocator = $"{schemaName}.mt_immutable_timestamp({RawLocator})";
 }
Exemplo n.º 26
0
        public static void ToBytesBuffer(byte value, Span <byte> buffer, int startingIndex = 0, Casing casing = Casing.Upper)
        {
            var difference   = ((value & 0xF0U) << 4) + (value & 0x0FU) - 0x8989U;
            var packedResult = ((((uint)-(int)difference & 0x7070U) >> 4) + difference + 0xB9B9U) | (uint)casing;

            buffer[startingIndex + 1] = (byte)packedResult;
            buffer[startingIndex]     = (byte)(packedResult >> 8);
        }
Exemplo n.º 27
0
 public SubunitFileName(String UnitFileName, Casing Casing, String DotReplacement) : base(UnitFileName, Casing, DotReplacement)
 {
 }
        /// <summary>
        /// Gets the stats of a given and family name.
        /// </summary>
        /// <param name="givenName">The given name.</param>
        /// <param name="familyName">The family name.</param>
        /// <param name="casing">The casing.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">
        /// A given name is required to get name stats.
        /// or
        /// A family name is required to get name stats.
        /// </exception>
        public NameStatsResponse GetNameStatsByName(string givenName, string familyName, Casing? casing = null)
        {
            if (string.IsNullOrEmpty(givenName)) throw new ArgumentNullException("givenName", "A given name is required to get name stats.");
            if (string.IsNullOrEmpty(familyName)) throw new ArgumentNullException("familyName", "A family name is required to get name stats.");

            var request = GetNameStatsRequest(casing);
            request.AddParameter("givenName", givenName);
            request.AddParameter("familyName", familyName);

            return Execute<NameStatsResponse>(request);
        }
Exemplo n.º 29
0
    public GameObject GenerateCase(Vector2 size, Transform parent)
    {
        float      halfX = size.x / 2;
        float      halfY = size.y / 2;
        GameObject bomb  = Instantiate(Empty_Bomb, parent);

        bomb.name = size.x + "x" + size.y + " Casing (" + (size.x * size.y * 2 - 1) + " modules)";
        Casing     casing           = bomb.GetComponent <Casing>();
        Transform  visual_transform = casing.Visual;
        KMBombFace front_face       = casing.Front.GetComponent <KMBombFace>();
        KMBombFace rear_face        = casing.Back.GetComponent <KMBombFace>();

        front_face.Anchors  = new List <Transform>();
        front_face.Backings = new List <KMModuleBacking>();
        front_face.GetComponent <KMSelectable>().ChildRowLength = (int)size.x;
        rear_face.Anchors  = new List <Transform>();
        rear_face.Backings = new List <KMModuleBacking>();
        rear_face.GetComponent <KMSelectable>().ChildRowLength = (int)size.x;

        casing.Distance_Collider.size = new Vector3(size.x * 0.23f, 0.20f, size.y * 0.23f);
        casing.Selectable_Area.size   = new Vector3(size.x * 0.24f, size.y * 0.24f, 0.22f);
        casing.Selectable_Area.transform.Translate(0, -0.25f, 0);

        casing.Highlight.localScale = new Vector3(size.x * 0.24f, size.y * 0.24f, 0.22f);

        // casing.Body.localScale = new Vector3(size * 0.23f, 0.18f, size * 0.23f);

        const float crossbar_width         = 0.025f;
        const float widget_offset          = 0.22f;
        const float widget_constant_offset = crossbar_width + 0.00275f;

        //Make the widget anchors
        for (int w = 0; w < size.x; w++)
        {
            Transform Bface = new GameObject().GetComponent <Transform>();
            Bface.Translate(new Vector3(offset * (w - halfX + 0.5f), 0.0f, 0.0f));
            Bface.Rotate(-90, 0, 0);
            Bface.SetParent(casing.W_Bottom);
            Bface.localScale = new Vector3(0.12f, 0.03f, 0.17f);
            Bface.name       = "Bottom Face";
            bomb.GetComponent <KMBomb>().WidgetAreas.Add(Bface.gameObject);

            Transform Tface = new GameObject().GetComponent <Transform>();
            Tface.Translate(new Vector3(offset * (w - halfX + 0.5f), 0.0f, 0.0f));
            Tface.Rotate(-90, 180, 0);
            Tface.SetParent(casing.W_Top);
            Tface.localScale = new Vector3(0.12f, 0.03f, 0.17f);
            Tface.name       = "Top Face";
            bomb.GetComponent <KMBomb>().WidgetAreas.Add(Tface.gameObject);
        }

        for (int w = 0; w < size.y; w++)
        {
            Transform Lface = new GameObject().GetComponent <Transform>();
            Lface.Translate(new Vector3(0.0f, 0.0f, offset * (w - halfY + 0.5f)));
            Lface.Rotate(-90, 90, 0);
            Lface.SetParent(casing.W_Left);
            Lface.localScale = new Vector3(0.12f, 0.03f, 0.17f);
            Lface.name       = "Left Face";
            bomb.GetComponent <KMBomb>().WidgetAreas.Add(Lface.gameObject);

            Transform Rface = new GameObject().GetComponent <Transform>();
            Rface.Translate(new Vector3(0.0f, 0.0f, offset * (w - halfY + 0.5f)));
            Rface.Rotate(-90, -90, 0);
            Rface.SetParent(casing.W_Right);
            Rface.localScale = new Vector3(0.12f, 0.03f, 0.17f);
            Rface.name       = "Right Face";
            bomb.GetComponent <KMBomb>().WidgetAreas.Add(Rface.gameObject);
        }

        casing.W_Bottom.Translate(new Vector3(0, 0, size.y * -widget_offset / 2 - widget_constant_offset), Space.World);
        casing.W_Top.Translate(new Vector3(0, 0, size.y * widget_offset / 2 + widget_constant_offset), Space.World);
        casing.W_Left.Translate(new Vector3(size.x * -widget_offset / 2 - widget_constant_offset, 0, 0), Space.World);
        casing.W_Right.Translate(new Vector3(size.x * widget_offset / 2 + widget_constant_offset, 0, 0), Space.World);

        //Generate the crossbars.
        if (Cross_Bar.GetComponent <ExcludeFromTexturePack>() == null)
        {
            Cross_Bar.AddComponent <ExcludeFromTexturePack>();
        }
        var renderer = Cross_Bar.GetComponent <Renderer>();

        renderer.material             = new Material(renderer.sharedMaterial);
        renderer.sharedMaterial.color = MakeCaseColor(Tweaks.settings.CaseColors);

        for (int i = 0; i <= size.x; i++)
        {
            Transform CrossBar1 = Instantiate(Cross_Bar).GetComponent <Transform>();
            CrossBar1.SetParent(visual_transform);
            CrossBar1.localScale = new Vector3(crossbar_width, 0.22f, size.y * 0.22f + crossbar_width * ((i == 0 || i == size.x) ? 1 : -1));
            CrossBar1.Translate(new Vector3(offset * (i - halfX), 0, -0));
        }

        for (int i = 0; i <= size.y; i++)
        {
            Transform CrossBar2 = Instantiate(Cross_Bar).GetComponent <Transform>();
            CrossBar2.SetParent(visual_transform);
            CrossBar2.localScale = new Vector3(size.x * 0.22f + crossbar_width * ((i == 0 || i == size.y) ? 1 : -1), 0.22f, crossbar_width) - new Vector3(0.0001f, 0.0001f, 0.0001f); // Subtracted 0.0001 to prevent Z-fighting.
            CrossBar2.Translate(new Vector3(0, 0, offset * (i - halfY)));
        }

        // Generate The module backings and anchors
        for (int x = 0; x < size.x; x++)
        {
            for (int y = 0; y < size.y; y++)
            {
                GameObject front_backing = Instantiate(Bomb_Backing);    // Grab the prefab
                Transform  f             = front_backing.GetComponent <Transform>();
                f.SetParent(casing.Faces_F);
                f.Translate(new Vector3(offset * (x - halfX + 0.5f), offset * (y - halfY + 0.5f), -0.06f));
                f.name = "Bomb_Foam_" + x + "_" + y + "_F";
                Transform f_anchor = new GameObject().GetComponent <Transform>();    // We need to rotate the anchor relative to the backing, so we need a new transform
                f_anchor.position = f.position;
                f_anchor.parent   = f;
                f_anchor.Translate(0, 0.03f, 0);    // Move the modules out of the backing
                f_anchor.Rotate(new Vector3(0, 0, 0));
                f_anchor.name = "Anchor";
                front_face.Anchors.Add(f_anchor);
                front_face.Backings.Add(front_backing.GetComponent <KMModuleBacking>());
                // And do it all again for the back face
                GameObject rear_backing = Instantiate(Bomb_Backing);
                Transform  r            = rear_backing.GetComponent <Transform>();
                r.SetParent(casing.Faces_R);
                r.Translate(new Vector3(offset * (x - halfX + 0.5f), offset * (y - halfY + 0.5f), 0.06f));
                r.Rotate(new Vector3(0, 180, 0));
                r.name = "Bomb_Foam_" + x + "_" + y + "_R";
                Transform r_anchor = new GameObject().GetComponent <Transform>();
                r_anchor.position = r.position;
                r_anchor.parent   = r;
                r_anchor.Translate(0, -0.03f, 0);
                r_anchor.Rotate(new Vector3(0, 0, 180));
                r_anchor.name = "Anchor";
                rear_face.Anchors.Add(r_anchor);
                rear_face.Backings.Add(rear_backing.GetComponent <KMModuleBacking>());
            }
        }
        bomb.GetComponent <KMBomb>().Scale = Mathf.Min(2.2f / Mathf.Max(size.x, size.y), 1);

        foreach (KMSelectable selectable in bomb.GetComponentsInChildren <KMSelectable>())
        {
            selectable.gameObject.AddComponent <ModSelectable>();
        }

        bomb.AddComponent <ModBomb>();

        return(bomb);
    }
        /// <summary>
        /// Gets the name request.
        /// </summary>
        /// <param name="resource">The resource.</param>
        /// <param name="casing">The casing.</param>
        /// <returns></returns>
        private RestRequest GetNameRequest(string resource, Casing? casing = null)
        {
            var request = new RestRequest(string.Format("/name/{0}.json", resource), Method.GET);

            if (casing.HasValue)
            {
                request.AddParameter("casing", casing.Value);
            }

            return request;
        }
Exemplo n.º 31
0
        protected virtual XmlNode generateXmlWithoutSaving(XmlDocument xd)
        {
            string  nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : Casing.SafeAliasWithForcingCheck(ContentType.Alias);
            XmlNode x        = xd.CreateNode(XmlNodeType.Element, nodeName, "");

            XmlPopulate(xd, ref x, false);
            return(x);
        }
Exemplo n.º 32
0
        public static string BuildJsonStringLocator(string column, MemberInfo[] members, Casing casing = Casing.Default)
        {
            var locator = new StringBuilder(column);
            var depth   = 1;

            foreach (var memberInfo in members)
            {
                locator.Append(depth == members.Length ? " ->> " : " -> ");
                locator.Append($"'{memberInfo.Name.FormatCase(casing)}'");
                depth++;
            }

            return(locator.ToString());
        }
Exemplo n.º 33
0
 static Generic.IEnumerable<char> ConvertTo(this Generic.IEnumerable<char> me, Casing to)
 {
     switch (to)
     {
         default:
         case Casing.Normal:
             foreach (var c in me)
                 yield return c;
             break;
         case Casing.Pascal:
         case Casing.Camel:
             bool nextUpper = to == Casing.Pascal;
             foreach (var c in me)
             {
     //						Console.Write(c);
                 if (c == ' ')
                     nextUpper = true;
                 else if (nextUpper)
                 {
                     nextUpper = false;
                     yield return char.ToUpper(c);
                 }
                 else
                     yield return c;
             }
     //					Console.WriteLine();
             break;
         case Casing.Lower:
             foreach (var c in me)
                 if (c == ' ')
                     yield return '_';
                 else
                     yield return c;
             break;
         case Casing.Upper:
             foreach (var c in me)
                 if (c == ' ')
                     yield return '_';
                 else
                     yield return char.ToUpper(c);
             break;
     }
 }
Exemplo n.º 34
0
 private static bool[] AsOrder(this string str, Casing casing)
 {
     return(str.Select(c => c == ' ' ^ casing == Casing.Uppercase).ToArray());
 }
Exemplo n.º 35
0
 /// <summary>
 ///     Use the default serialization (ilmerged Newtonsoft.Json) with Enum values
 ///     stored as either integers or strings
 /// </summary>
 /// <param name="enumStyle"></param>
 /// <param name="casing">Casing style to be used in serialization</param>
 /// <param name="collectionStorage">Allow to set collection storage as raw arrays (without explicit types)</param>
 public void UseDefaultSerialization(EnumStorage enumStyle = EnumStorage.AsInteger, Casing casing = Casing.Default, CollectionStorage collectionStorage = CollectionStorage.Default)
 {
     Serializer(new JsonNetSerializer {
         EnumStorage = enumStyle, Casing = casing, CollectionStorage = collectionStorage
     });
 }
Exemplo n.º 36
0
 public void locator_for_enum_in_integer_mode(Casing casing, string memberName)
 {
     JsonLocatorField.For <Target>(EnumStorage.AsInteger, casing, x => x.Color)
     .SqlLocator.ShouldBe($"CAST(d.data ->> '{memberName}' as integer)");
 }
Exemplo n.º 37
0
        public static string BuildJsonObjectLocator(string column, MemberInfo[] members, Casing casing = Casing.Default)
        {
            var locator = new StringBuilder(column);

            foreach (var memberInfo in members)
            {
                locator.Append($" -> '{memberInfo.Name.FormatCase(casing)}'");
            }
            return(locator.ToString());
        }
Exemplo n.º 38
0
 private static string ConvertToProperCaseIfRequired(string text, Casing casing)
 {
     if (casing == Casing.ProperCase)
     {
         var textInfo = new CultureInfo("en-GB", false).TextInfo;
         return textInfo.ToTitleCase(text.ToLower());
     }
     return text;
 }
        /// <summary>
        /// Gets the name similarity.
        /// </summary>
        /// <param name="nameA">The name a.</param>
        /// <param name="nameB">The name b.</param>
        /// <param name="casing">The casing.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">
        /// A name is required to get a name similarity.
        /// or
        /// A name to compare to is required to get a name similarity.
        /// </exception>
        public NameSimilarityResponse GetNameSimilarity(string nameA, string nameB, Casing? casing = null)
        {
            if (string.IsNullOrEmpty(nameA)) throw new ArgumentNullException("nameA", "A name is required to get a name similarity.");
            if (string.IsNullOrEmpty(nameB)) throw new ArgumentNullException("nameB", "A name to compare to is required to get a name similarity.");

            var request = new RestRequest("/name/similarity.json", Method.GET);
            request.AddParameter("q1", nameA);
            request.AddParameter("q2", nameB);

            if (casing.HasValue)
            {
                request.AddParameter("casing", casing.Value);
            }

            return Execute<NameSimilarityResponse>(request);
        }
Exemplo n.º 40
0
 private static void GetAnythingCharacterSet(Casing casing, List<string> characters)
 {
     switch (casing)
     {
         case Casing.Lowered:
             characters.AddRange(Numbers);
             characters.AddRange(Lowercase);
             characters.AddRange(SpecialCharacters);
             break;
         case Casing.Uppered:
             characters.AddRange(Numbers);
             characters.AddRange(Uppercase);
             characters.AddRange(SpecialCharacters);
             break;
         default:
             characters.AddRange(Numbers);
             characters.AddRange(Lowercase);
             characters.AddRange(Uppercase);
             characters.AddRange(SpecialCharacters);
             break;
     }
 }
        /// <summary>
        /// Gets the stats of a name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="casing">The casing.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">A name is required to get name stats.</exception>
        public NameStatsResponse GetNameStatsByName(string name, Casing? casing = null)
        {
            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "A name is required to get name stats.");

            var request = GetNameStatsRequest(casing);
            request.AddParameter("name", name);

            return Execute<NameStatsResponse>(request);
        }
Exemplo n.º 42
0
        private void saveProperties(ref SaveClickEventArgs e)
        {
            this.CreateChildControls();

            GenericProperties.GenericProperty gpData = gp.GenricPropertyControl;
            if (gpData.Name.Trim() != "" && gpData.Alias.Trim() != "")
            {
                if (doesPropertyTypeAliasExist(gpData))
                {
                    string[] info = { gpData.Name, gpData.Type.ToString() };
                    cms.businesslogic.propertytype.PropertyType pt = cType.AddPropertyType(cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(gpData.Type), Casing.SafeAliasWithForcingCheck(gpData.Alias.Trim()), gpData.Name);
                    pt.Mandatory        = gpData.Mandatory;
                    pt.ValidationRegExp = gpData.Validation;
                    pt.Description      = gpData.Description;

                    if (gpData.Tab != 0)
                    {
                        cType.SetTabOnPropertyType(pt, gpData.Tab);
                    }

                    gpData.Clear();
                }
                else
                {
                    e.Message  = ui.Text("contentTypeDublicatePropertyType");
                    e.IconType = umbraco.BasePages.BasePage.speechBubbleIcon.warning;
                }
            }

            foreach (GenericProperties.GenericPropertyWrapper gpw in _genericProperties)
            {
                cms.businesslogic.propertytype.PropertyType pt = gpw.PropertyType;
                pt.Alias              = gpw.GenricPropertyControl.Alias;
                pt.Name               = gpw.GenricPropertyControl.Name;
                pt.Description        = gpw.GenricPropertyControl.Description;
                pt.ValidationRegExp   = gpw.GenricPropertyControl.Validation;
                pt.Mandatory          = gpw.GenricPropertyControl.Mandatory;
                pt.DataTypeDefinition = cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(gpw.GenricPropertyControl.Type);
                if (gpw.GenricPropertyControl.Tab == 0)
                {
                    cType.removePropertyTypeFromTab(pt);
                }
                else
                {
                    cType.SetTabOnPropertyType(pt, gpw.GenricPropertyControl.Tab);
                }

                pt.Save();
            }

            // Sort order
            foreach (HtmlInputHidden propSorter in _sortLists)
            {
                if (propSorter.Value.Trim() != "")
                {
                    string tabId = propSorter.ID;
                    // remove leading "propSort_" and trailing "_Content"
                    tabId = tabId.Substring(9, tabId.Length - 9 - 8);
                    // calc the position of the prop SO i.e. after "t_<tabId>Contents[]="
                    int propSOPosition = "t_".Length + tabId.Length + "Contents[]=".Length + 1;

                    string[] tempSO = propSorter.Value.Split("&".ToCharArray());
                    for (int i = 0; i < tempSO.Length; i++)
                    {
                        string propSO           = tempSO[i].Substring(propSOPosition);
                        int    currentSortOrder = int.Parse(propSO);
                        cms.businesslogic.propertytype.PropertyType.GetPropertyType(currentSortOrder).SortOrder = i;
                    }
                }
            }
        }
Exemplo n.º 43
0
 protected SourceFileName(String UnitFileName, Casing Casing, String DotReplacement)
 {
     this.UnitFileName   = UnitFileName;
     this.Casing         = Casing;
     this.DotReplacement = DotReplacement;
 }