actorserializer.cs

来自「工作流的基本资料(文档资料」· CS 代码 · 共 59 行

CS
59
字号
using System;
using NetBpm.Util.Client;
using NetBpm.Workflow.Organisation;
using NetBpm.Workflow.Organisation.EComp;

namespace NetBpm.Workflow.Delegation.Impl.Serializer
{
	public class ActorSerializer : AbstractConfigurable, ISerializer
	{
		private static readonly ServiceLocator serviceLocator;

		static ActorSerializer()
		{
			serviceLocator = ServiceLocator.Instance;
		}

		public String Serialize(Object object_Renamed)
		{
			String serialized = null;

			if ((!(object_Renamed is IUser)) && (!(object_Renamed is IGroup)))
			{
				throw new ArgumentException("couldn't serialize " + object_Renamed);
			}

			if (object_Renamed != null)
			{
				IActor actor = (IActor) object_Renamed;
				serialized = actor.Id;
			}

			return serialized;
		}

		public Object Deserialize(String text)
		{
			if (text == null)
				return null;

			IActor actor = null;
			IOrganisationSessionLocal organisationComponent = (IOrganisationSessionLocal) serviceLocator.GetService(typeof (IOrganisationSessionLocal));
			try
			{
					actor = organisationComponent.FindActorById(text);
					serviceLocator.Release(organisationComponent);
			}
			catch (Exception t)
			{
				throw new ArgumentException("couldn't deserialize " + text + " to a User : " + t.GetType().FullName + " : " + t.Message);
			}
			finally
			{
				serviceLocator.Release(organisationComponent);
			}

			return actor;
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?