internal string[] AddClassesToSchema(string schemaName, ClassCollection classCollection)
        {
            List <string> notAdded = new List <string>();
            FeatureSchema fsc      = null;
            var           fidx     = _schemas.IndexOf(schemaName);

            if (fidx >= 0)
            {
                fsc = _schemas[fidx];
            }
            else
            {
                fsc = new FeatureSchema(schemaName, "");
                AddSchema(fsc);
            }

            foreach (ClassDefinition cls in classCollection)
            {
                var cidx = fsc.Classes.IndexOf(cls.Name);
                if (cidx >= 0)
                {
                    notAdded.Add(cls.Name);
                }
                else
                {
                    ClassDefinition copy = FdoSchemaUtil.CloneClass(cls, false);
                    AddClass(fsc.Name, copy);
                }
            }

            return(notAdded.ToArray());
        }
Exemple #2
0
 private void AddDictonaryEntry(ClassCollection classCollection, float r, float g, float b, int count)
 {
     if (count < classCollection.classes.Count)
     {
         ClassColors.Add(classCollection.classes[count], new Color(r, g, b));
     }
 }
Exemple #3
0
        /// <summary>
        /// Searches for a class within the collection with the specified <paramref name="displayName"/>
        /// </summary>
        /// <param name="displayName">The display name</param>
        /// <param name="level">The level of the character</param>
        /// <returns>A character class corresponding to the specified display name.  Returns null if a specific class is not found.</returns>
        public static ClassBase GetCharacterClass(string displayName)
        {
            Type characterClassType = ClassCollection.FindClass(displayName).GetType();

            ClassBase characterClass = (ClassBase)Activator.CreateInstance(Type.GetType(characterClassType.ToString()));

            return(characterClass);
        }
Exemple #4
0
        // TODO 序列化的文件是Json文件,
        static void Main(string[] args)
        {
            BaseClass ba   = new BaseClass();
            SerTest   st2  = new SerTest(1000, 5000f, 1000f, 1000f);
            string    path = "D:\\Desktop\\1.bin";

            BinarySerializeHelper.InstanceDataToFile(st2, path);
            SerTest mc = BinarySerializeHelper.FileToInstanceData <SerTest>(path); mc.Print();

            MemoryStream stram = BinarySerializeHelper.InstanceDataToMemory(st2);
            SerTest      m0    = BinarySerializeHelper.MemoryToInstanceData <SerTest>(stram, 0); m0.Print();

            SoapSerializeHelper.InstanceDataToFile(st2, path);
            SerTest mc1 = BinarySerializeHelper.FileToInstanceData <SerTest>(path); mc1.Print();

            MemoryStream stram1 = BinarySerializeHelper.InstanceDataToMemory(st2);
            SerTest      m01    = BinarySerializeHelper.MemoryToInstanceData <SerTest>(stram1, 0); m01.Print();



            /* 测试结果:两种都正常使用*/
            /* 测试 集合 */
            ClassCollection cc1 = new ClassCollection();
            // 第一种 字段全为null
            MemoryStream temp = BinarySerializeHelper.InstanceDataToMemory(cc1);

            Console.WriteLine(temp.Length);
            ClassCollection cc2 = BinarySerializeHelper.MemoryToInstanceData <ClassCollection>(temp, 0);

            cc2.Print();
            Console.WriteLine("---------------------");
            // 第二种 正常
            List <SerTest> list = new List <SerTest>();
            Dictionary <string, SerTest> dict = new Dictionary <string, SerTest>();
            Stack <SerTest> stack             = new Stack <SerTest>();
            Queue <SerTest> queue             = new Queue <SerTest>();

            list.Add(st2); dict.Add("1", st2); stack.Push(st2); queue.Enqueue(st2);
            ClassCollection cc3 = new ClassCollection(list, dict, stack, queue);

            cc3.Myfloat = 0.9f;
            MemoryStream temp2 = BinarySerializeHelper.InstanceDataToMemory(cc3);

            Console.WriteLine("**");
            Console.WriteLine(temp2.Length);
            ClassCollection cc4 = BinarySerializeHelper.MemoryToInstanceData <ClassCollection>(temp2, 0);

            cc4.PrintDetail();
            Console.WriteLine(cc4.x);
            Console.WriteLine(cc4.Myfloat);
            Console.ReadLine();
        }
 public ClassCollection SelectClass(string procedureName)
 {
     OpenConnection();
     List<ClassTableModal> result = DbConnection.Query<ClassTableModal>(procedureName,
     commandType: System.Data.CommandType.StoredProcedure).ToList<ClassTableModal>();
     ClassCollection collection = new ClassCollection();
     foreach (ClassTableModal modal in result)
     {
         collection.Add(modal);
     }
     CloseConnection();
     return collection;
 }
Exemple #6
0
        public override ClassDefinition GetClassDefinition(string schemaName, string className)
        {
            EnsureSchemaRetrieved();

            if (_schemas.IndexOf(schemaName) >= 0)
            {
                FeatureSchema   fs      = _schemas[schemaName];
                ClassCollection classes = fs.Classes;

                if (classes.IndexOf(className) >= 0)
                {
                    return(classes[className]);
                }
            }

            return(null);
        }
Exemple #7
0
 void GetOuterClasses(ClassCollection classes, IClass curClass)
 {
     if (curClass != null)
     {
         foreach (IClass c in curClass.InnerClasses)
         {
             if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn))
             {
                 if (c != GetInnermostClass())
                 {
                     GetOuterClasses(classes, c);
                     classes.Add(c);
                 }
                 break;
             }
         }
     }
 }
        public BlockTraineeOperationViewModel(TraineeManagementBussiness trainees, TraineeOperationBussiness traineeOperation,
                                              BlockClassManagement blockClasses)
            : base(trainees)
        {
            _traineeOperation = traineeOperation;
            _traineeOperation.OperationEnableEvent += Enable;

            _blockClasses = blockClasses;
            _blockClasses.BlockClassCollection.ForEach(c => ClassCollection.Add(c.ClassName));
            _blockClasses.BlockClassChangedEvent += (operation, regularClass, newIndex) =>
            {
                ClassCollection.Clear();
                _blockClasses.BlockClassCollection.ForEach(c => ClassCollection.Add(c.ClassName));
            };

            ClassComboWidth = 200;
            VisRemain       = Visibility.Hidden;
        }
Exemple #9
0
        public override ClassDescriptor[] GetClassNames(string schemaName)
        {
            EnsureSchemaRetrieved();

            List <ClassDescriptor> classNames = new List <ClassDescriptor>();

            if (_schemas.IndexOf(schemaName) >= 0)
            {
                FeatureSchema   fs      = _schemas[schemaName];
                ClassCollection classes = fs.Classes;

                for (int i = 0; i < classes.Count; i++)
                {
                    classNames.Add(new ClassDescriptor(fs.Name, classes[i].Name));
                }
            }

            return(classNames.ToArray());
        }
Exemple #10
0
        /// <remarks>
        /// Returns all (nestet) classes in which the carret currently is exept
        /// the innermost class, returns an empty collection if the carret is in
        /// no class or only in the innermost class.
        /// the most outer class is the last in the collection.
        /// </remarks>
        ClassCollection GetOuterClasses()
        {
            ClassCollection classes = new ClassCollection();

            if (cu != null)
            {
                foreach (IClass c in cu.Classes)
                {
                    if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn))
                    {
                        if (c != GetInnermostClass())
                        {
                            GetOuterClasses(classes, c);
                            classes.Add(c);
                        }
                        break;
                    }
                }
            }

            return(classes);
        }
		public static void SaveScript(ClassCollection cc,Stream stream){
			EnsureClassCollectionSerializer();
			ccSerializer.Serialize(stream,cc);
		}
        public ClassCollection getClass(int line, int station, int department)
        {

            SqlConnection con = new SqlConnection(conStr);
            con.Open();

            ClassCollection Class = new ClassCollection();

            String qry = String.Empty;
            qry = @"SELECT id , description FROM class where line={0} and station = {1} and
                department={2} ORDER by id";

            qry = String.Format(qry, line,station , department);

            SqlCommand cmd = new SqlCommand(qry, con);
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            dr.Close();
            cmd.Dispose();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Class.Add(new Class(department, (int)dt.Rows[i]["id"], (string)dt.Rows[i]["description"]));
            }

            con.Close();
            con.Dispose();
            return Class;
        }
        internal string[] AddClassesToSchema(string schemaName, ClassCollection classCollection)
        {
            List<string> notAdded = new List<string>();
            FeatureSchema fsc = null;
            var fidx = _schemas.IndexOf(schemaName);
            if (fidx >= 0)
            {
                fsc = _schemas[fidx];
            }
            else
            {
                fsc = new FeatureSchema(schemaName, "");
                AddSchema(fsc);
            }

            foreach (ClassDefinition cls in classCollection)
            {
                var cidx = fsc.Classes.IndexOf(cls.Name);
                if (cidx >= 0)
                {
                    notAdded.Add(cls.Name);
                }
                else
                {
                    ClassDefinition copy = FdoSchemaUtil.CloneClass(cls, false);
                    AddClass(fsc.Name, copy);
                }
            }

            return notAdded.ToArray();
        }
Exemple #14
0
        /// <summary>
        /// Returns the display names for the character classes
        /// </summary>
        /// <returns>A list of class display names</returns>
        public static List <string> GetClassDisplayNames()
        {
            List <string> characterClasses = ClassCollection.GetDisplayNames();

            return(characterClasses);
        }
Exemple #15
0
		/// <remarks>
		/// Returns all (nestet) classes in which the carret currently is exept
		/// the innermost class, returns an empty collection if the carret is in 
		/// no class or only in the innermost class.
		/// the most outer class is the last in the collection.
		/// </remarks>
		ClassCollection GetOuterClasses()
		{
			ClassCollection classes = new ClassCollection();
			if (cu != null) {
				foreach (IClass c in cu.Classes) {
					if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) {
						if (c != GetInnermostClass()) {
							GetOuterClasses(classes, c);
							classes.Add(c);
						}
						break;
					}
				}
			}
			
			return classes;
		}
Exemple #16
0
		void GetOuterClasses(ClassCollection classes, IClass curClass)
		{
			if (curClass != null) {
				foreach (IClass c in curClass.InnerClasses) {
					if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) {
						if (c != GetInnermostClass()) {
							GetOuterClasses(classes, c);
							classes.Add(c);
						}
						break;
					}
				}
			}
		}
		public static void SaveScript(ClassCollection cc,string filename){
			EnsureClassCollectionSerializer();
			using (var stream = File.Create(filename)) {
				ccSerializer.Serialize(stream,cc);
				stream.Flush();
				stream.Close();
			}
		}
Exemple #18
0
        /// <remarks>
        /// does the dynamic lookup for the typeName
        /// </remarks>
        public IReturnType DynamicLookup(string typeName)
        {
//			Console.WriteLine("starting dynamic lookup");
//			Console.WriteLine("name == " + typeName);

            // try if it exists a variable named typeName
            ReturnType variable = SearchVariable(typeName);

            if (variable != null)
            {
                showStatic = false;
                return(variable);
            }
//			Console.WriteLine("No Variable found");

            if (callingClass == null)
            {
                return(null);
            }
            //// somehow search in callingClass fields is not returning anything, so I am searching here once again
            foreach (IField f in callingClass.Fields)
            {
                if (f.Name == typeName)
                {
//					Console.WriteLine("Field found " + f.Name);
                    return(f.ReturnType);
                }
            }
            //// end of mod for search in Fields

            // try if typeName is a method parameter
            IReturnType p = SearchMethodParameter(typeName);

            if (p != null)
            {
//				Console.WriteLine("MethodParameter Found");
                showStatic = false;
                return(p);
            }
//			Console.WriteLine("No Parameter found");

            // check if typeName == value in set method of a property
            if (typeName == "value")
            {
                p = SearchProperty();
                if (p != null)
                {
                    showStatic = false;
                    return(p);
                }
            }
//			Console.WriteLine("No Property found");

            // try if there exists a nonstatic member named typeName
            showStatic = false;
            IReturnType t = SearchMember(callingClass == null ? null : new ReturnType(callingClass.FullyQualifiedName), typeName);

            if (t != null)
            {
                return(t);
            }
//			Console.WriteLine("No nonstatic member found");

            // try if there exists a static member named typeName
            showStatic = true;
            t          = SearchMember(callingClass == null ? null : new ReturnType(callingClass.FullyQualifiedName), typeName);
            if (t != null)
            {
                showStatic = false;
                return(t);
            }
//			Console.WriteLine("No static member found");

            // try if there exists a static member in outer classes named typeName
            ClassCollection classes = GetOuterClasses();

            foreach (IClass c in GetOuterClasses())
            {
                t = SearchMember(callingClass == null ? null : new ReturnType(c.FullyQualifiedName), typeName);
                if (t != null)
                {
                    showStatic = false;
                    return(t);
                }
            }
//			Console.WriteLine("No static member in outer classes found");
//			Console.WriteLine("DynamicLookUp resultless");
            return(null);
        }
		public static string SaveScript(ClassCollection cc){
			EnsureClassCollectionSerializer();
			var writer =new StringWriter();
			ccSerializer.Serialize(writer,cc);
			return writer.ToString();
		}
Exemple #20
0
        public static string addSchemtoSDF(string SDFFile, string schemaName, string schemaDesc)
        {
            try
            {
                FeatureSchema      schema1    = new FeatureSchema(schemaName, schemaDesc);
                IConnectionManager conmanager = FeatureAccessManager.GetConnectionManager();

                //sdf fdo connection
                using (IConnection connect = SDFConnection(SDFFile))
                {
                    //get connection dict
                    IConnectionPropertyDictionary conprop = connect.ConnectionInfo.ConnectionProperties;

                    connect.Open();

                    //check connection state
                    OSGeo.FDO.Connections.ConnectionState connstate = connect.ConnectionState;
                    if (connstate != OSGeo.FDO.Connections.ConnectionState.ConnectionState_Open)
                    {
                        result = "\nCannot read SDF File \n" + SDFFile;
                    }
                    else
                    {
                        //add spatial context to the schema
                        SDF.SDFSchemaManager.spatial_context(connect);

                        result = "Read SDF File \n" + SDFFile;

                        //create command to alter schema
                        IApplySchema applyschema = (IApplySchema)connect.CreateCommand(CommandType.CommandType_ApplySchema) as IApplySchema;

                        //FeatureClassCollection fcoll;
                        ClassCollection fcoll = schema1.Classes;

                        //create all feature class
                        FeatureClass class_points     = new FeatureClass("Points", "Point information");
                        FeatureClass class_alignment  = new FeatureClass("Alignments", "Alignment information");
                        FeatureClass class_parcels    = new FeatureClass("Parcels", "Parcels information");
                        FeatureClass class_pipes      = new FeatureClass("Pipes", "Pipes information");
                        FeatureClass class_structures = new FeatureClass("Structures", "Structures information");

                        //add properties here
                        Schema_manager.add_property(class_points, connect);
                        Schema_manager.add_property(class_alignment, connect);
                        Schema_manager.add_property(class_parcels, connect);
                        Schema_manager.add_property(class_pipes, connect);
                        Schema_manager.add_property(class_structures, connect);

                        schema1.Classes.Add(class_points);
                        schema1.Classes.Add(class_alignment);
                        schema1.Classes.Add(class_parcels);
                        schema1.Classes.Add(class_pipes);
                        schema1.Classes.Add(class_structures);

                        //create property definition for each feature class

                        applyschema.FeatureSchema = schema1;
                        applyschema.Execute();
                        result = "Successfully Created SDF file with blank Schema \n" + SDFFile;
                    }
                    connect.Close();
                }
            }
            catch (SystemException ex)
            {
            }
            return(result);
        }