public void DeserializeEnumClass()
        {
            string json = @"{
  ""StoreColor"": ""Red"",
  ""NullableStoreColor1"": ""White"",
  ""NullableStoreColor2"": null
}";

            EnumClass enumClass = JsonConvert.DeserializeObject <EnumClass>(json, new StringEnumConverter());

            Assert.AreEqual(StoreColor.Red, enumClass.StoreColor);
            Assert.AreEqual(StoreColor.White, enumClass.NullableStoreColor1);
            Assert.AreEqual(null, enumClass.NullableStoreColor2);
        }
        public void DeserializeFlagEnum()
        {
            string json = @"{
  ""StoreColor"": ""Red, White"",
  ""NullableStoreColor1"": 0,
  ""NullableStoreColor2"": ""black, Red, White""
}";

            EnumClass enumClass = JsonConvert.DeserializeObject <EnumClass>(json, new StringEnumConverter());

            Assert.AreEqual(StoreColor.Red | StoreColor.White, enumClass.StoreColor);
            Assert.AreEqual((StoreColor)0, enumClass.NullableStoreColor1);
            Assert.AreEqual(StoreColor.Red | StoreColor.White | StoreColor.Black, enumClass.NullableStoreColor2);
        }
            public bool Equals(EnumClass other)
            {
                if (ReferenceEquals(null, other))
                {
                    return(false);
                }

                if (ReferenceEquals(this, other))
                {
                    return(true);
                }

                return(Equals(other.Setting, Setting));
            }
        public void DeserializeEnumClassUndefined()
        {
            string json = @"{
  ""StoreColor"": 1000,
  ""NullableStoreColor1"": 1000,
  ""NullableStoreColor2"": null
}";

            EnumClass enumClass = JsonConvert.DeserializeObject <EnumClass>(json, new StringEnumConverter());

            Assert.AreEqual((StoreColor)1000, enumClass.StoreColor);
            Assert.AreEqual((StoreColor)1000, enumClass.NullableStoreColor1);
            Assert.AreEqual(null, enumClass.NullableStoreColor2);
        }
Пример #5
0
 /// <summary>
 /// Constructor to add a new named item to the enumeration.
 /// </summary>
 ///
 /// <param name="name">the name of the enum object,must not be empty or <c>null</c></param>
 /// <exception cref="IllegalArgumentException if the name is <c>null</c>or an empty string"/>
 /// <exception cref="IllegalArgumentException if the getEnumClass() method returnsa null or invalid Class"/>
 protected internal Enum(String name) : base()
 {
     if (name == null)
     {
         //allow the enum class to be forcibly loaded. See method forciblyLoadClass.
     }
     else
     {
         this.iToString = null;
         Init(name);
         iName     = name;
         iHashCode = 7 + EnumClass.GetHashCode() + 3 * name.GetHashCode();
         // cannot create toString here as subclasses may want to include other data
     }
 }
        public void SerializeEnumClass()
        {
            EnumClass enumClass = new EnumClass();
            enumClass.StoreColor = StoreColor.Red;
            enumClass.NullableStoreColor1 = StoreColor.White;
            enumClass.NullableStoreColor2 = null;

            string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter());

            StringAssert.AreEqual(@"{
  ""StoreColor"": ""Red"",
  ""NullableStoreColor1"": ""White"",
  ""NullableStoreColor2"": null
}", json);
        }
    public void SerializeFlagEnum()
    {
      EnumClass enumClass = new EnumClass();
      enumClass.StoreColor = StoreColor.Red | StoreColor.White;
      enumClass.NullableStoreColor1 = StoreColor.White & StoreColor.Yellow;
      enumClass.NullableStoreColor2 = StoreColor.Red | StoreColor.White | StoreColor.Black;

      string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter());

      Assert.AreEqual(@"{
  ""StoreColor"": ""Red, White"",
  ""NullableStoreColor1"": 0,
  ""NullableStoreColor2"": ""Black, Red, White""
}", json);
    }
    public void SerializeEnumClassWithCamelCase()
    {
      EnumClass enumClass = new EnumClass();
      enumClass.StoreColor = StoreColor.Red;
      enumClass.NullableStoreColor1 = StoreColor.DarkGoldenrod;
      enumClass.NullableStoreColor2 = null;

      string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter { CamelCaseText = true });

      Assert.AreEqual(@"{
  ""StoreColor"": ""red"",
  ""NullableStoreColor1"": ""darkGoldenrod"",
  ""NullableStoreColor2"": null
}", json);
    }
    public void SerializeEnumClass()
    {
      EnumClass enumClass = new EnumClass();
      enumClass.StoreColor = StoreColor.Red;
      enumClass.NullableStoreColor1 = StoreColor.White;
      enumClass.NullableStoreColor2 = null;

      string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter());

      Assert.AreEqual(@"{
  ""StoreColor"": ""Red"",
  ""NullableStoreColor1"": ""White"",
  ""NullableStoreColor2"": null
}", json);
    }
        public void SerializeFlagEnum()
        {
            EnumClass enumClass = new EnumClass();
            enumClass.StoreColor = StoreColor.Red | StoreColor.White;
            enumClass.NullableStoreColor1 = StoreColor.White & StoreColor.Yellow;
            enumClass.NullableStoreColor2 = StoreColor.Red | StoreColor.White | StoreColor.Black;

            string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter());

            StringAssert.AreEqual(@"{
  ""StoreColor"": ""Red, White"",
  ""NullableStoreColor1"": 0,
  ""NullableStoreColor2"": ""Black, Red, White""
}", json);
        }
    public void SerializeEnumClassUndefined()
    {
      EnumClass enumClass = new EnumClass();
      enumClass.StoreColor = (StoreColor)1000;
      enumClass.NullableStoreColor1 = (StoreColor)1000;
      enumClass.NullableStoreColor2 = null;

      string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter());

      Assert.AreEqual(@"{
  ""StoreColor"": 1000,
  ""NullableStoreColor1"": 1000,
  ""NullableStoreColor2"": null
}", json);
    }
        public void SerializeEnumClassWithCamelCase()
        {
            EnumClass enumClass = new EnumClass();
            enumClass.StoreColor = StoreColor.Red;
            enumClass.NullableStoreColor1 = StoreColor.DarkGoldenrod;
            enumClass.NullableStoreColor2 = null;

            string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter { CamelCaseText = true });

            StringAssert.AreEqual(@"{
  ""StoreColor"": ""red"",
  ""NullableStoreColor1"": ""darkGoldenrod"",
  ""NullableStoreColor2"": null
}", json);
        }
        public void SerializeEnumClassUndefined()
        {
            EnumClass enumClass = new EnumClass();
            enumClass.StoreColor = (StoreColor)1000;
            enumClass.NullableStoreColor1 = (StoreColor)1000;
            enumClass.NullableStoreColor2 = null;

            string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter());

            StringAssert.AreEqual(@"{
  ""StoreColor"": 1000,
  ""NullableStoreColor1"": 1000,
  ""NullableStoreColor2"": null
}", json);
        }
Пример #14
0
        private void PrepareTopicDictonary()
        {
            var parentTypeString = EnumClass.GetTopicParentTypeString(TopicParentType.DataStructures);

            if (!TopicParentMapping.ContainsKey(parentTypeString))
            {
                TopicParentMapping.Add(parentTypeString, new List <string>());
            }
            TopicParentMapping[parentTypeString].Add(EnumClass.GetTopicTypeString(TopicType.Linked_List));
            TopicParentMapping[parentTypeString].Add(EnumClass.GetTopicTypeString(TopicType.Tree));

            parentTypeString = EnumClass.GetTopicParentTypeString(TopicParentType.Others);
            if (!TopicParentMapping.ContainsKey(parentTypeString))
            {
                TopicParentMapping.Add(parentTypeString, new List <string>());
            }
        }
Пример #15
0
        public Topic(TopicParentType topicParent, TopicType topicName, string subTopicName = "")
        {
            Topicparent        = new TopicParent(topicParent);
            TopicName          = topicName;
            TopicNameString    = EnumClass.GetTopicTypeString(topicName);
            SubTopicList       = new List <SubTopic>();
            TopicParentMapping = new Dictionary <string, List <string> >();
            PrepareSubTopicDictonary();

            if (string.IsNullOrWhiteSpace(subTopicName))
            {
                SubTopicSelected = SubTopicList.FirstOrDefault();
            }
            else
            {
                SubTopicSelected = SubTopicList.Where(x => x.SubTopicDescription == subTopicName).FirstOrDefault();
            }
        }
Пример #16
0
        public static string[][] OptionsForPreposition(Type typeOfPreposition)
        {
            string[][] result;
            if (prepositionOptions.TryGetValue(typeOfPreposition, out result))
            {
                return(result);
            }

            string[][] newEntry;
            lock (typeof(TextParsing)) //Make sure the ResourceCollection is up to date by the time we set prepositionOptions.
            {
                ResourceCollection collection = GetCollection(typeOfPreposition);
                if (typeof(EnumClass <>).IsAssignableFrom(typeOfPreposition))
                {
                    //FieldInfo field = typeOfPreposition.GetMethod("backingMetaData", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                    //EnumMetaData field.GetValue(null);
                    EnumClass[] objects = EnumClass.GetValues(typeOfPreposition);

                    newEntry = new string[objects.Length][];
                    for (int i = 0; i < objects.Length; i++)
                    {
                        string   name    = objects[i].Name;
                        string   list    = collection.GetValue(name);
                        string[] options = list.Split(',');
                        newEntry[i] = options;
                    }
                }
                else
                {
                    Array values = Enum.GetValues(typeOfPreposition);
                    newEntry = new string[values.Length][];
                    for (int i = 0; i < values.Length; i++)
                    {
                        string   name    = Enum.GetName(typeOfPreposition, values.GetValue(i));
                        string   list    = collection.GetValue(name);
                        string[] options = list.Split(',');
                        newEntry[i] = options;
                    }
                }
                prepositionOptions[typeOfPreposition] = newEntry;
            }

            return(newEntry);
        }
Пример #17
0
 /// <summary>
 /// 获取所有的基础设备类型
 /// </summary>
 /// <returns></returns>
 public List <BaseDeviceTypeModel> GetAllBaseDeviceTypeModel()
 {
     try
     {
         BaseDeviceTypeModel        model;
         List <BaseDeviceTypeModel> list      = new List <BaseDeviceTypeModel>();
         List <EnumModel>           modellist = EnumClass.GetEnumModelList <BaseDeviceType>();
         for (int i = 0; i < modellist.Count; i++)
         {
             model           = new BaseDeviceTypeModel();
             model.id        = modellist[i].key;
             model.type_name = modellist[i].value;
             list.Add(model);
         }
         return(list);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void SerializeEnumClassWithCamelCase()
        {
            EnumClass enumClass = new EnumClass()
            {
                StoreColor          = StoreColor.Red,
                NullableStoreColor1 = StoreColor.DarkGoldenrod,
                NullableStoreColor2 = null
            };

#pragma warning disable CS0618 // Type or member is obsolete
            string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter {
                CamelCaseText = true
            });
#pragma warning restore CS0618 // Type or member is obsolete

            StringAssert.AreEqual(@"{
  ""StoreColor"": ""red"",
  ""NullableStoreColor1"": ""darkGoldenrod"",
  ""NullableStoreColor2"": null
}", json);
        }
Пример #19
0
        public void ReadRow_AutoMappedEnum_ReturnsExpected()
        {
            using var importer = Helpers.GetImporter("Enums.xlsx");

            ExcelSheet sheet = importer.ReadSheet();

            sheet.ReadHeading();

            // Valid cell value.
            EnumClass row1 = sheet.ReadRow <EnumClass>();

            Assert.Equal(TestEnum.Member, row1.Value);

            // Different case cell value.
            Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <NullableEnumClass>());

            // Empty cell value.
            Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <EnumClass>());

            // Invalid cell value.
            Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <EnumClass>());
        }
Пример #20
0
        public static IList <EnumClass> GetEnumDetails(string enumName)
        {
            IList <EnumClass> enumClassList = new List <EnumClass>();

            Type type = GetEnumType(enumName);

            EnumClass enumClass = new EnumClass {
                EnumName = enumName
            };

            foreach (var value in Enum.GetValues(type))
            {
                enumClass.EnumFields.Add(new EnumField()
                {
                    EnumValue = (int)value,
                    EnumText  = value.ToString()
                });
            }

            enumClassList.Add(enumClass);

            return(enumClassList);
        }
Пример #21
0
        public void t20_enum_member()
        {
            EnumClass value = parser.Parse <EnumClass>("{\"Colors\":\"Teal\",\"Style\":\"Blink, Dotted\"}");

            Assert.IsNotNull(value);
            Assert.AreEqual(Color.Teal, value.Colors);
            Assert.AreEqual(Style.Blink | Style.Dotted, value.Style);

            value = parser.Parse <EnumClass>("{\"Colors\":3,\"Style\":10}");
            Assert.IsNotNull(value);
            Assert.AreEqual(Color.Rainbow, value.Colors);
            Assert.AreEqual(Style.Dash | Style.Thin, value.Style);

            value = parser.Parse <EnumClass>("{\"Colors\":\"3\",\"Style\":\"10\"}");
            Assert.IsNotNull(value);
            Assert.AreEqual(Color.Rainbow, value.Colors);
            Assert.AreEqual(Style.Dash | Style.Thin, value.Style);

            value = parser.Parse <EnumClass>("{\"Colors\":\"sfdoijsdfoij\",\"Style\":\"sfdoijsdfoij\"}");
            Assert.IsNotNull(value);
            Assert.AreEqual(Color.Cyan, value.Colors);
            Assert.AreEqual(Style.None, value.Style);
        }
Пример #22
0
        public void TestEnumMember()
        {
            EnumClass value = "{\"Colors\":\"Green\",\"Style\":\"Bold, Underline\"}".FromJson <EnumClass>();

            Assert.IsNotNull(value);
            Assert.AreEqual(Color.Green, value.Colors);
            Assert.AreEqual(Style.Bold | Style.Underline, value.Style);

            value = "{\"Colors\":3,\"Style\":10}".FromJson <EnumClass>();
            Assert.IsNotNull(value);
            Assert.AreEqual(Color.Yellow, value.Colors);
            Assert.AreEqual(Style.Italic | Style.Strikethrough, value.Style);

            value = "{\"Colors\":\"3\",\"Style\":\"10\"}".FromJson <EnumClass>();
            Assert.IsNotNull(value);
            Assert.AreEqual(Color.Yellow, value.Colors);
            Assert.AreEqual(Style.Italic | Style.Strikethrough, value.Style);

            value = "{\"Colors\":\"sfdoijsdfoij\",\"Style\":\"sfdoijsdfoij\"}".FromJson <EnumClass>();
            Assert.IsNotNull(value);
            Assert.AreEqual(Color.Red, value.Colors);
            Assert.AreEqual(Style.None, value.Style);
        }
Пример #23
0
        public ActionResult PersonManage()
        {
            ViewData["GenderList"]          = servPersonInfoBLL.ReadPersonXml("GenderList");          //性别
            ViewData["NationList"]          = servPersonInfoBLL.ReadPersonXml("NationList");          //民族
            ViewData["ReligionList"]        = servPersonInfoBLL.ReadPersonXml("ReligionList");        //宗教信仰
            ViewData["BloodTypeList"]       = servPersonInfoBLL.ReadPersonXml("BloodTypeList");       //血型
            ViewData["NativeLanguageList"]  = servPersonInfoBLL.ReadPersonXml("NativeLanguageList");  //母语
            ViewData["NationalityList"]     = servPersonInfoBLL.ReadPersonXml("NationalityList");     //国籍
            ViewData["PoliticalStatusList"] = servPersonInfoBLL.ReadPersonXml("PoliticalStatusList"); //政治面貌
            BaseOrganizitionInfoQuery query = new BaseOrganizitionInfoQuery();

            query.region_id = 1;
            query.org_type  = 1;
            List <BaseOrganizitionInfoModel> orgList = baseOrganizationBLL.GetOrganizationTree(query);

            ViewData["orgList"]       = orgList;                                                    //部门
            ViewData["staffType"]     = EnumClass.GetEnumModelList <EnumClass.PersonStaffType>();   //职工类型
            ViewData["staffStatus"]   = EnumClass.GetEnumModelList <EnumClass.PersonStaffStatus>(); //职工状态
            ViewData["studentType"]   = EnumClass.GetEnumModelList <EnumClass.StudentType>();       //学生类型
            ViewData["studentStatus"] = EnumClass.GetEnumModelList <EnumClass.StudentStatus>();     //学生状态
            ViewData["teachStatus"]   = EnumClass.GetEnumModelList <EnumClass.TeachStatus>();       //教师状态
            ViewData["teachLevel"]    = EnumClass.GetEnumModelList <EnumClass.TeacherLevel>();      //教师等级
            return(View());
        }
Пример #24
0
    static void Main()
    {
        if (default_args.anonymous() != 7771)
        {
            throw new Exception("anonymous (1) failed");
        }
        if (default_args.anonymous(1234) != 1234)
        {
            throw new Exception("anonymous (2) failed");
        }

        if (default_args.booltest() != true)
        {
            throw new Exception("booltest (1) failed");
        }
        if (default_args.booltest(true) != true)
        {
            throw new Exception("booltest (2) failed");
        }
        if (default_args.booltest(false) != false)
        {
            throw new Exception("booltest (3) failed");
        }

        EnumClass ec = new EnumClass();

        if (ec.blah() != true)
        {
            throw new Exception("EnumClass failed");
        }

        if (default_args.casts1() != null)
        {
            throw new Exception("casts1 failed");
        }

        if (default_args.casts2() != "Hello")
        {
            throw new Exception("casts2 failed");
        }

        if (default_args.casts1("Ciao") != "Ciao")
        {
            throw new Exception("casts1 not default failed");
        }

        if (default_args.chartest1() != 'x')
        {
            throw new Exception("chartest1 failed");
        }

        if (default_args.chartest2() != '\0')
        {
            throw new Exception("chartest2 failed");
        }

        if (default_args.chartest1('y') != 'y')
        {
            throw new Exception("chartest1 not default failed");
        }

        if (default_args.chartest1('y') != 'y')
        {
            throw new Exception("chartest1 not default failed");
        }

        if (default_args.reftest1() != 42)
        {
            throw new Exception("reftest1 failed");
        }

        if (default_args.reftest1(400) != 400)
        {
            throw new Exception("reftest1 not default failed");
        }

        if (default_args.reftest2() != "hello")
        {
            throw new Exception("reftest2 failed");
        }

        // rename
        Foo foo = new Foo();

        foo.newname();
        foo.newname(10);
        foo.renamed3arg(10, 10.0);
        foo.renamed2arg(10);
        foo.renamed1arg();

        // exception specifications
        try {
            default_args.exceptionspec();
            throw new Exception("exceptionspec 1 failed");
        } catch (Exception) {
        }
        try {
            default_args.exceptionspec(-1);
            throw new Exception("exceptionspec 2 failed");
        } catch (Exception) {
        }
        try {
            default_args.exceptionspec(100);
            throw new Exception("exceptionspec 3 failed");
        } catch (Exception) {
        }
        Except ex = new Except(false);

        try {
            ex.exspec();
            throw new Exception("exspec 1 failed");
        } catch (Exception) {
        }
        try {
            ex.exspec(-1);
            throw new Exception("exspec 2 failed");
        } catch (Exception) {
        }
        try {
            ex.exspec(100);
            throw new Exception("exspec 3 failed");
        } catch (Exception) {
        }
        try {
            ex = new Except(true);
            throw new Exception("Except constructor 1 failed");
        } catch (Exception) {
        }
        try {
            ex = new Except(true, -2);
            throw new Exception("Except constructor 2 failed");
        } catch (Exception) {
        }

        // Default parameters in static class methods
        if (Statics.staticmethod() != 10 + 20 + 30)
        {
            throw new Exception("staticmethod 1 failed");
        }
        if (Statics.staticmethod(100) != 100 + 20 + 30)
        {
            throw new Exception("staticmethod 2 failed");
        }
        if (Statics.staticmethod(100, 200, 300) != 100 + 200 + 300)
        {
            throw new Exception("staticmethod 3 failed");
        }


        Tricky tricky = new Tricky();

        if (tricky.privatedefault() != 200)
        {
            throw new Exception("privatedefault failed");
        }
        if (tricky.protectedint() != 2000)
        {
            throw new Exception("protectedint failed");
        }
        if (tricky.protecteddouble() != 987.654)
        {
            throw new Exception("protecteddouble failed");
        }
        if (tricky.functiondefault() != 500)
        {
            throw new Exception("functiondefault failed");
        }
        if (tricky.contrived() != 'X')
        {
            throw new Exception("contrived failed");
        }

        if (default_args.constructorcall().val != -1)
        {
            throw new Exception("constructorcall test 1 failed");
        }

        if (default_args.constructorcall(new Klass(2222)).val != 2222)
        {
            throw new Exception("constructorcall test 2 failed");
        }

        if (default_args.constructorcall(new Klass()).val != -1)
        {
            throw new Exception("constructorcall test 3 failed");
        }

        // const methods
        ConstMethods cm = new ConstMethods();

        if (cm.coo() != 20)
        {
            throw new Exception("coo test 1 failed");
        }
        if (cm.coo(1.0) != 20)
        {
            throw new Exception("coo test 2 failed");
        }
    }
Пример #25
0
 /// <summary>
 /// 设备告警
 /// </summary>
 /// <returns></returns>
 public ActionResult InformAlarm()
 {
     ViewData["alarmLevelList"] = EnumClass.GetEnumModelList <EnumClass.AlarmLevel>();
     ViewData["region"]         = servScheduleBll.GetAllRegion();
     return(View());
 }
Пример #26
0
        private BaseAreaTypeDAL baseAreaTypeDAL                 = new BaseAreaTypeDAL();         //区域类型
        #region 设备注册相关
        /// <summary>
        /// 获取所有未注册设备
        /// </summary>
        /// <returns></returns>
        public List <TempDeviceCustom> GetUnRegisterDevice()
        {
            try
            {
                ServTempDeviceQuery        tempDeviceQuery = new ServTempDeviceQuery();
                List <ServTempDeviceModel> list            = new List <ServTempDeviceModel>();
                //获取所有的临时设备
                list = servTempDeviceDAL.GetEntities(tempDeviceQuery);
                //获取子系统枚举
                List <EnumModel>        enumList = EnumClass.GetEnumModelList <SubSystem>();
                TempDeviceCustom        tempDevice;
                List <TempDeviceCustom> tempDeviceCustomList = new List <TempDeviceCustom>();
                for (int i = 0; i < enumList.Count; i++)
                {
                    List <ServTempDeviceModel> tempDeviceModelList = list.Where(n => n.subsystem_id == enumList[i].key).ToList();
                    if (tempDeviceModelList.Count > 0)
                    {
                        tempDevice      = new TempDeviceCustom();
                        tempDevice.pId  = -1;
                        tempDevice.id   = enumList[i].key - 1;
                        tempDevice.name = enumList[i].value;
                        tempDevice.ip   = (enumList[i].key - 1).ToString();
                        tempDevice.pip  = "-1";
                        tempDeviceCustomList.Add(tempDevice);
                    }
                    List <string> ipList1 = new List <string>();
                    var           ipList  = tempDeviceModelList.GroupBy(n => n.ext1).ToList();
                    for (int j = 0; j < ipList.Count; j++)
                    {
                        ipList1.Add(ipList[j].Key);
                        tempDevice      = new TempDeviceCustom();
                        tempDevice.pId  = enumList[i].key - 1;
                        tempDevice.id   = -5;
                        tempDevice.name = ipList[j].Key;
                        tempDevice.ip   = ipList[j].Key;
                        tempDevice.pip  = (enumList[i].key - 1).ToString();
                        tempDeviceCustomList.Add(tempDevice);
                    }

                    for (int j = 0; j < tempDeviceModelList.Count; j++)
                    {
                        tempDevice              = new TempDeviceCustom();
                        tempDevice.pId          = tempDeviceModelList[j].subsystem_id - 1;
                        tempDevice.id           = tempDeviceModelList[j].id;
                        tempDevice.name         = tempDeviceModelList[j].device_name;
                        tempDevice.device_code  = tempDeviceModelList[j].device_code;
                        tempDevice.device_type  = tempDeviceModelList[j].device_type;
                        tempDevice.subsystem_id = tempDeviceModelList[j].subsystem_id;
                        tempDevice.search_code  = tempDeviceModelList[j].search_code;
                        tempDevice.ip           = "";
                        tempDevice.pip          = tempDeviceModelList[j].ext1;
                        tempDeviceCustomList.Add(tempDevice);
                    }
                }
                tempDevice      = new TempDeviceCustom();
                tempDevice.pId  = -1;
                tempDevice.id   = -2;
                tempDevice.name = "添加其他设备";
                tempDeviceCustomList.Add(tempDevice);
                return(tempDeviceCustomList);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #27
0
	private void _slilderMove (EnumClass.SliderDirection sliderDirection)
	{
		if (gameMap.SliderMap (sliderDirection)) {
			ResetMap ();
			if (gameMap.CheckGameOver ()) {
				MainController.instance.ShowDialog ("游戏结束", true, null);
			}
		}
	}
Пример #28
0
 public void Init()
 {
     instance = new EnumClass();
 }
Пример #29
0
 ///
 ///          <summary> * (6) get EnumClass attribute Class </summary>
 ///          * <returns> EnumClass the value of the attribute </returns>
 ///
 public virtual EnumClass getClassJDF()
 {
     return(EnumClass.getEnum(getAttribute(AttributeName.CLASS, null, null)));
 }
Пример #30
0
        // ************************************************************************
        // * Attribute getter / setter
        // * ************************************************************************
        //

        //         ---------------------------------------------------------------------
        //        Methods for Attribute Class
        //        ---------------------------------------------------------------------
        ///
        ///          <summary> * (5) set attribute Class </summary>
        ///          * <param name="enumVar">: the enumVar to set the attribute to </param>
        ///
        public virtual void setClass(EnumClass enumVar)
        {
            setAttribute(AttributeName.CLASS, enumVar == null ? null : enumVar.getName(), null);
        }
    static void Main() 
    {
      if (default_args.anonymous() != 7771)
        throw new Exception("anonymous (1) failed");
      if (default_args.anonymous(1234) != 1234)
        throw new Exception("anonymous (2) failed");

      if (default_args.booltest() != true)
        throw new Exception("booltest (1) failed");
      if (default_args.booltest(true) != true)
        throw new Exception("booltest (2) failed");
      if (default_args.booltest(false) != false)
        throw new Exception("booltest (3) failed");

      EnumClass ec = new EnumClass();
      if (ec.blah() != true)
        throw new Exception("EnumClass failed");

      if (default_args.casts1() != null)
        throw new Exception("casts1 failed");

      if (default_args.casts2() != "Hello")
        throw new Exception("casts2 failed");

      if (default_args.casts1("Ciao") != "Ciao")
        throw new Exception("casts1 not default failed");

      if (default_args.chartest1() != 'x')
        throw new Exception("chartest1 failed");

      if (default_args.chartest2() != '\0')
        throw new Exception("chartest2 failed");

      if (default_args.chartest1('y') != 'y')
        throw new Exception("chartest1 not default failed");

      if (default_args.chartest1('y') != 'y')
        throw new Exception("chartest1 not default failed");

      if (default_args.reftest1() != 42)
        throw new Exception("reftest1 failed");

      if (default_args.reftest1(400) != 400)
        throw new Exception("reftest1 not default failed");

      if (default_args.reftest2() != "hello")
        throw new Exception("reftest2 failed");

      // rename
      Foo foo = new Foo();
      foo.newname(); 
      foo.newname(10); 
      foo.renamed3arg(10, 10.0); 
      foo.renamed2arg(10); 
      foo.renamed1arg(); 

      // exception specifications
      try {
        default_args.exceptionspec();
        throw new Exception("exceptionspec 1 failed");
      } catch (Exception) {
      }
      try {
        default_args.exceptionspec(-1);
        throw new Exception("exceptionspec 2 failed");
      } catch (Exception) {
      }
      try {
        default_args.exceptionspec(100);
        throw new Exception("exceptionspec 3 failed");
      } catch (Exception) {
      }
      Except ex = new Except(false);
      try {
        ex.exspec();
        throw new Exception("exspec 1 failed");
      } catch (Exception) {
      }
      try {
        ex.exspec(-1);
        throw new Exception("exspec 2 failed");
      } catch (Exception) {
      }
      try {
        ex.exspec(100);
        throw new Exception("exspec 3 failed");
      } catch (Exception) {
      }
      try {
        ex = new Except(true);
        throw new Exception("Except constructor 1 failed");
      } catch (Exception) {
      }
      try {
        ex = new Except(true, -2);
        throw new Exception("Except constructor 2 failed");
      } catch (Exception) {
      }

      // Default parameters in static class methods
      if (Statics.staticmethod() != 10+20+30)
        throw new Exception("staticmethod 1 failed");
      if (Statics.staticmethod(100) != 100+20+30)
        throw new Exception("staticmethod 2 failed");
      if (Statics.staticmethod(100,200,300) != 100+200+300)
        throw new Exception("staticmethod 3 failed");


      Tricky tricky = new Tricky();
      if (tricky.privatedefault() != 200)
        throw new Exception("privatedefault failed");
      if (tricky.protectedint() != 2000)
        throw new Exception("protectedint failed");
      if (tricky.protecteddouble() != 987.654)
        throw new Exception("protecteddouble failed");
      if (tricky.functiondefault() != 500)
        throw new Exception("functiondefault failed");
      if (tricky.contrived() != 'X')
        throw new Exception("contrived failed");

      if (default_args.constructorcall().val != -1)
        throw new Exception("constructorcall test 1 failed");

      if (default_args.constructorcall(new Klass(2222)).val != 2222)
        throw new Exception("constructorcall test 2 failed");

      if (default_args.constructorcall(new Klass()).val != -1)
        throw new Exception("constructorcall test 3 failed");

      // const methods 
      ConstMethods cm = new ConstMethods();
      if (cm.coo() != 20)
        throw new Exception("coo test 1 failed");
      if (cm.coo(1.0) != 20)
        throw new Exception("coo test 2 failed");
    }
Пример #32
0
 static JDFAutoNotification()
 {
     atrInfoTable[0]  = new AtrInfoTable(AttributeName.CLASS, 0x22222222, AttributeInfo.EnumAttributeType.enumeration, EnumClass.getEnum(0), null);
     atrInfoTable[1]  = new AtrInfoTable(AttributeName.JOBID, 0x33333111, AttributeInfo.EnumAttributeType.string_, null, null);
     atrInfoTable[2]  = new AtrInfoTable(AttributeName.JOBPARTID, 0x33333111, AttributeInfo.EnumAttributeType.string_, null, null);
     atrInfoTable[3]  = new AtrInfoTable(AttributeName.TYPE, 0x33333333, AttributeInfo.EnumAttributeType.NMTOKEN, null, null);
     elemInfoTable[0] = new ElemInfoTable(ElementName.COSTCENTER, 0x66666666);
     elemInfoTable[1] = new ElemInfoTable(ElementName.EMPLOYEE, 0x33333333);
     elemInfoTable[2] = new ElemInfoTable(ElementName.PART, 0x33333331);
 }
Пример #33
0
        // GET: Map
        public ActionResult Index()
        {
            int regionID = 0;

            if (Request.QueryString["regionID"] != null)//页面带条件刷新
            {
                regionID = int.Parse(Request.QueryString["regionID"]);
            }
            HttpCookie cookie = Request.Cookies["mainControlRegionId"];

            if (cookie != null && Request.QueryString["regionID"] == null)//cookie主控园区id
            {
                //Request.Cookies.Get()
                if (cookie.Value != "")
                {
                    regionID = int.Parse(Server.HtmlEncode(cookie.Value));
                }
            }



            JavaScriptSerializer         tojson = new JavaScriptSerializer();
            List <BaseRegionConfigModel> baseRegionConfigModelList = baseMapConfigBLL.GetAllRegionConfig();



            string type;
            int    groupId;

            ViewData["VideoInfo"] = tojson.Serialize(-1); // new List<Model.ServDeviceInfoModel>();
            if (Request.QueryString["type"] != null)      //页面带条件刷新
            {
                type = Request.QueryString["type"].ToString();
                if (type == "monitor")
                {
                    if (Request.QueryString["groupId"] != null)//页面带条件刷新
                    {
                        groupId = int.Parse(Request.QueryString["groupId"]);
                        ViewData["VideoInfo"] = tojson.Serialize(GetVideoPatrolDevice(groupId));
                    }
                }
            }



            //int regionID = Request.QueryString["regionID"] == null ? 0 : int.Parse(Request.QueryString["regionID"]);
            //if (regionID == 0)
            //{

            //    if (baseRegionConfigModelList.Count > 0)
            //    {
            //        regionID = baseRegionConfigModelList[0].id;
            //    }
            //}

            ViewData["NowMapType"]  = baseMapConfigBLL.GetRegionConfigModelByID(regionID);
            ViewData["InitMapType"] = baseMapConfigBLL.GetRegionInitMapTypeByID(regionID);
            BaseNewMapConfigModel        newMapConfig2D        = null;
            BaseNewMapConfigModel        newMapConfig25D       = null;
            List <BaseNewMapConfigModel> newMapConfigModelList = baseMapConfigBLL.GetDefalutNewMapConfigByRegionID(regionID);

            for (int i = 0; i < newMapConfigModelList.Count; i++)
            {
                if (newMapConfigModelList[i].map_type == (int)CSM.Common.EnumClass.MapType.二维)
                {
                    newMapConfig2D = newMapConfigModelList[i];
                }
                else if (newMapConfigModelList[i].map_type == (int)CSM.Common.EnumClass.MapType.二点五维)
                {
                    newMapConfig25D = newMapConfigModelList[i];
                }
            }
            ViewData["Map2DConfig"]  = tojson.Serialize(newMapConfig2D);
            ViewData["Map25DConfig"] = tojson.Serialize(newMapConfig25D);


            ViewData["AllRegion"] = baseRegionConfigModelList;
            ViewData["regionID"]  = regionID;
            string regionImg = "";

            for (int i = 0; i < baseRegionConfigModelList.Count; i++)
            {
                if (baseRegionConfigModelList[i].id == regionID)
                {
                    regionImg = baseRegionConfigModelList[i].region_image;
                    break;
                }
            }
            //ViewData["regionImg"] = tojson.Serialize(regionImg);
            //当前地图类型
            //ViewData["NowMapType"] = baseMapConfigBLL.GetMapEngine(Server.MapPath("/ConfigFile/map/mapConfig.xml"));//获取地图配置中当前的地图类型
            //当前2D地图的配置
            //BaseMapConfigModel mapConfi2D = baseMapConfigBLL.GetNowMapConfig(Server.MapPath("/ConfigFile/map/mapConfig.xml"), (int)MapType.二维);
            //ViewData["Map2DConfig"] = tojson.Serialize(mapConfi2D);
            //当前2.5地图的配置
            //BaseMapConfigModel mapConfi25D = baseMapConfigBLL.GetNowMapConfig(Server.MapPath("/ConfigFile/map/mapConfig.xml"), (int)MapType.二点五维);
            //ViewData["Map25DConfig"] = tojson.Serialize(mapConfi25D);
            //默认行业
            BaseIndustryModel industryModel = baseMapConfigBLL.GetDefaultIndustry(Server.MapPath("/ConfigFile/map/mapConfig.xml"));

            //获取Serv_Device_Info中设备的全部数据(需要园区id,行业id)
            //ViewData["AllDeviceInfo"] = tojson.Serialize(servDeviceInfoBLL.GetDeviceInfoAndIconUrl(regionID, industryModel.id));
            ViewData["AllDeviceInfo"] = JsonHelper.ObjectToString <List <DeviceInfoCustom> >(servDeviceInfoBLL.GetDeviceInfoAndIconUrl(regionID, industryModel.id));
            //获取Serv_Area_Info中区域的全部数据(需要园区id)
            ViewData["AreaInfo"] = tojson.Serialize(servAreaInfoBLL.GetAreaInfoAndBuilding(regionID, industryModel.id));
            //自定义设备类型
            //ViewData["DefinedDevices"] = tojson.Serialize(baseMapConfigBLL.GetAllDeviceDefined(Server.MapPath("/ConfigFile/map/mapConfig.xml")));
            //获取自定义类型表和基本类型表的对应关系表
            //ViewData["TypeDefined"] = tojson.Serialize(baseMapConfigBLL.GetAllDeviceDefinedDevice());
            //地图左侧设备工具栏
            ViewData["leftDeviceTool"] = baseMapConfigBLL.GetDefinedDeviceTypeTool(industryModel.id);
            //ViewData["leftDeviceToolJson"] = tojson.Serialize(ViewData["leftDeviceTool"]);
            //地图右侧区域工具栏
            ViewData["rightAreaTool"]     = baseMapConfigBLL.GetAreaTypeTool(Server.MapPath("/ConfigFile/map/mapConfig.xml"));
            ViewData["floorBuildingArea"] = tojson.Serialize(servAreaInfoBLL.GetFloorBuildingAreaInfoCustom());
            //获取确警结论
            ViewData["confirmAlarmResultList"] = EnumClass.GetEnumModelList <EnumClass.ConfirmAlarmResult>();

            //加载父级事件
            ViewData["parentEventList"] = eventTypeBll.GetChildEventType(-1);
            return(View());
        }
            public void should_cast_enum_value_to_int_for_enum_type()
            {
                var enumtest = new EnumClass() { Color = ConsoleColor.DarkBlue };

                Assert.Equal("[Color]1", enumtest.ToViewModelString(Delimiters.Default));
            }
Пример #35
0
            public static int AbsoluteDifference(EnumClass firstValue, EnumClass secondValue)
            {
                var absoluteDifference = Math.Abs(firstValue.Value - secondValue.Value);

                return(absoluteDifference);
            }
 public IActionResult AddNewPatient(string SelectRole, EnumClass SelectSensor, EnumClass SelectWard,
                                    EnumClass SelectDepartment, string patientName, string patientSurname,
                                    string patientPassword, string patientLogin)
 {
     return(View("~/Areas/PatientArea/Views/AddNewPatient.cshtml"));
 }
Пример #37
0
 //频道首页右侧的局部页 NavStr为导航枚举
 public ActionResult _HomeRight(EnumClass.ChannelHomeRightNav NavEnum = EnumClass.ChannelHomeRightNav.MyWord, long urlUserId = 0, int pageIndex = 1, int pageSize = 10)
 {
     string ViewName = null;
     switch (NavEnum)
     {
         case EnumClass.ChannelHomeRightNav.MySale:
             ViewName = "_MySale";
             break;
         case EnumClass.ChannelHomeRightNav.MyShareMemory:
             ViewName = "_MyShareMemory";
             break;
         case EnumClass.ChannelHomeRightNav.MyFood:
             ViewName = "_MyFood";
             break;
         case EnumClass.ChannelHomeRightNav.TheirFood:
             ViewName = "_TheirFood";
             break;
         case EnumClass.ChannelHomeRightNav.TheirSale:
             ViewName = "_TheirSale";
             break;
         case EnumClass.ChannelHomeRightNav.TheirShareMemory:
             ViewName = "_TheirShareMemory";
             break;
         case EnumClass.ChannelHomeRightNav.TheirWord:
             ViewName = "Microblog/_TheirWord";
             break;
         default:
             ViewBag.MyWord = MyWord(urlUserId, pageIndex, pageSize);
             ViewName = "Microblog/_MyWord";
             break;
     }
     return View(ViewName);
 }
Пример #38
0
 public TestClass1(EnumClass enumClass)
 {
     _enumClass = enumClass;
 }
Пример #39
0
	public bool SliderMap (EnumClass.SliderDirection direction)
	{
		int[,] itemsValueTemp = new int[GameConfig.MAP_X, GameConfig.MAP_Y]; 
		Array.Copy (itemsValue, itemsValueTemp, itemsValue.Length);
		switch (direction) {
		case EnumClass.SliderDirection.LEFT:
			_sliderLeft ();
			break;
		case EnumClass.SliderDirection.RIGHT:
			_sliderRight ();
			break;
		case EnumClass.SliderDirection.DOWN:
			_sliderDown ();
			break;
		case EnumClass.SliderDirection.UP:
			_sliderUP ();
			break;
		default :
			return false;
		}
		if (_isSliderSucess (itemsValueTemp)) {
			RandomPosValue ();
			return true;
		}
		return false;
	}
Пример #40
0
 /// <summary>
 /// 频道首页右侧局部页
 /// </summary>
 /// <returns></returns>
 public string ChannelHomeRight(EnumClass.ChannelHomeRightNav NavEnum,long urlUserId=0)
 {
     RouteValueDictionary rvd = new RouteValueDictionary();
     rvd.Add("NavEnum", NavEnum);
     rvd.Add("urlUserId", urlUserId);
     return urlHelper.Action("_HomeRight", "Channel", rvd);
 }
Пример #41
0
 public void Init()
 {
     instance = new EnumClass();
 }