本文整理汇总了C#中model.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# model.GetType方法的具体用法?C# model.GetType怎么用?C# model.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BoatMenu
public int BoatMenu(model.Boat a_boat)
{
Console.Clear();
Console.WriteLine("");
Console.WriteLine("-----Boat specifics-----");
Console.WriteLine("Type: {0}", a_boat.GetType());
Console.WriteLine("Length: {0}", a_boat.GetLength());
Console.WriteLine("");
Console.WriteLine("---------------");
Console.WriteLine("");
Console.WriteLine("(D) to Delete boat (U) to Update boat");
ConsoleKeyInfo input = Console.ReadKey();
if (input.Key == ConsoleKey.D)
{
return 1;
}
else if (input.Key == ConsoleKey.U)
{
return 2;
}
else return 0; //returnera nåt annat
}
示例2: DeleteBoat
public model.Boat DeleteBoat(model.Boat a_selectedBoat, model.Member a_selectedMember)
{
Console.Clear();
Console.WriteLine("");
Console.WriteLine("-----Delete boat from registry-----");
Console.WriteLine("Do you want to DELETE the following boat?");
Console.WriteLine("Owner:{0} {1}", a_selectedMember.GetFirstName(), a_selectedMember.GetLastName());
Console.WriteLine("Type: {0}", a_selectedBoat.GetType());
Console.WriteLine("Length: {0}", a_selectedBoat.GetLength());
Console.WriteLine("");
Console.WriteLine("Please press (Y) Yes or (N) No");
ConsoleKeyInfo input = Console.ReadKey();
if (input.Key == ConsoleKey.Y)
{
return a_selectedBoat;
}
else
{
return null;
}
}
示例3: UpdateBoat
public model.Boat UpdateBoat(model.Boat a_selectedBoat)
{
int boatType;
double length;
Console.Clear();
Console.WriteLine("");
Console.WriteLine("-----Update boat information-----");
Console.WriteLine("");
Console.WriteLine("Type: {0}", a_selectedBoat.GetType());
Console.WriteLine("Length: {0}", a_selectedBoat.GetLength());
Console.WriteLine("**********");
Console.WriteLine("Please change the information by entering below:");
Console.WriteLine("");
Console.WriteLine("Boat type: ");
Console.WriteLine("Please enter (1)Sailboat, (2)Motorsailer, (3)Motorboat, (4)Canoe, (5)Other ");
boatType = Int32.Parse(Console.ReadLine());
Console.WriteLine("Length in foot: ");
length = double.Parse(Console.ReadLine());
Console.WriteLine("");
Console.WriteLine("Boat information updated!");
model.Boat.BoatType type = (model.Boat.BoatType)boatType;
return new model.Boat(type, length);
}
示例4: numStandardComponents
private static int numStandardComponents(model.Type t)
{
int n = 0;
if (typeof(Varies).IsAssignableFrom(t.GetType()))
{
n = numStandardComponents(((Varies) t).Data);
}
else if (typeof(Composite).IsAssignableFrom(t.GetType()))
{
n = ((Composite) t).Components.Length;
}
else
{
n = 1;
}
return n;
}
示例5: getPrimitive
/// <summary> Attempts to extract a Primitive from the given type. If it's a composite,
/// drills down through first components until a primitive is reached.
/// </summary>
private static Primitive getPrimitive(model.Type type)
{
Primitive p = null;
if (typeof(Varies).IsAssignableFrom(type.GetType()))
{
p = getPrimitive(((Varies) type).Data);
}
else if (typeof(Composite).IsAssignableFrom(type.GetType()))
{
try
{
p = getPrimitive(((Composite) type).getComponent(0));
}
catch (HL7Exception)
{
throw new System.ApplicationException("Internal error: HL7Exception thrown on Composite.getComponent(0).");
}
}
else if (type is Primitive)
{
p = (Primitive) type;
}
return p;
}
示例6: getComponent
/// <summary> Returns the component (or sub-component, as the case may be) at the given
/// index. If it does not exist, it is added as an "extra component".
/// If comp > 1 is requested from a Varies with GenericPrimitive data, the
/// data is set to GenericComposite (this avoids the creation of a chain of
/// ExtraComponents on GenericPrimitives).
/// Components are numbered from 1.
/// </summary>
private static ca.uhn.hl7v2.model.Type getComponent(model.Type type, int comp)
{
model.Type ret = null;
if (typeof(Varies).IsAssignableFrom(type.GetType()))
{
Varies v = (Varies) type;
try
{
if (comp > 1 && typeof(GenericPrimitive).IsAssignableFrom(v.Data.GetType()))
v.Data = new GenericComposite(v.Message);
}
catch (DataTypeException de)
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
System.String message = "Unexpected exception copying data to generic composite: " + de.Message;
log.error(message, de);
throw new System.ApplicationException(message);
}
ret = getComponent(v.Data, comp);
}
else
{
if (typeof(Primitive).IsAssignableFrom(type.GetType()) && comp == 1)
{
ret = type;
}
else if (typeof(GenericComposite).IsAssignableFrom(type.GetType()) || (typeof(Composite).IsAssignableFrom(type.GetType()) && comp <= numStandardComponents(type)))
{
//note that GenericComposite can return components > number of standard components
try
{
ret = ((Composite) type).getComponent(comp - 1);
}
catch (System.Exception e)
{
//TODO: This may not be the write exception type: Error() was originally thrown, but was not in project.
throw new ApplicationException("Internal error: HL7Exception thrown on getComponent(x) where x < # standard components.", e);
}
}
else
{
ret = type.ExtraComponents.getComponent(comp - numStandardComponents(type) - 1);
}
}
return ret;
}
示例7: numComponents
/// <summary> Returns the number of components in the given field, i.e. the
/// number of standard components (e.g. 6 for CE) plus any extra components that
/// have been added at runtime. This may vary by repetition, as different reps
/// may have different extra components.
/// </summary>
/*public static int numComponents(Type field) throws HL7Exception {
return numComponents(seg.getField(field, rep));
}*/
/// <summary> Returns the number of sub-components in the specified component, i.e.
/// the number of standard sub-components (e.g. 6 for CE) plus any extra components that
/// that have been added at runtime.
/// </summary>
/// <param name="component">numbered from 1
/// </param>
public static int numSubComponents(model.Type type, int component)
{
int n = - 1;
if (component == 1 && typeof(Primitive).IsAssignableFrom(type.GetType()))
{
//note that getComponent(primitive, 1) below returns the primitive
//itself -- if we do numComponents on it, we'll end up with the
//number of components in the field, not the number of subcomponents
n = 1;
}
else
{
model.Type comp = getComponent(type, component);
n = numComponents(comp);
}
return n;
/*
//Type t = seg.getField(field, rep);
if (Varies.class.isAssignableFrom(type.getClass())) {
return numSubComponents(((Varies) type).getData(), component);
} else if (Primitive.class.isAssignableFrom(type.getClass()) && component == 1) {
n = 1;
} else if (Composite.class.isAssignableFrom(type.getClass()) && component <= numStandardComponents(t)) {
n = numComponents(((Composite) type).getComponent(component - 1));
} else { //we're being asked about subcomponents of an extra component
n = numComponents(t.getExtraComponents().getComponent(component - numStandardComponents(t) - 1));
}
return n;
*/
}