Summary description for Projects
예제 #1
0
        internal static NamedSchema NewInstance(JObject j, Names names)
        {
            string type = JsonHelper.GetRequiredString(j, "type");

            NamedSchema result;
            if (names.TryGetValue(type, out result))
            {
                if (j.Count != 1) throw new AvroTypeException("Extra fields in: " + j);
                return result;
            }

            switch (type)
            {
                case "fixed":
                    return FixedSchema.NewInstance(j, names);
                case "enum":
                    return EnumSchema.NewInstance(j, names);
                case "record":
                    return RecordSchema.NewInstance(Type.RECORD, j, names);
                case "error":
                    return RecordSchema.NewInstance(Type.ERROR, j, names);
                default:
                    return null;
            }
        }
예제 #2
0
 private FixedSchema(Name name, int size, Names names)
     : base(Type.FIXED, name, names)
 {
     if (size <= 0) throw new ArgumentOutOfRangeException("size", "size must be greater than zero.");
     
     this.size = size;
 }
예제 #3
0
        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            var constraints = ReadConstraints(conn, schemaName.DbName);

            //sort tables - parents first (this is moving to SchemaPostprocess)
            //TableSorter.Sort(tables, constraints); 

            foreach (DataConstraint keyColRow in constraints)
            {
                //find my table:
                string fullKeyDbName = GetFullDbName(keyColRow.TableName, keyColRow.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => fullKeyDbName == t.Name);
                if (table == null)
                {
                    bool ignoreCase = true;
                    table = schema.Tables.FirstOrDefault(t => 0 == string.Compare(fullKeyDbName, t.Name, ignoreCase));
                    if (table == null)
                    {
                        WriteErrorLine("ERROR L46: Table '" + keyColRow.TableName + "' not found for column " + keyColRow.ColumnName);
                        continue;
                    }
                }

                bool isForeignKey = keyColRow.ConstraintName != "PRIMARY"
                                    && keyColRow.ReferencedTableName != null;

                if (isForeignKey)
                {
                    LoadForeignKey(schema, table, keyColRow.ColumnName, keyColRow.TableName, keyColRow.TableSchema,
                                   keyColRow.ReferencedColumnName, keyColRow.ReferencedTableName, keyColRow.ReferencedTableSchema,
                                   keyColRow.ConstraintName, nameFormat, names);
                }

            }
        }
        /// レイアウト要素のClipping領域(Fitオプションなし)の変更を試みる
        /// @param layoutElement レイアウト要素
        /// @param target 変更箇所
        /// @param value 変更値
        /// @param[out] changed 変更後、制約を満たす形に訂正されたClipping領域
        /// @return 試行結果(訂正箇所)
        public static TryResult TryChange(
            LayoutElement layoutElement, Names target, int value,
            out ClientRect changed)
        {
            Debug.Assert(layoutElement.IsWindowValid);
            Debug.Assert(!layoutElement.Fit);

            // 準備
            var original = ClippingInputCorrector.GetOriginal(layoutElement);
            var window = Utilities.GetWindowRect(layoutElement.WindowType, layoutElement.Window);

            // 訂正
            switch (target) {
              case Names.X:
              case Names.Y: {
            return ClippingInputCorrector.TryChangePosition(
            original, target, value, window,
            Constants.MinimumClippingSize, out changed);
              }
              case Names.Width:
              case Names.Height: {
            return ClippingInputCorrector.TryChangeSize(
            original, target, value, window,
            Constants.MinimumClippingSize, out changed);
              }
              default: Debug.Fail("switch"); throw new System.ArgumentException();
            }
        }
예제 #5
0
        private static Protocol Parse(JToken j)
        {
            string protocol = JsonHelper.GetRequiredString(j, "protocol");
            string snamespace = JsonHelper.GetRequiredString(j, "namespace");
            string doc = JsonHelper.GetOptionalString(j, "doc");

            Names names = new Names();

            JToken jtypes = j["types"];
            List<Schema> types = new List<Schema>();
            if (jtypes is JArray)
            {
                foreach (JToken jtype in jtypes)
                {
                    Schema schema = Schema.ParseJson(jtype, names);
                    types.Add(schema);
                }
            }


            JToken jmessages = j["messages"];
            List<Message> messages = new List<Message>();


            foreach (JProperty jmessage in jmessages)
            {
                Message message = Message.Parse(jmessage, names);
                messages.Add(message);
            }

            


            return new Protocol(protocol, snamespace, doc, types, messages);
        }
예제 #6
0
        public VertexVievModel(Vertex v, Graph g, Positions p, Names n)
        {
            vertex= v;

            graph = g;
            positionedGraph = p;

            namedGraph = n;
        }
예제 #7
0
 protected Person(Names id, string title, string firstName, string lastName, string sortValue, bool isFemale = false)
 {
     Id = id;
     Title = title;
     FirstName = firstName;
     LastName = lastName;
     SortValue = sortValue;
     IsFemale = isFemale;
 }
예제 #8
0
 internal static ArraySchema NewInstance(JToken j, Names names)
 {
     JToken t = j["items"];
     if (null == t)
     {
         throw new AvroTypeException("Array does not have 'items'");
     }
     return new ArraySchema(Schema.ParseJson(t, names));
 }
예제 #9
0
	public override void OnInspectorGUI ()
	{
		DrawDefaultInspector ();
		EditorGUILayout.Space ();

		if (target != null && GUILayout.Button ("Load", EditorStyles.miniButton))
		{
			Names.CurrentCollection = (Names)target;
		}
	}
 /// LayoutElement.Clipping*の関連するプロパティを返す
 public static Names GetDependent(Names target)
 {
     switch (target) {
       case Names.X: return Names.Width;
       case Names.Y: return Names.Height;
       case Names.Width: return Names.X;
       case Names.Height: return Names.Y;
       default: Debug.Fail("switch"); throw new System.ArgumentException();
     }
 }
        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            //TableSorter.Sort(tables, constraints); //sort tables - parents first

            var constraints = ReadConstraints(conn, schemaName.DbName);

            var allKeys2 = ReadForeignConstraints(conn, schemaName.DbName);
            var foreignKeys = allKeys2.Where(k => k.ConstraintType == "FOREIGN KEY").ToList();
            var primaryKeys = allKeys2.Where(k => k.ConstraintType == "PRIMARY KEY").ToList();


            foreach (DataConstraint keyColRow in constraints)
            {
                //find my table:
                string constraintFullDbName = GetFullDbName(keyColRow.TableName, keyColRow.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => constraintFullDbName == t.Name);
                if (table == null)
                {
                    WriteErrorLine("ERROR L138: Table '" + keyColRow.TableName + "' not found for column " + keyColRow.ColumnName);
                    continue;
                }

                //todo: must understand better how PKEYs are encoded.
                //In Sasha's DB, they don't end with "_pkey", you need to rely on ReadForeignConstraints().
                //In Northwind, they do end with "_pkey".
                bool isPrimaryKey = keyColRow.ConstraintName.EndsWith("_pkey")
                    || primaryKeys.Count(k => k.ConstraintName == keyColRow.ConstraintName) == 1;

                if (isPrimaryKey)
                {
                    //A) add primary key
                    DbLinq.Schema.Dbml.Column primaryKeyCol = table.Type.Columns.First(c => c.Name == keyColRow.ColumnName);
                    primaryKeyCol.IsPrimaryKey = true;
                }
                else
                {
                    DataForeignConstraint dataForeignConstraint = foreignKeys.FirstOrDefault(f => f.ConstraintName == keyColRow.ConstraintName);

                    if (dataForeignConstraint == null)
                    {
                        string msg = "Missing data from 'constraint_column_usage' for foreign key " + keyColRow.ConstraintName;
                        WriteErrorLine(msg);
                        //throw new ApplicationException(msg);
                        continue; //as per Andrus, do not throw. //putting together an Adnrus_DB test case.
                    }

                    LoadForeignKey(schema, table, keyColRow.ColumnName, keyColRow.TableName, keyColRow.TableSchema,
                                   dataForeignConstraint.ColumnName, dataForeignConstraint.ReferencedTableName,
                                   dataForeignConstraint.ReferencedTableSchema,
                                   keyColRow.ConstraintName, nameFormat, names);

                }

            }
        }
예제 #12
0
        /// <summary>
        /// Loads the foreign key.
        /// </summary>
        /// <param name="schema">The schema.</param>
        /// <param name="table">The table.</param>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="tableSchema">The table schema.</param>
        /// <param name="referencedColumnName">Name of the referenced column.</param>
        /// <param name="referencedTableName">Name of the referenced table.</param>
        /// <param name="referencedTableSchema">The referenced table schema.</param>
        /// <param name="constraintName">Name of the constraint.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <param name="names">The names.</param>
        protected virtual void LoadForeignKey(Database schema, Table table, string columnName, string tableName, string tableSchema,
            string referencedColumnName, string referencedTableName, string referencedTableSchema,
            string constraintName,
            NameFormat nameFormat, Names names)
        {
            var foreignKey = BuildForeignKey(names.ColumnsNames[tableName], columnName);
            var reverseForeignKey = BuildForeignKey(names.ColumnsNames[referencedTableName], referencedColumnName);

            var associationName = CreateAssociationName(tableName, tableSchema,
                referencedTableName, referencedTableSchema, constraintName, foreignKey, nameFormat);

            //both parent and child table get an [Association]
            var assoc = new Association();
            assoc.IsForeignKey = true;
            assoc.Name = constraintName;
            assoc.Type = null;
            assoc.ThisKey = foreignKey;
            assoc.OtherKey = reverseForeignKey;
            assoc.Member = associationName.ManyToOneMemberName;
            assoc.CardinalitySpecified = false;
            // TODO: generate assoc.Cardinality?
            table.Type.Associations.Add(assoc);

            //and insert the reverse association:
            var reverseAssociation = new Association();
            reverseAssociation.Name = constraintName;
            reverseAssociation.Type = table.Type.Name;
            reverseAssociation.Member = associationName.OneToManyMemberName;
            reverseAssociation.CardinalitySpecified = false;
            // TODO: generate reverseAssociation.Cardinality?
            reverseAssociation.ThisKey = reverseForeignKey;
            reverseAssociation.OtherKey = foreignKey;
            reverseAssociation.DeleteRule = "NO ACTION";

            string referencedFullDbName = GetFullDbName(referencedTableName, referencedTableSchema);
            var referencedTable = schema.Tables.FirstOrDefault(t => referencedFullDbName == t.Name);
            if (referencedTable == null)
            {
                //try case-insensitive match 
                //reason: MySql's Key_Column_Usage table contains both 'Northwind' and 'northwind'
                referencedTable = schema.Tables.FirstOrDefault(t => referencedFullDbName.ToLower() == t.Name.ToLower());
            }

            if (referencedTable == null)
            {
                ReportForeignKeyError(schema, referencedFullDbName);
            }
            else
            {
                referencedTable.Type.Associations.Add(reverseAssociation);
                assoc.Type = referencedTable.Type.Name;
            }
        }
예제 #13
0
        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            var constraints = ReadConstraints(conn, schemaName.DbName);

            foreach (DataConstraint constraint in constraints)
            {
                //find my table:
                string constraintFullDbName = GetFullDbName(constraint.TableName, constraint.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => constraintFullDbName == t.Name);
                if (table == null)
                {
                    WriteErrorLine("ERROR L100: Table '" + constraint.TableName + "' not found for column " + constraint.ColumnNameList);
                    continue;
                }

                //if (table.Name.StartsWith("E"))
                //    Logger.Write("---Dbg");

                if (constraint.ConstraintType == "P")
                {
                    //A) add primary key
                    DbLinq.Schema.Dbml.Column pkColumn = table.Type.Columns.Where(c => constraint.ColumnNames.Contains(c.Name)).First();
                    pkColumn.IsPrimaryKey = true;
                }
                else if (constraint.ConstraintType == "R")
                {
                    //if not PRIMARY, it's a foreign key. (constraint_type=="R")
                    //both parent and child table get an [Association]
                    DataConstraint referencedConstraint = constraints.FirstOrDefault(c => c.ConstraintName == constraint.ReverseConstraintName);
                    if (constraint.ReverseConstraintName == null || referencedConstraint == null)
                    {
                        WriteErrorLine("ERROR L127: given R_contraint_name='" + constraint.ReverseConstraintName + "', unable to find parent constraint");
                        continue;
                    }

                    LoadForeignKey(schema, table, constraint.ColumnNameList, constraint.TableName, constraint.TableSchema,
                                   referencedConstraint.ColumnNameList, referencedConstraint.TableName,
                                   referencedConstraint.TableSchema,
                                   constraint.ConstraintName, nameFormat, names);

                }
                // custom type, this is a trigger
                else if (constraint.ConstraintType == "T" && constraint.ColumnNames.Count == 1)
                {
                    var column = table.Type.Columns.Where(c => c.Name == constraint.ColumnNames[0]).First();
                    column.Expression = constraint.Expression;
                    column.IsDbGenerated = true;
                }
            }

            //GuessSequencePopulatedFields(schema);
        }
예제 #14
0
파일: Message.cs 프로젝트: thirumg/Avro.NET
        internal static Message Parse(Newtonsoft.Json.Linq.JProperty jmessage, Names names)
        {
            string name = jmessage.Name;
            string doc = JsonHelper.GetOptionalString(jmessage.Value, "doc");
            JToken jrequest = jmessage.Value["request"];
            JToken jresponse = jmessage.Value["response"];
            JToken jerrors = jmessage.Value["errors"];

            List<Parameter> request = new List<Parameter>();

            foreach (JToken jtype in jrequest)
            {
                Parameter parameter = new Parameter();
                parameter.Name = JsonHelper.GetRequiredString(jtype, "name");
                parameter.Schema = Schema.ParseJson(jtype, names);

                if (null == parameter.Schema)
                    throw new SchemaParseException(jtype.ToString());

                request.Add(parameter);
            }

            Schema response = Schema.ParseJson(jresponse, names);


            
            UnionSchema uerrorSchema = null;
            if (null != jerrors)
            {
                Schema errorSchema = Schema.ParseJson(jerrors, names);


                if (!(errorSchema is UnionSchema))
                {
                    throw new AvroException("");
                }

                uerrorSchema = errorSchema as UnionSchema;
            }



            return new Message(name, doc, request, response, uerrorSchema);


            //Message message = new Message(name, 



            //throw new NotImplementedException();
        }
예제 #15
0
    public static Names[] GetNames()
    {
        List<Names> list = new List<Names>();
        DataTable dt = DataStore.GetDataTable();
        foreach (DataRow row in dt.Rows)
        {
            Names _names = new Names();
            _names.FirstName = row["Name"].ToString();
            _names.Age = row["age"].ToString();

            list.Add(_names);
        }
        return list.ToArray();
    }
예제 #16
0
        private static Field createField(JToken jfield, Names names)
        {
            string name = JsonHelper.GetRequiredString(jfield, "name");
            string doc = JsonHelper.GetOptionalString(jfield, "doc");

            string defaultValue = JsonHelper.GetOptionalString(jfield, "default");

            JToken jtype = jfield["type"];
            if (null == jtype)
            {
                throw new SchemaParseException("'type' was not found for field: " + name);
            }
            Schema type = Schema.ParseJson(jtype, names);

            return new Field(type, name, defaultValue);
        }
        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            //TableSorter.Sort(tables, constraints); //sort tables - parents first

            var foreignKeys = ReadConstraints(conn, schemaName.DbName);

            foreach (DataConstraint keyColRow in foreignKeys)
            {
                //find my table:
                string constraintFullDbName = GetFullDbName(keyColRow.TableName, keyColRow.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => constraintFullDbName == t.Name);
                if (table == null)
                {
                    WriteErrorLine("ERROR L138: Table '"
                                              + keyColRow.TableName
                                              + "' not found for column "
                                              + keyColRow.ColumnName);
                    continue;
                }

                if (keyColRow.ConstraintType.Equals("P")) //'PRIMARY KEY'
                {
                    //foreach (string pk_name in keyColRow.column_name_primaries)
                    //{
                    DbLinq.Schema.Dbml.Column primaryKeyCol = table.Type.Columns.First(c => c.Name == keyColRow.ColumnName);
                    primaryKeyCol.IsPrimaryKey = true;
                    //}
                    continue;
                }

                if (keyColRow.ConstraintType.Equals("R")) //'FOREIGN KEY'
                {
                    // This is very bad...
                    if (!names.ColumnsNames[keyColRow.ReferencedTableName].ContainsKey(keyColRow.ReferencedColumnName))
                        continue;

                    LoadForeignKey(schema, table, keyColRow.ColumnName, keyColRow.TableName,
                                   keyColRow.TableSchema,
                                   keyColRow.ReferencedColumnName, keyColRow.ReferencedTableName,
                                   keyColRow.ReferencedTableSchema,
                                   keyColRow.ConstraintName, nameFormat, names);

                }

            }
        }
예제 #18
0
        internal static UnionSchema NewInstance(JArray a, Names names)
        {
            List<Schema> schemas = new List<Schema>();
            ISet<string> uniqueSchemas = new HashSet<string>();

            foreach (JToken jvalue in a)
            {
                Schema unionTypes = Schema.ParseJson(jvalue, names);
                string name = unionTypes.GetName();
                if (uniqueSchemas.Contains(name))
                {
                    throw new SchemaParseException("Duplicate type in union: " + name);
                }
                uniqueSchemas.Add(name);
                schemas.Add(unionTypes);
            }

            return new UnionSchema(schemas);
        }
예제 #19
0
        public virtual Database Load(string databaseName, INameAliases nameAliases, NameFormat nameFormat,
            bool loadStoredProcedures, string contextNamespace, string entityNamespace)
        {
            // check if connection is open. Note: we may use something more flexible
            if (Connection.State != ConnectionState.Open)
                Connection.Open();

            // get the database name. If we don't have one, take it from connection string...
            if (string.IsNullOrEmpty(databaseName))
                databaseName = Connection.Database;
            // ... and if connection string doesn't provide a name, then throw an error
            if (string.IsNullOrEmpty(databaseName))
                throw new ArgumentException("A database name is required. Please specify /database=<databaseName>");

            var schemaName = NameFormatter.GetSchemaName(databaseName, GetExtraction(databaseName), nameFormat);
            var names = new Names();
            var schema = new Database
                             {
                                 Name = schemaName.DbName,
                                 Class = schemaName.ClassName,
                                 BaseType = typeof(DataContext).FullName,
                                 ContextNamespace = contextNamespace,
                                 EntityNamespace = entityNamespace,
                             };

            // order is important, we must have:
            // 1. tables
            // 2. columns
            // 3. constraints
            LoadTables(schema, schemaName, Connection, nameAliases, nameFormat, names);
            LoadColumns(schema, schemaName, Connection, nameAliases, nameFormat, names);
            LoadConstraints(schema, schemaName, Connection, nameFormat, names);
            if (loadStoredProcedures)
                LoadStoredProcedures(schema, schemaName, Connection, nameFormat);
            CheckNamesCaseSafety(schema);

            // check for duplicate names between properties
            CheckNames(schema);
            // generate backing fields name (since we have here correct names)
            GenerateStorageFields(schema);

            return schema;
        }
        //=================================================================
        // 訂正
        //=================================================================
        /// レイアウト要素のSWScale*の変更を試みる
        /// @param target 変更箇所
        /// @param value 変更値
        /// @param[out] changed 変更後、制約を満たす形に訂正された値
        /// @return 訂正された
        public static bool TryChange(Names target, float value, out float changed)
        {
            float lowerBound = 0.0F;
            float upperBound = 0.0F;
            switch (target) {
              case Names.LumaGBlur:
              case Names.ChromaGBlur: {
            lowerBound = 0.0F;
            upperBound = 2.0F;
            break;
              }
              case Names.LumaSharpen:
              case Names.ChromaSharpen: {
            lowerBound = 0.0F;
            upperBound = 4.0F;
            break;
              }
              case Names.ChromaHShift:
              case Names.ChromaVShift: {
            lowerBound = 0.0F;
            upperBound = 1.0F;
            break;
              }
              default: Debug.Fail("switch"); throw new System.ArgumentException();
            }

            /// @attention 浮動小数点数の比較
            if (value < lowerBound) {
              changed = lowerBound;
              return false;
            } else if (upperBound < value) {
              changed = upperBound;
              return false;
            } else {
              changed = value;
              return true;
            }
        }
예제 #21
0
        internal static RecordSchema NewInstance(Type type, JToken j, Names names)
        {
            JToken jfields = j["fields"];

            if (null == jfields)
            {
                throw new SchemaParseException("'fields' cannot be null for record");
            }

            if (jfields.Type != JTokenType.Array) {
                throw new SchemaParseException("'fields' not an array for record");
            }

            Name name = GetName(j);
            IDictionary<string, Field> fields = new Dictionary<string, Field>();
            RecordSchema result = new RecordSchema(type, name, fields, names);
            foreach (JObject jfield in jfields)
            {
                string fieldName = JsonHelper.GetRequiredString(jfield, "name");
                Field field = createField(jfield, names);
                fields.Add(fieldName, field);
            }
            return result;
        }
예제 #22
0
        /// <summary>
        /// Loads the columns.
        /// </summary>
        /// <param name="schema">The schema.</param>
        /// <param name="schemaName">Name of the schema.</param>
        /// <param name="conn">The conn.</param>
        /// <param name="nameAliases">The name aliases.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <param name="names">The names.</param>
        protected void LoadColumns(Database schema, SchemaName schemaName, IDbConnection conn, INameAliases nameAliases, NameFormat nameFormat, Names names)
        {
            var columnRows = ReadColumns(conn, schemaName.DbName);
            foreach (var columnRow in columnRows)
            {
                var columnName = CreateColumnName(columnRow.ColumnName, columnRow.TableName, columnRow.TableSchema, nameAliases, nameFormat);
                names.AddColumn(columnRow.TableName, columnName);

                //find which table this column belongs to
                string fullColumnDbName = GetFullDbName(columnRow.TableName, columnRow.TableSchema);
                DbLinq.Schema.Dbml.Table tableSchema = schema.Tables.FirstOrDefault(tblSchema => fullColumnDbName == tblSchema.Name);
                if (tableSchema == null)
                {
                    WriteErrorLine("ERROR L46: Table '" + columnRow.TableName + "' not found for column " + columnRow.ColumnName);
                    continue;
                }
                var column = new Column();
                column.Name = columnName.DbName;
                column.Member = columnName.PropertyName;
                column.DbType = columnRow.FullType;

                if (columnRow.PrimaryKey.HasValue)
                    column.IsPrimaryKey = columnRow.PrimaryKey.Value;

                bool? generated = (nameAliases != null) ? nameAliases.GetColumnGenerated(columnRow.ColumnName, columnRow.TableName, columnRow.TableSchema) : null;
                if (!generated.HasValue)
                    generated = columnRow.Generated;
                if (generated.HasValue)
                    column.IsDbGenerated = generated.Value;

                AutoSync? autoSync = (nameAliases != null) ? nameAliases.GetColumnAutoSync(columnRow.ColumnName, columnRow.TableName, columnRow.TableSchema) : null;
                if (autoSync.HasValue)
                    column.AutoSync = autoSync.Value;

                // the Expression can originate from two sources:
                // 1. DefaultValue
                // 2. Expression
                // we use any valid source (we can't have both)
                if (column.IsDbGenerated && columnRow.DefaultValue != null)
                    column.Expression = columnRow.DefaultValue;

                column.CanBeNull = columnRow.Nullable;

                string columnTypeAlias = nameAliases != null ? nameAliases.GetColumnForcedType(columnRow.ColumnName, columnRow.TableName, columnRow.TableSchema) : null;
                var columnType = MapDbType(columnName.DbName, columnRow);

                var columnEnumType = columnType as EnumType;
                if (columnEnumType != null)
                {
                    var enumType = column.SetExtendedTypeAsEnumType();
                    enumType.Name = columnEnumType.Name;
                    foreach (KeyValuePair<string, int> enumValue in columnEnumType.EnumValues)
                    {
                        enumType[enumValue.Key] = enumValue.Value;
                    }
                }
                else if (columnTypeAlias != null)
                    column.Type = columnTypeAlias;
                else
                    column.Type = columnType.ToString();

                tableSchema.Type.Columns.Add(column);
            }
        }
예제 #23
0
 private static IPropertyName P(string name, params object[] args)
 {
     return(Names.Property(name, args));
 }
 public FigureProperties(Names name, Colors color)
 {
     this.name  = name;
     this.color = color;
 }
예제 #25
0
 public Parent(Names id, string title, string firstName, string lastName, string sortValue, bool isFemale = false)
     : base(id, title, firstName, lastName, sortValue, isFemale)
 {
     Children = new List<Child>();
 }
예제 #26
0
 /// <summary>
 /// <c>GET</c> request to the <c>enrich.get_policy</c> API, read more about this API online:
 /// <para></para>
 /// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-get-policy.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-get-policy.html</a>
 /// </summary>
 public Task <GetEnrichPolicyResponse> GetPolicyAsync(Names name = null, Func <GetEnrichPolicyDescriptor, IGetEnrichPolicyRequest> selector = null, CancellationToken ct = default) => GetPolicyAsync(selector.InvokeOrDefault(new GetEnrichPolicyDescriptor().Name(name: name)), ct);
예제 #27
0
 internal static object GetAddIndex(SubRecordAddIndexContext context)
 {
     return(Names.GetAddIndexAmbiguous(context, "NAME"));
 }
예제 #28
0
        private void btnHire_Click(object sender, RoutedEventArgs e)
        {
            var aircraftsTypesFree = this.FlightSchool.Aircrafts.Select(a => a.Type);

            Dictionary <TrainingAircraftType, int> types = this.FlightSchool.Aircrafts.GroupBy(a => a.Type).
                                                           Select(group =>
                                                                  new
            {
                Type  = group.Key,
                Count = group.Sum(g => g.Type.MaxNumberOfStudents)
            }).ToDictionary(g => g.Type, g => g.Count);;


            foreach (PilotStudent student in this.FlightSchool.Students)
            {
                var firstAircraft = student.Rating.Aircrafts.OrderBy(a => a.TypeLevel).FirstOrDefault(a => types.ContainsKey(a) && types[a] > 0);

                if (firstAircraft != null && types.ContainsKey(firstAircraft))
                {
                    types[firstAircraft]--;
                }
            }

            List <PilotRating> possibleRatings = new List <PilotRating>();

            foreach (PilotRating rating in PilotRatings.GetRatings())
            {
                if (rating.Aircrafts.Exists(a => types.ContainsKey(a) && types[a] > 0))
                {
                    possibleRatings.Add(rating);
                }
            }

            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2811"), string.Format(Translator.GetInstance().GetString("MessageBox", "2811", "message")), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                List <Town> towns = Towns.GetTowns(this.FlightSchool.FlightSchool.Airport.Profile.Country);

                Town         town      = towns[rnd.Next(towns.Count)];
                DateTime     birthdate = MathHelpers.GetRandomDate(GameObject.GetInstance().GameTime.AddYears(-35), GameObject.GetInstance().GameTime.AddYears(-23));
                PilotProfile profile   = new PilotProfile(Names.GetInstance().getRandomFirstName(town.Country), Names.GetInstance().getRandomLastName(town.Country), birthdate, town);

                Instructor instructor     = (Instructor)cbInstructor.SelectedItem;
                string     airlinerFamily = cbTrainAircraft.SelectedItem.ToString();

                PilotStudent student = new PilotStudent(profile, GameObject.GetInstance().GameTime, instructor, GeneralHelpers.GetPilotStudentRating(instructor, possibleRatings), airlinerFamily);

                TrainingAircraft aircraft = getStudentAircraft(student);

                student.Aircraft = aircraft;

                this.FlightSchool.addStudent(student);
                instructor.addStudent(student);

                setHireStudentsStatus();

                double studentPrice = GeneralHelpers.GetInflationPrice(PilotStudent.StudentCost);

                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -studentPrice);
            }
        }
예제 #29
0
        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            var constraints = ReadConstraints(conn, schemaName.DbName);

            foreach (DataConstraint constraint in constraints)
            {
                //find my table:
                string constraintFullDbName    = GetFullDbName(constraint.TableName, constraint.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => constraintFullDbName == t.Name);
                if (table == null)
                {
                    WriteErrorLine("ERROR L100: Table '" + constraint.TableName + "' not found for column " + constraint.ColumnNameList);
                    continue;
                }

                //if (table.Name.StartsWith("E"))
                //    Logger.Write("---Dbg");

                if (constraint.ConstraintType == "P")
                {
                    //A) add primary key
                    DbLinq.Schema.Dbml.Column pkColumn = table.Type.Columns.Where(c => constraint.ColumnNames.Contains(c.Name)).First();
                    pkColumn.IsPrimaryKey = true;
                }
                else if (constraint.ConstraintType == "R")
                {
                    //if not PRIMARY, it's a foreign key. (constraint_type=="R")
                    //both parent and child table get an [Association]
                    DataConstraint referencedConstraint = constraints.FirstOrDefault(c => c.ConstraintName == constraint.ReverseConstraintName);
                    if (constraint.ReverseConstraintName == null || referencedConstraint == null)
                    {
                        WriteErrorLine("ERROR L127: given R_contraint_name='" + constraint.ReverseConstraintName + "', unable to find parent constraint");
                        continue;
                    }

                    LoadForeignKey(schema, table, constraint.ColumnNameList, constraint.TableName, constraint.TableSchema,
                                   referencedConstraint.ColumnNameList, referencedConstraint.TableName,
                                   referencedConstraint.TableSchema,
                                   constraint.ConstraintName, nameFormat, names);
                }
                // custom type, this is a trigger
                else if (constraint.ConstraintType == "T" && constraint.ColumnNames.Count == 1)
                {
                    var column = table.Type.Columns.Where(c => c.Name == constraint.ColumnNames[0]).First();
                    column.Expression    = constraint.Expression;
                    column.IsDbGenerated = true;
                }
            }

            //GuessSequencePopulatedFields(schema);
        }
        private void btnHire_Click(object sender, RoutedEventArgs e)
        {
            Random rnd = new Random();

            ComboBox cbInstructor = new ComboBox();

            cbInstructor.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbInstructor.Width = 200;
            cbInstructor.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbInstructor.DisplayMemberPath   = "Profile.Name";
            cbInstructor.SelectedValuePath   = "Profile.Name";

            foreach (Instructor instructor in this.FlightSchool.Instructors.Where(i => i.Students.Count < FlightSchool.MaxNumberOfStudentsPerInstructor))
            {
                cbInstructor.Items.Add(instructor);
            }

            cbInstructor.SelectedIndex = 0;

            if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PanelFlightSchool", "1005"), cbInstructor) == PopUpSingleElement.ButtonSelected.OK && cbInstructor.SelectedItem != null)
            {
                List <Town> towns = Towns.GetTowns(this.FlightSchool.Airport.Profile.Country);

                Town         town      = towns[rnd.Next(towns.Count)];
                DateTime     birthdate = MathHelpers.GetRandomDate(GameObject.GetInstance().GameTime.AddYears(-55), GameObject.GetInstance().GameTime.AddYears(-23));
                PilotProfile profile   = new PilotProfile(Names.GetInstance().getRandomFirstName(), Names.GetInstance().getRandomLastName(), birthdate, town);

                PilotStudent student = new PilotStudent(profile, GameObject.GetInstance().GameTime, (Instructor)cbInstructor.SelectedItem);

                this.FlightSchool.addStudent(student);
                ((Instructor)cbInstructor.SelectedItem).addStudent(student);

                showStudents();

                this.ParentPage.updatePage();

                txtStudents.Text = this.FlightSchool.NumberOfStudents.ToString();

                double studentPrice = GeneralHelpers.GetInflationPrice(PilotStudent.StudentCost);

                int studentsCapacity = Math.Min(this.FlightSchool.Instructors.Count * FlightSchool.MaxNumberOfStudentsPerInstructor, this.FlightSchool.TrainingAircrafts.Sum(f => f.Type.MaxNumberOfStudents));

                btnHire.IsEnabled = studentsCapacity > this.FlightSchool.Students.Count && GameObject.GetInstance().HumanAirline.Money > studentPrice;

                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -studentPrice);
            }
        }
예제 #31
0
 internal static object GetAddIndex(SubRecordAddIndexContext context)
 {
     return(Names.GetAddIndexForAIData(context));
 }
예제 #32
0
 public static INamespaceName GetAnonymousNamespace()
 {
     return(Names.Namespace("A.N{0}", NextCounter()));
 }
예제 #33
0
 public static ITypeName GetAnonymousTypeName()
 {
     return(Names.Type("SomeType{0}, SomeAssembly{1}, 9.8.7.6", NextCounter(), NextCounter()));
 }
 public async void DeleteItem(Person person)
 {
     Names.Remove(person);
     await _sqlCrud.DeleteItem(person);
 }
예제 #35
0
 public bool IsNamed(string name)
 {
     return(Names.Contains(name, StringComparer.OrdinalIgnoreCase));
 }
예제 #36
0
 public AncientUrn() : this(Names.RandomElement())
 {
 }
        private void GenerateClass(JObject[] examples, JsonType type)
        {
            var jsonFields    = new Dictionary <string, JsonType>();
            var fieldExamples = new Dictionary <string, IList <object> >();

            var first = true;

            foreach (var obj in examples)
            {
                foreach (var prop in obj.Properties())
                {
                    JsonType fieldType;
                    var      currentType = new JsonType(this, prop.Value);
                    var      propName    = prop.Name;

                    if (jsonFields.TryGetValue(propName, out fieldType))
                    {
                        var commonType = fieldType.GetCommonType(currentType);

                        jsonFields[propName] = commonType;
                    }
                    else
                    {
                        var commonType = currentType;
                        if (first)
                        {
                            commonType = commonType.MaybeMakeNullable(this);
                        }
                        else
                        {
                            commonType = commonType.GetCommonType(JsonType.GetNull(this));
                        }
                        jsonFields.Add(propName, commonType);
                        fieldExamples[propName] = new List <object>();
                    }

                    var fe  = fieldExamples[propName];
                    var val = prop.Value;
                    if (val.Type == JTokenType.Null || val.Type == JTokenType.Undefined)
                    {
                        if (!fe.Contains(null))
                        {
                            fe.Insert(0, null);
                        }
                    }
                    else
                    {
                        var v = val.Type == JTokenType.Array || val.Type == JTokenType.Object ? val : val.Value <object>();
                        if (!fe.Any(x => v.Equals(x)))
                        {
                            fe.Add(v);
                        }
                    }
                }
                first = false;
            }

            if (UseNestedClasses)
            {
                foreach (var field in jsonFields)
                {
                    Names.Add(field.Key.ToLower());
                }
            }

            foreach (var field in jsonFields)
            {
                var fieldType = field.Value;
                if (fieldType.Type == JsonTypeEnum.Object)
                {
                    var subexamples = new List <JObject>(examples.Length);
                    foreach (var obj in examples)
                    {
                        JToken value;
                        if (obj.TryGetValue(field.Key, out value))
                        {
                            if (value.Type == JTokenType.Object)
                            {
                                subexamples.Add((JObject)value);
                            }
                        }
                    }

                    fieldType.AssignOriginalName(field.Key);
                    fieldType.AssignName(CreateUniqueClassName(field.Key));
                    fieldType.AssignNewAssignedName(ToTitleCase(field.Key));

                    GenerateClass(subexamples.ToArray(), fieldType);
                }

                if (fieldType.InternalType != null && fieldType.InternalType.Type == JsonTypeEnum.Object)
                {
                    var subexamples = new List <JObject>(examples.Length);
                    foreach (var obj in examples)
                    {
                        JToken value;
                        if (obj.TryGetValue(field.Key, out value))
                        {
                            if (value.Type == JTokenType.Array)
                            {
                                if (value.Count() > 50)
                                {
                                    var takeABunchOfItems = (JArray)value; // Take like 30 items from the array this will increase the chance of getting all the objects accuralty while not analyzing all the data
                                    int count             = 0;
                                    foreach (var item in (JArray)takeABunchOfItems)
                                    {
                                        if (count > 50)
                                        {
                                            break;
                                        }

                                        // if (!(item is JObject)) throw new NotSupportedException("Arrays of non-objects are not supported yet.");
                                        if ((item is JObject))
                                        {
                                            subexamples.Add((JObject)item);
                                        }
                                        ++count;
                                    }
                                }
                                else
                                {
                                    foreach (var item in (JArray)value)
                                    {
                                        // if (!(item is JObject)) throw new NotSupportedException("Arrays of non-objects are not supported yet.");
                                        if ((item is JObject))
                                        {
                                            subexamples.Add((JObject)item);
                                        }
                                    }
                                }
                            }
                            else if (value.Type == JTokenType.Object) //TODO J2C : ONLY LOOP OVER 50 OBJECT AND NOT THE WHOLE THING
                            {
                                foreach (var item in (JObject)value)
                                {
                                    // if (!(item.Value is JObject)) throw new NotSupportedException("Arrays of non-objects are not supported yet.");
                                    if ((item.Value is JObject))
                                    {
                                        subexamples.Add((JObject)item.Value);
                                    }
                                }
                            }
                        }
                    }

                    field.Value.InternalType.AssignOriginalName(field.Key);
                    field.Value.InternalType.AssignName(CreateUniqueClassNameFromPlural(field.Key));
                    field.Value.InternalType.AssignNewAssignedName(pluralizationService.Singularize(ToTitleCase(field.Key)));

                    GenerateClass(subexamples.ToArray(), field.Value.InternalType);
                }
            }

            type.Fields = jsonFields.Select(x => new FieldInfo(this, x.Key, x.Value, UsePascalCase, UseJsonAttributes, UseJsonPropertyName, fieldExamples[x.Key])).ToList();

            if (!string.IsNullOrEmpty(type.AssignedName))
            {
                Types.Add(type);
            }
        }
예제 #38
0
 /// <summary>
 /// Retourne une chaîne qui représente l'objet actuel.
 /// </summary>
 /// <returns>Chaîne qui représente l'objet actuel.</returns>
 public override string ToString() => $"{Date.ToShortDateString()} {Names.FirstOrDefault().Value}";
예제 #39
0
 /// <summary>
 /// Checks whether this cell has a certain name pointing to it.
 /// </summary>
 /// <param name="name">The name to be checked.</param>
 /// <returns>True, if that name is pointing to this cell, otherwise false.</returns>
 public bool HasName(string name)
 {
     return(Names.Where(p => p.Name == name).Count() > 0);
 }
예제 #40
0
        private void GenerateClass(JObject[] examples, JsonType type)
        {
            var jsonFields    = new Dictionary <string, JsonType>();
            var fieldExamples = new Dictionary <string, IList <object> >();

            var first = true;

            foreach (var obj in examples)
            {
                foreach (var prop in obj.Properties())
                {
                    JsonType fieldType;
                    var      currentType = new JsonType(this, prop.Value);
                    var      propName    = prop.Name;
                    if (jsonFields.TryGetValue(propName, out fieldType))
                    {
                        var commonType = fieldType.GetCommonType(currentType);

                        jsonFields[propName] = commonType;
                    }
                    else
                    {
                        var commonType = currentType;
                        if (first)
                        {
                            commonType = commonType.MaybeMakeNullable(this);
                        }
                        else
                        {
                            commonType = commonType.GetCommonType(JsonType.GetNull(this));
                        }
                        jsonFields.Add(propName, commonType);
                        fieldExamples[propName] = new List <object>();
                    }
                    var fe  = fieldExamples[propName];
                    var val = prop.Value;
                    if (val.Type == JTokenType.Null || val.Type == JTokenType.Undefined)
                    {
                        if (!fe.Contains(null))
                        {
                            fe.Insert(0, null);
                        }
                    }
                    else
                    {
                        var v = val.Type == JTokenType.Array || val.Type == JTokenType.Object ? val : val.Value <object>();
                        if (!fe.Any(x => v.Equals(x)))
                        {
                            fe.Add(v);
                        }
                    }
                }
                first = false;
            }

            if (UseNestedClasses)
            {
                foreach (var field in jsonFields)
                {
                    Names.Add(field.Key.ToLower());
                }
            }

            foreach (var field in jsonFields)
            {
                var fieldType = field.Value;
                if (fieldType.Type == JsonTypeEnum.Object)
                {
                    var subexamples = new List <JObject>(examples.Length);
                    foreach (var obj in examples)
                    {
                        JToken value;
                        if (obj.TryGetValue(field.Key, out value))
                        {
                            if (value.Type == JTokenType.Object)
                            {
                                subexamples.Add((JObject)value);
                            }
                        }
                    }

                    fieldType.AssignName(CreateUniqueClassName(field.Key));
                    GenerateClass(subexamples.ToArray(), fieldType);
                }

                if (fieldType.InternalType != null && fieldType.InternalType.Type == JsonTypeEnum.Object)
                {
                    var subexamples = new List <JObject>(examples.Length);
                    foreach (var obj in examples)
                    {
                        JToken value;
                        if (obj.TryGetValue(field.Key, out value))
                        {
                            if (value.Type == JTokenType.Array)
                            {
                                foreach (var item in (JArray)value)
                                {
                                    if (!(item is JObject))
                                    {
                                        throw new NotSupportedException("Arrays of non-objects are not supported yet.");
                                    }
                                    subexamples.Add((JObject)item);
                                }
                            }
                            else if (value.Type == JTokenType.Object)
                            {
                                foreach (var item in (JObject)value)
                                {
                                    if (!(item.Value is JObject))
                                    {
                                        throw new NotSupportedException("Arrays of non-objects are not supported yet.");
                                    }

                                    subexamples.Add((JObject)item.Value);
                                }
                            }
                        }
                    }

                    field.Value.InternalType.AssignName(CreateUniqueClassNameFromPlural(field.Key));
                    GenerateClass(subexamples.ToArray(), field.Value.InternalType);
                }
            }

            type.Fields = jsonFields.Select(x => new FieldInfo(this, x.Key, x.Value, UsePascalCase, fieldExamples[x.Key])).ToArray();

            Types.Add(type);
        }
예제 #41
0
 /// <summary>
 /// <c>GET</c> request to the <c>enrich.get_policy</c> API, read more about this API online:
 /// <para></para>
 /// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-get-policy.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-get-policy.html</a>
 /// </summary>
 public GetEnrichPolicyResponse GetPolicy(Names name = null, Func <GetEnrichPolicyDescriptor, IGetEnrichPolicyRequest> selector = null) => GetPolicy(selector.InvokeOrDefault(new GetEnrichPolicyDescriptor().Name(name: name)));
예제 #42
0
        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            var constraints = ReadConstraints(conn, schemaName.DbName);

            //sort tables - parents first (this is moving to SchemaPostprocess)
            //TableSorter.Sort(tables, constraints);

            // Deal with non existing foreign key database
            if (constraints != null)
            {
                foreach (DataConstraint keyColRow in constraints)
                {
                    //find my table:
                    string tableFullDbName         = GetFullDbName(keyColRow.TableName, keyColRow.TableSchema);
                    DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => tableFullDbName == t.Name);
                    if (table == null)
                    {
                        WriteErrorLine("ERROR L46: Table '" + keyColRow.TableName + "' not found for column " + keyColRow.ColumnName);
                        continue;
                    }

                    bool isForeignKey = keyColRow.ConstraintName != "PRIMARY" &&
                                        keyColRow.ReferencedTableName != null;

                    if (isForeignKey)
                    {
                        LoadForeignKey(schema, table, keyColRow.ColumnName, keyColRow.TableName, keyColRow.TableSchema,
                                       keyColRow.ReferencedColumnName, keyColRow.ReferencedTableName,
                                       keyColRow.ReferencedTableSchema,
                                       keyColRow.ConstraintName, nameFormat, names);
                    }
                }
            }
        }
예제 #43
0
        public void GenerateClasses()
        {
            if (CodeWriter == null)
            {
                CodeWriter = new CSharpCodeWriter();
            }
            if (ExplicitDeserialization && !(CodeWriter is CSharpCodeWriter))
            {
                throw new ArgumentException("只支持C#的反序列化");
            }
            if (used)
            {
                throw new InvalidOperationException("JsonClassGenerator的此实例已被使用。请创建一个新的实例。");
            }
            used = true;

            var writeToDisk = TargetFolder != null;

            if (writeToDisk && !Directory.Exists(TargetFolder))
            {
                Directory.CreateDirectory(TargetFolder);
            }


            JObject[] examples;
            var       example = Example.StartsWith("HTTP/") ? Example.Substring(Example.IndexOf("\r\n\r\n")) : Example;

            using (var sr = new StringReader(example))
                using (var reader = new JsonTextReader(sr))
                {
                    var json = JToken.ReadFrom(reader);
                    if (json is JArray)
                    {
                        examples = ((JArray)json).Cast <JObject>().ToArray();
                    }
                    else if (json is JObject)
                    {
                        examples = new[] { (JObject)json };
                    }
                    else
                    {
                        throw new Exception("输入的JSON必须是一个JSON数组或JSON对象");
                    }
                }


            Types = new List <JsonType>();
            Names.Add(MainClass);
            var rootType = new JsonType(this, examples[0]);

            rootType.IsRoot = true;
            rootType.AssignName(MainClass);
            GenerateClass(examples, rootType);

            if (writeToDisk)
            {
                var parentFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                if (writeToDisk && !NoHelperClass && ExplicitDeserialization)
                {
                    File.WriteAllBytes(Path.Combine(TargetFolder, "JsonClassHelper.cs"), Properties.Resources.JsonClassHelper);
                }
                if (SingleFile)
                {
                    WriteClassesToFile(Path.Combine(TargetFolder, MainClass + CodeWriter.FileExtension), Types);
                }
                else
                {
                    foreach (var type in Types)
                    {
                        var folder = TargetFolder;
                        if (!UseNestedClasses && !type.IsRoot && SecondaryNamespace != null)
                        {
                            var s = SecondaryNamespace;
                            if (s.StartsWith(Namespace + "."))
                            {
                                s = s.Substring(Namespace.Length + 1);
                            }
                            folder = Path.Combine(folder, s);
                            Directory.CreateDirectory(folder);
                        }
                        WriteClassesToFile(Path.Combine(folder, (UseNestedClasses && !type.IsRoot ? MainClass + "." : string.Empty) + type.AssignedName + CodeWriter.FileExtension), new[] { type });
                    }
                }
            }
            else if (OutputStream != null)
            {
                WriteClassesToFile(OutputStream, Types);
            }
        }
 protected static void AssertUniqueAsmMethods(IContextStatistics actual, params string[] ids)
 {
     Assert.AreEqual(Sets.NewHashSetFrom(ids.Select(id => Names.Method(id))), actual.UniqueAsmMethods);
 }
예제 #45
0
 private string GetKillName()
 {
     return(Names.RandomFirstName() + " " + Names.RandomLastName());
 }
예제 #46
0
        public async Task AddAsync(Names namesOfUser)
        {
            await this.agencyDbContext.Names.AddAsync(namesOfUser);

            await this.agencyDbContext.SaveChangesAsync();
        }
예제 #47
0
        /// <summary>
        /// Loads the tables in the given schema.
        /// </summary>
        /// <param name="schema">The schema.</param>
        /// <param name="schemaName">Name of the schema.</param>
        /// <param name="conn">The conn.</param>
        /// <param name="nameAliases">The name aliases.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <param name="names">The names.</param>
        protected virtual void LoadTables(Database schema, SchemaName schemaName, IDbConnection conn, INameAliases nameAliases, NameFormat nameFormat, Names names)
        {
            var tables = ReadTables(conn, schemaName.DbName);
            foreach (var row in tables)
            {
                var tableName = CreateTableName(row.Name, row.Schema, nameAliases, nameFormat);
                names.TablesNames[tableName.DbName] = tableName;

                var table = new Table();
                table.Name = tableName.DbName;
                table.Member = tableName.MemberName;
                table.Type.Name = tableName.ClassName;
                schema.Tables.Add(table);
            }
        }
예제 #48
0
 public Rook(Colors color, Names name)
     : base(color, name)
 {
 }
예제 #49
0
        /// <summary>
        /// Loads database schema
        /// </summary>
        /// <param name="databaseName"></param>
        /// <param name="nameAliases"></param>
        /// <param name="nameFormat"></param>
        /// <param name="loadStoredProcedures"></param>
        /// <param name="contextNamespace"></param>
        /// <param name="entityNamespace"></param>
        /// <returns></returns>
        public virtual Database Load(string databaseName, INameAliases nameAliases, NameFormat nameFormat,
            bool loadStoredProcedures, string contextNamespace, string entityNamespace)
        {
            // check if connection is open. Note: we may use something more flexible
            if (Connection.State != ConnectionState.Open)
                Connection.Open();

            // get the database name. If we don't have one, take it from connection string...
            if (string.IsNullOrEmpty(databaseName))
                databaseName = Connection.Database;
            // ... and if connection string doesn't provide a name, then throw an error
            if (string.IsNullOrEmpty(databaseName))
                throw new ArgumentException("A database name is required. Please specify /database=<databaseName>");

            databaseName = GetDatabaseNameAliased(databaseName, nameAliases);

            var schemaName = NameFormatter.GetSchemaName(databaseName, GetExtraction(databaseName), nameFormat);
            var names = new Names();
            var schema = new Database
                             {
                                 Name = schemaName.DbName,
                                 Class = GetRuntimeClassName(schemaName.ClassName, nameAliases),
                                 BaseType = typeof(DataContext).FullName,
                                 ContextNamespace = contextNamespace,
                                 EntityNamespace = entityNamespace,
                             };

            // order is important, we must have:
            // 1. tables
            // 2. columns
            // 3. constraints
            LoadTables(schema, schemaName, Connection, nameAliases, nameFormat, names);
            LoadColumns(schema, schemaName, Connection, nameAliases, nameFormat, names);
            CheckColumnsName(schema);
            LoadConstraints(schema, schemaName, Connection, nameFormat, names);
            CheckConstraintsName(schema);
            if (loadStoredProcedures)
                LoadStoredProcedures(schema, schemaName, Connection, nameFormat);
            // names aren't checked here anymore, because this confuses DBML editor.
            // they will (for now) be checked before .cs generation
            // in the end, when probably will end up in mapping source (or somewhere around)
            //CheckNamesSafety(schema);

            // generate backing fields name (since we have here correct names)
            GenerateStorageAndMemberFields(schema);

            return schema;
        }
예제 #50
0
    // Use this for initialization
    void Start()
    {
        mainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();

        students = new List<GameObject>();

        names = GetComponent<Names>();
        taglines = GetComponent<Taglines>();
        majors = GetComponent<Majors>();

        //load character parts from resources folder into arrays
        bodies = System.Array.ConvertAll( Resources.LoadAll("Bodies", typeof(GameObject)),o=>(GameObject)o);
        heads = System.Array.ConvertAll(Resources.LoadAll("Heads", typeof(GameObject)), o => (GameObject)o);
        clothes = System.Array.ConvertAll(Resources.LoadAll("Clothes", typeof(GameObject)), o => (GameObject)o);
        hairs = System.Array.ConvertAll(Resources.LoadAll("Hairs", typeof(GameObject)), o => (GameObject)o);
    }
예제 #51
0
 public string[] GetNames()
 {
     return((string[])Names.Clone());
 }
 public int FindIndex(string name)
 {
     return(Names.FindIndex(item => item == name));
 }
예제 #53
0
 public FigureProperties(Names name, Colors color)
 {
     this.name = name;
     this.color = color;
 }
예제 #54
0
 public IEnumerable <string> GetDisplayNames()
 {
     return(Names.Select(GetDisplayName));
 }
 public Child(Names id, string title, string firstName, string lastName, string sortValue, bool isFemale = false)
     : base(id, title, firstName, lastName, sortValue, isFemale)
 {
 }
예제 #56
0
 /// <summary>
 /// Sets alias names for this option.
 /// </summary>
 /// <param name="names">The alias names for this option.</param>
 /// <returns>The current <see cref="Option"/> instance.</returns>
 public Option Alias(params string[] names)
 {
     Names.AddRange(names);
     return(this);
 }
예제 #57
0
 public Paths(string sampleRoot, string resultRoot, string samplePath, Names resultnames)
 {
     _sampleRoot = sampleRoot;
     _resultRoot = resultRoot;
     SamplePath = samplePath;
     Resultnames = resultnames;
 }
예제 #58
0
 public string GetStaticMethodQualifiedName(Function function)
 {
     return($"{GlobalFunctionClassName}.{Names.GetNameForDecl(function)}");
 }
예제 #59
0
 public static string GetName(ushort acre) => Names.TryGetValue(acre, out var name) ? name : "???";
예제 #60
0
        public void GenerateClasses()
        {
            if (CodeWriter == null)
            {
                CodeWriter = new CSharpCodeWriter();
            }
            if (ExplicitDeserialization && !(CodeWriter is CSharpCodeWriter))
            {
                throw new ArgumentException("Explicit deserialization is obsolete and is only supported by the C# provider.");
            }

            if (used)
            {
                throw new InvalidOperationException("This instance of JsonClassGenerator has already been used. Please create a new instance.");
            }
            used = true;


            var writeToDisk = TargetFolder != null;

            if (writeToDisk && !Directory.Exists(TargetFolder))
            {
                Directory.CreateDirectory(TargetFolder);
            }


            JObject[] examples;
            var       example = Example.StartsWith("HTTP/") ? Example.Substring(Example.IndexOf("\r\n\r\n")) : Example;

            using (var sr = new StringReader(example))
                using (var reader = new JsonTextReader(sr))
                {
                    var json = JToken.ReadFrom(reader);
                    if (json is JArray)
                    {
                        examples = ((JArray)json).Cast <JObject>().ToArray();
                    }
                    else if (json is JObject)
                    {
                        examples = new[] { (JObject)json };
                    }
                    else
                    {
                        throw new Exception("Sample JSON must be either a JSON array, or a JSON object.");
                    }
                }


            Types = new List <JsonType>();
            Names.Add(MainClass);
            var rootType = new JsonType(this, examples[0]);

            rootType.IsRoot = true;
            rootType.AssignName(MainClass);
            GenerateClass(examples, rootType);

            if (writeToDisk)
            {
                var parentFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                if (writeToDisk && !NoHelperClass && ExplicitDeserialization)
                {
                    File.WriteAllText(Path.Combine(TargetFolder, "JsonClassHelper.cs"), NFinalCompiler.Json.JsonClassGeneratorLib.Resource.JsonClassHelper);
                }
                if (SingleFile)
                {
                    WriteClassesToFile(Path.Combine(TargetFolder, MainClass + CodeWriter.FileExtension), Types);
                }
                else
                {
                    foreach (var type in Types)
                    {
                        var folder = TargetFolder;
                        if (!UseNestedClasses && !type.IsRoot && SecondaryNamespace != null)
                        {
                            var s = SecondaryNamespace;
                            if (s.StartsWith(Namespace + "."))
                            {
                                s = s.Substring(Namespace.Length + 1);
                            }
                            folder = Path.Combine(folder, s);
                            Directory.CreateDirectory(folder);
                        }
                        WriteClassesToFile(Path.Combine(folder, (UseNestedClasses && !type.IsRoot ? MainClass + "." : string.Empty) + type.AssignedName + CodeWriter.FileExtension), new[] { type });
                    }
                }
            }
            else if (OutputStream != null)
            {
                WriteClassesToFile(OutputStream, Types);
            }
        }