Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the IISWebsite class.
 /// </summary>
 /// <param name="configArgsModel"></param>
 public IISConfigEx(ConfigArgsModel configArgsModel)
     : base(configArgsModel)
 {
     virtualName = string.Format("/{0}", string.IsNullOrWhiteSpace(Model.VirtualName) ? "" : Model.VirtualName.TrimStart('/'));
     webName     = Model.WebName;
     SetIsapiRestriction();
 }
Esempio n. 2
0
        public IISBaseConfig(ConfigArgsModel configArgsModel)
        {
            this.Model = configArgsModel;
            EnableDotNetExtension();
            int port;

            if (string.IsNullOrEmpty(configArgsModel.Port) || !int.TryParse(configArgsModel.Port, out port))
            {
                configArgsModel.Port = "80";
            }
            else
            {
                configArgsModel.Port = port.ToString();
            }
        }
Esempio n. 3
0
        public ConfigArgsModel Parse()
        {
            ConfigArgsModel model = new ConfigArgsModel();
            Type            t     = model.GetType();

            foreach (PropertyInfo proptyinfo in t.GetProperties())
            {
                Type propertyType = proptyinfo.PropertyType;
                bool isBool       = (propertyType == typeof(System.Boolean)); //当前属性是否bool值

                object[] obj = proptyinfo.GetCustomAttributes(typeof(ArgsSortAttribute), true);
                if (obj.Length != 1)
                {
                    continue;
                }
                ArgsSortAttribute objAttr     = (obj[0] as ArgsSortAttribute);
                string            objKeyValue = objAttr.ArgsFormat.ToLower().Trim(); //参数值
                int objKeyIndex = objAttr.ArgsIndex;                                 //参数位置
                int valueIndex  = objAttr.ValueIndex;
                if (objKeyIndex > Args.Count - 1)                                    //当索引超出参数时,跳过
                {
                    continue;
                }

                if (objKeyIndex >= 0) //直接通过索引查找输入的参数
                {
                    string getValue = Args[objKeyIndex + valueIndex];
                    if (IsCheckArgs(getValue))
                    {
                        continue;
                    }
                    proptyinfo.SetValue(model, Convert.ChangeType(getValue, propertyType), null);
                    continue;
                }
                int getKeyIndex = Args.IndexOf(objKeyValue); //判断输入的参数中是否存在当前参数
                if (isBool)                                  //当前实体对像如果Bool值,只需要判断当前参数是否存在
                {
                    proptyinfo.SetValue(model, getKeyIndex >= 0, null);
                    continue;
                }
                if (getKeyIndex < 0) //输入参数中如果不存在此实体的参数,则直接进入下一个参数的转换
                {
                    continue;
                }
                int getValueIndex = getKeyIndex + valueIndex;
                if (getValueIndex > Args.Count - 1)
                {
                    continue;
                }
                string val = Args[getValueIndex];

                if (IsCheckArgs(val))
                {
                    continue;
                }
                proptyinfo.SetValue(model, Convert.ChangeType(val, propertyType), null);
            }

            this.Model = model;
            return(this.Model);
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the IISWebsite class.
 /// </summary>
 /// <param name="configArgsModel"></param>
 public IISConfig(ConfigArgsModel configArgsModel)
     : base(configArgsModel)
 {
 }