private static void CreateClassMembers(IClass t, IGenerator g) { var wrapped = t.Field(_interface, _wrappedFieldName); var ctor = t.Constructor(g.Arg <IIndexerProperty>("wrapped")).Public; using (var c = ctor.Code()) { c.Assign(wrapped, ctor.Args[0]); } var indexerProperty = t.Indexer(typeof(long), g.Arg <int>("i"), g.Arg <string>("s")).Public; var getter = indexerProperty.Getter(); using (var c = getter.Code()) { c.Return(wrapped.Indexer(getter.Args[0], getter.Args[1])); } var setter = indexerProperty.Setter(); using (var c = setter.Code()) { c.Assign(wrapped.Indexer(setter.Args[0], setter.Args[1]), setter.Value); } }
private void ImplConstructor() { // public ProxyIValueObject(IValueObject target) var ctor = _proxy.Constructor(g.Arg(_interfaceType, "target")).Public; using (var c = ctor.Code()) { // _target = target; c.Assign(_target, ctor.Args[0]); } }
private static void CreateClassMembers(IClass t, IGenerator g) { var wrapped = t.Field(_interface, _wrappedFieldName); var ctor = t.Constructor(g.Arg <IReadWriteProperty>("wrapped")).Public; using (var c = ctor.Code()) { c.Assign(wrapped, ctor.Args[0]); } var readWriteProperty = t.Property(typeof(int), _propertyName).Public; var getter = readWriteProperty.Getter(); using (var c = getter.Code()) { c.Return(wrapped.Property(_propertyName)); } var setter = readWriteProperty.Setter(); using (var c = setter.Code()) { c.Assign(wrapped.Property(_propertyName), setter.Value); } }
private void CreateClassMembers(IClass c) { var wrapped = c.Field(_interface, _wrappedFieldName); var ctor = c.Constructor(_g.Arg <IOutParamMethod>("wrapped")).Public; using (var code = ctor.Code()) { code.Assign(wrapped, ctor.Args[0]); } var simpleMethod = c.Method(_methodName, _g.ArgOut <int>("i")).Public; using (var code = simpleMethod.Code()) { var result = wrapped.Invoke(_methodName, simpleMethod.Args[0]); code.Return(result); } }
private IClass DefineWrapper() { IClass c = _g.Class("HodgepodgeWrapper").In(_namespace).Implements(_interface); { var wrapped = c.Field(_interface, _wrappedFieldName); var ctor = c.Constructor(_g.Arg <IHodgepodge>("wrapped")).Public; using (var c1 = ctor.Code()) { c1.Assign(wrapped, ctor.Args[0]); } foreach (MemberInfo info in _interface.GetMembers(BindingFlags.Public | BindingFlags.Instance)) { switch (info.MemberType) { case MemberTypes.Method: MethodInfo mi = (MethodInfo)info; if (!mi.IsSpecialName) { WrapMethod(c, wrapped, mi); } break; case MemberTypes.Property: PropertyInfo pi = (PropertyInfo)info; WrapProperty(c, wrapped, pi); break; default: Console.WriteLine(info + " : " + info.MemberType); break; } } } return(c); }