Пример #1
0
        internal void DeserializeTypeInfo(XElement parent)
        {
            var types = from typeNodes in parent.Descendants("Types").Descendants("T")
                        select new
            {
                ID       = Convert.ToInt32(typeNodes.Attribute("id").Value),
                TypeDesp = typeNodes.AttributeWithAlterName("name", "n", string.Empty),
            };

            if (types.FirstOrDefault() == null)
            {
                types = from typeNodes in parent.Descendants("Types").Descendants("Type")
                        select new
                {
                    ID       = Convert.ToInt32(typeNodes.Attribute("id").Value),
                    TypeDesp = typeNodes.AttributeWithAlterName("name", "n", string.Empty),
                }
            }
            ;

            types.ForEach(t =>
            {
                try
                {
                    TypeContext[t.ID] = TypeCreator.GetTypeInfo(t.TypeDesp);
                }
                catch (System.Exception)
                {
                }
            });
        }
Пример #2
0
        private static object CreateSerializableInstance(string typeDescription, params object[] constructorParams)
        {
            Type type = TypeCreator.GetTypeInfo(typeDescription);

            ExceptionHelper.FalseThrow <TypeLoadException>(type != null, Resource.TypeLoadException, typeDescription);

            return(CreateSerializableInstance(type, constructorParams));
        }