Exemplo n.º 1
0
        public virtual void ReadFromInput(ContentReader input)
        {
            Halign      = input.ReadString();
            Valign      = input.ReadString();
            Horizontal  = input.ReadString();
            Vertical    = input.ReadString();
            Width       = input.ReadString();
            Height      = input.ReadString();
            Hidden      = input.ReadBoolean();
            Alpha       = input.ReadSingle();
            AspectRatio = input.ReadString();
            ID          = input.ReadString();
            Class       = input.ReadString();

            int count = input.ReadInt32();

            Children = new List <WidgetPrototype>();
            for (int i = 0; i < count; i++)
            {
                // Hack: content is built in a different project (Adrift.Content.Pipeline). The assembly qualified name
                // is different when writing than when loading. We aren't necessarily worried about what project
                // the class was from, we want to know how to instantiate it.
                // The alternative to this would be to make Adrift.Content.Common a library instead of a shared project,
                // however this is not ideal since we want that project to be able to be referenced by both .NET Framework
                // and .NET Core projects.
                string          assemblyName          = GetType().Assembly.FullName.Split(',')[0];
                string          className             = input.ReadString().Split(',')[0];
                string          assemblyQualifiedName = string.Format("{0}, {1}", className, assemblyName);
                WidgetPrototype widget = (WidgetPrototype)Activator.CreateInstance(Type.GetType(assemblyQualifiedName));
                widget.ReadFromInput(input);
                Children.Add(widget);
            }
        }
Exemplo n.º 2
0
        public void ReadFromInput(ContentReader input)
        {
            Width  = input.ReadString();
            Height = input.ReadString();

            int count = input.ReadInt32();

            Children = new List <WidgetPrototype>();
            for (int i = 0; i < count; i++)
            {
                string          assemblyName          = GetType().Assembly.FullName.Split(',')[0];
                string          className             = input.ReadString().Split(',')[0];
                string          assemblyQualifiedName = string.Format("{0}, {1}", className, assemblyName);
                WidgetPrototype widget = (WidgetPrototype)Activator.CreateInstance(Type.GetType(assemblyQualifiedName));
                widget.ReadFromInput(input);
                Children.Add(widget);
            }
        }