/// <summary> /// 创建对象 /// </summary> /// <param name="type">授权对象的接口类型</param> /// <returns>授权对象</returns> public IPermissionObject CreateObject(System.Type type) { ExceptionHelper.FalseThrow <ArgumentNullException>(type != null, "type"); PermissionObjBaseImpl result = null; if (type == typeof(IApplication)) { result = new ApplicationImpl(); } else if (type == typeof(IRole)) { result = new RoleImpl(); } else if (type == typeof(IPermission)) { result = new PermissionImpl(); } else { throw new InvalidOperationException(string.Format(Resource.InvalidObjectTypeCreation, type.ToString())); } return(result); }
private static PermissionObjBaseImpl CreateObjectByType(System.Type type) { PermissionObjBaseImpl result = null; if (type == typeof(IApplication)) { result = new ApplicationImpl(); } else if (type == typeof(IRole)) { result = new RoleImpl(); } else if (type == typeof(IPermission)) { result = new PermissionImpl(); } else { throw new InvalidOperationException(string.Format(Resource.InvalidObjectTypeCreation, type.ToString())); } return(result); }
private OP.IApplication CastApplication(PC.SchemaObjectBase o) { if (o == null) throw new ArgumentNullException("o"); if (o.SchemaType != PC.StandardObjectSchemaType.Applications.ToString()) throw new ArgumentException(string.Format("无法将{0}转换成IApplication", o), "o"); OP.ApplicationImpl app = new OP.ApplicationImpl(); var wrapper = (OP.IApplicationPropertyAccessible)app; wrapper.CodeName = o.Properties.GetValue<string>("CodeName", string.Empty); wrapper.Description = o.Properties.GetValue<string>("Description", string.Empty); wrapper.ID = o.ID; wrapper.Name = o.Properties.GetValue<string>("Name", string.Empty); wrapper.ResourceLevel = o.Properties.GetValue<string>("ResourceLevel", string.Empty); return app; }
/// <summary> /// 创建对象 /// </summary> /// <param name="type">授权对象的接口类型</param> /// <returns>授权对象</returns> public IPermissionObject CreateObject(System.Type type) { ExceptionHelper.FalseThrow<ArgumentNullException>(type != null, "type"); PermissionObjBaseImpl result = null; if (type == typeof(IApplication)) result = new ApplicationImpl(); else if (type == typeof(IRole)) result = new RoleImpl(); else if (type == typeof(IPermission)) result = new PermissionImpl(); else throw new InvalidOperationException(string.Format(Resource.InvalidObjectTypeCreation, type.ToString())); return result; }