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


C# Case类代码示例

本文整理汇总了C#中Case的典型用法代码示例。如果您正苦于以下问题:C# Case类的具体用法?C# Case怎么用?C# Case使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Merge

        public static void Merge(Case[] cases, int left, int mid, int right)
        {
            Case [] temp = new Case[20];
            int i, left_end, num_elements, tmp_pos;

            left_end = (mid - 1);
            tmp_pos = left;
            num_elements = (right - left + 1);

            while ((left <= left_end) && (mid <= right))
            {
                if (ComparePriority(cases[left].priority, cases[mid].priority))
                    temp[tmp_pos++] = cases[left++];
                else
                    temp[tmp_pos++] = cases[mid++];
            }

            while (left <= left_end)
                temp[tmp_pos++] = cases[left++];

            while (mid <= right)
                temp[tmp_pos++] = cases[mid++];

            for (i = 0; i < num_elements; i++)
            {
                cases[right] = temp[right];
                right--;
            }
        }
开发者ID:bogdanuifalean,项目名称:JuniorMind,代码行数:29,代码来源:UnitTest1.cs

示例2: ToCase

        /// <summary>
        /// Converts the phrase to specified convention.
        /// </summary>
        /// <param name="phrase"></param>
        /// <param name="cases">The cases.</param>
        /// <returns>string</returns>
        public static string ToCase(this string phrase, Case cases)
        {
            string[] splittedPhrase = phrase.Split(' ', '-', '.');
            var sb = new StringBuilder();

            if (cases == Case.CamelCase)
            {

                sb.Append(char.ToLower(splittedPhrase[0][0]));
                sb.Append(splittedPhrase[0].Substring(1));
                splittedPhrase[0] = string.Empty;
            }
            else if (cases == Case.PascalCase)
                sb = new StringBuilder();

            foreach (var s in splittedPhrase)
            {
                char[] splittedPhraseChars = s.ToCharArray();
                if (splittedPhraseChars.Length > 0)
                {
                    splittedPhraseChars[0] = ((new String(splittedPhraseChars[0], 1)).ToUpper().ToCharArray())[0];
                }
                sb.Append(new String(splittedPhraseChars));
            }
            return sb.ToString();
        }
开发者ID:pellehenriksson,项目名称:ReSTore,代码行数:32,代码来源:CaseExtensions.cs

示例3: GeneratePropertyCode

        public override string GeneratePropertyCode(string propertyName, Case classCase, IEnumerable<AttributeProxy> attributes, DocumentType documentType)
        {
            if (documentType != DocumentType.Xml)
            {
                return base.GeneratePropertyCode(propertyName, classCase, attributes, documentType);
            }

            var sb = new StringBuilder();

            sb.AppendFormat(
                @"[XmlIgnore]
            public {0} {1} {{ get; set; }}", TypeAlias, propertyName).AppendLine().AppendLine();

            foreach (var attribute in attributes)
            {
                sb.AppendLine(attribute.ToCode());
            }

            sb.AppendFormat(
                @"public string {0}String
            {{
            get
            {{
            return {0} == null ? null : {0}{1};
            }}
            set
            {{
            {0} = string.IsNullOrEmpty(value) ? null : ({2}){3};
            }}
            }}", propertyName, _toString, TypeAlias, _parse);

            return sb.ToString();
        }
开发者ID:sethkontny,项目名称:CSharpinator,代码行数:33,代码来源:NullableBclClass.cs

示例4: Write

        public void Write(string @namespace, Case classCase, Case propertyCase, TextWriter writer, bool skipNamespace, DocumentType documentType)
        {
            WriteHeader(writer, documentType);

            if (!skipNamespace)
            {
                WriteUsings(writer, documentType);
                writer.WriteLine();
                writer.WriteLine("namespace {0}", @namespace);
                writer.WriteLine("{");
            }

            var usedClasses = _repository.GetUsedClasses().ToList();

            if (usedClasses.Count == 0)
            {
                writer.WriteLine("/* No used classes found! */");
            }

            writer.WriteLine(
                string.Join(
                    "\r\n\r\n",
                    _repository.GetUsedClasses().Select(x => x.GenerateCSharpCode(classCase, propertyCase, documentType))));

            if (!skipNamespace)
            {
                writer.WriteLine("}");
            }
        }
开发者ID:sethkontny,项目名称:CSharpinator,代码行数:29,代码来源:ClassGenerator.cs

示例5: Create_Case

        public Create_Case(Case incomingCase, string _formEditMode)
        {
            InitializeComponent();
            formEditMode = _formEditMode;

            NewCase = incomingCase;
        }
开发者ID:the-simian,项目名称:TREND-Application,代码行数:7,代码来源:Create_Case.cs

示例6: Execute

 public void Execute(Case @case, Action next)
 {
     //Behavior chooses not to invoke next().
     //Since the cases are never invoked, they don't
     //have the chance to throw exceptions, resulting
     //in all 'passing'.
 }
开发者ID:leijiancd,项目名称:fixie,代码行数:7,代码来源:CaseLifecycleTests.cs

示例7: PersonalPronoun

 private PersonalPronoun(Case personalPronounCase, Number number, Person person, string name)
 {
     _case = personalPronounCase;
       _number = number;
       _person = person;
       _name = name;
 }
开发者ID:skeletank,项目名称:Language-Learning,代码行数:7,代码来源:PersonalPronoun.cs

示例8: GeneratePropertyCode

        public string GeneratePropertyCode(string propertyName, Case classCase, IEnumerable<AttributeProxy> attributes, DocumentType documentType)
        {
            string typeName;

            var userDefinedClass = _class as UserDefinedClass;
            if (userDefinedClass != null)
            {
                typeName =
                    string.IsNullOrEmpty(userDefinedClass.CustomName)
                        ? userDefinedClass.TypeName.FormatAs(classCase)
                        : userDefinedClass.CustomName;
            }
            else
            {
                typeName = ((IBclClass)_class).TypeAlias;
            }

            var sb = new StringBuilder();

            foreach (var attribute in attributes)
            {
                sb.AppendLine(string.Format("{0}", attribute.ToCode()));
            }

            sb.AppendFormat("public List<{0}> {1} {{ get; set; }}", typeName, propertyName);

            return sb.ToString();
        }
开发者ID:sethkontny,项目名称:CSharpinator,代码行数:28,代码来源:ListClass.cs

示例9: APISpecExample

    public APISpecExample()
    {
      Contract.Ensures(State == Case.A);

      _case = Case.A;

    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:Protocols.cs

示例10: GeneratePropertyCode

        public override string GeneratePropertyCode(string propertyName, Case classCase, IEnumerable<AttributeProxy> attributes, DocumentType documentType)
        {
            var sb = new StringBuilder();

            var ignoreAttribute = documentType == DocumentType.Xml ? "[XmlIgnore]" : "[IgnoreDataMember]";

            sb.AppendFormat(
                @"{0}
            public DateTime {1} {{ get; set; }}", ignoreAttribute, propertyName).AppendLine().AppendLine();

            foreach (var attribute in attributes)
            {
                sb.AppendLine(attribute.ToCode());
            }

            sb.AppendFormat(
                @"public string {0}String
            {{
            get
            {{
            return {0}.ToString(""{1}"", new CultureInfo(""en-US""));
            }}
            set
            {{
            {0} = DateTime.ParseExact(value, ""{1}"", new CultureInfo(""en-US""));
            }}
            }}", propertyName, Format);

            return sb.ToString();
        }
开发者ID:sethkontny,项目名称:CSharpinator,代码行数:30,代码来源:FormattedDateTime.cs

示例11: GeneratePropertyCode

        public override string GeneratePropertyCode(string propertyName, Case classCase, IEnumerable<AttributeProxy> attributes, DocumentType documentType)
        {
            var sb = new StringBuilder();

            var ignoreAttribute = documentType == DocumentType.Xml ? "[XmlIgnore]" : "[IgnoreDataMember]";

            sb.AppendFormat(
                @"{0}
            public bool {1} {{ get; set; }}", ignoreAttribute, propertyName).AppendLine().AppendLine();

            foreach (var attribute in attributes)
            {
                sb.AppendLine(attribute.ToCode());
            }

            sb.AppendFormat(
                @"public string {0}String
            {{
            get
            {{
            return {0} ? ""True"" : ""False"";
            }}
            set
            {{
            {0} = bool.Parse(value);
            }}
            }}", propertyName);

            return sb.ToString();
        }
开发者ID:sethkontny,项目名称:CSharpinator,代码行数:30,代码来源:PascalCaseBooleanClass.cs

示例12: CaseDetailWindow

 public CaseDetailWindow (Case c, Gtk.Window parent) :
         base(Gtk.WindowType.Toplevel)
 {
     this.Build ();
     case_show.Case = c;
     case_show.HideEditingButtons ();
 }
开发者ID:monsterlabs,项目名称:HumanRightsTracker,代码行数:7,代码来源:CaseDetailWindow.cs

示例13: Execute

        public void Execute(Type testClass, Convention convention, Case[] cases)
        {
            foreach (var @case in cases)
            {
                var exceptions = @case.Exceptions;

                try
                {
                    var instance = construct(testClass);

                    var fixture = new Fixture(testClass, instance, convention.CaseExecution.Behavior, new[] { @case });
                    convention.InstanceExecution.Behavior.Execute(fixture);

                    Lifecycle.Dispose(instance);
                }
                catch (PreservedException preservedException)
                {
                    var constructionException = preservedException.OriginalException;
                    exceptions.Add(constructionException);
                }
                catch (Exception constructionException)
                {
                    exceptions.Add(constructionException);
                }
            }
        }
开发者ID:ncgonz,项目名称:fixie,代码行数:26,代码来源:CreateInstancePerCase.cs

示例14: ShouldBe

 public static void ShouldBe(this string actual, string expected, Case caseSensitivity, [InstantHandle] Func<string> customMessage)
 {
     if (caseSensitivity == Case.Sensitive)
         ShouldBe(actual, expected, customMessage);
     else
         ShouldBe(actual, expected, customMessage, StringCompareShould.IgnoreCase);
 }
开发者ID:sholland1,项目名称:shouldly,代码行数:7,代码来源:StringShouldBeTestExtensions.cs

示例15: onCaseClick

    public void onCaseClick(Case c)
    {
        if (c.getUnit () == null)
        {
            Debug.Log (c.posX + " - " + c.posY);
            if (selectedUnit)
            {
                selectedUnit.setSelected (false);
                setSelectedUnit (null);
            }
        }
        else
        {
            if (selectedUnit && selectedUnit != c.getUnit ())
            {
                selectedUnit.setSelected (false);
                c.getUnit ().setSelected (true);
            }
            else if (selectedUnit != c.getUnit ())
            {
                c.getUnit ().setSelected (true);
            }

            setSelectedUnit(c.getUnit ());

            Debug.Log (c.posX + " - " + c.posY + " " + c.getUnit().gameObject.name);
        }
    }
开发者ID:Robien,项目名称:OW,代码行数:28,代码来源:UIManager.cs


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