本文整理汇总了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--;
}
}
示例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();
}
示例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();
}
示例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("}");
}
}
示例5: Create_Case
public Create_Case(Case incomingCase, string _formEditMode)
{
InitializeComponent();
formEditMode = _formEditMode;
NewCase = incomingCase;
}
示例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'.
}
示例7: PersonalPronoun
private PersonalPronoun(Case personalPronounCase, Number number, Person person, string name)
{
_case = personalPronounCase;
_number = number;
_person = person;
_name = name;
}
示例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();
}
示例9: APISpecExample
public APISpecExample()
{
Contract.Ensures(State == Case.A);
_case = Case.A;
}
示例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();
}
示例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();
}
示例12: CaseDetailWindow
public CaseDetailWindow (Case c, Gtk.Window parent) :
base(Gtk.WindowType.Toplevel)
{
this.Build ();
case_show.Case = c;
case_show.HideEditingButtons ();
}
示例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);
}
}
}
示例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);
}
示例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);
}
}