Ejemplo n.º 1
0
    static void TestUniqueString()
    {
        int    i  = 15;
        string s  = "foo" + i.ToString();
        string s2 = UniqueString.Intern(s);
        string s3 = UniqueString.Intern(s, false);

        Debug.Log(System.Object.ReferenceEquals(s, s2));
        Debug.Log(System.Object.ReferenceEquals(s, s3));
        UniqueString.Clear();
    }
        public void TestIfStringIsUnique()
        {
            // chech if string is unique
            Assert.True(UniqueString.IsUniqueChars("abcdfghjkl"));
            Assert.False(UniqueString.IsUniqueChars("aabvbcvbcvb"));

            // check is string is unique (using lowercase)
            Assert.True(UniqueString.IsUniqueCharsLowerCase("agdwetyf"));
            Assert.False(UniqueString.IsUniqueCharsLowerCase("aasdfsdfsdfsdfsd"));

            // compare to one another
            Assert.True(UniqueString.CompareEveryCharacter("agdwetyf"));
            Assert.False(UniqueString.CompareEveryCharacter("asdfsdfsdfsdfsda"));
        }
Ejemplo n.º 3
0
    static void TestUniqueString()
    {
        int    i  = 15;
        string s  = "foo" + i.ToString();
        string s2 = UniqueString.Intern(s);
        string s3 = UniqueString.Intern(s, false);

        Debug.Log(System.Object.ReferenceEquals(s, s2));
        Debug.Log(System.Object.ReferenceEquals(s, s3));
        UniqueString.Clear();

        GraphicsDeviceType[] dt = PlayerSettings.GetGraphicsAPIs(BuildTarget.Android);
        foreach (var d in dt)
        {
            Debug.Log(d);
        }
    }
Ejemplo n.º 4
0
        private static void AddIdToUniqueString(Dictionary <string, UniqueString> idToUniqueString, string id, string newValue)
        {
            UniqueString oldValue;

            if (idToUniqueString.TryGetValue(id, out oldValue))
            {
                if (oldValue.Value != newValue)
                {
                    oldValue.HasConflict = true;
                }
            }
            else
            {
                idToUniqueString[id] = new UniqueString {
                    Value = newValue
                };
            }
        }
Ejemplo n.º 5
0
        public ArmDeployment(IResourceManagementClient resourceManagementClient, string location)
        {
            Client   = resourceManagementClient;
            Location = location;
            var template = new TemplateBuilder().Template;

            var suffix = UniqueString.Create();

            DeploymentName = $"armeval-deployment-{suffix}";

            var deploymentProperties = new DeploymentProperties
            {
                Mode       = DeploymentMode.Incremental,
                Template   = template,
                Parameters = template["parameters"]
            };

            Deployment = new Deployment(deploymentProperties, Location);
        }
Ejemplo n.º 6
0
    public static string Intern(string str, bool removable = true)
    {
        if (str == null)
        {
            return((string)null);
        }
        string str1 = UniqueString.IsInterned(str);

        if (str1 != null)
        {
            return(str1);
        }
        if (!removable)
        {
            return(string.Intern(str));
        }
        UniqueString.m_strings.Add(str, str);
        return(str);
    }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            var condition = true;

            //just keeping the current solving problem in if condition; nothing else
            if (condition)
            {
                KStacks.MainMethod();
            }
            else
            {
                #region LinkedLists
                LinkIntersection.MainMethod();
                SumList.MainMethod();
                RemoveDups <int> .MainMethod();

                ReturnKthToLast.MainMethod(1);
                DeleteMiddleNode.MainMethod();
                LoopDetection.MainMethod();
                #endregion

                #region Array and Strings
                StringRotation.IsStringRotation("waterbottle", "erbottlewat");
                ZeroMatrixImplementation();
                RotateMatrixImplementation(4);
                StringCompression.CompressedString("aabcccccaaa");
                OneAway.IsStringOneAway("pale", "paled");
                PalindromePermutation.IsPalindromePermutation("Mr. owl ate my Metal worm");
                URLify.URLifyString("Spaces in this string will be replaced by percent20");
                IsStringPermutation.VerifyStringPermutation("abdcdefgh", "aefgb2cdh");
                UniqueString.VerifyUniqueStringAsciiSet("!@#$%$^&*()EFgh");
                HashTableImplentation();
                SwapWithoutTemp.SwapWithoutTempVar(12, 24);
                #endregion
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// LUA结构支持
        /// </summary>
        /// <returns></returns>
        public override void GetLuaStruct(StringBuilder code)
        {
            base.GetLuaStruct(code);
            int idx;

            if (!string.IsNullOrWhiteSpace(PropertyName))
            {
                code.AppendLine($@"['PropertyName'] = '{PropertyName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['PropertyName'] = nil,");
            }

            code.AppendLine($@"['IsCaption'] ={(IsCaption.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Alias))
            {
                code.AppendLine($@"['Alias'] = '{Alias.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Alias'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(Group))
            {
                code.AppendLine($@"['Group'] = '{Group.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Group'] = nil,");
            }

            code.AppendLine($@"['CreateIndex'] ={(CreateIndex.ToString().ToLower())},");

            code.AppendLine($@"['IsPrimaryKey'] ={(IsPrimaryKey.ToString().ToLower())},");

            code.AppendLine($@"['IsExtendKey'] ={(IsExtendKey.ToString().ToLower())},");

            code.AppendLine($@"['IsIdentity'] ={(IsIdentity.ToString().ToLower())},");

            code.AppendLine($@"['IsGlobalKey'] ={(IsGlobalKey.ToString().ToLower())},");

            code.AppendLine($@"['UniqueIndex'] ={UniqueIndex},");

            code.AppendLine($@"['IsRequired'] ={(IsRequired.ToString().ToLower())},");

            code.AppendLine($@"['IsUserReadOnly'] ={(IsUserReadOnly.ToString().ToLower())},");

            code.AppendLine($@"['IsMemo'] ={(IsMemo.ToString().ToLower())},");


            code.AppendLine($@"['DenyClient'] ={(DenyClient.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Prefix))
            {
                code.AppendLine($@"['Prefix'] = '{Prefix.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Prefix'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(Suffix))
            {
                code.AppendLine($@"['Suffix'] = '{Suffix.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Suffix'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(InputType))
            {
                code.AppendLine($@"['InputType'] = '{InputType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['InputType'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ComboBoxUrl))
            {
                code.AppendLine($@"['ComboBoxUrl'] = '{ComboBoxUrl.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ComboBoxUrl'] = nil,");
            }

            code.AppendLine($@"['IsMoney'] ={(IsMoney.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(GridAlign))
            {
                code.AppendLine($@"['GridAlign'] = '{GridAlign.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['GridAlign'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DataFormater))
            {
                code.AppendLine($@"['DataFormater'] = '{DataFormater.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DataFormater'] = nil,");
            }

            code.AppendLine($@"['DenyClient'] ={(DenyClient.ToString().ToLower())},");

            code.AppendLine($@"['GridDetails'] ={(GridDetails.ToString().ToLower())},");

            code.AppendLine($@"['NoneGrid'] ={(NoneGrid.ToString().ToLower())},");

            code.AppendLine($@"['NoneDetails'] ={(NoneDetails.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(GridDetailsCode))
            {
                code.AppendLine($@"['GridDetailsCode'] = '{GridDetailsCode.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['GridDetailsCode'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CppType))
            {
                code.AppendLine($@"['CppType'] = '{CppType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CppType'] = nil,");
            }

            if (CppTypeObject != null)
            {
                code.AppendLine($@"['CppTypeObject'] ='{CppTypeObject}',");
            }

            if (!string.IsNullOrWhiteSpace(CppName))
            {
                code.AppendLine($@"['CppName'] = '{CppName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CppName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CppLastType))
            {
                code.AppendLine($@"['CppLastType'] = '{CppLastType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CppLastType'] = nil,");
            }

            code.AppendLine($@"['IsIntDecimal'] ={(IsIntDecimal.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(CsType))
            {
                code.AppendLine($@"['CsType'] = '{CsType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CsType'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CustomType))
            {
                code.AppendLine($@"['CustomType'] = '{CustomType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CustomType'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(LastCsType))
            {
                code.AppendLine($@"['LastCsType'] = '{LastCsType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['LastCsType'] = nil,");
            }

            if (EnumConfig != null)
            {
                code.AppendLine($@"['EnumConfig'] = {EnumConfig.GetLuaStruct()},");
            }

            code.AppendLine($@"['IsCompute'] ={(IsCompute.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ComputeGetCode))
            {
                code.AppendLine($@"['ComputeGetCode'] = '{ComputeGetCode.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ComputeGetCode'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ComputeSetCode))
            {
                code.AppendLine($@"['ComputeSetCode'] = '{ComputeSetCode.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ComputeSetCode'] = nil,");
            }

            code.AppendLine($@"['IsMiddleField'] ={(IsMiddleField.ToString().ToLower())},");

            code.AppendLine($@"['InnerField'] ={(InnerField.ToString().ToLower())},");

            code.AppendLine($@"['IsSystemField'] ={(IsSystemField.ToString().ToLower())},");

            code.AppendLine($@"['IsInterfaceField'] ={(IsInterfaceField.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Initialization))
            {
                code.AppendLine($@"['Initialization'] = '{Initialization.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Initialization'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(EmptyValue))
            {
                code.AppendLine($@"['EmptyValue'] = '{EmptyValue.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['EmptyValue'] = nil,");
            }

            code.AppendLine($@"['DenyScope'] ='{DenyScope}',");

            code.AppendLine($@"['Nullable'] ={(Nullable.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Max))
            {
                code.AppendLine($@"['Max'] = '{Max.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Max'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(Min))
            {
                code.AppendLine($@"['Min'] = '{Min.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Min'] = nil,");
            }

            code.AppendLine($@"['UniqueString'] ={(UniqueString.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ColumnName))
            {
                code.AppendLine($@"['ColumnName'] = '{ColumnName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ColumnName'] = nil,");
            }

            code.AppendLine($@"['DbNullable'] ={(DbNullable.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(DbType))
            {
                code.AppendLine($@"['DbType'] = '{DbType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DbType'] = nil,");
            }

            code.AppendLine($@"['Precision'] ={Datalen},");

            if (!string.IsNullOrWhiteSpace(ArrayLen))
            {
                code.AppendLine($@"['ArrayLen'] = '{ArrayLen.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ArrayLen'] = nil,");
            }

            code.AppendLine($@"['Scale'] ={Scale},");

            code.AppendLine($@"['DbIndex'] ={DbIndex},");

            code.AppendLine($@"['Unicode'] ={(Unicode.ToString().ToLower())},");

            code.AppendLine($@"['FixedLength'] ={(FixedLength.ToString().ToLower())},");

            code.AppendLine($@"['IsBlob'] ={(IsBlob.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(StorageProperty))
            {
                code.AppendLine($@"['StorageProperty'] = '{StorageProperty.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['StorageProperty'] = nil,");
            }

            code.AppendLine($@"['DbInnerField'] ={(DbInnerField.ToString().ToLower())},");

            code.AppendLine($@"['NoStorage'] ={(NoStorage.ToString().ToLower())},");

            code.AppendLine($@"['KeepStorageScreen'] ='{KeepStorageScreen}',");

            code.AppendLine($@"['CustomWrite'] ={(CustomWrite.ToString().ToLower())},");

            code.AppendLine($@"['IsLinkField'] ={(IsLinkField.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(LinkTable))
            {
                code.AppendLine($@"['LinkTable'] = '{LinkTable.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['LinkTable'] = nil,");
            }

            code.AppendLine($@"['IsLinkKey'] ={(IsLinkKey.ToString().ToLower())},");

            code.AppendLine($@"['IsLinkCaption'] ={(IsLinkCaption.ToString().ToLower())},");

            code.AppendLine($@"['IsUserId'] ={(IsUserId.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(LinkField))
            {
                code.AppendLine($@"['LinkField'] = '{LinkField.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['LinkField'] = nil,");
            }

            code.AppendLine($@"['IsCustomCompute'] ={(IsCustomCompute.ToString().ToLower())},");

            code.AppendLine($@"['CanGet'] ={(CanGet.ToString().ToLower())},");

            code.AppendLine($@"['CanSet'] ={(CanSet.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(AccessType))
            {
                code.AppendLine($@"['AccessType'] = '{AccessType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['AccessType'] = nil,");
            }

            code.AppendLine($@"['ReadOnly'] ={(ReadOnly.ToString().ToLower())},");

            code.AppendLine($@"['CanInput'] ={(CanUserInput.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ExtendRole))
            {
                code.AppendLine($@"['ExtendRole'] = '{ExtendRole.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ExtendRole'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ValueSeparate))
            {
                code.AppendLine($@"['ValueSeparate'] = '{ValueSeparate.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ValueSeparate'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ArraySeparate))
            {
                code.AppendLine($@"['ArraySeparate'] = '{ArraySeparate.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ArraySeparate'] = nil,");
            }

            code.AppendLine($@"['ExtendArray'] ={(ExtendArray.ToString().ToLower())},");

            code.AppendLine($@"['IsKeyValueArray'] ={(IsKeyValueArray.ToString().ToLower())},");

            code.AppendLine($@"['IsRelation'] ={(IsRelation.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ExtendPropertyName))
            {
                code.AppendLine($@"['ExtendPropertyName'] = '{ExtendPropertyName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ExtendPropertyName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ExtendClassName))
            {
                code.AppendLine($@"['ExtendClassName'] = '{ExtendClassName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ExtendClassName'] = nil,");
            }

            code.AppendLine($@"['ExtendClassIsPredestinate'] ={(ExtendClassIsPredestinate.ToString().ToLower())},");

            code.AppendLine($@"['IsRelationField'] ={(IsRelationField.ToString().ToLower())},");

            code.AppendLine($@"['IsRelationValue'] ={(IsRelationValue.ToString().ToLower())},");

            code.AppendLine($@"['IsRelationArray'] ={(IsRelationArray.ToString().ToLower())},");

            code.AppendLine($@"['IsExtendArray'] ={(IsExtendArray.ToString().ToLower())},");

            code.AppendLine($@"['IsExtendValue'] ={(IsExtendValue.ToString().ToLower())},");
        }
Ejemplo n.º 9
0
        public void Test_IsUnique2(string str, bool expected)
        {
            var actual = UniqueString.IsUnique2(str);

            Assert.That(actual, Is.EqualTo(expected));
        }
Ejemplo n.º 10
0
 public void IsUnique_UniqueStringPassed_ReturnsTrue()
 {
     Assert.IsTrue(UniqueString.IsUnique("abcdefg"));
 }
Ejemplo n.º 11
0
 public void IsUnique1_EmptyStringPassed_ReturnsTrue()
 {
     Assert.IsTrue(UniqueString.IsUnique1(""));
 }
Ejemplo n.º 12
0
 public void IsUnique1_NonUniqueStringPassed_ReturnsFalse()
 {
     Assert.IsFalse(UniqueString.IsUnique1("abca"));
 }