当前位置: 首页>>代码示例>>C#>>正文


C# CPrivileges.GetType方法代码示例

本文整理汇总了C#中CPrivileges.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# CPrivileges.GetType方法的具体用法?C# CPrivileges.GetType怎么用?C# CPrivileges.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPrivileges的用法示例。


在下文中一共展示了CPrivileges.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteConnectionConfig

        public void ExecuteConnectionConfig(string strConfigFile, int iRecursion, List<string> lstArguments, bool blIncPlugin) {

            //FileStream stmConfigFile = null;
            try {

                if (File.Exists(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Configs"),strConfigFile)) == true) {

                    //stmConfigFile = new FileStream(String.Format(@"{0}Configs\{1}", AppDomain.CurrentDomain.BaseDirectory, strConfigFile), FileMode.Open);

                    string[] a_strConfigData = File.ReadAllLines(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs"), strConfigFile));

                    if (a_strConfigData != null) {

                        foreach (string strLine in a_strConfigData) {
                            if (strLine.Length > 0 && Regex.Match(strLine, "^[ ]+//.*").Success == false) { // AND not a comment..

                                if (lstArguments != null) {

                                    string strReplacedLine = strLine;

                                    for (int i = 0; i < lstArguments.Count; i++) {
                                        strReplacedLine = strReplacedLine.Replace(String.Format("%arg:{0}%", i), lstArguments[i]);
                                    }

                                    List<string> lstWordifiedCommand = Packet.Wordify(strReplacedLine);
                                    // procon.protected.config.demand 48543 CanKickPlayers procon.protected.send admin.say "You're not allowed to kick" player phogue
                                    if (lstWordifiedCommand.Count >= 3 && String.Compare(lstWordifiedCommand[0], "procon.protected.config.demand", true) == 0) {

                                        UInt32 ui32PrivilegesFlags = 0;

                                        if (UInt32.TryParse(lstWordifiedCommand[1], out ui32PrivilegesFlags) == true) {
                                            CPrivileges cpConfigPrivs = new CPrivileges(ui32PrivilegesFlags);
                                            bool blHasPrivileges = false;

                                            try {
                                                System.Reflection.PropertyInfo[] a_piAllProperties = cpConfigPrivs.GetType().GetProperties();

                                                foreach (System.Reflection.PropertyInfo pInfo in a_piAllProperties) {
                                                    if (String.Compare(pInfo.GetGetMethod().Name, "get_" + lstWordifiedCommand[2]) == 0) {
                                                        blHasPrivileges = (bool)pInfo.GetValue(cpConfigPrivs, null);
                                                        break;
                                                    }
                                                }

                                                if (blHasPrivileges == false) {

                                                    // If they have asked for a command on failure..
                                                    if (lstWordifiedCommand.Count > 3) {
                                                        if (blIncPlugin == true) {
                                                            this.Parent.ExecutePRoConCommandCon(this, lstWordifiedCommand.GetRange(3, lstWordifiedCommand.Count - 3), iRecursion++);
                                                        } else {
                                                            this.Parent.ExecutePRoConCommand(this, lstWordifiedCommand.GetRange(3, lstWordifiedCommand.Count - 3), iRecursion++);
                                                        }
                                                    }

                                                    // Cancel execution of the config file, they don't have the demanded privileges.
                                                    break;
                                                }
                                            }
                                            catch (Exception e) {
                                                FrostbiteConnection.LogError("Parsing a config.", String.Empty, e);
                                                break;
                                            }
                                        }
                                        else {
                                            // Cancel execution of the config file, wrong format for demand.
                                            break;
                                        }
                                    }
                                    else {
                                        if (blIncPlugin == true) {
                                            this.Parent.ExecutePRoConCommandCon(this, lstWordifiedCommand, iRecursion++);
                                        } else {
                                            this.Parent.ExecutePRoConCommand(this, lstWordifiedCommand, iRecursion++);
                                        }
                                    }
                                }
                                else {
                                    if (blIncPlugin == true) {
                                        this.Parent.ExecutePRoConCommandCon(this, Packet.Wordify(strLine), iRecursion++);
                                    } else {
                                        this.Parent.ExecutePRoConCommand(this, Packet.Wordify(strLine), iRecursion++);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e) {
                FrostbiteConnection.LogError("ExecuteConnectionConfig", String.Empty, e);
            }
        }
开发者ID:Webs961,项目名称:Procon-1,代码行数:93,代码来源:PRoConClient.cs


注:本文中的CPrivileges.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。