S
shapper
Hello,
I have an attribute on a project as follows:
public class GoogleVerifyAttribute : FilterAttribute, IActionFilter
{
public void OnActionExecuting(ActionExecutingContext context) {
ViewResult view = (ViewResult)context.Result;
if (view == null) return;
ViewModel model = (ViewModel)view.ViewData.Model;
if (model == null) return;
if (model.Verify == null) model.Verify = new GoogleVerify();
model.Verify.Key = Setup.Settings.GoogleVerifyKey;
} // OnActionExecuting
} // GoogleVerifyAttribute
ViewModel is a class that I have in all my projects:
public class ViewModel {
public GoogleVerify Verify { get; set; }
// Some other properties
} // ViewModel
And all my models inherit view model:
public class SomeViewModel {
// Some properties
}
What I am trying to do is somehow to move GoogleVerifyAttribute to a
common library but when using it in each project to be able to define
the following line different ways from project to project:
model.Verify.Key = Setup.Settings.GoogleVerifyKey;
For example in other project I might have just:
model.Verify.Key = "ldsjk";
Is there a way to do this?
I was "playing" a little bit with interfaces but I got lost in the
way ...
Thanks,
Miguel
I have an attribute on a project as follows:
public class GoogleVerifyAttribute : FilterAttribute, IActionFilter
{
public void OnActionExecuting(ActionExecutingContext context) {
ViewResult view = (ViewResult)context.Result;
if (view == null) return;
ViewModel model = (ViewModel)view.ViewData.Model;
if (model == null) return;
if (model.Verify == null) model.Verify = new GoogleVerify();
model.Verify.Key = Setup.Settings.GoogleVerifyKey;
} // OnActionExecuting
} // GoogleVerifyAttribute
ViewModel is a class that I have in all my projects:
public class ViewModel {
public GoogleVerify Verify { get; set; }
// Some other properties
} // ViewModel
And all my models inherit view model:
public class SomeViewModel {
// Some properties
}
What I am trying to do is somehow to move GoogleVerifyAttribute to a
common library but when using it in each project to be able to define
the following line different ways from project to project:
model.Verify.Key = Setup.Settings.GoogleVerifyKey;
For example in other project I might have just:
model.Verify.Key = "ldsjk";
Is there a way to do this?
I was "playing" a little bit with interfaces but I got lost in the
way ...
Thanks,
Miguel