Esempio n. 1
0
        public void Create_CacheKey_withPropertyNameEmpty()
        {
            const string EMPTY_PROPERTY_NAME = "";
            Action       actual = () => NameCreator.CacheKey(typeof(string), typeof(Int32), EMPTY_PROPERTY_NAME);

            Assert.Throws <ArgumentNullException>(actual);
        }
Esempio n. 2
0
        public TypeNameCreator(ExistingNames existingNames)
        {
            this.existingNames    = existingNames;
            createUnknownTypeName = CreateNameCreator("Type");
            createEnumName        = CreateNameCreator("Enum");
            createStructName      = CreateNameCreator("Struct");
            createDelegateName    = CreateNameCreator("Delegate");
            createClassName       = CreateNameCreator("Class");
            createInterfaceName   = CreateNameCreator("Interface");

            var names = new string[] {
                "Exception",
                "EventArgs",
                "Attribute",
                "Form",
                "Dialog",
                "Control",
                "Stream",
            };

            foreach (var name in names)
            {
                nameInfos.Add(name, CreateNameCreator(name));
            }
        }
        private static void Work(object?state)
        {
            var searchContext = (SearchContext)state;

            foreach (var russianWord in searchContext.RussianWords)
            {
                if (searchContext.CancellationToken.IsCancellationRequested)
                {
                    break;
                }

                if (searchContext.CheckUpperCase)
                {
                    var enWORD = NameCreator.CreateWord(russianWord.ToUpper(), searchContext.Letters);
                    if (!string.IsNullOrEmpty(enWORD))
                    {
                        searchContext.Add(enWORD);
                    }
                }
                else
                {
                    var enWord = NameCreator.CreateWord(russianWord, searchContext.Letters);
                    if (!string.IsNullOrEmpty(enWord))
                    {
                        searchContext.Add(enWord);
                    }
                }
            }

            searchContext.RaiseComplete();
        }
        public CreateIndexStatementCollection BuildStatement()
        {
            IDictionary <string, CreateIndexStatement> createIndexStatements = new Dictionary <string, CreateIndexStatement>();

            string tableName = NameCreator.EscapeName(_entityMapping.TableName);

            foreach (var indexMapping in _entityMapping.IndexMappings)
            {
                string indexName = GetIndexName(indexMapping);

                // There is a single CreateIndexStatement per indexName
                if (!createIndexStatements.TryGetValue(indexName, out CreateIndexStatement createIndexStatement))
                {
                    createIndexStatement = new CreateIndexStatement
                    {
                        IsUnique  = indexMapping.IsUnique,
                        IndexName = indexName,
                        TableName = tableName,
                        Columns   = new Collection <CreateIndexStatement.IndexColumn>()
                    };

                    createIndexStatements.Add(indexName, createIndexStatement);
                }

                createIndexStatement.Columns.Add(new CreateIndexStatement.IndexColumn
                {
                    ColumnName = indexMapping.PropertyName, // FIXME:
                    Order      = indexMapping.Order
                });
            }

            return(new CreateIndexStatementCollection(createIndexStatements.Values));
        }
        public CreateTableStatement BuildStatement()
        {
            var keyMembers = entitySet.ElementType.KeyMembers.Cast <EdmProperty>().ToArray();

            // Only create a CompositePrimaryKeyStatement if there is a composite primary key.
            // If there is just one key member this is handled using a constraint.
            CompositePrimaryKeyStatement compositePrimaryKeyStatement = null;

            if (keyMembers.Length > 1)
            {
                compositePrimaryKeyStatement = new CompositePrimaryKeyStatementBuilder(keyMembers).BuildStatement();
            }

            var simpleColumnCollection = new ColumnStatementCollectionBuilder(entitySet.ElementType.Properties, keyMembers).BuildStatement();
            var foreignKeyCollection   = new ForeignKeyStatementBuilder(associationTypeContainer.GetAssociationTypes(entitySet.Name)).BuildStatement();

            var columnStatements = new List <IStatement>();

            columnStatements.AddRange(simpleColumnCollection);
            columnStatements.AddIfNotNull(compositePrimaryKeyStatement);
            columnStatements.AddRange(foreignKeyCollection);

            return(new CreateTableStatement
            {
                TableName = NameCreator.EscapeName(entitySet.Table),
                ColumnStatementCollection = new ColumnStatementCollection(columnStatements)
            });
        }
Esempio n. 6
0
        public InsertStatement BuildStatement()
        {
            var columnNameCollection = new ColumnNameStatementCollectionBuilder(_entityMapping).BuildStatement();

            var columnNameStatements = new List <ISqlStatement>();

            columnNameStatements.AddRange(columnNameCollection);

            var columnParametersBuilder = new ColumnParameterStatementCollectionBuilder(_entity, _entityMapping);;

            var columnParameterStatements = new List <ISqlStatement>();

            columnParameterStatements.AddRange(columnParametersBuilder.BuildStatement());

            return(new InsertStatement
            {
                TableName = NameCreator.EscapeName(_entityMapping.TableName),

                ColumnNameStatementCollection = new ColumnNameStatementCollection(columnNameStatements),

                ColumnParameterStatementCollection = new ColumnParameterStatementCollection(columnParameterStatements),

                Parameters = columnParametersBuilder.Parameters
            });
        }
Esempio n. 7
0
        public CreateTableStatement BuildStatement()
        {
            var keyMembers = _entityMapping.ColumnMappings.Where(p => p.IsKey).ToList();

            // Only create a CompositePrimaryKeyStatement if there is a composite primary key.
            // If there is just one key member this is handled using a constraint.
            CompositePrimaryKeyStatement compositePrimaryKeyStatement = null;

            if (keyMembers.Count > 1)
            {
                compositePrimaryKeyStatement = new CompositePrimaryKeyStatementBuilder(keyMembers).BuildStatement();
            }

            var simpleColumnCollection = new ColumnStatementCollectionBuilder(_entityMapping.ColumnMappings, keyMembers).BuildStatement();

            var foreignKeyCollection = new ForeignKeyStatementBuilder(_model, _entityMapping.ForeignKeyMappings).BuildStatement();

            var columnStatements = new List <ISqlStatement>();

            columnStatements.AddRange(simpleColumnCollection);
            columnStatements.AddIfNotNull(compositePrimaryKeyStatement);
            columnStatements.AddRange(foreignKeyCollection);

            return(new CreateTableStatement
            {
                TableName = NameCreator.EscapeName(_entityMapping.TableName),
                ColumnStatementCollection = new ColumnStatementCollection(columnStatements)
            });
        }
Esempio n. 8
0
 // Start is called before the first frame update
 protected virtual void Start()
 {
     NameCreator.PersonName p = NameCreator.Generate();
     isMale          = p.isMale;
     userName        = p.name;
     gameObject.name = userName;
     world           = GetComponentInParent <WorldController>();
 }
Esempio n. 9
0
        public DeleteStatement BuildStatement()
        {
            var keyMembers = _entityMapping.ColumnMappings.Where(p => p.IsKey).ToList();

            var pk      = keyMembers.First();
            var pkValue = _entityMapping.GetColumn(_entity, pk.PropertyName);

            var pkParameter = _parameters.Add(pkValue);

            return(new DeleteStatement
            {
                TableName = NameCreator.EscapeName(_entityMapping.TableName),
                PkName = pk.ColumnName,
                PkParameterName = pkParameter.Name,
                Parameters = _parameters
            });
        }
Esempio n. 10
0
        public void CreateWord_Test()
        {
            var result = NameCreator.CreateWord("РЫСЬ", new[]
            {
                new NameCreator.Letter {
                    Ru = 'Р', En = "P"
                },
                new NameCreator.Letter {
                    Ru = 'Ы', En = "bI"
                },
                new NameCreator.Letter {
                    Ru = 'С', En = "C"
                },
                new NameCreator.Letter {
                    Ru = 'Ь', En = "b"
                }
            });

            Assert.AreEqual("PbICb", result);
        }
Esempio n. 11
0
        public static string GetTableName(this EntityType entityType)
        {
            MetadataProperty metadataProperty;

            if (!entityType.MetadataProperties.TryGetValue("TableName", false, out metadataProperty))
            {
                return(entityType.Name);
            }

            if (metadataProperty.Value.GetType().Name != "DatabaseName")
            {
                return(entityType.Name);
            }

            object metadataPropertyValue     = metadataProperty.Value;
            Type   metadataPropertyValueType = metadataProperty.Value.GetType();

            // The type DatabaseName is internal. So we need reflection...
            // GetValue() overload with one value was introduces in .net 4.5 so use the overload with two parameters.
            var name = (string)metadataPropertyValueType.GetProperty("Name").GetValue(metadataPropertyValue, null);

            return(NameCreator.EscapeName(name));
        }
        public UpdateStatement BuildStatement()
        {
            var columnSetCollection = new ColumnSetStatementCollectionBuilder(_entity, _entityMapping, _parameters).BuildStatement();

            var columnSetStatements = new List <ISqlStatement>();

            columnSetStatements.AddRange(columnSetCollection);

            var keyMembers = _entityMapping.ColumnMappings.Where(p => p.IsKey).ToList();
            var pk         = keyMembers.First();
            var pkValue    = _entityMapping.GetColumn(_entity, pk.PropertyName);

            var pkParameter = _parameters.Add(pkValue);

            return(new UpdateStatement
            {
                TableName = NameCreator.EscapeName(_entityMapping.TableName),
                ColumnSetStatementCollection = new ColumnSetStatementCollection(columnSetStatements),
                PkColumn = pk.ColumnName,
                PkParameter = pkParameter.Name,
                Parameters = _parameters
            });
        }
        public CreateIndexStatementCollection BuildStatement()
        {
            IDictionary <string, CreateIndexStatement> createIndexStatments = new Dictionary <string, CreateIndexStatement>();

            foreach (var edmProperty in entitySet.ElementType.Properties)
            {
                var indexAnnotations = edmProperty.MetadataProperties
                                       .Select(x => x.Value)
                                       .OfType <IndexAnnotation>();

                string tableName = NameCreator.EscapeName(entitySet.Table);
                foreach (var index in indexAnnotations.SelectMany(ia => ia.Indexes))
                {
                    CreateIndexStatement createIndexStatement;
                    string indexName = GetIndexName(index, edmProperty);
                    if (!createIndexStatments.TryGetValue(indexName, out createIndexStatement))
                    {
                        createIndexStatement = new CreateIndexStatement
                        {
                            IsUnique = index.IsUnique,
                            Name     = indexName,
                            Table    = tableName,
                            Columns  = new Collection <CreateIndexStatement.IndexColumn>()
                        };
                        createIndexStatments.Add(indexName, createIndexStatement);
                    }

                    createIndexStatement.Columns.Add(new CreateIndexStatement.IndexColumn
                    {
                        Name  = edmProperty.Name,
                        Order = index.Order
                    });
                }
            }

            return(new CreateIndexStatementCollection(createIndexStatments.Values));
        }
        public SqliteAssociationType(AssociationType associationType, EntityContainer container)
        {
            FromRoleEntitySetName = associationType.Constraint.FromRole.Name;
            ToRoleEntitySetName   = associationType.Constraint.ToRole.Name;

            string fromTable = container.GetEntitySetByName(FromRoleEntitySetName, true).Table;
            string toTable;

            if (IsSelfReferencing(associationType))
            {
                toTable             = fromTable;
                ToRoleEntitySetName = FromRoleEntitySetName;
            }
            else
            {
                toTable = container.GetEntitySetByName(ToRoleEntitySetName, true).Table;
            }

            FromTableName     = NameCreator.EscapeName(fromTable);
            ToTableName       = NameCreator.EscapeName(toTable);
            ForeignKey        = associationType.Constraint.ToProperties.Select(x => x.Name);
            ForeignPrimaryKey = associationType.Constraint.FromProperties.Select(x => x.Name);
            CascadeDelete     = associationType.Constraint.FromRole.DeleteBehavior == OperationAction.Cascade;
        }
Esempio n. 15
0
 private void SignIn()
 {
     if (ControllerManager.instance.GetButtonDown(ControllerInputWrapper.Buttons.B, PlayerID.One))
     {
         SignInPanel.FindChild("NameCreator").FindChild("LetterHolder").GetComponent <NameCreator>().Reset();
         state = Enums.UIStates.Splash;
         UpdatePanels(SplashPanel);
         SFXManager.instance.PlayNegative();
         ControllerManager.instance.AllowPlayerRemoval(ControllerInputWrapper.Buttons.B);
     }
     if (ControllerManager.instance.GetButtonDown(ControllerInputWrapper.Buttons.Start, PlayerID.One))
     {
         NameCreator nameCreator = SignInPanel.FindChild("NameCreator").FindChild("LetterHolder").GetComponent <NameCreator>();
         string      text        = nameCreator.t.text;
         if (text.Length > 0 && text.ToCharArray()[text.Length - 1] != ' ')
         {
             nameCreator.Reset();
             ProfileData pd = new ProfileData(text);
             ProfileManager.instance.AddProfile(pd);
             SignInToMain();
             SFXManager.instance.PlayAffirm();
         }
     }
 }
 private string GetIndexName(IndexAttribute index, EdmProperty property)
 {
     return(index.Name == null?IndexNameCreator.CreateName(entitySet.ElementType.GetTableName(), property.Name) : NameCreator.EscapeName(index.Name));
 }
Esempio n. 17
0
        public void Create_CacheKey_withThreeParameters()
        {
            string cacheKey = NameCreator.CacheKey(typeof(string), typeof(Int32), "PropertyName");

            Assert.Equal("System.String-System.Int32-PropertyName", cacheKey);
        }
Esempio n. 18
0
        public void Create_CacheKey_withTwoParameters()
        {
            string cacheKey = NameCreator.CacheKey(typeof(string), typeof(Int32));

            Assert.Equal("System.String-System.Int32", cacheKey);
        }
Esempio n. 19
0
 public void Add(string name, NameCreator nameCreator) => nameInfos.Add(new NameInfo(name, nameCreator));
Esempio n. 20
0
 public NameInfo(string name, NameCreator nameCreator)
 {
     this.name        = name;
     this.nameCreator = nameCreator;
 }
Esempio n. 21
0
        public void CreateTableNameTest()
        {
            string result = NameCreator.EscapeName("Test");

            Assert.AreEqual("\"Test\"", result);
        }
Esempio n. 22
0
    private void Start()
    {
        var foodPreference = Random.Range(0, 100);

        if (foodPreference >= 0 && foodPreference < 30)
        {
            TypeOfCreature = "Carnivorous";
        }
        if (foodPreference >= 30 && foodPreference <= 100)
        {
            TypeOfCreature = "Herbiverous";
        }

        _t = transform; // default transform of creature (parent)
        //name = "creature" + gameObject.GetInstanceID(); // name of creature (planning on randomising this)

        _t.gameObject.layer = LayerMask.NameToLayer("Creature");

        _environment    = EnvironmentController.GetInstance();
        _settingsReader = SettingsReader.GetInstance();

        // everything from here is to do with the transforms of the creature and its limbs
        _maxRootScale = new Vector3
        {
            x = _settingsReader.RootMaxRootScaleX,
            y = _settingsReader.RootMaxRootScaleY,
            z = _settingsReader.RootMaxRootScaleZ
        };

        _minRootScale = new Vector3
        {
            x = _settingsReader.RootMinRootScaleX,
            y = _settingsReader.RootMinRootScaleY,
            z = _settingsReader.RootMinRootScaleZ
        };

        _jointFrequency = ChromosomeComposition.JointFrequency;
        _jointAmplitude = ChromosomeComposition.JointAmplitude;
        _jointPhase     = ChromosomeComposition.JointPhase;

        RootSetup();

        EyeSetup();

        MouthSetup();

        GenitalSetup();

        VariableSetup();

        InvokeRepeating("UpdateState", 0, 5f);      // update state every 5 seconds
        InvokeRepeating("RandomDirection", 1F, 5F); // update direction every 5 seconds

        Root.GetComponent <Rigidbody>().SetDensity(4F);
        Root.AddComponent <AudioSource>();
        _ms = GetComponentsInChildren <MeshRenderer>();
        ChromosomeComposition.SetTypeOfCreature(TypeOfCreature);
        // setup a name
        name = NameCreator.Name(ChromosomeComposition);
        NameSetup();
    }