Example #1
0
 public bool Equals(WString other)
 {
     if (WrappedValue == null)
     {
         return(other.WrappedValue == null ? true : false);
     }
     return(WrappedValue.Equals(other.WrappedValue));
 }
Example #2
0
 public int CompareTo(WString other)
 {
     if (WrappedValue == null)
     {
         return(other == null ? 0 : -1);
     }
     return(WrappedValue.CompareTo(other.WrappedValue));
 }
Example #3
0
 public ITypeFacade GetElementType(IObjectFacade objectFacade)
 {
     if (IsCollection)
     {
         var introspectableSpecification = WrappedValue.GetFacet <ITypeOfFacet>().GetValueSpec(((ObjectFacade)objectFacade).WrappedNakedObject, framework.MetamodelManager.Metamodel);
         var elementSpec = framework.MetamodelManager.GetSpecification(introspectableSpecification);
         return(new TypeFacade(elementSpec, FrameworkFacade, framework));
     }
     return(null);
 }
Example #4
0
        private static void SetProperty_Generic <T>(Dictionary <String, WrappedValue <T> > collection, String symName, T value)
        {
            WrappedValue <T> val = null;

            if (!collection.TryGetValue(symName, out val))
            {
                throw new ApplicationException("No such property");
            }
            val.Value = value;
        }
        public Task SendCommand(ServerCommand command)
        {
            // Store where the message originated from
            command.ServerId = _serverIdManager.ServerId;

            // Wrap the value so buses that need to serialize can call ToString()
            var wrappedValue = new WrappedValue(command, _serializer);

            // Send the command to the all servers
            return _messageBus.Send(_serverIdManager.ServerId, ServerSignal, wrappedValue);
        }
Example #6
0
        public Task SendCommand(ServerCommand command)
        {
            // Store where the message originated from
            command.ServerId = _serverIdManager.ServerId;

            // Wrap the value so buses that need to serialize can call ToString()
            var wrappedValue = new WrappedValue(command, _serializer);

            // Send the command to the all servers
            return(_messageBus.Send(_serverIdManager.ServerId, ServerSignal, wrappedValue));
        }
Example #7
0
 private void HandleServerCommands(IList <Message> messages)
 {
     foreach (var message in messages)
     {
         // Only handle server commands
         if (ServerSignal.Equals(message.SignalKey))
         {
             // Uwrap the command and raise the event
             var command = WrappedValue.Unwrap <ServerCommand>(message.Value, _serializer);
             OnCommand(command);
         }
     }
 }
Example #8
0
        private bool DecryptIf(Dictionary <string, object> currenttree, string key, dynamic value, TypeConverter converter)
        {
            var didSomething = false;

            if (ShouldTryDecryption(value, converter))
            {
                // TODO properly some try-catch-all error handling to prevent nasty blowups. Nothing fancy.
                var wrap           = new WrappedValue((string)value);
                var unwrappedValue = this.encrypt.UnwrapAndDecrypt(wrap);
                currenttree[key] = unwrappedValue;
                didSomething     = true;
            }

            return(didSomething);
        }
        public void HappyPath()
        {
            byte[]       key    = new byte[16], iv = new byte[16], value = new byte[16];
            SecureRandom random = new SecureRandom();

            random.NextBytes(key);
            random.NextBytes(iv);
            random.NextBytes(value);

            var wrappedString = new WrappedValue {
                EncryptedAESKey = key, IV = iv, EncryptedValue = value
            }.ToString();

            Assert.StartsWith("ENC[", wrappedString);

            var wrap = new WrappedValue(wrappedString);

            Assert.Equal(key, wrap.EncryptedAESKey);
            Assert.Equal(iv, wrap.IV);
            Assert.Equal(value, wrap.EncryptedValue);
        }
Example #10
0
            public void HappyPath_EncryptAndThenDecrypt(string value)
            {
                var e = new Encrypt {
                    PublicKey = publicKey, PrivateKey = privateKey
                };

                WrappedValue wrapped = e.EncryptAndWrap(value);

                Assert.NotNull(wrapped);
                Assert.NotNull(wrapped.EncryptedAESKey);
                Assert.NotNull(wrapped.IV);
                Assert.NotNull(wrapped.EncryptedValue);

                string wrapHexed = wrapped.ToString();

                Assert.NotNull(wrapHexed);
                Assert.NotEqual(string.Empty, wrapHexed);

                WrappedValue unhexedWrap = null;

                try
                {
                    unhexedWrap = new WrappedValue(wrapHexed);
                }
                catch
                {
                    // no-op
                }

                Assert.NotNull(unhexedWrap);
                Assert.Equal(wrapped.EncryptedValue, unhexedWrap.EncryptedValue);

                string decryptedValue = e.UnwrapAndDecrypt(unhexedWrap);

                Assert.NotNull(decryptedValue);
                Assert.Equal(value, decryptedValue);
            }
Example #11
0
 public int CompareTo(WUInt32 other)
 {
     return(WrappedValue.CompareTo(other.WrappedValue));
 }
Example #12
0
 public bool Equals(uint other)
 {
     return(WrappedValue.Equals(other));
 }
Example #13
0
 public int CompareTo(uint other)
 {
     return(WrappedValue.CompareTo(other));
 }
Example #14
0
 public int CompareTo(WTimeSpan other)
 {
     return(WrappedValue.CompareTo(other.WrappedValue));
 }
Example #15
0
 public int CompareTo(WDecimal other)
 {
     return(WrappedValue.CompareTo(other.WrappedValue));
 }
Example #16
0
 public override string ToString()
 {
     return(WrappedValue.ToString());
 }
Example #17
0
 public bool Equals(WDateTime other)
 {
     return(WrappedValue.Equals(other.WrappedValue));
 }
Example #18
0
 public bool IsOfType(ITypeFacade otherSpec)
 {
     return(WrappedValue.IsOfType(((TypeFacade)otherSpec).WrappedValue));
 }
Example #19
0
 public bool Equals(WGuid other)
 {
     return(WrappedValue.Equals(other.WrappedValue));
 }
Example #20
0
 public int CompareTo(WGuid other)
 {
     return(WrappedValue.CompareTo(other.WrappedValue));
 }
Example #21
0
 public bool Equals(double other)
 {
     return(WrappedValue.Equals(other));
 }
Example #22
0
 public bool Equals(long other)
 {
     return(WrappedValue.Equals(other));
 }
Example #23
0
 public bool Equals(WTimeSpan other)
 {
     return(WrappedValue.Equals(other.WrappedValue));
 }
Example #24
0
 public bool Equals(WUInt32 other)
 {
     return(WrappedValue.Equals(other.WrappedValue));
 }
Example #25
0
 public int CompareTo(WDateTime other)
 {
     return(WrappedValue.CompareTo(other.WrappedValue));
 }
Example #26
0
 protected void RegisterObject(String symName, WrappedValue <Material> obj)
 {
     _materials[symName] = obj;
 }
Example #27
0
 private Task SendMessage(string key, object value)
 {
     var wrappedValue = new WrappedValue(value, _serializer);
     return _messageBus.Send(_connectionId, key, wrappedValue).Catch();
 }
Example #28
0
 protected void RegisterObject(String symName, WrappedValue <double> obj)
 {
     _doubles[symName] = obj;
 }
Example #29
0
 public override int GetHashCode()
 {
     return(WrappedValue.GetHashCode());
 }
Example #30
0
 public override string ToString()
 {
     return(WrappedValue?.ToString() ?? "");
 }
Example #31
0
 public bool Equals(WDecimal other)
 {
     return(WrappedValue.Equals(other.WrappedValue));
 }
Example #32
0
 public override int GetHashCode()
 {
     return(WrappedValue != null ? WrappedValue.GetHashCode() : 0);
 }