/// <summary> /// Default ctor /// </summary> protected NestedTypeBuilder(TypeBuilder parent, string parentFullName, ClassFile cf, InnerClass inner) { this.parent = parent; this.parentFullName = parentFullName; this.cf = cf; this.inner = inner; }
/// <summary> /// メソッド例 /// </summary> public void Method() { // this.prop = TestMethod.StaticMethod() prop = StaticMethod(); // this.prop = TestLogic.StaticMethod() prop = TestMethod.StaticMethod(); // this.prop = TestMethod.InnerClass.StaticMethod() prop = InnerClass.StaticMethod(); // this.prop = TestMethod.InnerClass.StaticMethod() prop = TestMethod.InnerClass.StaticMethod(); // this.prop = TestMethod.InnerClass.StaticMethodArg("test") prop = TestMethod.InnerClass.StaticMethodArg("test"); // this.prop = TestMethod.InnerClass.StaticMethodArg(propInt.toString()) prop = TestMethod.InnerClass.StaticMethodArg(propInt.ToString()); // this.prop = OtherClass.StaticMethod() prop = OtherClass.StaticMethod(); // this.prop = OtherClass.InnerClass.StaticMethod() prop = OtherClass.InnerClass.StaticMethod(); // this.prop = OtherClassc.InnerClass.StaticMethodArg("test") prop = OtherClass.InnerClass.StaticMethodArg("test"); // this.prop = OtherClass.InnerClass.StaticMethodArg(propInt.toString()) prop = OtherClass.InnerClass.StaticMethodArg(propInt.ToString()); }
public C01IdentityConversion() { var a1 = new OuterClass <InnerClass>(); var a2 = new InnerClass(); a1.Method(a2); }
static void Main(string[] args) { //DisposClass dis = new DisposClass(); //using (dis) //{ // Console.WriteLine("using block"); //} //Console.WriteLine("outside using block"); using (DisposClass dis = new DisposClass(), dis2 = new DisposClass()) { K.WriteLine("using bloguu"); //dis.Dispose(); } //Point2D p2 = new Point2D(); //Point3D p3 = new Point3D(); NestedNamesoacesExamp nesObj = new NestedNamesoacesExamp(); Namespace3.InnerClass inObj = new Namespace3.InnerClass(); Namespace3.Namespace4.InInnerClass ininnerObj = new Namespace3.Namespace4.InInnerClass(); InnerClass inObgfj = new InnerClass(); //added using NameSpaces2.Namespace3 ; K.ReadKey(); }
internal void Throw() { if (Depth == 0) { throw ExceptionToThrow; } InnerClass inner = new InnerClass(); InnerClass firstInner = inner; for (int i = 1; i < Depth - 1; i++) { inner.Inner = new InnerClass(); inner = inner.Inner; } try { firstInner.Throw(ExceptionToThrow); } catch (Exception ex) { throw new Exception("Wrapped a caught mock exception", ex); } }
/// <summary> /// Should the given class be implemented? /// </summary> protected static bool ShouldImplement(InnerClass inner, TargetFramework target) { if ((target.ImportPublicOnly) && (!(inner.IsPublic || inner.IsProtected))) { return(false); } return(true); }
internal static IEnumerable<NestedTypeBuilder> Create(TypeBuilder parent, string parentFullName, ClassFile cf, InnerClass inner) { if (cf.IsInterface && cf.Fields.Any()) { yield return new NestedInterfaceConstantsTypeBuilder(parent, parentFullName, cf, inner); } yield return new NestedTypeBuilder(parent, parentFullName, cf, inner); }
public void test1() { var innerClass = new InnerClass(); if (innerClass.Equals(IntPtr.Zero)) { Fail(); } }
public object InnerClassDeserializer(IShapeshifterReader reader) { _dataSavedForLaterAccess = new InnerClass() { Value = "OVER" }; return(_dataSavedForLaterAccess); }
public OuterClass() { InnerClass nested = new InnerClass(this); // ошибка компиляции //nested.a = 1; //nested.b = 1; nested.c = 1; }
public void FuncTest() { InnerClass innerClass = new InnerClass() { x = 2 }; InnerFuncTest(innerClass, InnerEnum.E1); }
public static void Main() { InnerClass inner = new InnerClass(); // Get the type of InnerClass. Type innerType = inner.GetType(); // Get the IsSealed property of innerClass. bool isSealed = innerType.IsSealed; Console.WriteLine("{0} is sealed: {1}.", innerType.FullName, isSealed); }
public void test2() { var innerClass = new InnerClass <object>(); object i; var result = innerClass.GetValueNull(out i); AssertNull(i); AssertFalse(result); }
public void CallMethodsThrowsExceptionWithoutArgumentValidation() { var mAct = typeof(InnerClass).GetMethod("Act"); var act = MethodInvokerGenerator.CreateDelegate(mAct, false); var instance = new InnerClass(); Assert.Throws <NullReferenceException>(() => act(null, new object[] { 1 })); Assert.Throws <NullReferenceException>(() => act(instance, null)); Assert.Throws <IndexOutOfRangeException>(() => act(instance, new object[0])); }
public void CallMethodsThrowsExceptionWithArgumentValidation() { var mAct = typeof(InnerClass).GetMethod("Act"); var act = MethodInvokerGenerator.CreateDelegate(mAct); var instance = new InnerClass(); Assert.Throws <ArgumentNullException>(() => act(null, new object[] { 1 })); Assert.Throws <ArgumentNullException>(() => act(instance, null)); Assert.Throws <ArgumentException>(() => act(instance, new object[0])); Assert.Throws <InvalidCastException>(() => act(instance, new object[] { "string" })); }
public new static void ModifierMethod() { Console.WriteLine("ModifierClassDerive"); Console.WriteLine(intPub); Console.WriteLine(intInt); Console.WriteLine(intPro); // protected修饰的成员在派生类可以访问 // Console.WriteLine(intPri); // private修饰的成员在派生类不可以访问 // 调用基类中内部类的public静态方法 InnerClass.InnerMethod(); // protected修饰的内部类在派生类可以访问 }
public bool Equals(InnerClass other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(other.Name, Name)); }
public static void Main() { try { throw new Exception("Stacktrace with 1 frame"); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine("Stacktrace:"); Console.WriteLine(new System.Diagnostics.StackTrace(e)); } Catch(() => { throw new Exception("Stacktrace with 2 frames"); }); Catch(() => ThrowException("Stacktrace with 3 frames", 1)); Catch(() => ThrowException("Stacktrace with 4 frames", 2)); Catch(() => { var message = "Stack frame with method overload using ref parameter"; ThrowException(ref message); }); Catch(() => { int i; ThrowException("Stack frame with method overload using out parameter", out i); }); Catch(() => ThrowExceptionGeneric <double> ("Stack frame with 1 generic parameter")); Catch(() => ThrowExceptionGeneric <double, string> ("Stack frame with 2 generic parameters")); Catch(() => ThrowExceptionGeneric(12)); Catch(() => InnerClass.ThrowException("Stack trace with inner class")); Catch(() => InnerGenericClass <string> .ThrowException("Stack trace with inner generic class")); Catch(() => InnerGenericClass <string> .ThrowException("Stack trace with inner generic class and method generic parameter", "string")); Catch(() => InnerGenericClass <string> .ThrowException <string> ("Stack trace with inner generic class and generic overload", "string")); Catch(() => InnerGenericClass <string> .InnerInnerGenericClass <int> .ThrowException("Stack trace with 2 inner generic class and generic overload")); Catch(() => InnerGenericClass <int> .InnerInnerGenericClass <string> .ThrowException("Stack trace with 2 inner generic class and generic overload")); Catch(() => { var d = new Dictionary <string, string> (); d.ContainsKey(null); // ArgumentNullException }); }
public void TestWoopsaClientSubscriptionDisappearingProperty() { bool isValueChanged = false; MainClass objectServer = new MainClass(); InnerClass inner = new InnerClass(); objectServer.Inner = inner; using (WoopsaServer server = new WoopsaServer(objectServer, TestingPort)) { using (WoopsaClient client = new WoopsaClient(TestingUrl)) { WoopsaBoundClientObject root = client.CreateBoundRoot(); WoopsaObject Inner = root.Items.ByName(nameof(MainClass.Inner)) as WoopsaObject; WoopsaClientProperty propertyInfo = Inner.Properties.ByName(nameof(InnerClass.Info)) as WoopsaClientProperty; WoopsaClientSubscription subscription = propertyInfo.Subscribe( (sender, e) => { isValueChanged = true; }, TimeSpan.FromMilliseconds(10), TimeSpan.FromMilliseconds(20)); inner.Info = "Test"; Stopwatch watch = new Stopwatch(); watch.Start(); while ((!isValueChanged) && (watch.Elapsed < TimeSpan.FromSeconds(20))) { Thread.Sleep(10); } if (isValueChanged) { Console.WriteLine("Notification after {0} ms", watch.Elapsed.TotalMilliseconds); } else { Console.WriteLine("No notification received"); } isValueChanged = false; objectServer.Inner = new BaseInnerClass(); // objectServer.Inner = new object(); while ((!isValueChanged) && (watch.Elapsed < TimeSpan.FromSeconds(20))) { Thread.Sleep(10); } subscription.Unsubscribe(); Assert.AreEqual(true, isValueChanged); } } }
static public void Main() { OuterClass oc = new OuterClass(); InnerClass ic = new InnerClass(oc); oc.show_oc_i1(); ic.change_OC_I1(10); oc.show_oc_i1(); ic.change_OC_I1(20); oc.show_oc_i1(); ic.change_OC_I1(30); oc.show_oc_i1(); ic.change_OC_I1(40); oc.show_oc_i1(); }
protected override void Read(uint Length, System.IO.BinaryReader Reader, ConstantPool Pool) { ushort Count = Reader.ReadUInt16BE(); for (int i = 0; i < Count; i++) { InnerClass Class = new InnerClass(); ushort InnerClassInfoIndex = Reader.ReadUInt16BE(); ushort OuterClassInfoIndex = Reader.ReadUInt16BE(); ushort InnerNameIndex = Reader.ReadUInt16BE(); Class.InnerClassInfo = InnerClassInfoIndex != 0 ? ((Constants.Class)Pool[InnerClassInfoIndex]).Value : null; Class.OuterClassInfo = OuterClassInfoIndex != 0 ? ((Constants.Class)Pool[OuterClassInfoIndex]).Value : null; Class.InnerName = InnerNameIndex != 0 ? ((Constants.Utf8)Pool[InnerNameIndex]).Value : null; Class.AccessFlags = (InnerClassAccessFlags)Reader.ReadUInt16BE(); Classes.Add(Class); } }
public void SmokeSerialization() { var oldContext = new MsgPackContext(); oldContext.RegisterConverter(new InnerClassConverter()); var newContext = new MsgPackContext(); newContext.DiscoverConverters <InnerClass>(); var s = Guid.NewGuid().ToString("B"); var expected = new InnerClass { B = s }; MsgPackSerializer.Serialize(expected, newContext).ShouldBe(MsgPackSerializer.Serialize(expected, oldContext)); MsgPackSerializer.Deserialize <InnerClass>(MsgPackSerializer.Serialize(expected, oldContext), newContext).B.ShouldBe(s); MsgPackSerializer.Deserialize <InnerClass>(MsgPackSerializer.Serialize(expected, newContext), oldContext).B.ShouldBe(s); }
public DictSettingResponse MapDictionarySetting(AppSettings appSettings) { var result = new DictSettingResponse() { DictionaryValues = new Dictionary <string, InnerClass>() }; foreach (var dictEntry in appSettings.DictionarySettings) { var value = new InnerClass() { IsEnabled = dictEntry.Value.IsEnabled, Name = dictEntry.Value.Name }; result.DictionaryValues.Add(dictEntry.Key, value); } return(result); }
void ParseInnerClasses(InnerClass[] classes, string enclosingClass) { int parentIndex = -1; int childCount = 0; for (int i = 0; i < classes.Length; i++) { if (classes[i].InnerLongName == Name) { parentIndex = i; if (classes[i].OuterLongName == null) { classes[i].OuterLongName = enclosingClass; } } else if (classes[i].OuterLongName == Name || classes[i].OuterLongName == null) { childCount++; } } if (parentIndex != -1 || childCount != 0) { OuterAndInnerClasses = new InnerClass[1 + childCount]; int j = 1; for (int i = 0; i < classes.Length; i++) { if (i == parentIndex) { OuterAndInnerClasses[0] = classes[i]; } else if (classes[i].OuterLongName == Name || classes[i].OuterLongName == null) { OuterAndInnerClasses[j++] = classes[i]; } } } }
public static void Main() { try { throw new Exception("Stacktrace with 1 frame"); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine("Stacktrace:"); Console.WriteLine(new System.Diagnostics.StackTrace(e)); } Catch(() => { throw new Exception("Stacktrace with 2 frames"); }); Catch(() => ThrowException("Stacktrace with 3 frames", 1)); Catch(() => ThrowException("Stacktrace with 4 frames", 2)); Catch(() => { var message = "Stack frame with method overload using ref parameter"; ThrowException(ref message); }); Catch(() => { int i; ThrowException("Stack frame with method overload using out parameter", out i); }); Catch(() => ThrowExceptionGeneric <double> ("Stack frame with 1 generic parameter")); Catch(() => ThrowExceptionGeneric <double, string> ("Stack frame with 2 generic parameters")); Catch(() => ThrowExceptionGeneric(12)); Catch(() => InnerClass.ThrowException("Stack trace with inner class")); Catch(() => InnerGenericClass <string> .ThrowException("Stack trace with inner generic class")); Catch(() => InnerGenericClass <string> .ThrowException("Stack trace with inner generic class and method generic parameter", "string")); Catch(() => InnerGenericClass <string> .ThrowException <string> ("Stack trace with inner generic class and generic overload", "string")); Catch(() => InnerGenericClass <string> .InnerInnerGenericClass <int> .ThrowException("Stack trace with 2 inner generic class and generic overload")); Catch(() => InnerGenericClass <int> .InnerInnerGenericClass <string> .ThrowException("Stack trace with 2 inner generic class and generic overload")); Catch(() => InnerGenericClass <int> .ThrowException("Stack trace with nested type argument", "string", null)); Catch(() => { var d = new Dictionary <string, string> (); d.ContainsKey(null); // ArgumentNullException }); /* * The following test include ambiguous methods we can't resolve. Testing this is hard, so I'm leaving a test behind but disabling it for the time being * In this case the ambiguous methods are: * public static void Foo<K> (int a, bool hard_crash, GenClass<T> arg, List<int> zz) * public static void Foo<K> (int a, bool hard_crash, GenClass<T> arg, List<double> zz) * * The are ambiguous because the only difference is the instantiation on the last parameter which we can't * figure out from a stacktrace. */ //Catch (() => ComplicatedTestCase.Run ()); }
public override void Load(string s, string path) { try{ // NOT USE LINQ using(StringReader sr = new StringReader(s)){ string line; bool param_start = false; List<InnerClass> temp = new List<InnerClass>(); while( (line = sr.ReadLine()) != null ){ string[] element = line.Split(','); if( param_start == false ){ if( element[0] == "Type" ){ param_start = true; continue; } } InnerClass param = new InnerClass(); param.SoundType = (SOUND_TYPE)Enum.Parse(typeof(SOUND_TYPE), element[0]); param.SoundKey = element[1]; param.AssetPath = element[2]; float volume; if( float.TryParse(element[3], out volume) ){ param.Volume = volume; } temp.Add(param); } m_Param = new InnerClass[temp.Count]; temp.CopyTo(m_Param); } /* // USE LINQ MODE IEnumerable<string> lines = s.Split('\r'); IEnumerable<InnerClass> _params = from line in lines let elements = line.Split(',') let hp = int.Parse(elements[1]) let attack = int.Parse(elements[0]) let speed = int.Parse(elements[2]) let next_lv = int.Parse(elements[3]) select new InnerClass(attack, hp, speed, next_lv); lv_param = new List<InnerClass>(_params); */ } catch(System.Exception err){ Debug.Log(err.Message); throw new System.Exception(); } }
public OuterClass() { foo = new InnerClass() }
public static bool testMethod() { return(InnerClass.testMethod()); }
internal static IEnumerable <NestedTypeBuilder> Create(TypeBuilder parent, string parentFullName, ClassFile cf, InnerClass inner) { if (cf.IsInterface && cf.Fields.Any()) { yield return(new NestedInterfaceConstantsTypeBuilder(parent, parentFullName, cf, inner)); } yield return(new NestedTypeBuilder(parent, parentFullName, cf, inner)); }
public override CompileAttribute Read(EndianBinaryReader reader, List<CompileConstant> constants, int length) { Classes = new List<InnerClass>(); short classCount = reader.ReadInt16(); for (int i = 0; i < classCount; i++) { var c = new InnerClass(); c.InnerClassInfo = reader.ReadInt16(); c.OuterClassInfo = reader.ReadInt16(); c.InnerName = reader.ReadInt16(); c.InnerModifier = (Modifier)reader.ReadInt16(); Classes.Add(c); } return this; }
public InnerTest2(InnerClass c) { C = c; }
OuterClass() { InnerClass Test = new InnerClass(); }
static void Main(string[] args) { OuterClass TestOne = new OuterClass(); InnerClass TestTwo = new InnerClass(); // does not compile }
public DemoClass() { // note usage of plain "this". _innerClass = new InnerClass(this); }
public void TestWoopsaClientSubscriptionDisappearingProperty() { bool isValueChanged = false; MainClass objectServer = new MainClass(); InnerClass inner = new InnerClass(); objectServer.Inner = inner; using (WoopsaServer server = new WoopsaServer(objectServer)) { using (WoopsaClient client = new WoopsaClient("http://localhost/woopsa")) { WoopsaBoundClientObject root = client.CreateBoundRoot(); WoopsaObject Inner = root.Items.ByName(nameof(MainClass.Inner)) as WoopsaObject; WoopsaClientProperty propertyInfo = Inner.Properties.ByName(nameof(InnerClass.Info)) as WoopsaClientProperty; WoopsaClientSubscription subscription = propertyInfo.Subscribe( (sender, e) => { isValueChanged = true; }, TimeSpan.FromMilliseconds(10), TimeSpan.FromMilliseconds(20)); inner.Info = "Test"; Stopwatch watch = new Stopwatch(); watch.Start(); while ((!isValueChanged) && (watch.Elapsed < TimeSpan.FromSeconds(20))) Thread.Sleep(10); if (isValueChanged) Console.WriteLine("Notification after {0} ms", watch.Elapsed.TotalMilliseconds); else Console.WriteLine("No notification received"); isValueChanged = false; objectServer.Inner = new BaseInnerClass(); // objectServer.Inner = new object(); while ((!isValueChanged) && (watch.Elapsed < TimeSpan.FromSeconds(20))) Thread.Sleep(10); subscription.Unsubscribe(); Assert.AreEqual(true, isValueChanged); } } }
// Import Message Asset /* public override void Load(string s, string path) { string text_asset = ""; if( File.Exists(path) ){ bool isRead = false; int encoding_index = 0; int[] encodings = { 932, // Shit-JIS 1200, // utf-16 65001, // utf-8 }; do{ // Shift-JIS using( StreamReader sr = new StreamReader(path, Encoding.GetEncoding(encodings[encoding_index])) ){ text_asset = sr.ReadToEnd(); } if( text_asset.Substring(0, ClassListImporterUtil.KEY_WORD.Length) == ClassListImporterUtil.KEY_WORD ){ isRead = true; } if( isRead == false ){ ++encoding_index; if( encoding_index >= encodings.Length ){ //EditorUtility.DisplayDialog("Import Error", ClassListImporterUtil.KEY_WORD + " is Not Found", "OK"); return; } } }while(isRead == false); } } */ public override void Load(string s, string path) { try{ // NOT USE LINQ using(StringReader sr = new StringReader(s)){ string line; bool param_start = false; List<InnerClass> temp = new List<InnerClass>(); while( (line = sr.ReadLine()) != null ){ string[] element = line.Split(','); if( param_start == false ){ if( element[0] == "Map" ){ param_start = true; continue; } } //System.Text.Encoding.GetEncoding(932).GetString(bytesData) InnerClass param = new InnerClass(); //byte[] tempa = Encoding.GetEncoding(932).GetBytes(element[0]); //element[0] = param.ClassName = element[0]; param.Score = int.Parse(element[1]); temp.Add(param); } m_Param = new InnerClass[temp.Count]; temp.CopyTo(m_Param); } } catch(System.Exception err){ Debug.Log(err.Message); throw new System.Exception(); } }
/// <summary> /// A method referencing a inner class /// </summary> /// <param name="name">The name</param> /// <param name="inner">A inner class with type <seealso cref="InnerClass"/></param> public void SetInnerClass(string name, InnerClass inner) { inner.Name = name; _class = inner; }
public OuterClass(InnerClass innerClass) { this.innerClass = innerClass; }
public static void Main() { var newInnerClass = new InnerClass(); InnerClass.printVariable(true); }
public static void Main() { InnerClass instanceOfInnerClass = new InnerClass(); instanceOfInnerClass.LogBoolToTheConsole(true); }
/// <summary> /// Default ctor /// </summary> public NestedInterfaceConstantsTypeBuilder(TypeBuilder parent, string parentFullName, ClassFile cf, InnerClass inner) : base(parent, parentFullName, cf, inner) { }
public void TestMatchWhenContractIsDifferent() { var testStruct = new TestStruct { IntData = 42, StringData = "hooray", DecimalData = 5.0000000m, InnerData = new InnerStruct { IntData = 777, StringData = "string string string" } }; var testClass = new InnerClass { IntData = 42, StringData = "hooray" }; Assert.IsFalse(DataContractMatcher.AreEquivalent(testStruct, testClass)); }