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


C# Variables.Maximum方法代码示例

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


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

示例1: ProcessType

        private void ProcessType(string prefix, Type type, Variables.Root variables, bool isNested)
        {
            foreach(Type nestedType in type.NestedTypes){
                ProcessType(prefix+"."+type.Identifier, nestedType, variables, true);
            }

            // declaration type
            variables.Increment("javaTypesTotal");

            string declPrefix = "javaUnknown";

            switch(type.Declaration){
                case Type.DeclarationType.Class: variables.Increment(declPrefix = "javaClasses"); break;
                case Type.DeclarationType.Interface: variables.Increment(declPrefix = "javaInterfaces"); break;
                case Type.DeclarationType.Enum: variables.Increment(declPrefix = "javaEnums"); break;
                case Type.DeclarationType.Annotation: variables.Increment(declPrefix = "javaAnnotations"); break;
            }

            if (isNested){
                variables.Increment(declPrefix+(type.Modifiers.HasFlag(Modifiers.Static) ? "NestedStatic" : "NestedInner"));
            }

            foreach(Modifiers modifier in JavaModifiers.Values.Where(modifier => type.Modifiers.HasFlag(modifier))){
                variables.Increment(declPrefix+JavaModifiers.ToString(modifier).CapitalizeFirst());
            }

            // identifier
            TypeIdentifier identifier = new TypeIdentifier(prefix, type.Identifier);

            int simpleNameLength = identifier.Name.Length;
            variables.Increment("javaNamesSimpleTotal", simpleNameLength);
            variables.Minimum("javaNamesSimpleMin", simpleNameLength);
            variables.Maximum("javaNamesSimpleMax", simpleNameLength);

            int fullLength = identifier.FullName.Length;
            variables.Increment("javaNamesFullTotal", fullLength);
            variables.Minimum("javaNamesFullMin", fullLength);
            variables.Maximum("javaNamesFullMax", fullLength);

            JavaGlobalInfo global = variables.GetStateObject<JavaState>(this).GlobalInfo;
            global.IdentifiersSimpleTop.Add(identifier);
            global.IdentifiersSimpleBottom.Add(identifier);
            global.IdentifiersFullTop.Add(identifier);
            global.IdentifiersFullBottom.Add(identifier);

            if (type.Declaration == Type.DeclarationType.Annotation){
                // annotation elements
                int methodCount = type.GetData().Methods.Count;
                variables.Increment("javaAnnotationsElementsTotal", methodCount);
                variables.Minimum("javaAnnotationsElementsMin", methodCount);
                variables.Maximum("javaAnnotationsElementsMax", methodCount);
            }
            else{
                // fields
                List<Field> fields = type.GetData().Fields;
                int fieldsDefault = fields.Count;

                variables.Increment(declPrefix+"FieldsTotal", fields.Count);
                variables.Minimum(declPrefix+"FieldsMin", fields.Count);
                variables.Maximum(declPrefix+"FieldsMax", fields.Count);

                foreach(Modifiers modifier in JavaModifiers.Values){
                    int count = fields.Count(field => field.Modifiers.HasFlag(modifier));
                    if (modifier == Modifiers.Public || modifier == Modifiers.Protected || modifier == Modifiers.Private)fieldsDefault -= count;

                    variables.Increment(declPrefix+"Fields"+JavaModifiers.ToString(modifier).CapitalizeFirst(), count);
                }

                variables.Increment(declPrefix+"FieldsDefaultVisibility", fieldsDefault);

                // methods
                List<Method> constructorMethods = type.GetData().Methods.Where(method => method.IsConstructor).ToList();
                List<Method> classMethods = type.GetData().Methods.Where(method => !method.IsConstructor).ToList();

                int methodsDefault = classMethods.Count;

                if (type.GetData().CanHaveConstructors){
                    variables.Increment(declPrefix+"ConstructorsTotal", Math.Max(1, constructorMethods.Count)); // if 0, count an implicit constructor
                }

                variables.Increment(declPrefix+"MethodsTotal", classMethods.Count);
                variables.Minimum(declPrefix+"MethodsMin", classMethods.Count);
                variables.Maximum(declPrefix+"MethodsMax", classMethods.Count);

                foreach(Modifiers modifier in JavaModifiers.Values){
                    int count = classMethods.Count(method => method.Modifiers.HasFlag(modifier));
                    if (modifier == Modifiers.Public || modifier == Modifiers.Protected || modifier == Modifiers.Protected)methodsDefault -= count;

                    variables.Increment(declPrefix+"Methods"+JavaModifiers.ToString(modifier).CapitalizeFirst(), count);
                }

                variables.Increment(declPrefix+"MethodsDefaultVisibility", methodsDefault);
            }

            // enums
            if (type.Declaration == Type.DeclarationType.Enum){
                Type.DataEnum enumData = type.GetData<Type.DataEnum>();

                variables.Increment("javaEnumsValuesTotal", enumData.EnumValues.Count);
                variables.Minimum("javaEnumsValuesMin", enumData.EnumValues.Count);
//.........这里部分代码省略.........
开发者ID:chylex,项目名称:Code-Statistics,代码行数:101,代码来源:JavaHandler.cs

示例2: ProcessFileContents

        protected virtual void ProcessFileContents(File file, Variables.Root variables)
        {
            string[] contents = file.Contents.Split('\n');

            int lineCount = 0, charCount = 0, maxCharsPerLine = 0;

            foreach(string line in contents){
                if (!line.Trim().Equals("{")){
                    ++lineCount;
                }

                if (line.Length > 0){
                    int realLength = ParseUtils.CountCharacters(line);

                    charCount += realLength;
                    maxCharsPerLine = Math.Max(maxCharsPerLine, realLength);
                }
            }

            variables.Increment(Key+"LinesTotal", lineCount);
            variables.Increment(Key+"CharsTotal", charCount);
            variables.Maximum(Key+"LinesMax", lineCount);
            variables.Maximum(Key+"CharsMax", charCount);
            variables.Maximum(Key+"CharsPerLineMax", maxCharsPerLine);

            State state = variables.GetStateObject<State>(stateOwner);

            FileIntValue fileLines = new FileIntValue(file, lineCount);
            state.MaxLines.Add(fileLines);
            state.MinLines.Add(fileLines);

            FileIntValue fileChars = new FileIntValue(file, charCount);
            state.MaxChars.Add(fileChars);
            state.MinChars.Add(fileChars);
        }
开发者ID:chylex,项目名称:Code-Statistics,代码行数:35,代码来源:AbstractLanguageFileHandler.cs

示例3: Process

        public override void Process(File file, Variables.Root variables)
        {
            base.Process(file, variables);

            JavaState state = variables.GetStateObject<JavaState>(this);
            JavaFileInfo info = state.Process(file);

            variables.Increment("javaImportsTotal", info.Imports.Count);
            variables.Maximum("javaImportsMax", info.Imports.Count);

            foreach(Type type in info.Types){
                ProcessType(info.Package, type, variables, false);
            }
        }
开发者ID:chylex,项目名称:Code-Statistics,代码行数:14,代码来源:JavaHandler.cs


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