public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var obj = JObject.Load(reader);
            RegistrationModelBase model;

            var type = obj["Type"];
            if (type == null)
            {
                obj["Type"] = ((IdentityTypes)0).ToString();
                type = obj["Type"];
            }

            string modelType = type.Value<string>();
            IdentityTypes actualType;
            if (!Enum.TryParse<IdentityTypes>(modelType, out actualType))
                throw new NotSupportedException("Invalid AssetType Provided");

            switch (actualType)
            {
                case IdentityTypes.USER:
                    model = new UserRegistrationModel();
                    break;
                case IdentityTypes.ENTERPRISE:
                    model = new EnterpriseUserRegistrationModel();
                    break;
                default:
                    model = new AssetRegistrationModel();
                    break;
            }

            serializer.Populate(obj.CreateReader(), model);
            return model;
        }
Exemple #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var obj = JObject.Load(reader);
            RegistrationModelBase model;

            var type = obj["Type"];

            if (type == null)
            {
                obj["Type"] = ((IdentityTypes)0).ToString();
                type        = obj["Type"];
            }

            string        modelType = type.Value <string>();
            IdentityTypes actualType;

            if (!Enum.TryParse <IdentityTypes>(modelType, out actualType))
            {
                throw new NotSupportedException("Invalid AssetType Provided");
            }

            switch (actualType)
            {
            case IdentityTypes.USER:
                model = new UserRegistrationModel();
                break;

            case IdentityTypes.ENTERPRISE:
                model = new EnterpriseUserRegistrationModel();
                break;

            default:
                model = new AssetRegistrationModel();
                break;
            }

            serializer.Populate(obj.CreateReader(), model);
            return(model);
        }
Exemple #3
0
 public AssetProfile(AssetRegistrationModel assetModel) : base(assetModel as UserRegistrationModel)
 {
     this.NationalId       = assetModel.NationalId;
     this.DriversLicenseId = assetModel.DrivingLicenceId;
 }
Exemple #4
0
 public Asset(AssetRegistrationModel model, AssetProfile profile) : base(model, profile, RoleNames.ROLE_ASSET)
 {
 }
Exemple #5
0
 public AssetProfile(AssetRegistrationModel assetModel) : base(assetModel as UserRegistrationModel)
 {
     this.NationalId = assetModel.NationalId;
     this.DriversLicenseId = assetModel.DrivingLicenceId;
 }
Exemple #6
0
 public Asset(AssetRegistrationModel model, AssetProfile profile) : base(model, profile, RoleNames.ROLE_ASSET)
 {
 }