Esempio n. 1
0
 public JSInternalError(VirtualMachine vm, string message, string stackTrace, JSObject inherited)
     : base(vm, message, inherited)
 {
     Contract.Requires(!string.IsNullOrEmpty(stackTrace));
     Contract.Requires(inherited == vm.InternalError);
     OwnMembers.Add("stackTrace", stackTrace);
 }
Esempio n. 2
0
 public JSError(VirtualMachine vm, string message, JSObject inherited)
     : base(vm, inherited)
 {
     Contract.Requires(inherited != null);
     OwnMembers.Add("name", "Error");
     OwnMembers.Add("message", message);
 }
Esempio n. 3
0
        public virtual JSObject GetPrototype()
        {
            JSValue result;

            if (!OwnMembers.TryGetValue(PrototypeMemberName, out result))
            {
                result = VM.NewObject();
                OwnMembers.Add(PrototypeMemberName, result);
            }
            return(result.RequireObject());
        }
Esempio n. 4
0
        public override JSValue GetMember(JSValue member)
        {
            var name   = member.CastToString();
            var result = base.GetMember(name);

            if (result == null)
            {
                Func <VirtualMachine, JSObject, JSValue> factory;
                if (_lazyMemberFactories.TryGetValue(name, out factory))
                {
                    result = factory(VM, this);
                    OwnMembers.Add(name, result);
                }
            }
            return(result ?? Undefined);
        }
Esempio n. 5
0
 public bool IsPropertyValueValid(string propertyName, ref string errorMessageTemplate, ContextIdentifiers contextIdentifiers,
                                  string ruleId)
 {
     if (propertyName == "OwnMembers" && contextIdentifiers == ContextIdentifier.Save)
     {
         var persistentReferenceMemberInfos = OwnMembers.OfType <PersistentReferenceMemberInfo>().Where(info => info.TypeAttributes.OfType <PersistentAssociationAttribute>().Any());
         foreach (var persistentReferenceMemberInfo in persistentReferenceMemberInfos)
         {
             var associationAttribute = persistentReferenceMemberInfo.TypeAttributes.OfType <PersistentAssociationAttribute>().FirstOrDefault();
             if (associationAttribute != null)
             {
                 var persistentCollectionMemberInfos = persistentReferenceMemberInfo.Owner.OwnMembers.OfType <PersistentCollectionMemberInfo>();
                 if (!persistentCollectionMemberInfos.Any(info => info.TypeAttributes.OfType <PersistentAssociationAttribute>()
                                                          .Any(attribute => attribute.AssociationName == associationAttribute.AssociationName)))
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }