本文整理汇总了C#中Derived类的典型用法代码示例。如果您正苦于以下问题:C# Derived类的具体用法?C# Derived怎么用?C# Derived使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Derived类属于命名空间,在下文中一共展示了Derived类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshingEntityDerivedFromAbstractClass
public void RefreshingEntityDerivedFromAbstractClass()
{
using (var store = NewDocumentStore())
{
using (var session = store.OpenSession())
{
var d = new Derived();
session.Store(d);
session.SaveChanges();
using (var seperateSession = store.OpenSession())
{
var loaded = seperateSession.Load<Derived>(d.Id);
Assert.NotNull(loaded);
Assert.Empty(loaded.Foos);
loaded.AddFoo(new Foo() { Name = "a" });
seperateSession.SaveChanges();
}
session.Advanced.Refresh(d);
Assert.Single(d.Foos);
}
}
}
示例2: Run
public void Run()
{
// Array Covariance
// http://msdn.microsoft.com/en-us/library/aa664572(v=vs.71).aspx
/*
* For any two reference-types A and B, if an implicit reference conversion (Section 6.1.4) or explicit reference conversion (Section 6.2.3)
* exists from A to B, then the same reference conversion also exists from the array type A[R] to the array type B[R],
* where R is any given rank-specifier (but the same for both array types).
* This relationship is known as array covariance.
* Array covariance in particular means that a value of an array type A[R] may actually be a reference to an instance of an array type B[R],
* provided an implicit reference conversion exists from B to A.
*
* Because of array covariance, assignments to elements of reference type arrays include a run-time check that ensures that the value
* being assigned to the array element is actually of a permitted type (Section 7.13.1).
* */
Base[] baseArray = new Base[1];
Derived[] derivedArray = new Derived[] { new Derived() };
// array element assignment is covariant
baseArray[0] = new Derived();
baseArray[0] = new OtherDerived();
// This assignment is not type safe but it is allowed
baseArray = derivedArray;
baseArray[0] = new Derived();
// ArrayTypeMismatchException at RUNTIME
baseArray[0] = new OtherDerived();
populate(derivedArray);
}
示例3: DoIt
public void DoIt()
{
var stringArray1 = new string[] {"A", "B", "C"};
Array.Reverse(stringArray1);
string[] stringArray2 = {"Hello", "World"};
Array.Sort(stringArray2);
var r = stringArray2.Concat(stringArray1);
foreach(var i in r)
{
Console.Out.WriteLine(">>> " + i);
}
var d = new Derived();
Console.Out.WriteLine("Value: " + d.Value);
var list = new List<string>
{
"ghi",
"abc",
"rhj"
};
list.Sort((s, s1) => string.Compare(s, s1) * -1);
foreach (var i in list)
{
Console.Out.WriteLine("> " + i);
}
}
示例4: Main
public static void Main ()
{
//Base[] derivedArray = new Base [10];
//Base[] baseArray = new Derived [10];
Derived[] derivedArray = new Derived [10];
test (derivedArray);
}
示例5: Main
static void Main()
{
Base B = new Base();
Derived D = new Derived();
B.Message();
D.Message();
}
示例6: Run
public void Run()
{
var b = new Base();
b.Execute();
b = new Derived();
b.Execute();
}
示例7: DemoVanInterface
public void DemoVanInterface()
{
IBankAccount account = new Derived();
account.Withdraw(10m);
Console.WriteLine($"Balance: {((Base)account).Balance}");
}
示例8: Main
public static void Main(string[] args)
{
var br = new BaseResult();
var dr = new DerivedResult();
var bas = new Base();
var derived = new Derived();
bas.Method();
bas.MethodWithParameter1(br);
bas.MethodWithParameter1(dr);
bas.MethodWithParameter2(dr);
bas = derived;
bas.Method();
bas.MethodWithParameter1(br);
bas.MethodWithParameter1(dr);
bas.MethodWithParameter2(dr);
derived.Method();
derived.MethodWithParameter1(br);
derived.MethodWithParameter1(dr);
derived.MethodWithParameter2(br);
derived.MethodWithParameter2(dr);
}
示例9: Main
static void Main()
{
var b = new Base("A");
var d = new Derived("B", "C");
TestLogger.Log("Static method calls...");
TestLogger.Log(Base.S("D")); // "DBS"
TestLogger.Log(Derived.S("E")); // "EDS"
TestLogger.Log("Instance method calls...");
TestLogger.Log(b.I("F")); // "AFBI";
TestLogger.Log(d.I("G")); // "BCGDI";
TestLogger.Log("Virtual method calls...");
TestLogger.Log(b.V("H")); // "AHBV";
TestLogger.Log(((Base)d).V("I")); // "BCIDV";
TestLogger.Log("Interface method calls...");
TestLogger.Log(((IMN)b).M("J")); // "AJBM";
TestLogger.Log(((IMN)d).M("K")); // "BCKDM";
TestLogger.Log(((IOP)b).O("L")); // "ALBO";
TestLogger.Log(((IOP)d).O("M")); // "BMBO";
TestLogger.Log("Virtual interface method calls...");
TestLogger.Log(((IMN)b).N("N")); // "ANBN";
TestLogger.Log(((IMN)d).N("O")); // "BCODN";
TestLogger.Log(((IOP)b).P("P")); // "APBP";
TestLogger.Log(((IOP)d).P("Q")); // "BCQDP";
}
示例10: run
void run()
{
if (director_primitives.PrintDebug) Console.WriteLine("------------ Start ------------ ");
Caller myCaller = new Caller();
// test C++ base class
using (Base myBase = new Base(100.0))
{
makeCalls(myCaller, myBase);
}
if (director_primitives.PrintDebug) Console.WriteLine("--------------------------------");
// test vanilla C++ wrapped derived class
using (Base myBase = new Derived(200.0))
{
makeCalls(myCaller, myBase);
}
if (director_primitives.PrintDebug) Console.WriteLine("--------------------------------");
// test director / C# derived class
using (Base myBase = new CSharpDerived(300.0))
{
makeCalls(myCaller, myBase);
}
if (director_primitives.PrintDebug) Console.WriteLine("------------ Finish ------------ ");
}
示例11: Execute
public void Execute()
{
var assembly = Assembly.LoadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "protobuf-net.dll"));
var derived = new Derived()
{
BaseFirstProperty = "BaseFirst",
BaseSecProperty = "BaseSec",
DerivedFirstProperty = "DerivedFirst"
};
var reflectionSerializer = assembly.GetType("ProtoBuf.Serializer");
var getTypeSerializer = typeof(Serializer);
var reflectionMethods = reflectionSerializer.GetMethods(BindingFlags.Static | BindingFlags.Public);
var reflectionGenericMethodInfo = reflectionMethods.First<MethodInfo>(method => method.Name == "SerializeWithLengthPrefix");
var reflectionSpecificMethodInfo = reflectionGenericMethodInfo.MakeGenericMethod(new Type[] { derived.GetType() });
var getTypeMethods = getTypeSerializer.GetMethods(BindingFlags.Static | BindingFlags.Public);
var getTypeGenericMethodInfo = getTypeMethods.First<MethodInfo>(method => method.Name == "SerializeWithLengthPrefix");
var getTypeSpecificMethodInfo = getTypeGenericMethodInfo.MakeGenericMethod(new Type[] { derived.GetType() });
var reflectionStream = new MemoryStream();
var getTypeStream = new MemoryStream();
reflectionSpecificMethodInfo.Invoke(null, new object[] { reflectionStream, derived, PrefixStyle.Base128 });
getTypeSpecificMethodInfo.Invoke(null, new object[] { getTypeStream, derived, PrefixStyle.Base128 });
Assert.AreEqual(37, (int)reflectionStream.Length, "loaded dynamically");
Assert.AreEqual(37, (int)getTypeStream.Length, "loaded statically");
}
示例12: MainMethod
public static int MainMethod(string[] args)
{
dynamic d = new Derived();
short x = d;
if (x == short.MaxValue)
return 0;
return 1;
}
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:8,代码来源:Conformance.dynamic.overloadResolution.Operators.2class2operators.conversion.cs
示例13: Given
protected override void Given()
{
_result = new Derived();
_calculation = new Calculation(new Variable("Grasp", "Output", typeof(Base)), Expression.Constant(_result));
_schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { _calculation });
}
示例14: Main
static void Main()
{
Base B = new Base();
Derived D = new Derived();
B.a = 1234;
D.a = 5.678;
Console.WriteLine(B.a);
Console.WriteLine(D.a);
}
示例15: Factory
void Factory(out Base b)
{
// covariant assignment
if (DateTime.Now.Year > 2013) {
b = new Derived();
} else {
b = new OtherDerived();
}
}