private ProxyGenerator(string rootOfClasses, DynaType type, bool persist)
 {
     Type            = type;
     rootOfGenerated = RootOfGeneratedSources(type);
     this.persist    = persist;
     targetClassPath = new FileInfo(rootOfClasses);
 }
Ejemplo n.º 2
0
        protected DynaUIText(Section_AHDR AHDR, DynaType type, Game game, Endianness endianness) : base(AHDR, type, game, endianness)
        {
            using (var reader = new EndianBinaryReader(AHDR.data, endianness))
            {
                reader.BaseStream.Position = dynaUIEnd;

                Text_AssetID       = reader.ReadUInt32();
                font               = reader.ReadByte();
                fontSizeW          = reader.ReadByte();
                fontSizeH          = reader.ReadByte();
                fontSpacingX       = reader.ReadByte();
                fontSpacingY       = reader.ReadByte();
                textBoxInsetTop    = reader.ReadByte();
                textBoxInsetLeft   = reader.ReadByte();
                textBoxInsetRight  = reader.ReadByte();
                textBoxInsetBottom = reader.ReadByte();
                justifyX           = reader.ReadByte();
                justifyY           = reader.ReadByte();
                textFlags          = reader.ReadByte();
                ShadowColor        = reader.ReadColor();
                shadowOffsetX      = reader.ReadSingle();
                shadowOffsetY      = reader.ReadSingle();
                shadowScaleX       = reader.ReadSingle();
                shadowScaleY       = reader.ReadSingle();
            }
        }
Ejemplo n.º 3
0
 public static ProxyGenerator ForClasPath(
     IList <FileInfo> classPath,
     DirectoryInfo destinationDirectory,
     DynaType type,
     bool persist,
     ILogger logger)
 => new ProxyGenerator(classPath, destinationDirectory, type, persist, logger);
Ejemplo n.º 4
0
 private ProxyGenerator(IList <FileInfo> rootOfClasses, DirectoryInfo rootOfGenerated, DynaType type, bool persist, ILogger logger)
 {
     this.rootOfGenerated = rootOfGenerated;
     Type         = type;
     this.persist = persist;
     this.logger  = logger;
 }
Ejemplo n.º 5
0
        public DynaUI(Section_AHDR AHDR, DynaType type, Game game, Endianness endianness) : base(AHDR, type, game, endianness)
        {
            using (var reader = new EndianBinaryReader(AHDR.data, endianness))
            {
                reader.BaseStream.Position = dynaDataStartPosition;

                PositionX                   = reader.ReadSingle();
                PositionY                   = reader.ReadSingle();
                PositionZ                   = reader.ReadSingle();
                Width                       = reader.ReadSingle();
                Height                      = reader.ReadSingle();
                Flags.FlagValueInt          = reader.ReadUInt32();
                Color                       = reader.ReadColor();
                UIMotion_Selected_AssetID   = reader.ReadUInt32();
                UIMotion_Unselected_AssetID = reader.ReadUInt32();
                Brightness                  = reader.ReadByte();
                reader.ReadByte();
                reader.ReadByte();
                reader.ReadByte();
                autoMenuUp    = reader.ReadUInt32();
                autoMenuDown  = reader.ReadUInt32();
                autoMenuLeft  = reader.ReadUInt32();
                autoMenuRight = reader.ReadUInt32();
                custom        = reader.ReadUInt32();
                customWidget  = reader.ReadUInt32();
            }
        }
Ejemplo n.º 6
0
 private ResourceDispatcherGenerator(IList <Action> actions, FileInfo rootOfClasses, DirectoryInfo rootOfGenerated, DynaType type, bool persist, ILogger logger)
 {
     _actions         = actions;
     _rootOfClasses   = rootOfClasses;
     _rootOfGenerated = rootOfGenerated;
     Type             = type;
     _persist         = persist;
     _logger          = logger;
 }
Ejemplo n.º 7
0
        public DynaHud(Section_AHDR AHDR, DynaType type, Game game, Endianness endianness) : base(AHDR, type, game, endianness)
        {
            using (var reader = new EndianBinaryReader(AHDR.data, endianness))
            {
                reader.BaseStream.Position = dynaDataStartPosition;

                PositionX = reader.ReadSingle();
                PositionY = reader.ReadSingle();
                PositionZ = reader.ReadSingle();
                ScaleX    = reader.ReadSingle();
                ScaleY    = reader.ReadSingle();
                ScaleZ    = reader.ReadSingle();
            }
        }
Ejemplo n.º 8
0
        public DynaHudMeter(Section_AHDR AHDR, DynaType type, Game game, Endianness endianness) : base(AHDR, type, game, endianness)
        {
            using (var reader = new EndianBinaryReader(AHDR.data, endianness))
            {
                reader.BaseStream.Position = dynaHudEnd;

                StartValue    = reader.ReadSingle();
                MinValue      = reader.ReadSingle();
                MaxValue      = reader.ReadSingle();
                IncrementTime = reader.ReadSingle();
                DecrementTime = reader.ReadSingle();
                StartIncrement_SoundAssetID = reader.ReadUInt32();
                Increment_SoundAssetID      = reader.ReadUInt32();
                StartDecrement_SoundAssetID = reader.ReadUInt32();
                Decrement_SoundAssetID      = reader.ReadUInt32();
            }
        }
Ejemplo n.º 9
0
 public Input(
     Type protocol,
     string fullyQualifiedClassName,
     string source,
     FileInfo sourceFile,
     DynaClassLoader classLoader,
     DynaType type,
     bool persist)
 {
     Protocol = protocol;
     FullyQualifiedClassName = fullyQualifiedClassName;
     Source      = source;
     SourceFile  = sourceFile;
     ClassLoader = classLoader;
     Type        = type;
     Persist     = persist;
 }
 private static string RootOfGeneratedSources(DynaType type)
 => type == DynaType.Main ?
 Properties.Instance.GetProperty("proxy.generated.sources.main", GeneratedSources) :
 Properties.Instance.GetProperty("proxy.generated.sources.test", GeneratedTestSources);
Ejemplo n.º 11
0
 private static DirectoryInfo RootOfGeneratedSources(DynaType type)
 => type == DynaType.Main ?
 new DirectoryInfo(Properties.Instance.GetProperty("resource.dispatcher.generated.sources.main", GeneratedSources)) :
 new DirectoryInfo(Properties.Instance.GetProperty("resource.dispatcher.generated.sources.test", GeneratedTestSources));
Ejemplo n.º 12
0
        //should proxy a certain interface, and then in construction take a certain lambda to handle each call
        //...


        public static FnProxifier BuildProxifier(Type tGrain)
        {
            var tProxy = DynaType.Design(x => {
                //x.Name = $"{tGrain.Name}_Wrapper"; //need to get nice names of types

                x.BaseType    = typeof(GrainProxy <>).MakeGenericType(tGrain);
                x.Attributes |= TypeAttributes.Serializable | TypeAttributes.Public;

                x.Constructor()
                .ArgTypes(typeof(Fixture), typeof(AbstractKey))
                .PassThroughToBaseCtor();

                var grainInterfaces = new[] { tGrain }.Concat(tGrain.GetInterfaces()); //.Where(t => IsGrainInterface(t));

                //each interface fulfilled by grain type should be fulfilled by inward delegation --------------
                foreach (var tInterface in grainInterfaces)
                {
                    var methods = tInterface.GetMethods();

                    if (!methods.All(m => m.ReturnType.IsTaskType()))
                    {
                        throw new InvalidOperationException($"Can't proxy type {tInterface}, as not all of its methods return tasks!");
                    }

                    x.AddInterface(tInterface);

                    foreach (var m in methods)
                    {
                        var taskReturnType = GetTaskReturnType(m.ReturnType);
                        var mProxyDispatch = _mgProxyDispatch.MakeGenericMethod(taskReturnType);

                        var fMethod = x.StaticField($"__{Guid.NewGuid()}", typeof(MethodInfo))
                                      .Value(m);

                        var rParams = m.GetParameters();

                        x.OverrideMethod(m)
                        .Emit(il => {
                            //Delegate to GrainProxy.Dispatch(), via packaging of args into object array
                            il.Emit(OpCodes.Ldarg_0);
                            il.Emit(OpCodes.Ldsfld, fMethod);

                            il.Emit(OpCodes.Ldc_I4, rParams.Length);
                            il.Emit(OpCodes.Newarr, typeof(object));

                            foreach (var p in rParams)
                            {
                                il.Emit(OpCodes.Dup);
                                il.Emit(OpCodes.Ldc_I4, p.Position);
                                il.Emit(OpCodes.Ldarg, p.Position + 1);

                                if (p.ParameterType.IsValueType)
                                {
                                    il.Emit(OpCodes.Box, p.ParameterType);
                                }

                                il.Emit(OpCodes.Stelem, typeof(object));
                            }

                            il.Emit(OpCodes.Call, mProxyDispatch);

                            il.Emit(OpCodes.Ret);
                        });
                    }
                }
            });


            var exFixtureParam = Expression.Parameter(typeof(Fixture));
            var exKeyParam     = Expression.Parameter(typeof(AbstractKey));

            var exLambda = Expression.Lambda <FnProxifier>(
                Expression.New(
                    tProxy.GetConstructor(
                        new[] { typeof(Fixture), typeof(AbstractKey) }),
                    exFixtureParam,
                    exKeyParam
                    ),
                exFixtureParam,
                exKeyParam);

            return(exLambda.Compile());
        }
Ejemplo n.º 13
0
 private static DirectoryInfo RootOfGeneratedSources(DynaType type)
 => type == DynaType.Main ?
 new DirectoryInfo(Properties.Instance.GetProperty("proxy.generated.sources.main", GeneratedSources) !) :
Ejemplo n.º 14
0
 public DynaGeneric(Section_AHDR AHDR, DynaType type, Game game, Endianness endianness) : base(AHDR, type, game, endianness)
 {
     Data = AHDR.data.Skip(dynaDataStartPosition).Take(AHDR.data.Length - dynaDataStartPosition - _links.Length * Link.sizeOfStruct).ToArray();
 }