本文整理汇总了C#中INakedObjectAdapter.GetDomainObject方法的典型用法代码示例。如果您正苦于以下问题:C# INakedObjectAdapter.GetDomainObject方法的具体用法?C# INakedObjectAdapter.GetDomainObject怎么用?C# INakedObjectAdapter.GetDomainObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INakedObjectAdapter
的用法示例。
在下文中一共展示了INakedObjectAdapter.GetDomainObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Reset
public void Reset(INakedObjectAdapter inObjectAdapter) {
try {
var collection = (IList) property.GetValue(inObjectAdapter.GetDomainObject(), null);
collection.Clear();
property.SetValue(inObjectAdapter.GetDomainObject(), collection, null);
}
catch (Exception e) {
throw new ReflectionException(string.Format("Failed to get/set property {0} in {1}", property.Name, inObjectAdapter.Spec.FullName), e);
}
}
示例2: Reset
public void Reset(INakedObjectAdapter inObjectAdapter) {
try {
var collection = (IList) property.GetValue(inObjectAdapter.GetDomainObject(), null);
collection.Clear();
property.SetValue(inObjectAdapter.GetDomainObject(), collection, null);
}
catch (Exception e) {
throw new ReflectionException(Log.LogAndReturn($"Failed to get/set property {property.Name} in {inObjectAdapter.Spec.FullName}"), e);
}
}
示例3: GetTitleWithMask
public override string GetTitleWithMask(string mask, INakedObjectAdapter nakedObjectAdapter, INakedObjectManager nakedObjectManager) {
if (maskDelegate != null) {
return (string) maskDelegate(nakedObjectAdapter.GetDomainObject(), new object[] {mask});
}
if (maskMethod != null) {
return (string) maskMethod.Invoke(nakedObjectAdapter.GetDomainObject(), new object[] {mask});
}
return GetTitle(nakedObjectAdapter, nakedObjectManager);
}
示例4: HiddenReason
public string HiddenReason(INakedObjectAdapter nakedObjectAdapter) {
if (nakedObjectAdapter == null) {
return null;
}
var isHidden = (bool) methodDelegate(nakedObjectAdapter.GetDomainObject(), new object[] {});
return isHidden ? Resources.NakedObjects.Hidden : null;
}
示例5: GetCompletions
public object[] GetCompletions(INakedObjectAdapter inObjectAdapter, string autoCompleteParm) {
try {
object autoComplete = methodDelegate(inObjectAdapter.GetDomainObject(), new object[] { autoCompleteParm });
//returning an IQueryable
var queryable = autoComplete as IQueryable;
if (queryable != null) {
return queryable.Take(PageSize).ToArray();
}
//returning an IEnumerable (of string only)
var strings = autoComplete as IEnumerable<string>;
if (strings != null) {
return strings.ToArray();
}
//return type is a single object
if (!CollectionUtils.IsCollection(autoComplete.GetType())) {
return new object[] { autoComplete };
}
throw new NakedObjectDomainException("Must return IQueryable or a single object from autoComplete method: " + method.Name);
}
catch (ArgumentException ae) {
string msg = string.Format("autoComplete exception: {0} has mismatched parameter type - must be string", method.Name);
throw new InvokeException(msg, ae);
}
}
示例6: InvalidReason
public string InvalidReason(INakedObjectAdapter target, INakedObjectAdapter[] proposedArguments) {
if (methodDelegate != null) {
return (string)methodDelegate(target.GetDomainObject(), proposedArguments.Select(no => no.GetDomainObject()).ToArray());
}
//Fall back (e.g. if method has > 6 params) on reflection...
Log.WarnFormat("Invoking validate method via reflection as no delegate {0}.{1}", target, method);
return (string)InvokeUtils.Invoke(method, target, proposedArguments);
}
示例7: InitProperty
public void InitProperty(INakedObjectAdapter nakedObjectAdapter, INakedObjectAdapter value) {
try {
property.SetValue(nakedObjectAdapter.GetDomainObject(), value.GetDomainObject(), null);
}
catch (TargetInvocationException e) {
InvokeUtils.InvocationException("Exception executing " + property, e);
}
}
示例8: Exceeds
/// <summary>
/// Whether the provided argument exceeds the <see cref="SingleIntValueFacetAbstract.Value" /> maximum length}.
/// </summary>
public virtual bool Exceeds(INakedObjectAdapter nakedObjectAdapter) {
var str = nakedObjectAdapter.GetDomainObject() as string;
if (str == null) {
return false;
}
int maxLength = Value;
return maxLength != 0 && str.Length > maxLength;
}
示例9: SetProperty
public override void SetProperty(INakedObjectAdapter nakedObjectAdapter, INakedObjectAdapter value, ITransactionManager transactionManager, ISession session, ILifecycleManager lifecycleManager) {
try {
property.SetValue(nakedObjectAdapter.GetDomainObject(), value.GetDomainObject(), null);
}
catch (TargetInvocationException e) {
InvokeUtils.InvocationException("Exception executing " + property, e);
}
}
示例10: Init
public override void Init(INakedObjectAdapter collection, INakedObjectAdapter[] initData) {
Array newCollection = Array.CreateInstance(collection.GetDomainObject().GetType().GetElementType(), initData.Length);
collection.ReplacePoco(newCollection);
int i = 0;
foreach (INakedObjectAdapter nakedObject in initData) {
AsCollection(collection)[i++] = nakedObject.Object;
}
}
示例11: GetProperty
public object GetProperty(INakedObjectAdapter nakedObjectAdapter) {
try {
return propertyMethod.GetValue(nakedObjectAdapter.GetDomainObject(), null);
}
catch (TargetInvocationException e) {
InvokeUtils.InvocationException("Exception executing " + propertyMethod, e);
return null;
}
}
示例12: IsEditView
public override bool IsEditView(INakedObjectAdapter nakedObjectAdapter) {
var target = nakedObjectAdapter.GetDomainObject<IViewModelSwitchable>();
if (target != null) {
return target.IsEditView();
}
throw new NakedObjectSystemException(nakedObjectAdapter.Object == null ? "Null domain object" : "Wrong type of domain object: " + nakedObjectAdapter.Object.GetType().FullName);
}
示例13: IsEditable
public bool IsEditable(ISession session, ILifecycleManager lifecycleManager, INakedObjectAdapter target, IIdentifier identifier) {
object authorizer = GetAuthorizer(target, lifecycleManager);
Type authType = authorizer.GetType();
if ((typeof(INamespaceAuthorizer)).IsAssignableFrom(authType)) {
var nameAuth = (INamespaceAuthorizer) authorizer;
return nameAuth.IsEditable(session.Principal, target.Object, identifier.MemberName);
}
return isEditableDelegates[authType](authorizer, session.Principal, target.GetDomainObject(), identifier.MemberName);
}
示例14: Invoke
public void Invoke(INakedObjectAdapter nakedObjectAdapter, INakedObjectAdapter[] parameters, bool queryOnly, IIdentifier identifier, ISession session, ILifecycleManager lifecycleManager) {
IAuditor auditor = GetAuditor(nakedObjectAdapter, lifecycleManager);
IPrincipal byPrincipal = session.Principal;
string memberName = identifier.MemberName;
if (nakedObjectAdapter.Spec is IServiceSpec) {
string serviceName = nakedObjectAdapter.Spec.GetTitle(nakedObjectAdapter);
auditor.ActionInvoked(byPrincipal, memberName, serviceName, queryOnly, parameters.Select(no => no.GetDomainObject()).ToArray());
}
else {
auditor.ActionInvoked(byPrincipal, memberName, nakedObjectAdapter.GetDomainObject(), queryOnly, parameters.Select(no => no.GetDomainObject()).ToArray());
}
}
示例15: GetChoices
public object[] GetChoices(INakedObjectAdapter inObjectAdapter, IDictionary<string, INakedObjectAdapter> parameterNameValues) {
INakedObjectAdapter[] parms = FacetUtils.MatchParameters(parameterNames, parameterNameValues);
try {
object options = methodDelegate(inObjectAdapter.GetDomainObject(), parms.Select(p => p.GetDomainObject()).ToArray());
var enumerable = options as IEnumerable;
if (enumerable != null) {
return enumerable.Cast<object>().ToArray();
}
throw new NakedObjectDomainException(Log.LogAndReturn($"Must return IEnumerable from choices method: {method.Name}"));
}
catch (ArgumentException ae) {
throw new InvokeException(Log.LogAndReturn($"Choices exception: {method.Name} has mismatched (ie type of parameter does not match type of property) parameter types"), ae);
}
}