查找未项目[Serializable接口]

编程入门 行业动态 更新时间:2024-10-20 08:23:55
本文介绍了查找未项目[Serializable接口]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不知道是否有人知道的快捷方式,或如果有人写了一本反映工具告诉一个解决方案,对象不是标记为可序列。我切换一个网站转移到的StateServer和我需要的所有对象标记为可序列。我不想错过任何

I was wondering if anyone knows of a quick way or if anyone has written a reflection tool to tell which objects in a solution are not marked as serializable. I'm switching a site over to a StateServer and i need to have all objects marked as serializable. I don't want to miss any.

此外,第二部分做枚举必须是序列化?

Also, second part do enums have to be serializable?

该网站是一个ASP.NET 1.1的网站与2003年建成VS

The website is an ASP.NET 1.1 site built with VS 2003

推荐答案

枚举本质上是serialisable。

Enums are inherently serialisable.

我写了这个帮手越来越属性关闭对象,可以将行添加到您的应用程序的顶部调用以下code:

I wrote this helper for getting attributes off objects, you could add a line to the top of your application that calls the following code:

var assemblies = GetTheAssembliesFromYourApp(); foreach (var assembly in assemblies) { var types = assembly.GetTypes (); foreach (var type in types) { if (AttributeHelper.GetAttrbiute<Serializable> (type) == null) { // Log somewhere - this type isn't serialisable... } } } static class AttributeHelper { #region Static public methods #region GetAttribute static public T GetAttribute<T> (object obj) where T : Attribute { if (obj == null) throw new ArgumentNullException ("obj"); // If the object is a member info then we can use it, otherwise it's an instance of 'something' so get it's type... var member = (obj is System.Reflection.MemberInfo) ? (System.Reflection.MemberInfo)obj : obj.GetType (); return GetAttributeImpl<T> (member); } #endregion GetAttribute #endregion Static public methods #region Static methods #region GetAttributeImpl static T GetAttributeImpl<T> (System.Reflection.MemberInfo member) where T : Attribute { var attribs = member.GetCustomAttributes (typeof (T), false); if (attribs == null || attribs.Length == 0) return null; return attribs[0] as T; } #endregion GetAttributeImpl #endregion Static methods }

更多推荐

查找未项目[Serializable接口]

本文发布于:2023-06-07 15:20:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/568536.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:接口   项目   Serializable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!